![](/img/trans.png)
[英]How can I solve this error? NameError: name ‘model’ is not defined
[英]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')
您需要使用Client
或Bot
來實例化您的機器人。 在您的代碼中,您將機器人實例化為Client
,但您嘗試使用@bot.command()
創建命令。
您需要使用@client.command()
或@commands.command()
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.