Discord.py Self Bot using rewrite

*爱你&永不变心* 提交于 2020-01-06 05:44:07

问题


Hello im trying to make a selfbot using discord.py rewrite for educational testing.

Im stuck currently with making a simple command which responds to a command.

I want my selfbot to say "oof" when I type and send ">>>test"

here is my code:

import asyncio
import discord
from discord.ext import commands

bot = commands.Bot(command_prefix=(">>>"), self_bot=True)


@bot.event
async def on_ready():
    print("Bot presence t u r n e d on ( ͡° ͜ʖ ͡°)")


@bot.command()
async def test(self, ctx):
    await self.bot.say("oof")





bot.run("my token", bot=False)

回答1:


A self-bot isn't a bot that uses self, it's a bot that logs in using your credentials instead of a bot account. Self bots are against the Discord TOS (and you're not doing anything that requires one), so you should set up a bot account through their website and use a bot account for your bot.

That said, bot.say has been replaced by ctx.send in rewrite, and you're not in a cog so you shouldn't use self as all.

from discord.ext import commands

bot = commands.Bot(">>>", self_bot=True)

@bot.event
async def on_ready():
    print("Bot presence t u r n e d on ( ͡° ͜ʖ ͡°)")

@bot.command()
async def test(ctx):
    await ctx.send("oof")

bot.run("my token", bot=False)


来源:https://stackoverflow.com/questions/52084369/discord-py-self-bot-using-rewrite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!