【发布时间】:2020-07-21 16:01:37
【问题描述】:
我有它,所以我的机器人会删除并发送带有坏词的消息。出于某种原因,如果我连续做了 2 个坏词,它会删除第一条消息和 dm 的 me 一次,然后删除另外 2 条消息和 dm 的 me 两次。有人能告诉我我做错了什么吗?
@client.event
async def on_message(message):
bad_words = ['bad','bot']
user = client.get_user(647589407515213866)
for word in bad_words:
if (message.content.count(word) > 0) and (message.content.count(word) < 2):
print("A bad word was said")
await message.channel.purge(limit=1)
await user.send(f'User {message.author} wrote {word}')
else:
await client.process_commands(message)
谁能告诉我为什么它会堆积消息以及如何解决它?
【问题讨论】:
标签: python discord discord.py