我正在尝试为我为朋友服务器制作的机器人制作一个错误的单词过滤器,但是该列表区分大小写。我该如何解决?
@client.event async def on_message(message): author = message.author content = message.content channel = message.channel log = client.get_channel(log channel) bad_words=["bad","word","yellow"] if any(bad_word in content for bad_word in bad_words): embed = discord.Embed(title="Bad word detected!", color=discord.Color.red()) embed.add_field(name=f"{author.display_name}, you have said a forbidden word!", value="You have been sent to Jail!") embed2 = discord.Embed(title=f"Bad word sent by {author} in #{channel}.", color=discord.Color.red()) embed2.add_field(name="They said:", value=f"{author.display_name}: {content}") await message.delete() await author.add_roles(discord.utils.get(author.guild.roles, name="jail")) await channel.send(embed=embed) await log.send(embed=embed2) await client.process_commands(message)
将内容小写,然后再进行检查
content = message.content.lower()