From 6dbda5e502bb0de13697e98627b3db168db48920 Mon Sep 17 00:00:00 2001 From: christian Date: Sat, 7 Aug 2021 14:22:30 +0200 Subject: [PATCH] initial release of suggestionsbot --- suggestionsbot/discord_suggestions.py | 46 +++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 suggestionsbot/discord_suggestions.py diff --git a/suggestionsbot/discord_suggestions.py b/suggestionsbot/discord_suggestions.py new file mode 100644 index 00000000..21ccc7cb --- /dev/null +++ b/suggestionsbot/discord_suggestions.py @@ -0,0 +1,46 @@ +import discord +from discord.ext import commands +from settings import token +import datetime + +client = discord.Client() +#shit api. got switched like 1 year ago so like every single discusison about it is outdated. + +def get_suggestion_type(msg): + suggestion_type = "GENERIC" + if msg.startswith('!ze'): + suggestion_type = "ZOMBIE ESCAPE" + msg = msg.replace('!ze', '') + elif msg.startswith('!mg'): + suggestion_type = "MINIGAME" + msg = msg.replace('!mg', '') + elif msg.startswith('!zr'): + suggestion_type = "ZOMBIE RIOT" + msg = msg.replace('!zr', '') + elif msg.startswith('!forum'): + suggestion_type = "FORUM" + msg = msg.replace('!forum', '') + elif msg.startswith('!discord'): + suggestion_type = "DISCORD" + msg = msg.replace('!discord', '') + elif msg.startswith('!meta'): + suggestion_type = "META" + msg = msg.replace('!meta', '') + return suggestion_type, msg.strip() + +@client.event +async def on_message(message): + if message.author.bot: + return + if message.channel.name == 'suggestion-box': #suggestion-box + channel = client.get_channel(872925751295504476) #872925751295504476 + message_content = message.content + suggestion_type, message_content = get_suggestion_type(message_content) + now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + send_msg = f"""```DISCORD USER ID: {message.author.id}\nUSERNAME: {message.author}\nTYPE: {suggestion_type}\nTIME: {now}\nSUGGESTION: {message_content}```""" + send_channel_msg = f"""{message.author} your suggestion was sent to admins as type: {suggestion_type}. Specify Suggestion types by appending your message with one of the following commands: !ze !zr !mg !forum !discord !meta""" + await message.channel.purge(limit=1) + await message.channel.send(send_channel_msg) + await channel.send(send_msg) + +client.run(token)