我希望我的机器人在有人键入不存在的命令时向聊天室发送消息。我试过了,但什么也没发生。代码如下:
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix=BOT_PREFIX)
@bot.event
async def on_ready():
print("Logged in as: " + bot.user.name + "\n")
@bot.command()
async def asdasd(ctx):
try:
if asdasd:
await ctx.send('asd')
except discord.ext.commands.errors.CommandNotFound:
await ctx.send('error')
bot.run('My Token Here')
有一个异常处理程序事件专门用于此
例如:
阅读更多关于它的信息。所有不同的错误都可以在here中找到
祝你好运
相关问题 更多 >
编程相关推荐