如何跳过机器人执行命令 |不和谐的

How to skip bot from executing a command | discordpy

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

好吧,这可能不是一个完美的答案,但这可能有用或至少有所帮助:

@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 命令,它都不会响应或 运行 实际命令。 确保将前缀 ! 替换为您的前缀。