问题
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