Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Discord.py@bot.event_Python_Discord_Discord.py - Fatal编程技术网

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()事件,那么您也应该调用此协同程序


参考文献: