Skip to content

Instantly share code, notes, and snippets.

@4Kaylum
Created September 6, 2019 22:29
Show Gist options
  • Save 4Kaylum/92abd745a7da7303622072da1d2e30fd to your computer and use it in GitHub Desktop.
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"
"""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