Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- import asyncio
- import random
- import time
- import praw
- from googletrans import Translator
- from weather import Weather
- exp = 'exp.txt'
- #'/Users/Cy/Desktop/,/School/Personal Project/suzuakze/exp.txt'
- cache = 'cache.txt'
- #'/Users/Cy/Desktop/,/School/Personal Project/suzuakze/cache.txt'
- stalk_market = 'stalk_market.txt'
- #'/Users/Cy/Desktop/,/School/Personal Project/suzuakze/stalk_market.txt'
- client = discord.Client()
- r = praw.Reddit(client_id = "pB1R1zx8nq-Obw", client_secret = "wgSaKS4HzUtHEXyBIusSRLrjI2M", user_agent = "/u/c2ke", username = "DoritoFaceBot", password = "thisisapassword")
- t = Translator()
- w = Weather()
- stalk = 2000
- last_message = 0
- up = 30
- down = 40
- same = 50
- @client.event
- async def on_message(message):
- global stalk
- global last_message
- global up
- global down
- global same
- if message.author == client.user:
- return
- #----------------------------------------------------------------------------------------
- if message.content.lower().startswith("!hello"):
- msg = "hi {0.author.mention}!".format(message)
- await client.send_message(message.channel, msg)
- print('!hello, ' + str(message.author))
- if message.content.lower().startswith('!help'):
- await client.send_message(message.channel, "i'm currently in my alpha stage. the primary commands i have right now are:")
- await client.send_message(message.channel, "`!hello`, `!dice`, `!flip`, `role`, `!exp`, `!stalk help`, `!translate`, `!weather`, `!wp`, `!showerthought`, and `!til`")
- await client.send_message(message.channel, 'read more about each command here: *insert evan\'s website here*')
- print('!help, ' + str(message.author))
- if message.content.lower().startswith("ty suzukaze"):
- await client.send_message(message.channel, "i'm glad i could help!")
- #add image based thingies
- #redo help
- #----------------------------------------------------------------------------------------
- if message.content.lower().startswith('!dice'):
- randomDice = random.randint(1,6)
- await client.send_message(message.channel, "*shakes dice*")
- await asyncio.sleep(2)
- if randomDice == 6:
- await client.send_message(message.channel, "whoa, you got a **6**!")
- else:
- await client.send_message(message.channel, "you got a **" + str(randomDice) + "**!")
- print('!dice, ' + str(message.author))
- if message.content.lower().startswith('!flip'):
- if random.randint(1, 50) == 50:
- await client.send_message(message.channel, "(ヘ・_・)ヘ ┳━┳")
- await asyncio.sleep(1)
- await client.send_message(message.channel, "(╯°□°)╯︵ ┻━┻")
- else:
- await client.send_message(message.channel, "*insert coin in air noises here*")
- await asyncio.sleep(1)
- if random.randint(1,2) == 1:
- await client.send_message(message.channel, "heads!")
- else:
- await client.send_message(message.channel, "tails!")
- print('!flip, ' + str(message.author))
- #ADD CHOICES OPTION
- #----------------------------------------------------------------------------------------
- if message.content.lower().startswith('!role'):
- roleList = ["10-1", "10-2", "math extended", "math plus", "math", "french", "spanish", "spanish plus", "computer science", "music", "visual arts", "theatre", "film", "creative writing", "theatre tech", "photography", "sports leadership", "spicy"]
- enteredRole = message.content[6:].lower()
- role = discord.utils.get(message.server.roles, name=enteredRole)
- roles = [
- "376175453171613698"
- "376175469097254914"
- "367774687528353792"
- "367780169521299477"
- "367780299821678593"
- "367780190140760065"
- "367780203654807552"
- "367780221425811458"
- "367780418969141258"
- "367780451554820106"
- "367780467459751939"
- "367780497289641986"
- "367780528138616833"
- "367780552155070465"
- "367780585420095488"
- "367780679208927233"
- "367781743333474304"
- "389503593356460032"
- ]
- if role is None or role.name not in roleList:
- await client.send_message(message.channel, "sorry, i think that role doesnt exist! here's a list of roles i know of:")
- await client.send_message(message.channel, roleList)
- return
- elif role in message.author.roles:
- await client.remove_roles(message.author, role)
- await client.send_message(message.channel, "i removed the role from your account :P")
- return
- else:
- await client.add_roles(message.author, role)
- if message.content.startswith('!role spicy'):
- await client.send_message(message.channel, "(~˘▾˘)~ as my creator would say, stay spicy my brochacho ~(˘▾˘~)")
- else:
- await client.send_message(message.channel, "i added the role to your account :D")
- print('!role, ' + str(message.author))
- #make sure roles are up-to-date
- #----------------------------------------------------------------------------------------
- if message.content.lower().startswith(''):
- count_cache = 0
- count_exp = 0
- cache_r = open(cache, 'r')
- exp_r = open(exp, 'r')
- before = ""
- middle = ""
- after = ""
- for x in cache_r:
- count_cache += 1
- if x.startswith(str(message.author)):
- break
- for x in exp_r:
- count_exp += 1
- if count_exp <= count_cache - 1:
- before += str(x)
- elif count_exp == count_cache:
- middle += str(x)
- elif count_exp >= count_cache:
- after += str(x)
- middle = int(middle.strip()) + len(message.content)
- exp_w = open(exp, 'w')
- exp_w.write(str(before))
- exp_w.write(str(middle) + "\n")
- exp_w.write(str(after))
- exp_w.close()
- if message.content.lower().startswith('!exp'):
- count_cache = 0
- count_exp = 0
- cache_r = open(cache, 'r')
- exp_r = open(exp, 'r')
- for x in cache_r:
- count_cache += 1
- if x.startswith(str(message.author)):
- break
- for x in exp_r:
- count_exp += 1
- if count_exp == count_cache:
- msg = ("{0.author.mention} has " + x.strip() + "EXP!").format(message)
- await client.send_message(message.channel, msg)
- #add rank/leaderboard
- #----------------------------------------------------------------------------------------
- if message.content.lower().startswith(''):
- if stalk < 5:
- stalk = 5
- if stalk > 1 and stalk < 2000:
- up = 100
- down = 20
- same = -20
- if stalk > 2000 and stalk < 5000:
- up = 30
- down = 40
- same = 5
- if stalk > 5000 and stalk < 8500:
- up = 35
- down = 60
- same = 100
- if stalk > 7500 and stalk < 15000:
- up = 75
- down = 35
- same = -20
- if stalk > 15000 and stalk < 2500:
- up = 10
- down = 50
- same = 100
- if stalk > 25000:
- up = 30
- down = 40
- same = -20
- if len(message.content) == last_message:
- stalk += same
- last_message = len(message.content)
- elif len(message.content) >= last_message:
- stalk += up
- last_message = len(message.content)
- elif len(message.content) <= last_message:
- stalk -= down
- last_message = len(message.content)
- if message.content.lower().startswith('!stalk help'):
- await client.send_message(message.channel, 'to view current stalk prices, use `!stalk price`. to trade stalks, use `!stalk buy x` and `!stalk sell x`, with x being the amount of stalks.')
- if message.content.lower().startswith('!stalk price'):
- await client.send_message(message.channel, "currently, a stalk sells for " + str(stalk) + "¥. Check your account with `!stalk portfolio`")
- print('!stalk price, ' + str(message.author))
- if message.content.lower().startswith('!stalk portfolio'):
- stalk_r = open(stalk_market, 'r')
- cache_r = open(cache, 'r')
- count_cache_s = 0
- count_stalk = 0
- for x in cache_r:
- count_cache_s += 1
- if x.startswith(str(message.author)):
- break
- for x in stalk_r:
- count_stalk += 1
- if count_cache_s == count_stalk:
- stalk_yen = x.find('STK') + 3
- user_stalk = str(x[:stalk_yen])
- user_yen = str(x[stalk_yen:])
- msg = ("{0.author.mention} has `" + user_stalk + "` and `" + user_yen.strip() + "¥`").strip().format(message)
- await client.send_message(message.channel, msg)
- print('!stock portfolio, ' + str(message.author))
- if message.content.lower().startswith('!stalk buy '):
- stalk_r = open(stalk_market, 'r')
- stalk_r_2 = open(stalk_market, 'r')
- cache_r = open(cache, 'r')
- count_cache_s = 0
- count_stalk = 0
- count_stalk_s = 0
- pre = ""
- post = ""
- for x in cache_r:
- count_cache_s += 1
- if x.startswith(str(message.author)):
- break
- for x in stalk_r:
- count_stalk += 1
- if count_stalk == count_cache_s:
- cordinates = 'the cartel\'s location will bring you the key to space'
- elif count_stalk < count_cache_s:
- pre += str(x)
- elif count_stalk > count_cache_s:
- post += str(x)
- for x in stalk_r_2:
- count_stalk_s += 1
- if count_cache_s == count_stalk_s:
- stalk_cut = x.find('STK')
- yen_cut = x.find('STK') + 4
- user_stalk = str(x[:stalk_cut])
- user_yen = str(x[yen_cut:])
- amount = message.content[10:]
- total_price = stalk * int(amount)
- if int(total_price) <= int(user_yen):
- new_stalk = int(user_stalk) + int(amount)
- new_yen = int(user_yen) - int(total_price)
- mid = str(new_stalk) + " STK " + str(new_yen)
- stalk_w = open(stalk_market, 'w')
- stalk_w.write(str(pre))
- stalk_w.write(str(mid) + "\n")
- stalk_w.write(str(post))
- stalk_w.close()
- await client.send_message(message.channel, "your account has been updated!")
- else:
- await client.send_message(message.channel, "sorry, you don't seem to have enough yen...!")
- print('!stalk buy, ' + str(message.author))
- if message.content.lower().startswith('!stalk sell '):
- stalk_r = open(stalk_market, 'r')
- stalk_r_2 = open(stalk_market, 'r')
- cache_r = open(cache, 'r')
- count_cache_ss = 0
- count_stalk_s = 0
- count_stalk_ss = 0
- pre = ""
- post = ""
- for x in cache_r:
- count_cache_ss += 1
- if x.startswith(str(message.author)):
- break
- for x in stalk_r:
- count_stalk_s += 1
- if count_stalk_s == count_cache_ss:
- cordinates = 'the cartel\'s location will bring you the key to space'
- elif count_stalk_s < count_cache_ss:
- pre += str(x)
- elif count_stalk_s > count_cache_ss:
- post += str(x)
- for x in stalk_r_2:
- count_stalk_ss += 1
- if count_cache_ss == count_stalk_ss:
- stalk_cut = x.find('STK')
- yen_cut = x.find('STK') + 4
- user_stalk = str(x[:stalk_cut])
- user_yen = str(x[yen_cut:]).strip()
- amount = message.content[12:]
- total_price = stalk * int(amount)
- if int(amount) <= int(user_stalk):
- new_stalk = int(user_stalk) - int(amount)
- new_yen = int(user_yen) + int(total_price)
- mid = str(new_stalk) + " STK " + str(new_yen)
- stalk_w = open(stalk_market, 'w')
- stalk_w.write(str(pre))
- stalk_w.write(str(mid) + "\n")
- stalk_w.write(str(post))
- stalk_w.close()
- await client.send_message(message.channel, "your account has been updated!")
- else:
- await client.send_message(message.channel, "sorry, you don't seem to have enough stalks...!")
- print('!stock sell, ' + str(message.author))
- #----------------------------------------------------------------------------------------
- if message.content.lower().startswith('!translate'):
- trans = message.content[10:]
- completed_trans = t.translate(trans).text
- await client.send_message(message.channel, trans + " ---> " + completed_trans)
- print('!translate, ' + str(message.author))
- #----------------------------------------------------------------------------------------
- if message.content.lower().startswith('!weather'):
- location = w.lookup_by_location('Vancouver Canada')
- forecasts = location.forecast()
- count = 0
- for forecast in forecasts:
- count += 1
- if count == 1:
- weather_message = (((float(forecast.high()) + float(forecast.low()))/2) - 32) * (5/9)
- await client.send_message(message.channel, 'today there\'s **' + forecast.text().lower() + '** with an average temperature of **' + str(int(weather_message)) + 'C**!')
- if count == 2:
- weather_message = (((float(forecast.high()) + float(forecast.low()))/2) - 32) * (5/9)
- await client.send_message(message.channel, 'tommorrow there\'ll be **' + forecast.text().lower() + '** with an average temperature of **' + str(int(weather_message)) + 'C**!')
- if count == 3:
- break
- print('!weather, ' + str(message.author))
- #sunrise/sunset
- #----------------------------------------------------------------------------------------
- if message.content.lower().startswith('!wp'):
- prompts = ['']
- for submission in r.subreddit("WritingPrompts").hot(limit=25):
- if str(submission.title).startswith('[WP]'):
- prompts.append(submission.title)
- await client.send_message(message.channel, 'here\'s a writing prompt i found from reddit!')
- await client.send_message(message.channel, '"' + prompts[random.randint(1, 23)] + '"')
- print('!wp, ' + str(message.author))
- if message.content.lower().startswith('!showerthought'):
- prompts = ['']
- for submission in r.subreddit("Showerthoughts").hot(limit=25):
- prompts.append(submission.title)
- await client.send_message(message.channel, 'here\'s a shower thought i found from reddit!')
- await client.send_message(message.channel, '"' + prompts[random.randint(1, 24)] + '"')
- print('!showerthought, ' + str(message.author))
- if message.content.lower().startswith('!til'):
- prompts = ['']
- for submission in r.subreddit("TodayILearned").hot(limit=25):
- prompts.append(submission.title)
- await client.send_message(message.channel, 'here\'s a fact i found from reddit!')
- await client.send_message(message.channel, '"' + prompts[random.randint(1, 25)] + '"')
- print('!til, ' + str(message.author))
- #----------------------------------------------------------------------------------------
- if message.content.lower().startswith('!focus'):
- role = discord.utils.get(message.server.roles, name="focusing")
- await client.add_roles(message.author, role)
- print('!focus, ' + str(message.author))
- if message.content.lower().startswith('!unlock'):
- role = discord.utils.get(message.server.roles, name="focusing")
- await client.remove_roles(message.author, role)
- print('!unlock, ' + str(message.author))
- #----------------------------------------------------------------------------------------
- @client.event
- async def on_member_join(member):
- msg = ('welcome to SH2020 {0.mention}!').format(message)
- await client.send_message(discord.Object(id='372242666672619522'), msg)
- exp_w = open(exp, 'a')
- exp_w.write('0' + '\n')
- exp_w.close()
- cache_w = open(cache, 'a')
- cache_w.write(message.author + '\n')
- exp_w.close()
- stalk_w = open(stalk_market, 'a')
- stalk_w.write('1 STK 5000')
- stalk_w.close()
- @client.event
- async def on_member_remove(member):
- msg = ('bye {0.mention} ;-;').format(message)
- await client.send_message(discord.Object(id='372242666672619522'), msg)
- #----------------------------------------------------------------------------------------
- @client.event
- async def on_ready():
- print("logged in as: " + client.user.name)
- print("------")
- await client.send_message(discord.Object(id='389506544544382996'), 'i\'m on!')
- client.run("MzU5NzgzNjY2MzkxNTgwNjg1.DMA78w.t_KUNsPMI9X67PW9G6pFxWXCd94")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement