繁体   English   中英

如何解决“名称'bot'未定义”错误?

[英]How can I solve the “name 'bot' is not defined” error?

伙计们,我正在制作 discord 机器人,但我有一个错误,它说“名称'bot'未定义”。 任何人都可以帮忙吗? 谢谢

import discord
from discord.ext import commands
from discord.ext.commands import has_permissions

client = commands.Bot(command_prefix = ';')


@client.event
async def on_ready():
   print("{0.user} logged in as".format(client))
   

@bot.command(pass_context=True)
@has_permissions(administrator=True)
async def help(ctx):
   await ctx.send('Help')

client.run('TOKEN')

您需要使用ClientBot来实例化您的机器人。 在您的代码中,您将机器人实例化为Client ,但您尝试使用@bot.command()创建命令。

您需要使用@client.command()@commands.command()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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