邮箱:Discord.py@bot.Event [英] Discord.py @bot.event
本文介绍了邮箱:Discord.py@bot.Event的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我有一个同时使用@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("👍")
@bot.command()
async def info(ctx):
await ctx.send("Hello, thanks for testing out our bot. ~ techNOlogics")
@bot.command(pass_context=True)
async def meet(ctx,time):
if ctx.message.author.name == "techNOlogics":
await ctx.channel.purge(limit=1)
await ctx.send("**Meeting at " + time + " today!** React if you read.")
@bot.event ##THIS ONE HOLDS UP THE WHOLE SCRIPT
async def on_message(message):
await react(message)
推荐答案
混合使用on_message
事件和命令时,您需要添加await bot.process_commands(message)
,如下所示:
@bot.event
async def on_message(message):
await bot.process_commands(message)
# rest of code
如文件中所说:
此函数处理已注册到bot和其他组的命令。如果没有此协同例程,则不会触发任何命令。
如果选择重写on_Message()事件,则也应调用此协同例程。
引用:
这篇关于邮箱:Discord.py@bot.Event的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文