Created
June 9, 2018 17:43
-
-
Save wilm0x42/65457966da29b73f218825b64f290cca to your computer and use it in GitHub Desktop.
Bartending bot for discord
This file contains hidden or 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
import discord | |
import asyncio | |
from discord.ext.commands import Bot | |
from discord.ext import commands | |
import platform | |
import numpy as np | |
client = Bot(description="Bar Bot because HECK YEAH", command_prefix="!", pm_help = False) | |
client.bot_key = "Redacted for security. Look it up." | |
client.heck_count = 1 | |
client.command_prefix = "!" | |
client.swears = np.load("swears.npy").item() | |
client.drunk = np.load("drunk.npy").item() | |
client.usersCutoff = {} | |
client.drinkMenu = { | |
"beer": 1, | |
"sake": 1, | |
"wine": 2, | |
"whiskey": 5, | |
"vodka": 5, | |
"water": -1, | |
"coffee": -5, | |
"tea": -3, | |
"rum": 4, | |
"soda": 0, | |
"gin": 4, | |
"martini": 3 | |
} | |
client.swears["wilm0x42"] = 0 # HAHA | |
@client.event | |
async def on_ready(): | |
print('Logged in as '+client.user.name+' (ID:'+client.user.id+')') | |
print('Connected to '+str(len(client.servers))+' servers') | |
print('Connected to '+str(len(set(client.get_all_members())))+' users') | |
print('Invite link: https://discordapp.com/oauth2/authorize?client_id={}&scope=bot&permissions=8'.format(client.user.id)) | |
return await client.change_presence(game=discord.Game(name='!menu or !help')) | |
@client.event | |
async def on_message(message): | |
# If the message author isn't the bot and the message starts with the | |
# command prefix ('!' by default), check if command was executed | |
if message.author.id != client.user.id and message.content.startswith(client.command_prefix): | |
# Remove prefix and change to lowercase so commands aren't case-sensitive | |
message.content = message.content[1:].lower() | |
if message.content.startswith("ping"): | |
await client.send_message(message.channel, "Pong!") | |
if message.content.startswith("heck"): | |
await client.send_message(message.channel, "heck" * client.heck_count) | |
client.heck_count += 1 | |
if message.content.startswith("swear"): | |
swearer = message.author.name.lower() | |
if not swearer in client.swears: | |
client.swears[swearer] = 0 | |
if (len(message.content) > 5): | |
swearer = message.content[6:].lower() | |
if not swearer in client.swears: | |
client.swears[swearer] = 0 | |
client.swears[swearer] += 1 | |
msg = swearer + " swear jar: $" + str(client.swears[swearer]) + ".00" | |
await client.send_message(message.channel, msg) | |
if message.content.startswith("barfight"): | |
await client.send_message(message.channel, "https://www.youtube.com/watch?v=2DoDCYXDA10\n(Volume warning)") | |
if message.content.startswith("help"): | |
msg = "I'm BarBot v0.2, custom made by wilm0x42. Here's the list of bartending functions currently in my database:\n" | |
msg += "!heck - Hecking heck\n" | |
msg += "!swear - Check your swear jar\n" | |
msg += "!swear [username] - Increment someone's swear jar\n" | |
msg += "!menu - View the drinks I can serve you\n" | |
await client.send_message(message.channel, msg) | |
if message.content.startswith("menu"): | |
msg = "~ Colin's Bar ~\n" | |
msg += "- !beer\n" | |
msg += "- !sake\n" | |
msg += "- !wine\n" | |
msg += "- !whiskey\n" | |
msg += "- !vodka\n" | |
msg += "- !rum\n" | |
msg += "- !gin\n" | |
msg += "- !martini\n" | |
msg += "Non-alcoholic drinks:\n" | |
msg += "- !water\n" | |
msg += "- !coffee\n" | |
msg += "- !tea\n" | |
msg += "- !soda\n" | |
await client.send_message(message.channel, msg) | |
if message.content.startswith("cut off ") and message.author.name.lower() == "coliflower": | |
stoned = message.content[8:].lower() | |
client.usersCutoff[stoned] = 1 | |
await client.send_message(message.channel, "Affirmative: " + stoned + " is too drunk. :no_entry_sign:") | |
if message.content.startswith("allow ") and message.author.name.lower() == "coliflower": | |
allowed = message.content[6:].lower() | |
client.usersCutoff.pop(allowed, None) | |
await client.send_message(message.channel, "Affirmative: " + allowed + " is fine. :beer:") | |
if message.content.startswith("sober") and message.author.name.lower() == "coliflower": | |
for key in client.drunk: | |
client.drunk[key] /= 2 | |
await client.send_message(message.channel, "Everyone feels less dead and more not-alive.") | |
if message.content.startswith("very sober") and message.author.name.lower() == "coliflower": | |
for key in client.drunk: | |
client.drunk[key] = 0 | |
await client.send_message(message.channel, "Everyone feels much less dead and much more not-alive.") | |
if message.content.startswith("the whole bottle"): | |
if message.author.name.lower() == "coliflower": | |
client.drunk[message.author.name.lower()] += 25 | |
await client.send_message(message.channel, message.author.name + " is " + str(client.drunk[message.author.name.lower()]) + "% drunk. :beers:") | |
else: | |
await client.send_message(message.channel, "Woah there, partner!") | |
if message.content.startswith("a glass of sorrows"): | |
await client.send_message(message.channel, "Sorry, you can't drink that away...") | |
if message.content.startswith("rum and coke"): | |
client.usersCutoff[message.author.name.lower()] = 1 | |
await client.send_message(message.channel, ":warning: HORRIBLE TASTE DETECTED. NOT IN _THIS_ BAR YOU DON'T. :warning:") | |
if message.content.startswith("entire can of reddi-wip") and message.author.name.lower() == "wilm0x42": | |
client.drunk[message.author.name.lower()] = 0 | |
msg = "It is advisable that you rethink your life choices.\n" | |
msg += message.author.name + " is " + str(client.drunk[message.author.name.lower()]) + "% drunk. :cloud:" | |
await client.send_message(message.channel, msg) | |
# Check for drink orders | |
for key in client.drinkMenu: | |
if message.content.startswith(key): | |
if not (message.author.name.lower() in client.usersCutoff and client.drinkMenu[key] > 0): | |
if message.author.name.lower() in client.drunk: | |
client.drunk[message.author.name.lower()] += client.drinkMenu[key] | |
else: | |
client.drunk[message.author.name.lower()] = client.drinkMenu[key] | |
msg = message.author.name + " is " + str(client.drunk[message.author.name.lower()]) + "% drunk." | |
if client.drinkMenu[key] < 0: | |
msg += " :milk:" | |
elif client.drunk[message.author.name.lower()] > 1000: | |
msg += " :skull_crossbones:" | |
elif client.drunk[message.author.name.lower()] >= 200: | |
msg += " :skull:" | |
elif client.drunk[message.author.name.lower()] >= 100: | |
msg += " :dizzy::beer:" | |
elif client.drunk[message.author.name.lower()] >= 50: | |
msg += " :beers:" | |
elif client.drinkMenu[key] > 0: | |
msg += " :beer:" | |
elif client.drunk[message.author.name.lower()] < 0: | |
msg += " :heartbeat:" | |
await client.send_message(message.channel, msg) | |
else: | |
await client.send_message(message.channel, "Sorry! I've received orders to stop giving you drinks.") | |
client.run(client.bot_key) | |
np.save("swears.npy", client.swears) | |
np.save("drunk.npy", client.drunk) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment