【问题标题】:On_message command not letting other commands workOn_message 命令不允许其他命令工作
【发布时间】:2020-06-13 02:40:22
【问题描述】:

这是我正在使用的代码。这行得通,但其余命令不起作用。 我怎样才能使它不影响其他命令?

@client.event
async def on_message(message):
    if message.content.startswith('!'):
        await message.delete()

【问题讨论】:

标签: discord discord.py discord.py-rewrite


【解决方案1】:

命令还在后台使用某种on_message,因此通过添加您自己的on_message,您可以让它像您想使用自己的on_message 一样使用它,从而阻止默认消息。要使其同时使用两者,请将await client.process_commands(message) 添加到 on_message 的末尾。

@client.event
async def on_message(message):
    if message.content.startswith('!'):
        await message.delete()
    await client.process_commands(message)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-16
    • 2013-08-18
    • 1970-01-01
    • 2017-03-16
    • 1970-01-01
    相关资源
    最近更新 更多