Created
September 6, 2019 22:29
-
-
Save 4Kaylum/92abd745a7da7303622072da1d2e30fd to your computer and use it in GitHub Desktop.
A bot that, when a user uses a curse word, deletes their message and says "no swearing on my Christian Minecraft server"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""No swearing on my Christian Minecraft server""" | |
import json | |
import discord | |
from cogs import utils | |
class ChristianMinecraftServer(utils.Cog): | |
def __init__(self, bot:utils.CustomBot): | |
super().__init__(bot) | |
@utils.Cog.listener("on_message") | |
async def swear_listener(self, message:discord.Message): | |
"""Looks for swearing in the message and tells people off""" | |
if message.author.bot: | |
return | |
content = set(message.content.lower().strip().split()) | |
# with open("config/words.json") as a: | |
# swears = set(json.load(a)) | |
swears = {"fuck", "shit", "cunt", "gosh", "darn", "golly"} | |
if content.intersection(swears): | |
try: | |
await message.delete() | |
except discord.Forbidden: | |
pass | |
try: | |
await message.channel.send(f"{message.author.mention}, no swearing on my Christian Minecraft server.") | |
except discord.Forbidden: | |
pass | |
def setup(bot:utils.CustomBot): | |
x = ChristianMinecraftServer(bot) | |
bot.add_cog(x) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment