小编Max*_*Boy的帖子

Discord.py 脏话过滤器

我正在制作一个带有重写功能的discord.py 机器人。我想制作一个反脏话过滤器,这样如果有人在消息中脏话,它就会删除该消息并发送消息。我有一个脏话文件,其中包含我需要的所有单词。

这是我到目前为止的代码,但它不起作用:

@client.event
async def on_message(ctx, message):
    msg = message.content
    with open('badWords.txt') as BadWords:
        if msg in BadWords.read():
            await message.delete()
            await ctx.send("Dont use that word!")
        else:
            await ctx.process_commands(message)
Run Code Online (Sandbox Code Playgroud)

感谢所有帮助!

python file filter python-3.x discord.py

3
推荐指数
1
解决办法
7473
查看次数

标签 统计

discord.py ×1

file ×1

filter ×1

python ×1

python-3.x ×1