【发布时间】:2021-07-22 03:06:52
【问题描述】:
好的,所以我正在处理 Discord.py 中的 say 命令。我希望它检测用户是否在我的banned.txt 列表中使用了坏词,它不会说出来。问题是,如何让它检测大写和小写字母?例如,在我的列表中,它有“nigga”,但用户使用“NiGGa”。如何让 BOT 检测到它并且不会让 bot 这么说? 到目前为止,这是我的代码:
@commands.command()
async def say(self, message, *, content):
fp = open('banned.txt')
bad_list = [word.strip() for line in fp.readlines() for word in line.split(',') if word.strip() if word.lower()]
if any(word in content for word in bad_list):
await message.reply("Don't you dare!")
else:
await message.channel.trigger_typing()
await message.reply(f"```{content}```")
我无法在此处上传禁止的.txt,因为它违反了 ToS。
【问题讨论】:
标签: python python-3.x discord.py