Discord机器人Mute角色事件导致所有命令失效,请求技术协助
问题解决:Discord机器人on_message事件导致命令失效
问题根源是自定义on_message事件时,覆盖了discord.py默认的命令处理流程——机器人只会执行你编写的事件逻辑,不再响应任何命令。
只需在on_message函数末尾添加一行代码,就能让机器人同时处理消息事件和命令:
@bot.event async def on_message(message): user = message.author channel = bot.get_channel(1060922421491793981) role = discord.utils.get(user.guild.roles, id=1060693595964842165) if role in message.author.roles: await message.delete() await channel.send(f"@{user.display_name} **You are muted, You cant do this right now**") # 触发命令解析逻辑 await bot.process_commands(message)
这行代码会调用discord.py内置的命令处理机制,确保机器人既完成禁言检测,也能正常响应其他命令。
内容的提问来源于stack exchange,提问作者newtboot
相关产品推荐
相关产品推荐

