简体   繁体   中英

Discord.py Self Bot using rewrite

I'm trying to make a selfbot using discord.py rewrite.

I'm encountering issues when attempting to create a simple command.

I'd like my selfbot to respond with "oof" when ">>>test" is sent.

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)

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM