在保留命令的同时监听Discord.py中的消息

2024-05-14 13:18:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我的目标是让我的机器人总是在discord.py中监听特定的消息。在这个例子中,它应该听到的消息是$greet,它应该用“Say hello”响应它,并在文本对语音中大声朗读。

这工作很好,但它禁用常规命令,我有设置喜欢!玩吧!救命啊。有没有办法绕过这个限制?

示例代码:

@my_bot.event
async def on_message(message, timeout=10,):
    if message.content.startswith('$greet'):
        await my_bot.send_message(message.channel, 'Say hello', tts=True)
        msg = await my_bot.wait_for_message(author=message.author, content='hello')
        await my_bot.send_message(message.channel, 'Hello.')

预期产量:

User: !play
Bot: Now playing...
User: $greet
Bot: Say hello

实际产量:

User: !play
User: $greet
Bot: Say hello

Tags: send消息messagehellomybotchannelcontent

热门问题