我有这个机器人,它会在每次有人使用 on_message
事件发送消息时进行检查,并且出于某种原因,机器人似乎忽略了其他命令。
去掉检查msgs的功能后我发现了,命令工作得很好。
这是 on_message
事件代码:
@client.event
async def on_message(message):
text = message.content
chann = message.channel.id
yes1 = False
yes = False
for ide in ids:
if message.author.id == ide:
yes1 = True
for strf in comms:
if text.startswith(strf):
yes = True
if (yes == False) and (yes1 == False) and (chann == 822089739502616576) and (message.author.id != 769302967803183124):
print(message.author.id)
msg = await message.channel.send('lahne kel el commands ye bhim')
await message.delete()
await asyncio.sleep(2)
print('deleting message')
await msg.delete()
if yes and (message.author.id != 769302967803183124) and (message.channel.id == 331562608467509249):
print(message.author.id)
msg = await message.channel.send('mech lahne tekteb el commands ye bhim')
await message.delete()
await asyncio.sleep(2)
print('deletingmessage')
await msg.delete()
if yes1 and (chann == 331562608467509249) and (message.author.id != 769302967803183124):
await message.delete()
我不知道问题出在哪里。
答案 0 :(得分:1)
您需要在 on_message 协程的末尾添加 await client.process_commands(message)
。
作为 docs 状态:
<块引用>默认情况下,这个协程在 on_message() 事件中被调用。如果你选择覆盖 on_message() 事件,那么你也应该调用这个协程。