aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVidhu Kant Sharma <bokuwakanojogahoshii@yahoo.com>2020-12-16 11:03:04 +0530
committerVidhu Kant Sharma <bokuwakanojogahoshii@yahoo.com>2020-12-16 11:03:04 +0530
commitd2a22a6f26c39350adc71158e43e5c7c902a28f3 (patch)
treebd87ccacbc10eba986d96b5ed472488dd8c712ed
parentc9834b5e7db581decea1e80086a32d706dd10b8a (diff)
added functionality to catch curse words and added a help command
-rw-r--r--bot.py41
1 files changed, 35 insertions, 6 deletions
diff --git a/bot.py b/bot.py
index 6333c7f..1f474b5 100644
--- a/bot.py
+++ b/bot.py
@@ -9,8 +9,27 @@ def get_info():
info_messages = [random.choice(greetings) + " I'm a Discord bot created by Vidhu Kant Sharma", "This bot is pog"]
return random.choice(info_messages)
+bad_words = ['fuck', 'shit', 'bitch', 'cunt', 'sex']#, '', '', '', '', '', '', '', '', '', '', '', '')
+
+
+
CALL = "z!"
-HELP_MESSAGE = '```Every command should be prefixed with "' + CALL + '".\nsay repeats your previous message\ninfo displays info about the bot and the creator\nhelp shows this message```'
+HELP_MESSAGE = '```Every command should be prefixed with "' + CALL + '".\n\nsay repeats your previous message\ninfo displays info about the bot and the creator\nhelp shows this message```'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
@@ -22,6 +41,7 @@ client = discord.Client()
@client.event
async def on_ready():
print(f'{client.user} has connected to Discord!')
+ await client.change_presence(activity=discord.Game('Guess you are my little pogchamp'))
@@ -29,15 +49,24 @@ async def on_ready():
async def on_message(message):
if message.author == client.user:
return
-
+
+ # say something
if message.content[0:len(CALL) + 4] == CALL + 'say ':
- response = message.content[5:]
- await message.channel.send(response)
-
+ response = message.content[5:] # users message with the command removed
+
+ # check if the user said a bad word
+ if response[1:] in bad_words: # for some reason the first character is always a space
+ await message.channel.send('THIS IS A FAMILY FRIENDLY DISCORD SERVER')
+ await message.channel.send('NO ONE WILL FUCKING CURSE')
+ else:
+ await message.channel.send(response)
+
+ # send info message
if message.content == CALL + 'info':
response = get_info()
await message.channel.send(response)
-
+
+ # send help message
if message.content == CALL + 'help':
response = HELP_MESSAGE
await message.channel.send(response)