【发布时间】:2022-06-18 23:41:24
【问题描述】:
如果消息中没有单词,我希望机器人删除该消息,但仅在仅发送该“单词”时才删除
示例:no no word 是“Hate”,但如果我发送“I Hate you”,它不会删除消息... 只有当我说“讨厌”时它才会删除 这是我的代码..请帮助:)
nono = ['Hate']
@client.event
@commands.has_permissions(manage_messages = False)
async def on_message(message):
if message.author.id == client.user.id:
return
if message.guild is not None:
for word in nono:
if word in message.content:
await message.delete()
await message.author.send('I hate you too')
await client.process_commands(message)
else :
return
【问题讨论】:
-
不起作用:)
-
您为什么要使用
@commands.has_permissions(manage_messages = False)进行活动?这一切对我来说都很好。机器人删除了I Hate you,但没有删除I hate you,也许这是你的错误。 -
奇怪....我使用
@commands.has_permissions(manage_messages = False)来处理一个事件是因为我希望只有拥有管理消息权限的人不会删除该消息
标签: discord.py