【问题标题】:How to skip bot from executing a command | discordpy如何跳过机器人执行命令 |不和谐
【发布时间】:2021-08-30 01:50:28
【问题描述】:

我有问题。我正在构建一个机器人来过滤聊天,它有两个重要的命令。 "addword" 用于将单词添加到列表 但是这里如果我想使用“removeword”命令,机器人会认为它是列表中的一个单词并删除它,它不能正常工作。

【问题讨论】:

    标签: python discord command


    【解决方案1】:

    嗯,这可能不是一个完美的答案,但这可能有效或至少有帮助:

    @client.event
    async def on_message(message):
        if condition: # if this is true, the command will be executed
           await client.process_commands(message)
    
    

    通过这样做,我们可以将变量 condition 设置为您想要的任何值,例如:

    condition = not message.startswith('!removeword')

    该示例使得无论何时在聊天中键入 removeword 命令,它都不会响应或运行实际命令。 确保将前缀 ! 替换为您的。

    【讨论】:

      猜你喜欢
      • 2021-09-19
      • 2018-07-21
      • 2018-11-10
      • 2021-08-07
      • 2017-05-31
      • 2021-10-21
      • 2022-01-15
      • 2021-06-17
      • 2020-04-29
      相关资源
      最近更新 更多