【发布时间】:2020-12-03 19:54:17
【问题描述】:
我的 discord 机器人上有一个过滤器,可以删除来自所有人的消息,包括“discord.gg、@everyone、@here”,除非他们具有管理员角色。我的过滤器检查发送的每条消息,它首先检查该用户是否具有管理员角色,然后检查内容。如果某人在具有管理员角色时发送消息(包含这 3 个黑名单单词中的一个或全部),机器人将允许发送消息。 不知何故,过滤器停止工作,我不知道。该机器人是用 discord.py 编写的。 问题是过滤器阻止机器人发送任何类型的消息。我已经缩小到第 2 行(来自这段代码)。
@client.event
async def on_message(message):
if '735893522032623646' not in str(message.author.roles):
if 'discord.gg' in message.content:
await message.channel.purge(limit=1)
print('had inv link')
if '@everyone' in message.content:
await message.channel.purge(limit=1)
print('had everyone')
if '@here' in message.content:
await message.channel.purge(limit=1)
print('had here')
【问题讨论】:
标签: python discord discord.py