首页 > 解决方案 > discord.py 防止删除包含 #start 的消息

问题描述

#start所以在我正在制作的机器人中,有一个循环可以删除任何在特定时间没有说的消息。但我希望它删除任何包含“#start”和其他任何内容的消息。因此,如果我要#start在不和谐服务器上发送,机器人不会删除它,但如果我要发送一条消息说它#start testing会删除该消息。我不知道该怎么做。这就是我想出的:

while hour >= 12 and hour < 14:
   msg = await bot.wait_for_message(timeout=1, author=message.author)
   if "#start" not in msg.content:
      await bot.delete_message(msg)
   hour = int(time.strftime("%H"))

它说即使我在将消息写入 csv 文件时可以使用它,它msg也没有调用属性。content那么有什么想法吗?我全是耳朵

标签: pythonbotsdiscorddiscord.py

解决方案


推荐阅读