Advertisement
Faerlynn

Miku v0.21.2 (23.1.2019)

Jan 23rd, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 56.05 KB | None | 0 0
  1. import discord
  2. import random
  3. import time
  4. import os
  5. import timeit
  6. import sys
  7. import asyncio
  8. from youtube_dl import YoutubeDL
  9. from apiclient.discovery import build
  10. import datetime
  11. import ctypes
  12.  
  13. client = discord.Client()
  14.  
  15. def log(msg, message_channel, message_author, cmd_type):
  16.     if cmd_type == '':
  17.         cmd_type = 'unknown'
  18.     print('Command \'{0}\' used in {1} by {2}!'.format(cmd_type, str(message_channel), str(message_author)))
  19.  
  20. def reload_files():
  21.     global cuddle_message, hug_message, kiss_message, about, patchnotes, pat_message, version, slap_message, s_id, success
  22.     global miku_message, dev_key, youtube, help_message, shy_message
  23.     #Opens file for 'cuddle'
  24.     success = False
  25.     try:
  26.         file = open("bot_save_files\cuddle_messages.txt",'r')
  27.         line = file.readline()
  28.         cuddle_message = []
  29.         while line:
  30.             cuddle_message.append(line)
  31.             line = file.readline()
  32.         file.close()
  33.     except:
  34.         print("File 'cuddle_messages.txt' couldn't be opened!")
  35.         success = True
  36.  
  37.     #Opens file for 'hug'
  38.     try:
  39.         file = open("bot_save_files\hug_messages.txt",'r')
  40.         line = file.readline()
  41.         hug_message = []
  42.         while line:
  43.             hug_message.append(line)
  44.             line = file.readline()
  45.         file.close()
  46.     except:
  47.         print("File 'hug_messages.txt' couldn't be opened!")
  48.         success = True
  49.  
  50.     #Opens file for 'pat'
  51.     try:
  52.         file = open("bot_save_files\pat_messages.txt",'r')
  53.         line = file.readline()
  54.         pat_message = []
  55.         while line:
  56.             pat_message.append(line)
  57.             line = file.readline()
  58.         file.close()
  59.     except:
  60.         print("File 'pat_messages.txt' couldn't be opened!")
  61.         success = True
  62.        
  63.     #Opens file for 'kiss'
  64.     try:
  65.         file = open("bot_save_files\kiss_messages.txt",'r')
  66.         line = file.readline()
  67.         kiss_message = []
  68.         while line:
  69.             kiss_message.append(line)
  70.             line = file.readline()
  71.         file.close()
  72.     except:
  73.         print("File 'kiss_messages.txt' couldn't be opened!")
  74.         success = True
  75.        
  76.     #Opens file for 'about'
  77.     try:
  78.         about = ''
  79.         file = open("bot_save_files\\about.txt",'r')
  80.         about = file.read()
  81.         file.close()
  82.     except:
  83.         print("File 'about.txt' couldn't be opened!")
  84.         success = True
  85.  
  86.     #Opens file for 'about'
  87.     try:
  88.         version = ''
  89.         file = open("bot_save_files\\patch.txt",'r')
  90.         version = file.read()
  91.         file.close()
  92.     except:
  93.         print("File 'patch.txt' couldn't be opened!")
  94.         success = True
  95.  
  96.     #Opens file for 'patchnotes'
  97.     try:
  98.         patchnotes = ''
  99.         file = open("bot_save_files\\patch_notes.txt",'r')
  100.         patchnotes = file.read()
  101.         file.close()
  102.     except:
  103.         print("File 'patch_notes.txt' couldn't be opened!")
  104.         success = True
  105.  
  106.     #Opens file for 'slap'
  107.     try:
  108.         file = open("bot_save_files\slap_messages.txt",'r')
  109.         line = file.readline()
  110.         slap_message = []
  111.         while line:
  112.             slap_message.append(line)
  113.             line = file.readline()
  114.         file.close()
  115.     except:
  116.         print("File 'slap_messages.txt' couldn't be opened!")
  117.         success = True
  118.  
  119.     #Opens file for 'shy'
  120.     try:
  121.         file = open("bot_save_files\shy_messages.txt",'r')
  122.         line = file.readline()
  123.         shy_message = []
  124.         while line:
  125.             shy_message.append(line)
  126.             line = file.readline()
  127.         file.close()
  128.     except:
  129.         print("File 'shy_messages.txt' couldn't be opened!")
  130.         success = True
  131.  
  132.     #Opens fire for s_id
  133.     s_id = {}
  134.     try:
  135.         file = open("bot_save_files\server_id.txt",'r')
  136.         line = file.readline()
  137.         while line:
  138.             key, value = line.split(':')
  139.             s_id[key] = value[:1]
  140.             line = file.readline()
  141.         file.close()
  142.     except:
  143.         print("File 'server_id.txt' couldn't be opened!")
  144.         success = True
  145.  
  146.     #Opens file for 'miku reaction'
  147.     try:
  148.         file = open("bot_save_files\miku_reaction_msg.txt",'r')
  149.         line = file.readline()
  150.         miku_message = []
  151.         while line:
  152.             miku_message.append(line)
  153.             line = file.readline()
  154.         file.close()
  155.     except:
  156.         print("File 'miku_reaction_msg.txt' couldn't be opened!")
  157.         success = True
  158.  
  159.     #Opens file for 'help command'
  160.     try:
  161.         file = open("bot_save_files\help_list.txt", 'r')
  162.         help_message = file.read()
  163.         file.close()
  164.     except Exception as e:
  165.         print(e)
  166.     #Loads dev_key
  167.     file = open('bot_save_files\dev_key.txt', 'r')
  168.     dev_key = file.readline()
  169.     file.close()
  170.     youtube = build('youtube', 'v3', developerKey=dev_key)
  171.     return success
  172.        
  173.    
  174.  
  175. def save():
  176.     global s_id
  177.     key, value = '', ''
  178.     s_id_file = ''
  179.     for key, value in s_id.items():
  180.         s_id_file = s_id_file + "{0}:{1}\n".format(key, value)
  181.     os.remove("bot_save_files\server_id.txt")
  182.     file = open("bot_save_files\server_id.txt",'w')
  183.     file.write(str(s_id_file))
  184.     file.close()
  185.  
  186.  
  187. #startup variables
  188. ydl_opts = {
  189.     'format': 'bestaudio/best',
  190.     'outtmpl': 'tmp/%(id)s.%(ext)s',
  191.     'noplaylist': True,
  192.     'quiet': True,
  193.     'prefer_ffmpeg': True,
  194.     'audioformat': 'wav',
  195.     'forceduration':True
  196. }
  197.  
  198. game_number = 274**21
  199. game_active = False
  200. attempts = 0
  201. round_active = False
  202. error = ''
  203. player = ''
  204. author = ''
  205. msg = ''
  206. gmn_cp = {}
  207. gmn_number = {}
  208. gmn_a = {}
  209. edits = ['*', '__', '~~', '**', '***']
  210. players = {}
  211. playlist = {}
  212. cp = {}
  213. loop = {}
  214. lp = {}
  215. ytdl = YoutubeDL()
  216. urls = {}
  217. cpsong = {}
  218. miku_names = ['miku', 'Miku', 'M I K U', 'MIKU', 'm i k u', 'mIku', 'miKu', 'mikU', 'MIku', 'MiKu',
  219.               'MikU', 'mIKu', 'mIkU', 'mIKU', 'MiKU', 'MIkU', 'MIKu', 'miKU']
  220. play_list = {}
  221. info = {}
  222. dev_key = ''
  223. cpsong_two = {}
  224. voice_list = {}
  225.  
  226.  
  227. #@client.event
  228. async def message_in(message, c):
  229.     global game_number, game_active, error, round_active, attempts, about, player, author, msg, version, s_id, gmn_cp, success
  230.     global miku_message, edits, statuses, players, vc, playlist, cp, loop, lp, miku_names, cpsong
  231.     global play_list, ytdl, dev_key, youtube, client, help_message, cpsong_two, shy_message, voice_list
  232.     client = c
  233.     if message.author == client.user:
  234.         return
  235.     sid = message.server.id
  236.  
  237.     if not message.server.id in s_id:
  238.         s_id[message.server.id] = '$'
  239.         print('Creating a backup...')
  240.         msg = 'Creating a first settings for your server!'
  241.         await client.send_message(message.channel, msg)
  242.         save()
  243.         reload_files()
  244.         return
  245.    
  246.     #done       HELLO
  247.     if message.content.startswith('{0}hello'.format(s_id[sid])):
  248.         cmd = 'hello'
  249.         msg = '*Hello {0.author.mention}'.format(message) + '''! My name is MikuBot! If you wanna find more about me and my creator, just type* **`{0}about`** *and read!\nIf you want to know more, just type* **`{0}help`**, *and there you can find all my available commands!*'''.format(s_id[message.server.id])
  250.         log(msg, message.channel, message.author, cmd)
  251.         await client.send_message(message.channel, msg)
  252.  
  253.     #done       LOVE
  254.     if message.content.startswith('{0}love'.format(s_id[sid])):
  255.         cmd = 'love'
  256.         msg = "Hi Lily! This is just a reminder, that I, Ana Alexandra Adria Katalina Aisaka, really love you so so much!!! <3 always <3 *hugs you tightly and strokes your hair, then after moment of huggling she pats your head and giggles*"
  257.         log(msg, message.channel, message.author, cmd)
  258.         await client.send_message(message.channel, msg)
  259.  
  260.     #done       RANDOM NUMBER
  261.     if message.content.startswith('{0}random'.format(s_id[sid])):
  262.         cmd = 'random'
  263.         msg = ('Randomly generated number: '+str(random.randrange(101)))
  264.         log(msg, message.channel, message.author, cmd)
  265.         await client.send_message(message.channel, msg)
  266.  
  267.     #done       POKE
  268.     if message.content.startswith('{0}poke'.format(s_id[sid])):
  269.         cmd = "poke"
  270.         msg = str(message.content)[6:]
  271.         msg_list = msg.split(' ')
  272.         msg_recipient = ''
  273.         msg_author = str(message.author)[:-5]
  274.         msg_content_test = False
  275.         for i in range(len(msg_list)):
  276.             msg_check = msg_list[i]
  277.             if (('<@!' and '>') in msg_check) == True:
  278.                 msg_recipient = msg_check
  279.                 msg_content_test = True
  280.         if not '@' in msg_recipient:
  281.             msg_recipient = 'fridge'
  282.         if msg_content_test == False:
  283.             msg = '*' + msg_author + " tries to poke an empty air, and there should be nothing there.. But suddenly a white cloud appears before them, forming into a big ghost with a single long arm, and only three fingers. " + msg_author + " can't move any limbs, and as ghost's finger comes closer, they close their eyes, only to feel a small poke on their nose. When " + msg_author + " finally opens eyes, there is no more ghost to be seen.*"
  284.         else:
  285.             msg = '*' + msg_author + " pokes " + msg_recipient + "'s shoulder gently and then just waits for their response patiently.*"
  286.  
  287.         log(msg, message.channel, message.author, cmd)
  288.         await client.send_message(message.channel, msg)
  289.         if msg_recipient == '<@!492432534181773313>':
  290.             time.sleep(1)
  291.             msg = "*She looks at {0.author.mention} curiously, and after moment she pokes {0.author.mention}'s nose back.*".format(message)
  292.             await client.send_message(message.channel, msg)
  293.  
  294.     #done       CUDDLE
  295.     if message.content.startswith('{0}cuddle'.format(s_id[sid])):
  296.         cmd = 'cuddle'
  297.         try:
  298.             msg = str(message.content)[8:]
  299.             msg_list = msg.split(' ')
  300.             msg_recipient = ''
  301.             msg_author = str(message.author)[:-5]
  302.             msg_content_test = False
  303.            
  304.             for i in range(len(msg_list)):
  305.                 msg_check = msg_list[i]
  306.                 if (('<@!' and '>') in msg_check) == True:
  307.                     msg_recipient = msg_check
  308.                     msg_content_test = True
  309.             if not '!' in msg_recipient:
  310.                 msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
  311.             if not '@' in msg_recipient:
  312.                 msg_recipient = 'themselve'
  313.  
  314.             if msg_recipient == str(message.author.mention):
  315.                 msg = random.choice(cuddle_message).format('Miku', msg_recipient)
  316.             else:
  317.            
  318.                 if not msg_content_test:
  319.                     msg = '*' + msg_author + " cuddles their pillow, smiling but alone.*"
  320.                 else:
  321.                     msg = random.choice(cuddle_message).format(msg_author, msg_recipient)
  322.             log(msg, message.channel, message.author, cmd)
  323.        
  324.             await client.send_message(message.channel, msg)
  325.         except ValueError in error:
  326.             print(error)
  327.             await client.send_message(message.channel, 'Something went wrong.... :sob:\n'.format(error))
  328.        
  329.  
  330.     #done       HUG
  331.     if message.content.startswith('{0}hug'.format(s_id[sid])):
  332.         cmd = 'hug'
  333.         msg = str(message.content)[5:]
  334.         msg_list = msg.split(' ')
  335.         msg_recipient = ''
  336.         msg_author = str(message.author)[:-5]
  337.         msg_content_test = False
  338.         for i in range(len(msg_list)):
  339.             msg_check = msg_list[i]
  340.             if (('<@!' and '>') in msg_check) == True:
  341.                 msg_recipient = msg_check
  342.                 msg_content_test = True
  343.         if not '!' in msg_recipient:
  344.             msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
  345.         if not '@' in msg_recipient:
  346.             msg_recipient = 'someone adorable'
  347.         if not msg_content_test:
  348.             msg_recipient = 'bottle of expensive red wine'
  349.         if msg_recipient == str(message.author.mention):
  350.             msg = random.choice(hug_message).format('Miku', msg_recipient)
  351.         else:
  352.             msg = random.choice(hug_message).format(msg_author, msg_recipient)
  353.         log(msg, message.channel, message.author, cmd)
  354.         try:
  355.             await client.send_message(message.channel, msg)
  356.         except Exception in error:
  357.             print(error)
  358.             await client.send_message(message.channel, 'Something went wrong.... :sob:')
  359.  
  360.     #done       KISS
  361.     if message.content.startswith('{0}kiss'.format(s_id[sid])):
  362.         cmd = 'kiss'
  363.         msg = str(message.content)[5:]
  364.         msg_list = msg.split(' ')
  365.         msg_recipient = ''
  366.         msg_author = str(message.author)[:-5]
  367.         msg_content_test = False
  368.         for i in range(len(msg_list)):
  369.             msg_check = msg_list[i]
  370.             if (('<@!' and '>') in msg_check) == True:
  371.                 msg_recipient = msg_check
  372.                 msg_content_test = True
  373.         if not '!' in msg_recipient:
  374.                 msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
  375.         if not '@' in msg_recipient:
  376.             msg_recipient = 'someone cute'
  377.         if msg_content_test == False:
  378.             msg_recipient = 'bottle of cheap red wine'
  379.         if msg_recipient == str(message.author.mention):
  380.             msg = random.choice(kiss_message).format('Miku', msg_recipient)
  381.         else:
  382.             msg = random.choice(kiss_message).format(msg_author, msg_recipient)
  383.         log(msg, message.channel, message.author, cmd)
  384.         try:
  385.             await client.send_message(message.channel, msg)
  386.         except ValueError in error:
  387.             print(error)
  388.             await client.send_message(message.channel, 'Something went wrong.... :sob:')
  389.  
  390.     #done       PAT
  391.     if message.content.startswith('{0}pat'.format(s_id[sid])):
  392.         cmd = 'pat'
  393.         if '{0}pat '.format(s_id[sid]) in message.content:
  394.             msg = str(message.content)[4:]
  395.             msg_list = msg.split(' ')
  396.             msg_recipient = ''
  397.             msg_author = str(message.author)[:-5]
  398.             msg_content_test = False
  399.             for i in range(len(msg_list)):
  400.                 msg_check = msg_list[i]
  401.                 if (('<@!' and '>') in msg_check) == True:
  402.                     msg_recipient = msg_check
  403.                     msg_content_test = True
  404.             if not '!' in msg_recipient:
  405.                 msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
  406.             if not '@' in msg_recipient:
  407.                 msg_recipient = 'Pa Butt'
  408.             if msg_content_test == False:
  409.                 msg_recipient = 'invisible unicorn'
  410.             if msg_recipient == str(message.author.mention):
  411.                 msg = random.choice(pat_message).format('Miku', msg_recipient)
  412.             else:
  413.                 msg = random.choice(pat_message).format(msg_author, msg_recipient)
  414.             log(msg, message.channel, message.author, cmd)
  415.             try:        
  416.                 await client.send_message(message.channel, msg)
  417.             except ValueError in error:
  418.                 print(error)
  419.                 await client.send_message(message.channel, 'Something went wrong.... :sob:')
  420.  
  421.     #SLAP
  422.     if message.content.startswith('{0}slap'.format(s_id[sid])):
  423.         cmd = 'slap'
  424.         if '{0}slap '.format(s_id[sid]) in message.content:
  425.             msg = str(message.content)[5:]
  426.             msg_list = msg.split(' ')
  427.             msg_recipient = ''
  428.             msg_author = str(message.author)[:-5]
  429.             msg_content_test = False
  430.             for i in range(len(msg_list)):
  431.                 msg_check = msg_list[i]
  432.                 if (('<@!' and '>') in msg_check) == True:
  433.                     msg_recipient = msg_check
  434.                     msg_content_test = True
  435.             if not '!' in msg_recipient:
  436.                 msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
  437.             if not '@' in msg_recipient:
  438.                 msg_recipient = 'random emoji'
  439.             if msg_content_test == False:
  440.                 msg_recipient = 'air'
  441.             if msg_recipient == str(message.author.mention):
  442.                 msg = random.choice(pat_message).format('Miku', msg_recipient)
  443.             else:
  444.                 msg = random.choice(slap_message).format(msg_author, msg_recipient)
  445.             log(msg, message.channel, message.author, cmd)
  446.             try:
  447.                 abc = str(message.author.mention).strip('<')
  448.                 await client.send_message(message.channel, msg)
  449.                
  450.             except ValueError in error:
  451.                 print(error)
  452.                 await client.send_message(message.channel, 'Something went wrong.... :sob:')
  453.  
  454.                
  455.     #done       ZHY
  456.     if message.content.startswith('{0}shy'.format(s_id[sid])):
  457.         cmd = 'shy'
  458.         if '{0}shy '.format(s_id[sid]) in message.content:
  459.             msg = str(message.content)[4:]
  460.             msg_list = msg.split(' ')
  461.             msg_recipient = ''
  462.             msg_author = str(message.author)[:-5]
  463.             msg_content_test = False
  464.             for i in range(len(msg_list)):
  465.                 msg_check = msg_list[i]
  466.                 if (('<@!' and '>') in msg_check) == True:
  467.                     msg_recipient = msg_check
  468.                     msg_content_test = True
  469.             if not '!' in msg_recipient:
  470.                 msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
  471.             if not '@' in msg_recipient:
  472.                 msg_recipient = 'fridge'
  473.             if msg_content_test == False:
  474.                 msg_recipient = 'noone'
  475.             if msg_recipient == str(message.author.mention):
  476.                 msg = random.choice(shy_message).format('Miku', msg_recipient)
  477.             else:
  478.                 msg = random.choice(shy_message).format(msg_author, msg_recipient)
  479.             log(msg, message.channel, message.author, cmd)
  480.             try:        
  481.                 await client.send_message(message.channel, msg)
  482.             except Exception in error:
  483.                 print(error)
  484.                 await client.send_message(message.channel, 'Something went wrong.... :sob:')
  485.    
  486.     #done       HELP
  487.     if message.content.startswith('{0}help'.format(s_id[sid])):
  488.         msg = help_message.format(s_id[sid])
  489.         color = 4122822
  490.         embed = discord.Embed(title = 'List of my commands:', description = msg, color = color)
  491.         await client.send_message(message.author, embed = embed)
  492.         await client.add_reaction(message, '\U00002705')
  493.  
  494.     #done       ABOUT
  495.     if message.content.startswith('{0}about'.format(s_id[sid])):
  496.         cmd = 'about'
  497.         log(msg, message.channel, message.author, cmd)
  498.         await client.send_message(message.channel, about)
  499.  
  500.     #done       CHART
  501.     if message.content.startswith('{0}chart'.format(s_id[sid])):
  502.         cmd = 'chart'
  503.         msg = '''**日 a i u e o a i u e o 本
  504.        ー ア イ ウ エ オ あ い う え お
  505.        k カ キ ク ケ コ か き く け こ
  506.        s サ シ ス デ ソ さ し す せ そ
  507.        t タ チ ツ テ ト た ち つ て と
  508.        n ナ ニ ヌ ネ ノ な に ぬ ね の
  509.        m マ ミ ム メ モ ま み む め も
  510.        r ラ リ ル レ ロ ら り る れ ろ
  511.        h ハ ヒ フ ヘ ホ は ひ ふ へ ほ
  512.        w ワ       ヲ わ       を
  513.        y ヤ   ユ   ヨ や   ゆ   よ
  514.        n ン         ん**'''
  515.         color = 4122822
  516.         embed = discord.Embed(title = 'Katakana and hiragana chart:', description = msg, color = color)
  517.         log(msg, message.channel, message.author, cmd)
  518.         await client.send_message(message.channel, embed = embed)
  519.  
  520.     if message.content.startswith('{0}days'.format(s_id[sid])):
  521.         cmd = 'days'
  522.         msg = '''**日曜日** *Nichiyoubi* - Sun day - Sunday
  523. **月曜日** *Gatsuyoubi* - Moon day - Monday
  524. **火曜日** *Kayoubi* - Fire day - Tuesday
  525. **水曜日** *Suiyoubi* - Water day - Wednesday
  526. **木曜日** *Mokuyoubi* - Tree day - Thursday
  527. **金曜日** *Kinyoubi* - Gold day - Friday
  528. **土曜日** *Doyoubi* - Earth day - Saturday'''
  529.         log(msg, message.channel, message.author, cmd)
  530.         await client.send_message(message.channel, msg)
  531.        
  532.     #done       AYAYA AYAYAAAAAA
  533.     if (message.content.startswith('ayaya')) or (message.content.startswith('AYAYA')):
  534.         cmd = 'ayaya'
  535.         msg = '''**⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣬⡛⣿⣿⣿⣯⢻
  536. ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⢻⣿⣿⢟⣻⣿⣿⣿⣿⣿⣿⣮⡻⣿⣿⣧
  537. ⣿⣿⣿⣿⣿⢻⣿⣿⣿⣿⣿⣿⣆⠻⡫⣢⠿⣿⣿⣿⣿⣿⣿⣿⣷⣜⢻⣿
  538. ⣿⣿⡏⣿⣿⣨⣝⠿⣿⣿⣿⣿⣿⢕⠸⣛⣩⣥⣄⣩⢝⣛⡿⠿⣿⣿⣆⢝
  539. ⣿⣿⢡⣸⣿⣏⣿⣿⣶⣯⣙⠫⢺⣿⣷⡈⣿⣿⣿⣿⡿⠿⢿⣟⣒⣋⣙⠊
  540. ⣿⡏⡿⣛⣍⢿⣮⣿⣿⣿⣿⣿⣿⣿⣶⣶⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿
  541. ⣿⢱⣾⣿⣿⣿⣝⡮⡻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⠛⣋⣻⣿⣿⣿⣿
  542. ⢿⢸⣿⣿⣿⣿⣿⣿⣷⣽⣿⣿⣿⣿⣿⣿⣿⡕⣡⣴⣶⣿⣿⣿⡟⣿⣿⣿
  543. ⣦⡸⣿⣿⣿⣿⣿⣿⡛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⣿⣿⣿
  544. ⢛⠷⡹⣿⠋⣉⣠⣤⣶⣶⣿⣿⣿⣿⣿⣿⡿⠿⢿⣿⣿⣿⣿⣿⣷⢹⣿⣿
  545. ⣷⡝⣿⡞⣿⣿⣿⣿⣿⣿⣿⣿⡟⠋⠁⣠⣤⣤⣦⣽⣿⣿⣿⡿⠋⠘⣿⣿
  546. ⣿⣿⡹⣿⡼⣿⣿⣿⣿⣿⣿⣿⣧⡰⣿⣿⣿⣿⣿⣹⡿⠟⠉⡀⠄⠄⢿⣿
  547. ⣿⣿⣿⣽⣿⣼⣛⠿⠿⣿⣿⣿⣿⣿⣯⣿⠿⢟⣻⡽⢚⣤⡞⠄⠄⠄⢸⣿**'''
  548.         log(msg, message.channel, message.author, cmd)
  549.         await client.send_message(message.channel, msg)
  550.  
  551.     #done       INVITE
  552.     if message.content.startswith('{0}invite'.format(s_id[sid])):
  553.         msg = "*You can invite me to your server using this link:*\nhttps://discordapp.com/oauth2/authorize?client_id=492432534181773313&scope=bot"
  554.         await client.send_message(message.author, msg)
  555.  
  556.     #done       TERRARIA
  557.     if message.content.startswith('{0}terraria'.format(s_id[sid])):
  558.         cmd = 'terraria'
  559.         msg = '''
  560.        **IP:** 95.105.211.38
  561.        **Port:** 6666
  562.        **Password:** *Ask Ana#3140*
  563.        *Server is hosted same way as I am.. That means it runs whenever I am online!!
  564.        Connecting to the server requires* **TModLoader**. *Our mods will get downloaded automatically when connecting!*
  565.        **List of mods:** *RecipeBrowser, WhereIsMyItem, Boss Checklist*
  566.        *You can get TModLoader here: https://tmodloader.net/*
  567.        '''
  568.         color = 4122822
  569.         embed = discord.Embed(title = 'Our Terraria server: ', description = msg, color = color)
  570.         log(msg, message.channel, message.author, cmd)
  571.         await client.send_message(message.channel, embed = embed)
  572.  
  573.     #done       CHOICE
  574.     if message.content.startswith('{0}choice'.format(s_id[sid])):
  575.         cmd = 'choice'
  576.         msg = message.content[8:]
  577.         choice_list = []
  578.         choice_list = msg.split(',')
  579.         msg = "I've randomly chosen this for you: " + str(random.choice(choice_list))
  580.         log(msg, message.channel, message.author, cmd)
  581.         await client.send_message(message.channel, msg)
  582.  
  583.     #done       PATCHNOTES
  584.     if message.content.startswith('{0}patchnotes'.format(s_id[sid])):
  585.         cmd = 'patchnotes'
  586.         p_notes_split = patchnotes.split('<$>')
  587.         #print(p_notes_split)
  588.         log(msg, message.channel, message.author, cmd)
  589.         for i in p_notes_split:
  590.             msg = '```{0}```'.format(i)
  591.             await client.send_message(message.author, msg)
  592.  
  593.     #done       VERSION
  594.     if message.content.startswith('{0}version'.format(s_id[sid])):
  595.         cmd = 'version'
  596.         msg = '`Current version of this bot is: {0}`'.format(version)
  597.         log(msg, message.channel, message.author, cmd)
  598.         await client.send_message(message.channel, msg)
  599.  
  600.     #done       RANDOM NUMBER X Z
  601.     if message.content.startswith('{0}rnf'.format(s_id[sid])):
  602.         cmd = 'random number from <x, z>'
  603.         msg = message.content[5:]
  604.         numbers = []
  605.         numbers = msg.split(' ')
  606.         log(msg, message.channel, message.author, cmd)
  607.         error = ''
  608.         if len(numbers) == (1 or 0):
  609.             msg = 'You need two numbers!'
  610.             await client.send_message(message.channel, msg)
  611.         else:
  612.             try:
  613.                 print(numbers[0], numbers[1])
  614.                 a = int(round(float(numbers[0])))
  615.                 b = int(round(float(numbers[1])))
  616.                 print(a, b)
  617.                
  618.                 if a >= b:
  619.                     c = a
  620.                     a = b
  621.                     b = c
  622.                    
  623.                 if a == b:
  624.                     msg = "Your random number is not really random, but here you go: {0}".format(a)
  625.                 else:
  626.                     num = random.randrange(a, b+1)
  627.                     msg = "Your random number is: " + str(num)
  628.                 await client.send_message(message.channel, msg)
  629.                
  630.             except ValueError as error:
  631.                 print(error)
  632.                 msg = 'Something went wrong!'
  633.                 await client.send_message(message.channel, msg)
  634.  
  635.     #done       INCH to CM
  636.     if message.content.startswith('{0}cm'.format(s_id[sid])):
  637.         mes = str(message.content)[4:]
  638.         thingy = str(mes).split("'")
  639.         a, b = thingy[0], thingy[1]
  640.         try:
  641.             a, b = int(a), float(b)
  642.             msg =  str(round(a * 12 * 2.54 + b * 2.54, 2)) + 'cm'
  643.         except Exception as e:
  644.             msg = 'Error!\n{0}'.format(e)
  645.         await client.send_message(message.channel, msg)
  646.  
  647.     #done       CM TO INCH
  648.     if message.content.startswith('{0}inch'.format(s_id[sid])):
  649.         mes = float(str(message.content)[6:])
  650.         mes = int(round(mes))
  651.         try:
  652.             msg = str(int(mes // (30.48)))
  653.             mes = (mes % 30.48)*100000
  654.             zv = int(round(mes // 2.54))
  655.             zv = round(zv/100000)
  656.             msg += "'{0}".format(zv)
  657.         except Exception as e:
  658.             msg = 'Error!\n{0}'.format(e)
  659.         await client.send_message(message.channel, msg)
  660.            
  661.  
  662.     #done       COINFLIP
  663.     if message.content.startswith('{0}coinflip'.format(s_id[sid])):
  664.         cmd = 'coinflip'
  665.         num = random.randrange(1000)+1
  666.         if num == 741:
  667.             msg = "***It landed on it's side! How lucky!!!***"
  668.         else:
  669.             if num == 274:
  670.                 msg = "As coin spins in the air, you notice it doesn't stop spinning. After few seconds of spinning in the place, everything goes black, and from a dark purple portal long tentacle appears and takes your coin... You will need a new one, I guess..."
  671.             else:
  672.                 if num > 500:
  673.                     msg = 'Heads!' + '!'*random.randrange(4)
  674.                 else:
  675.                     msg = 'Tails!' + '!'*random.randrange(4)
  676.         #log(msg, message.channel, message.author, cmd)
  677.         print("Command '$" + cmd + "' used in " + str(message.channel) + ' by ' + str(message.author) +'! Rolled: ' + str(num))
  678.         await client.send_message(message.channel, msg)
  679.  
  680.     #done       RANDOM COLOUR
  681.     if message.content.startswith('{0}rc'.format(s_id[sid])):
  682.         cmd = 'random colour'
  683.         color = random.randrange(256**3)
  684.         print(color)
  685.         msg = str(f'#{color:06x}')
  686.         embed = discord.Embed(title = 'Your random colour: ', description = msg, color = color)
  687.         log(str(msg), message.channel, message.author, cmd)
  688.         await client.send_message(message.channel, embed = embed)
  689.  
  690.     #done       GUESS MY NUMBER
  691.     if message.content.startswith('{0}gmn'.format(s_id[sid])):
  692.        
  693.         if not str(message.author) in gmn_cp:
  694.             gmn_cp[str(message.author)] = False
  695.             gmn_a[str(message.author)] = 0
  696.             gmn_number[str(message.author)] = 0
  697.            
  698.         if gmn_cp[str(message.author)] == False:
  699.             await client.send_message(message.channel, "Oh.. S-senpai..! L-let's play a g-game..! I.. I will think of a number b-between 1 and 100, a-and you will have to g-guess it..!!")
  700.             time.sleep(0.25)
  701.             await client.send_message(message.channel, "I..I am w-waiting for y-your guess, s-senpai..! J-just type **`{0}gmn your_number`**...! G-good luck! *blushes*".format(s_id[message.server.id]))
  702.             game_number = random.randrange(100)+1
  703.             gmn_number[str(message.author)] = game_number
  704.             gmn_a[str(message.author)] = 0
  705.             player = str(message.author)
  706.             gmn_cp[str(message.author)] = True
  707.            
  708.         elif gmn_cp[str(message.author)] == True:
  709.             number = message.content[4:]
  710.             try:
  711.                 number = int(number)
  712.                 gmn_cp[str(message.author)] = True
  713.                
  714.                 if gmn_number[str(message.author)] == number:
  715.                     msg = "Y-yes..! That's the number I.. I've been thinking of! Y-you are so good s-senpai! :heart_eyes:"
  716.                     gmn_a[str(message.author)] = 0
  717.                     await client.send_message(message.channel, msg)
  718.                     gmn_a[str(message.author)] = 0
  719.                     gmn_cp[str(message.author)] = False
  720.  
  721.                    
  722.                 elif (gmn_a[str(message.author)] == 0) and (gmn_cp[str(message.author)] == True):
  723.  
  724.                     if gmn_number[str(message.author)] < number:
  725.                         msg = "T-that's not it, s-senpai..! :flushed: Your n-number is too b-big.. T-try again..! *blushes*"
  726.                         await client.send_message(message.channel, msg)
  727.                     else:
  728.                         msg = "T-that's not it, s-senpai..! :flushed: Your n-number is not b-big enough.. T-try again..! *blushes*"
  729.                         await client.send_message(message.channel, msg)
  730.  
  731.                     gmn_a[str(message.author)] = 1
  732.                     print('New game! Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
  733.                    
  734.                 elif (gmn_a[str(message.author)] == 1) and (gmn_cp[str(message.author)] == True):
  735.  
  736.                    
  737.                     if gmn_number[str(message.author)] < number:
  738.                         msg = "N-no senpai... S-still not my number.. It's n-not that big..."
  739.                         await client.send_message(message.channel, msg)
  740.                     else:
  741.                         msg = "N s-senpai... S-still not my special number.. It's even higher..."
  742.                         await client.send_message(message.channel, msg)
  743.                        
  744.                     gmn_a[str(message.author)] = 2
  745.                     print('Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
  746.  
  747.                    
  748.                 elif (gmn_a[str(message.author)] == 2) and (gmn_cp[str(message.author)] == True):
  749.                    
  750.                     if gmn_number[str(message.author)] < number:
  751.                         msg = "That's again n-not my n-number *blushes* T-too big..! Last chance..!"
  752.                         await client.send_message(message.channel, msg)
  753.                     else:
  754.                         msg = "N-not my n-number, senpai..! *blushes* Go h-higher..! L-last attempt..!"
  755.                         await client.send_message(message.channel, msg)
  756.                        
  757.                     gmn_a[str(message.author)] = 3
  758.                     print('Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
  759.                    
  760.                 elif (gmn_a[str(message.author)] == 3) and (gmn_cp[str(message.author)] == True):
  761.                    
  762.                     if gmn_number[str(message.author)] < number:
  763.                         msg = "I.. I am s-sorry, s-senpai..! Your number w-was t-too big..! I was t-thinking of a number " + str(gmn_number[str(message.author)])
  764.                         await client.send_message(message.channel, msg)
  765.                     else:
  766.                         msg = "S-senpai..! T-that's not my number..! I was t-thinking of a number " + str(gmn_number[str(message.author)])
  767.                         await client.send_message(message.channel, msg)
  768.                        
  769.                     print('Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
  770.                     gmn_a[str(message.author)] = 0
  771.                     gmn_cp[str(message.author)] = False
  772.                    
  773.             except:
  774.                 await client.send_message(message.channel, "That's not a number, b-baka s-senpai..!!")
  775.         else:
  776.             await client.send_message(message.channel, "I.. I'm s-sorry senpai, b-but... You h-haven't finished y-your previous g-game yet... :flushed:")
  777.  
  778.  
  779.     #done       LEWD
  780.     if message.content.startswith('{0}lewd'.format(s_id[sid])):
  781.         if str(message.author) == 'Ana#3140':
  782.             msg = 'Y-yes, s-senpai.. I.. I w-will do a-anything y-you want m-me to d-do.. A-anything... I.. I promise..:heart_eyes: I.. I p-promise t-to be a *good g-girl*..! ***__A-anything..!__***'
  783.         else:
  784.             msg = '**Y-YOU ARE SO L-LEWD, SENPAI**' + '!'*int(random.randrange(9)+3)
  785.         await client.send_message(message.channel, msg)
  786.  
  787.     #done       SERVER PREFIX CHANGE
  788.     if message.content.startswith('{0}prefix set'.format(s_id[sid])):
  789.         if message.author == message.server.owner:
  790.             try:
  791.                 prefix = message.content[12:]
  792.                 if len(prefix) > 1:
  793.                     msg = 'Prefix can consist of only one character!'
  794.                 else:
  795.                     s_id[message.server.id] = str(prefix)
  796.                     save()
  797.                     reload_files()
  798.                     msg = 'Prefix of this server has been changed to {0}'.format(prefix)
  799.             except:
  800.                 msg = 'Something went wrong!'
  801.         else:
  802.             msg = "I'm sorry s-senpai, b-but you are n-not owner of t-this server!"
  803.         await client.send_message(message.channel, msg)
  804.                
  805.  
  806.     #bet reaction
  807.     if (message.content.startswith('bet'))or (message.content.startswith('beet')) or (message.content.startswith('Bet')):
  808.         num = random.randrange(10000)
  809.         if num == 2714:
  810.             msg = 'BEEEEEEEEEEEEEEEEEEEEEEEEEEEET!!!!!'
  811.             await client.send_message(message.channel, msg)
  812.         else:
  813.             if num == 8743:
  814.                 msg = 'No bets allowed to underage trolls (That means you are not allowed to bet if you are not 18+.... B-baka senpai.. >.>)'
  815.                 await client.send_message(message.channel, msg)
  816.             else:
  817.                 msg = "{0}bet{0}".format(edits[random.randrange(5)])
  818.                 await client.send_message(message.channel, msg)
  819.  
  820.     #miku reaction
  821.     await miku_reaction(message)
  822.  
  823.     #Reactions for other bots
  824.     if (message.content.startswith('+pat <@!492432534181773313>')) or (message.content.startswith('{0}pat <@!492432534181773313>'.format(s_id[sid]))) or (message.content.startswith('{0}pat <@492432534181773313>'.format(s_id[sid]))):
  825.         await asyncio.sleep(1)
  826.         msg = 'Awwwwww t-thanks a lot for petting me, {0}! :sparkling_heart: :heart_eyes: ^~^'.format(message.author.mention)
  827.         await client.send_message(message.channel, msg)
  828.  
  829.     if (message.content.startswith('+hug <@!492432534181773313>')) or (message.content.startswith('{0}hug <@!492432534181773313>'.format(s_id[sid]))) or (message.content.startswith('{0}hug <@492432534181773313>'.format(s_id[sid]))):
  830.         await asyncio.sleep(1)
  831.         msg = 'Oh~, thanks s-senpai for hug! *she hugs {0} back tightly, smiling and blushing.*'.format(message.author.mention)
  832.         await client.send_message(message.channel, msg)
  833.  
  834.     if (message.content.startswith('+cuddle <@!492432534181773313>')) or (message.content.startswith('{0}cuddle <@!492432534181773313>'.format(s_id[sid]))) or (message.content.startswith('{0}cuddle <@492432534181773313>'.format(s_id[sid]))):
  835.         await asyncio.sleep(1)
  836.         msg = '*She giggles and cuddles {0} back, slightly stroking their back, still giggling.*'.format(message.author.mention)
  837.         await client.send_message(message.channel, msg)
  838.        
  839.     if (message.content.startswith('{0}poke <@!492432534181773313>'.format(s_id[sid]))) or (message.content.startswith('{0}poke <@492432534181773313>'.format(s_id[sid]))):
  840.         await asyncio.sleep(1)
  841.         msg = "*She looks at {0} curiously, and then she pokes {0} back.*".format(message.author.mention)
  842.         await client.send_message(message.channel, msg)
  843.  
  844.     if (message.content.startswith('{0}slap <@!492432534181773313>'.format(s_id[sid]))) or (message.content.startswith('{0}slap <@492432534181773313>'.format(s_id[sid]))):
  845.         await asyncio.sleep(1)
  846.         msg = '*She slaps {0} back, looking angry, annoyed but dissappointed and sad as well...*'.format(message.author.mention)
  847.         await client.send_message(message.channel, msg)
  848.  
  849.  
  850.     #dev only functions
  851.  
  852.     #done       STOP
  853.     if (message.content.startswith('{0}stop'.format(s_id[message.server.id]))) or (message.content.startswith('{0}bye'.format(s_id[message.server.id]))):
  854.         cmd = 'stop'
  855.         msg = ''
  856.         log(msg, message.channel, message.author, cmd)
  857.         if (str(message.author.id) == '207505077013839883') or (str(mesasge.author.id) == '296301865627287553'):
  858.             msg = 'G-good b-bye, s-senpai~ :heart:!'
  859.             await client.send_message(message.channel, msg)
  860.             print('Good b-bye Ana s-senpai~ <3')
  861.             client.logout()
  862.             save()
  863.             sys.exit(0)
  864.         else:
  865.             msg = 'Insufficient permissions...'
  866.             await client.send_message(message.channel, msg)
  867.  
  868.     #done       RELOAD FILES
  869.     if message.content.startswith('{0}rf'.format(s_id[message.server.id])):
  870.         cmd = 'reload files'
  871.         log(msg, message.channel, message.author, cmd)
  872.         author = str(message.author)
  873.         if author == 'Ana#3140':
  874.             reload_files()
  875.             if success == False:
  876.                 print('Files reloaded successfully...')
  877.             else:
  878.                 print('Reload unsuccessful...')
  879.         else:
  880.             msg = 'Insufficient permissions...'
  881.             await client.send_message(message.channel, msg)
  882.  
  883.     #done       CHANGE GAME STATUS
  884.     if message.content.startswith('{0}game'.format(s_id[message.server.id])):
  885.         cmd = 'game status'
  886.         if (str(message.author.id) == '207505077013839883') or (str(message.author.id) == '296301865627287553'):
  887.             if len(str(message.content)) >6:
  888.                 g = str(message.content)[6:]
  889.                 print(g, str(message.content))
  890.                 me = discord.utils.find(lambda s: s != None, client.servers).me
  891.                 if not me:
  892.                         return
  893.                 elif not me.game:
  894.                         updated_game = discord.Game(name = str(g))
  895.                 else:
  896.                         updated_game = me.game
  897.                         updated_game.name = str(g)
  898.             else:
  899.                 me = discord.utils.find(lambda s: s != None, client.servers).me
  900.                 if not me:
  901.                         return
  902.                 elif not me.game:
  903.                         updated_game = discord.Game(name = random.choice(statuses))
  904.                 else:
  905.                         updated_game = me.game
  906.                         updated_game.name = random.choice(statuses)
  907.             await client.change_presence(game = updated_game)
  908.             print('Changing game to: {0}'.format(str(updated_game)))
  909.            
  910.  
  911.     #done       PATCH CHANGE
  912.     if message.content.startswith('{0}patch set'.format(s_id[message.server.id])):
  913.         author = str(message.author)
  914.         author2 = message.author.id
  915.         cmd = 'patch'
  916.         msg = ''
  917.         patch = ''
  918.         log(msg, message.channel, message.author, cmd)
  919.         if author2 == '207505077013839883':
  920.             try:
  921.                 msg = 'Done!'
  922.                 patch = message.content
  923.                 patch = patch[11:]
  924.                 os.remove('bot_save_files\patch.txt')
  925.                 file = open('bot_save_files\patch.txt', 'w')
  926.                 file.write(str(patch))
  927.                 file.close()
  928.                 version = patch
  929.                 print('Current patch changed to {0}'.format(patch))
  930.                 ctypes.windll.kernel32.SetConsoleTitleW(patch)
  931.                 await client.send_message(message.channel, msg)
  932.             except:
  933.                 print('Something went wrong!')
  934.            
  935.     #WIP        TEST COMMAND
  936.     if message.content.startswith('{0}test'.format(s_id[message.server.id])):
  937.         cmd = 'test'
  938.         msg = type(vc)
  939.         await client.send_message(message.channel, msg)
  940.  
  941.     #MUSIC LOOP
  942.     if message.content.startswith('{0}loop'.format(s_id[message.server.id])):
  943.         if not message.server.id in loop:
  944.             loop[message.server.id] = True
  945.             msg = 'Looping current song!'
  946.             await client.send_message(message.channel, msg)
  947.            
  948.         elif loop[message.server.id] == True:
  949.             loop[message.server.id] = False
  950.             msg = 'Loop of the current song disabled!'
  951.             await client.send_message(message.channel, msg)
  952.            
  953.         elif loop[message.server.id] == False:
  954.             loop[message.server.id] = True
  955.             msg = 'Looping current song!'
  956.             await client.send_message(message.channel, msg)
  957.  
  958.  
  959.     #MUSIC LOOP PLAYLIST
  960.     if message.content.startswith('{0}lp'.format(s_id[message.server.id])):
  961.         if not message.server.id in lp:
  962.             lp[message.server.id] = True
  963.             msg = 'Looping current playlist!'
  964.             await client.send_message(message.channel, msg)
  965.            
  966.         elif lp[message.server.id] == True:
  967.             lp[message.server.id] = False
  968.             msg = 'Loop of the current playlist disabled!'
  969.             await client.send_message(message.channel, msg)
  970.            
  971.         elif lp[message.server.id] == False:
  972.             lp[message.server.id] = True
  973.             msg = 'Looping current playlist!'
  974.             await client.send_message(message.channel, msg)
  975.            
  976.     #MUSIC CONNECT
  977.     if message.content.startswith("{0}p ".format(s_id[message.server.id])):
  978.         channel = message.author.voice.voice_channel
  979.        
  980.         if not message.server.id in loop:
  981.             loop[message.server.id] = False
  982.  
  983.         if not message.server.id in lp:
  984.             lp[message.server.id] = False
  985.            
  986.         if not channel == None:
  987.             ytdl = YoutubeDL()
  988.             link = ''
  989.             if not message.server.id in playlist:
  990.                 playlist[message.server.id] = []
  991.             if not message.server.id in cp:
  992.                 cp[message.server.id] = 'False'
  993.  
  994.             link = str(message.content)[3:]
  995.             if 'https://www.youtube.com/playlist?list=' in link:
  996.                 troll = 'https://www.youtube.com/playlist?list='
  997.                 link = link[len(troll):]
  998.                 results = youtube.playlistItems().list(playlistId=link, part='contentDetails', maxResults = 50).execute()
  999.                 videoIds = [item['contentDetails']['videoId'] for item in results.get('items', [])]
  1000.                 playlist[sid] += videoIds
  1001.                 link = playlist[sid][0]
  1002.             else:
  1003.                 if 'https://youtu.be/' in link:
  1004.                     link = link.strip('https://youtu.be/')
  1005.                 if 'www.youtube.' in link:
  1006.                     link = link[32:]
  1007.                 if len(link) > 11:
  1008.                     link = link[:11]
  1009.                 playlist[message.server.id].append(link)
  1010.             await client.add_reaction(message, '\U00002705')
  1011.             await music_playlist(message)
  1012.         else:
  1013.             msg = "S-senpai..! You're n-not in a-any voice c-channel!"
  1014.             await client.send_message(message.channel, msg)
  1015.  
  1016.     #MUSIC DISCONENCT
  1017.     if message.content.startswith('{0}dc'.format(s_id[message.server.id])):
  1018.         if client.is_voice_connected(message.server):
  1019.             playlist[message.server.id] = []
  1020.             cp[message.server.id] = 'False'
  1021.             players[message.server.id].stop()
  1022.             loop[message.server.id] = False
  1023.             lp[message.server.id] = False
  1024.             cpsong[message.server.id] = ''
  1025.             msg = 'Bai baaaaai~'
  1026.             await client.send_message(message.channel, msg)
  1027.            
  1028.             await voice_list[sid].disconnect()
  1029.            
  1030.         else:
  1031.             msg = "S-senpai..! B-but I.. I'm n-not connected y-yet! :flushed:"
  1032.             await client.send_message(message.channel, msg)
  1033.  
  1034.     #MUSIC PLAYLIST
  1035.     if message.content.startswith('{0}playlist'.format(s_id[message.server.id])):
  1036.         mes = str(message.content).strip('{0}playlist'.format(s_id[message.server.id]))
  1037.         if 'del' in mes:
  1038.             mes = mes.strip(' del ')
  1039.             try:
  1040.                 try:
  1041.                     num = int(mes)
  1042.                 except:
  1043.                     print('Couldn\'t convert mes into num')
  1044.                 if not 0 < num <= len(playlist[sid]):
  1045.                     msg =  'B-but s-senpai!! T-that\'s not a... r-right n-number!!'
  1046.                     await client.send_message(message.channel, msg)
  1047.                 else:
  1048.                     del(playlist[message.server.id][num-1])
  1049.                     msg = 'Done..!'
  1050.                     await client.send_message(message.channel, msg)
  1051.             except:
  1052.                 msg = 'O-oh senpai..! I\'m s-sorry, b-but something went w-wrong!'
  1053.                 await client.send_message(message.channel, msg)
  1054.                
  1055.         elif 'delete' in mes:
  1056.             mes = mes.strip(' delete ')
  1057.             try:
  1058.                 try:
  1059.                     num = int(mes)
  1060.                 except:
  1061.                     print('Couldn\'t convert mes into num')
  1062.                 if not 0 < num <= len(playlist[sid]):
  1063.                     msg =  'S-senpai..!! W-wrong number! :flushed:'
  1064.                     await client.send_message(message.channel, msg)
  1065.                 else:
  1066.                     del(playlist[message.server.id][num-1])
  1067.                     msg = 'Done..!'
  1068.                     await client.send_message(message.channel, msg)
  1069.             except:
  1070.                 msg = 'O-oh senpai..! I\'m s-sorry, b-but something went w-wrong!'
  1071.                 await client.send_message(message.channel, msg)
  1072.         elif 'clear' in mes:
  1073.             try:
  1074.                 playlist[sid] = []
  1075.                 playlist[sid].append(cpsong[sid])
  1076.                 msg = 'Cleared playlist! Current song will keep playing.'
  1077.             except Exception as e:
  1078.                 msg = 'Something went wrong!\n{0}'.format(e)
  1079.             await client.send_message(message.channel, msg)
  1080.         else:
  1081.             await music_playlist_print(message)
  1082.  
  1083.  
  1084.     #MUSIC CURRENTLY PLAYING
  1085.     if message.content.startswith('{0}cp'.format(s_id[sid])):
  1086.         msg = '***Currently playing:***\n*{0}*  **Duration:** {1}'.format(info[sid]['title'], datetime.timedelta(seconds=info[sid]['duration']))
  1087.         if loop == True:
  1088.             msg += '\n**Loop of current song is** ***enabled!***'
  1089.         await client.send_message(message.channel, msg)
  1090.  
  1091.  
  1092.     #MUSIC SKIP
  1093.     if (message.content.startswith('{0}skip'.format(s_id[sid]))) or (message.content.startswith('{0}next'.format(s_id[sid]))):
  1094.         await music_skip(message)
  1095.     return None
  1096.        
  1097.  
  1098. async def music_playlist(message):
  1099.     global vc, cp, playlist, urllist, client
  1100.  
  1101.     if playlist[message.server.id] != []:
  1102.         url = playlist[message.server.id][0]
  1103.     else:
  1104.         return
  1105.    
  1106.     if (cp[message.server.id] == 'False') and (playlist[message.server.id] != []):
  1107.         await music_bot(url, message)
  1108.        
  1109.  
  1110. async def music_bot(url, message):
  1111.     global vc, cp, playlist, urllist, loop, ytdl, cpsong, info, client, cpsong_two, voice_list
  1112.     sid = message.server.id
  1113.    
  1114.     if not message.server.id in cpsong:
  1115.         cpsong[sid] = ''
  1116.     if not sid in cpsong_two:
  1117.         cpsong_two[sid] = ''
  1118.     if not sid in voice_list:
  1119.         voice_list[sid] = None
  1120.        
  1121.        
  1122.     cpsonglocal = {}
  1123.     timethingy = str(timeit.timeit())
  1124.    
  1125.     cpsong_two[sid] = url
  1126.     cpsong[sid] = timethingy
  1127.     cpsonglocal[sid] = timethingy
  1128.     if not client.is_voice_connected(message.server):
  1129.         while playlist[sid] != []:
  1130.  
  1131.             channel = message.author.voice.voice_channel
  1132.             vc = await client.join_voice_channel(channel)
  1133.             voice_list[sid] = vc
  1134.             musicplayer = await voice_list[sid].create_ytdl_player(url, before_options=" -reconnect 1 -reconnect_streamed 1"
  1135.                                                                            " -reconnect_delay_max 5")
  1136.             players[sid] = musicplayer
  1137.             musicplayer.start()
  1138.             cp[sid] = 'True'
  1139.            
  1140.             info[sid] = ytdl.extract_info(url, download = False)
  1141.            
  1142.             await asyncio.sleep(int(info[sid]['duration'])-1)
  1143.             if cpsong[sid] == cpsonglocal[sid]:
  1144.                 cp[sid] = 'False'
  1145.                 await loop_check(url, message)
  1146.             else:
  1147.                 return
  1148.                 print('no')
  1149.                
  1150.     elif client.is_voice_connected(message.server):
  1151.         while playlist[sid] != []:
  1152.             vc = client.voice_client_in(message.server)
  1153.             voice_list[sid] = vc
  1154.             musicplayer = await voice_list[sid].create_ytdl_player(url, before_options=" -reconnect 1 -reconnect_streamed 1"
  1155.                                                                            " -reconnect_delay_max 5")
  1156.             players[sid] = musicplayer
  1157.             musicplayer.start()
  1158.             cp[sid] = 'True'
  1159.            
  1160.             info[sid] = ytdl.extract_info(url, download = False)
  1161.            
  1162.             await asyncio.sleep(int(info[sid]['duration'])-1)
  1163.             if cpsong[sid] == cpsonglocal[sid]:
  1164.                 cp[sid] = 'False'
  1165.                 await loop_check(url, message)
  1166.             else:
  1167.                 return
  1168.                 print('no')
  1169.                    
  1170.    
  1171. async def loop_check(url, message):
  1172.     global loop, playlist, urllist, lp, client
  1173.  
  1174.     if lp[message.server.id] == True:
  1175.  
  1176.         playlist[message.server.id].append(url)
  1177.         del(playlist[message.server.id][0])
  1178.    
  1179.         await music_playlist(message)
  1180.        
  1181.     else:
  1182.    
  1183.         if loop[message.server.id] == True:
  1184.             await music_bot(url, message)
  1185.         elif loop[message.server.id] == False:
  1186.             del(playlist[message.server.id][0])
  1187.             await music_playlist(message)
  1188.  
  1189. async def music_skip(message):
  1190.     global players, playlist, urllist, cp, urls, client
  1191.     sid = message.server.id
  1192.  
  1193.     if 'DJ' in message.server.roles:
  1194.         print('SKIP TEST 1')
  1195.         if 'DJ' in message.author.roles:
  1196.  
  1197.             print('SKIP TEST 2')
  1198.             cp[message.server.id] = 'False'
  1199.             players[message.server.id].stop()
  1200.             playlist[message.server.id] = playlist[message.server.id][len(urls[message.server.id])+7:]
  1201.             msg = 'Skipping current song...'
  1202.             await client.send_message(message.channel, msg)
  1203.             await music_playlist(message)
  1204.         else:
  1205.             msg = 'Insufficent permission!'
  1206.             await client.send_message(message.channel, msg)
  1207.             print('SKIP TEST 3')
  1208.     else:
  1209.         if playlist[sid] == []:
  1210.             msg = '***There is no song playing at the moment! Queue some using {0}p url!***'.format(s_id[sid])
  1211.             await client.send_message(message.channel, msg)
  1212.             return
  1213.         else:
  1214.             if lp[sid] == True:
  1215.            
  1216.                 playlist[message.server.id].append(playlist[message.server.id][0])
  1217.                 del(playlist[message.server.id][0])
  1218.                
  1219.             else:
  1220.                 del(playlist[message.server.id][0])
  1221.             cp[message.server.id] = 'False'
  1222.             players[message.server.id].stop()
  1223.             msg = 'Skipping current song...'
  1224.             await client.send_message(message.channel, msg)
  1225.             await music_playlist(message)
  1226.  
  1227. async def music_playlist_print(message):
  1228.     global playlist, youtube, s_id, lp, client
  1229.     sid = message.server.id
  1230.     if not sid in playlist:
  1231.         msg = '**There are no songs in queue at the moment! Queue some using {0}p url!**'.format(s_id[sid])
  1232.         await client.send_message(message.channel, msg)
  1233.     else:
  1234.         urls = playlist[sid]
  1235.         ids = ','.join(urls)  
  1236.         msg = '***Current playlist:***\n'
  1237.  
  1238.         results = {}
  1239.         while results == {}:
  1240.             try:
  1241.                 results = youtube.videos().list(id=ids, part='snippet').execute()
  1242.             except:
  1243.                 print('Youtube results unsucessful, retrying...')
  1244.         msg += '\n'.join(
  1245.             '**{0}**: *{1}*'.format(i, item['snippet']['title'])
  1246.             for i, item in
  1247.             enumerate(results.get('items', []), start=1))
  1248.         if lp[sid] == True:
  1249.             msg += '\n**Loop of the playlist is** ***__enabled!__***'
  1250.         msg += ' \n**You can remove a song from queue by using {0}playlist delete <number_in_queue>!**'.format(s_id[sid])
  1251.         if not '1' in msg:
  1252.             msg = '**There are no songs in queue at the moment! Queue some using {0}p url!**'.format(s_id[sid])
  1253.         await send_message(message, msg)
  1254.     return
  1255.        
  1256. async def send_message(message, msg, *args, **kwargs):
  1257.     global lp, s_id, client
  1258.     sid = message.server.id
  1259.     if len(msg) > 1800:
  1260.         first2k = msg[:1800]
  1261.         last_nl = first2k.rfind('\n')
  1262.         firstMsg = msg[:last_nl]
  1263.         rest = msg[last_nl:]
  1264.         if lp[sid] == True:
  1265.             firstMsg += '\n**Loop of the playlist is** ***__enabled!__***'
  1266.         firstMsg += ' \n**You can remove a song from queue by using {0}playlist delete <number_in_queue>!**'.format(s_id[sid])
  1267.     else:
  1268.         firstMsg = msg
  1269.  
  1270.     await client.send_message(message.channel, firstMsg, *args, **kwargs)
  1271.  
  1272.        
  1273. async def miku_reaction(message):
  1274.     global miku_names, client
  1275.     for i in miku_names:
  1276.         if i in message.content:
  1277.             await asyncio.sleep(0.37)
  1278.             msg = random.choice(miku_message).format(message.author.mention)
  1279.             await client.send_message(message.channel, msg)
  1280.             return
  1281.            
  1282.  
  1283. statuses = ["with Lily", "with Ana", "with Yuno", "with Eri", "with Honoka", "with Nico", "with Nico", "with Nico Nico Niii~",
  1284.             "with Maki", "with herself", "with her toys", "with Nozomi", "with Kotori", "with Umi", "with Rin", "with Hanayo",
  1285.             "with Chika", "with Riko", "with Kanan", "with Dia", "with You-chan", "with Yoshiko", "with Yohanne", "with Hanamaru zuraaa~",
  1286.             "with Mari", "with Ruby", "with Taiga", "with her phone", "with Toastie", "with Ado-kun", "with adorable Ana-chan",
  1287.             "with Mashiro", "with Yuzu", "with Sprii", "with Katalina", "with her creator", "with Angela", "with her hair", "with Aqours", "with µ's",
  1288.             "with Luka", "Doki Doki Literature Club", "with Natsuki..?", "with Yuri", "with Sayori", "with Monika", "with Hana", "with her friends",
  1289.             "with Faerlynn", "nothing... Weird...", "with Satou", "with Shio", "with Livvy", "as Mercy", "as Ana", "as Brigitte", "as Pharah", "as D.Va",
  1290.             "as Mei", "as Sombra", "as Ashe", "as Moira", "as Symmetra", "as Tracer", "as Zarya", "as Miku", "as Luka", "as Athena", "as Echo",
  1291.             "as Efi", "with Katniss", "never have I ever", "with Kyō", "with Evitel", "with Taliesin"]
  1292.  
  1293.  
  1294. async def task_loop(client):
  1295.     while True:
  1296.         me = discord.utils.find(lambda s: s != None, client.servers).me
  1297.         if not me:
  1298.                 return
  1299.         elif not me.game:
  1300.                 updated_game = discord.Game(name = random.choice(statuses))              
  1301.         else:
  1302.                 updated_game = me.game
  1303.                 updated_game.name = random.choice(statuses)              
  1304.         await client.change_presence(game = updated_game)
  1305.         await asyncio.sleep(300 + random.randrange(150))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement