Python Discord.py@bot.event
所以我有一个脚本,它同时使用Python Discord.py@bot.event,python,discord,discord.py,Python,Discord,Discord.py,所以我有一个脚本,它同时使用@bot.event和@bot.command()。问题是当我有一个@bot.event等待时,@bot.command()将不会运行 这是我的密码: @bot.event async def on_ready(): print("Bot Is Ready And Online!") async def react(message): if message.content == "Meeting":
@bot.event
和@bot.command()
。问题是当我有一个@bot.event
等待时,@bot.command()
将不会运行
这是我的密码:
@bot.event
async def on_ready():
print("Bot Is Ready And Online!")
async def react(message):
if message.content == "Meeting":
await message.add_reaction("When using a mixture of the on_message
event with commands, you'll want to add await bot.process_commands(message)
, like so:
@bot.event
async def on_message(message):
await bot.process_commands(message)
# rest of code
@bot.event
_ready()上的异步定义:
打印(“机器人已准备就绪并联机!”)
异步def react(消息):
如果message.content==“会议”:
wait message.add_reaction(“当将on_message
事件与命令混合使用时,您需要添加wait bot.process_命令(message)
,如下所示:
@bot.event
异步def on_消息(消息):
等待bot.process_命令(消息)
#代码的其余部分
如文件所述:
此函数处理已注册到bot和其他组的命令。如果没有此协同程序,将不会触发任何命令
如果您选择覆盖on_message()事件,那么您也应该调用此协同程序
参考文献: