我已经添加了这段代码:@client.command(pass_context=True)
async def name(ctx):
username = ctx.message.author.display_name
到我的代码行的末尾,当我试图让机器人在线时,我得到了上面的错误。
你需要使用discord.ext.commands.Bot
而不是discord.Client
。 Bot
是Client
的子类,所以你也可以使用Client
实例的所有Bot
功能
from discord.ext.commands import Bot
bot = Bot("!")
@bot.command()
async def test(ctx):
await ctx.send("Command executed")
await bot.run("TOKEN")