Advertisement
Faerlynn

Miku v0.21.0 (16.1.2019)

Jan 16th, 2019
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 55.33 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.  
  225.  
  226. #@client.event
  227. async def message_in(message, c):
  228.     global game_number, game_active, error, round_active, attempts, about, player, author, msg, version, s_id, gmn_cp, success
  229.     global miku_message, edits, statuses, players, vc, playlist, cp, loop, lp, miku_names, cpsong
  230.     global play_list, ytdl, dev_key, youtube, client, help_message, cpsong_two, shy_message
  231.     client = c
  232.     if message.author == client.user:
  233.         return
  234.     sid = message.server.id
  235.  
  236.     if not message.server.id in s_id:
  237.         s_id[message.server.id] = '$'
  238.         print('Creating a backup...')
  239.         msg = 'Creating a first settings for your server!'
  240.         await client.send_message(message.channel, msg)
  241.         save()
  242.         reload_files()
  243.         return
  244.    
  245.     #done       HELLO
  246.     if message.content.startswith('{0}hello'.format(s_id[sid])):
  247.         cmd = 'hello'
  248.         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])
  249.         log(msg, message.channel, message.author, cmd)
  250.         await client.send_message(message.channel, msg)
  251.  
  252.     #done       LOVE
  253.     if message.content.startswith('{0}love'.format(s_id[sid])):
  254.         cmd = 'love'
  255.         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*"
  256.         log(msg, message.channel, message.author, cmd)
  257.         await client.send_message(message.channel, msg)
  258.  
  259.     #done       RANDOM NUMBER
  260.     if message.content.startswith('{0}random'.format(s_id[sid])):
  261.         cmd = 'random'
  262.         msg = ('Randomly generated number: '+str(random.randrange(101)))
  263.         log(msg, message.channel, message.author, cmd)
  264.         await client.send_message(message.channel, msg)
  265.  
  266.     #done       POKE
  267.     if message.content.startswith('{0}poke'.format(s_id[sid])):
  268.         cmd = "poke"
  269.         msg = str(message.content)[6:]
  270.         msg_list = msg.split(' ')
  271.         msg_recipient = ''
  272.         msg_author = str(message.author)[:-5]
  273.         msg_content_test = False
  274.         for i in range(len(msg_list)):
  275.             msg_check = msg_list[i]
  276.             if (('<@!' and '>') in msg_check) == True:
  277.                 msg_recipient = msg_check
  278.                 msg_content_test = True
  279.         if not '@' in msg_recipient:
  280.             msg_recipient = 'fridge'
  281.         if msg_content_test == False:
  282.             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.*"
  283.         else:
  284.             msg = '*' + msg_author + " pokes " + msg_recipient + "'s shoulder gently and then just waits for their response patiently.*"
  285.  
  286.         log(msg, message.channel, message.author, cmd)
  287.         await client.send_message(message.channel, msg)
  288.         if msg_recipient == '<@!492432534181773313>':
  289.             time.sleep(1)
  290.             msg = "*She looks at {0.author.mention} curiously, and after moment she pokes {0.author.mention}'s nose back.*".format(message)
  291.             await client.send_message(message.channel, msg)
  292.  
  293.     #done       CUDDLE
  294.     if message.content.startswith('{0}cuddle'.format(s_id[sid])):
  295.         cmd = 'cuddle'
  296.         try:
  297.             msg = str(message.content)[8:]
  298.             msg_list = msg.split(' ')
  299.             msg_recipient = ''
  300.             msg_author = str(message.author)[:-5]
  301.             msg_content_test = False
  302.            
  303.             for i in range(len(msg_list)):
  304.                 msg_check = msg_list[i]
  305.                 if (('<@!' and '>') in msg_check) == True:
  306.                     msg_recipient = msg_check
  307.                     msg_content_test = True
  308.             if not '!' in msg_recipient:
  309.                 msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
  310.             if not '@' in msg_recipient:
  311.                 msg_recipient = 'themselve'
  312.  
  313.             if msg_recipient == str(message.author.mention):
  314.                 msg = random.choice(cuddle_message).format('Miku', msg_recipient)
  315.             else:
  316.            
  317.                 if not msg_content_test:
  318.                     msg = '*' + msg_author + " cuddles their pillow, smiling but alone.*"
  319.                 else:
  320.                     msg = random.choice(cuddle_message).format(msg_author, msg_recipient)
  321.             log(msg, message.channel, message.author, cmd)
  322.        
  323.             await client.send_message(message.channel, msg)
  324.         except ValueError in error:
  325.             print(error)
  326.             await client.send_message(message.channel, 'Something went wrong.... :sob:\n'.format(error))
  327.        
  328.  
  329.     #done       HUG
  330.     if message.content.startswith('{0}hug'.format(s_id[sid])):
  331.         cmd = 'hug'
  332.         msg = str(message.content)[5:]
  333.         msg_list = msg.split(' ')
  334.         msg_recipient = ''
  335.         msg_author = str(message.author)[:-5]
  336.         msg_content_test = False
  337.         for i in range(len(msg_list)):
  338.             msg_check = msg_list[i]
  339.             if (('<@!' and '>') in msg_check) == True:
  340.                 msg_recipient = msg_check
  341.                 msg_content_test = True
  342.         if not '!' in msg_recipient:
  343.             msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
  344.         if not '@' in msg_recipient:
  345.             msg_recipient = 'someone adorable'
  346.         if not msg_content_test:
  347.             msg_recipient = 'bottle of expensive red wine'
  348.         if msg_recipient == str(message.author.mention):
  349.             msg = random.choice(hug_message).format('Miku', msg_recipient)
  350.         else:
  351.             msg = random.choice(hug_message).format(msg_author, msg_recipient)
  352.         log(msg, message.channel, message.author, cmd)
  353.         try:
  354.             await client.send_message(message.channel, msg)
  355.         except Exception in error:
  356.             print(error)
  357.             await client.send_message(message.channel, 'Something went wrong.... :sob:')
  358.  
  359.     #done       KISS
  360.     if message.content.startswith('{0}kiss'.format(s_id[sid])):
  361.         cmd = 'kiss'
  362.         msg = str(message.content)[5:]
  363.         msg_list = msg.split(' ')
  364.         msg_recipient = ''
  365.         msg_author = str(message.author)[:-5]
  366.         msg_content_test = False
  367.         for i in range(len(msg_list)):
  368.             msg_check = msg_list[i]
  369.             if (('<@!' and '>') in msg_check) == True:
  370.                 msg_recipient = msg_check
  371.                 msg_content_test = True
  372.         if not '!' in msg_recipient:
  373.                 msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
  374.         if not '@' in msg_recipient:
  375.             msg_recipient = 'someone cute'
  376.         if msg_content_test == False:
  377.             msg_recipient = 'bottle of cheap red wine'
  378.         if msg_recipient == str(message.author.mention):
  379.             msg = random.choice(kiss_message).format('Miku', msg_recipient)
  380.         else:
  381.             msg = random.choice(kiss_message).format(msg_author, msg_recipient)
  382.         log(msg, message.channel, message.author, cmd)
  383.         try:
  384.             await client.send_message(message.channel, msg)
  385.         except ValueError in error:
  386.             print(error)
  387.             await client.send_message(message.channel, 'Something went wrong.... :sob:')
  388.  
  389.     #done       PAT
  390.     if message.content.startswith('{0}pat'.format(s_id[sid])):
  391.         cmd = 'pat'
  392.         if '{0}pat '.format(s_id[sid]) in message.content:
  393.             msg = str(message.content)[4:]
  394.             msg_list = msg.split(' ')
  395.             msg_recipient = ''
  396.             msg_author = str(message.author)[:-5]
  397.             msg_content_test = False
  398.             for i in range(len(msg_list)):
  399.                 msg_check = msg_list[i]
  400.                 if (('<@!' and '>') in msg_check) == True:
  401.                     msg_recipient = msg_check
  402.                     msg_content_test = True
  403.             if not '!' in msg_recipient:
  404.                 msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
  405.             if not '@' in msg_recipient:
  406.                 msg_recipient = 'Pa Butt'
  407.             if msg_content_test == False:
  408.                 msg_recipient = 'invisible unicorn'
  409.             if msg_recipient == str(message.author.mention):
  410.                 msg = random.choice(pat_message).format('Miku', msg_recipient)
  411.             else:
  412.                 msg = random.choice(pat_message).format(msg_author, msg_recipient)
  413.             log(msg, message.channel, message.author, cmd)
  414.             try:        
  415.                 await client.send_message(message.channel, msg)
  416.             except ValueError in error:
  417.                 print(error)
  418.                 await client.send_message(message.channel, 'Something went wrong.... :sob:')
  419.  
  420.     #SLAP
  421.     if message.content.startswith('{0}slap'.format(s_id[sid])):
  422.         cmd = 'slap'
  423.         if '{0}slap '.format(s_id[sid]) in message.content:
  424.             msg = str(message.content)[5:]
  425.             msg_list = msg.split(' ')
  426.             msg_recipient = ''
  427.             msg_author = str(message.author)[:-5]
  428.             msg_content_test = False
  429.             for i in range(len(msg_list)):
  430.                 msg_check = msg_list[i]
  431.                 if (('<@!' and '>') in msg_check) == True:
  432.                     msg_recipient = msg_check
  433.                     msg_content_test = True
  434.             if not '!' in msg_recipient:
  435.                 msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
  436.             if not '@' in msg_recipient:
  437.                 msg_recipient = 'random emoji'
  438.             if msg_content_test == False:
  439.                 msg_recipient = 'air'
  440.             if msg_recipient == str(message.author.mention):
  441.                 msg = random.choice(pat_message).format('Miku', msg_recipient)
  442.             else:
  443.                 msg = random.choice(slap_message).format(msg_author, msg_recipient)
  444.             log(msg, message.channel, message.author, cmd)
  445.             try:
  446.                 abc = str(message.author.mention).strip('<')
  447.                 await client.send_message(message.channel, msg)
  448.                
  449.             except ValueError in error:
  450.                 print(error)
  451.                 await client.send_message(message.channel, 'Something went wrong.... :sob:')
  452.  
  453.     #shy
  454.     if message.content.startswith('{0}shy'.format(s_id[sid])):
  455.         cmd = 'shy'
  456.         if '{0}shy '.format(s_id[sid]) in message.content:
  457.             msg = str(message.content)[4:]
  458.             msg_list = msg.split(' ')
  459.             msg_recipient = ''
  460.             msg_author = str(message.author)[:-5]
  461.             msg_content_test = False
  462.             for i in range(len(msg_list)):
  463.                 msg_check = msg_list[i]
  464.                 if (('<@!' and '>') in msg_check) == True:
  465.                     msg_recipient = msg_check
  466.                     msg_content_test = True
  467.             if not '!' in msg_recipient:
  468.                 msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
  469.             if not '@' in msg_recipient:
  470.                 msg_recipient = 'fridge'
  471.             if msg_content_test == False:
  472.                 msg_recipient = 'noone'
  473.             if msg_recipient == str(message.author.mention):
  474.                 msg = random.choice(shy_message).format('Miku', msg_recipient)
  475.             else:
  476.                 msg = random.choice(shy_message).format(msg_author, msg_recipient)
  477.             log(msg, message.channel, message.author, cmd)
  478.             try:
  479.                 abc = str(message.author.mention).strip('<')
  480.                 await client.send_message(message.channel, msg)
  481.                
  482.             except ValueError 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.     #done       AYAYA AYAYAAAAAA
  521.     if (message.content.startswith('ayaya')) or (message.content.startswith('AYAYA')):
  522.         cmd = 'ayaya'
  523.         msg = '''**⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣬⡛⣿⣿⣿⣯⢻
  524. ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⢻⣿⣿⢟⣻⣿⣿⣿⣿⣿⣿⣮⡻⣿⣿⣧
  525. ⣿⣿⣿⣿⣿⢻⣿⣿⣿⣿⣿⣿⣆⠻⡫⣢⠿⣿⣿⣿⣿⣿⣿⣿⣷⣜⢻⣿
  526. ⣿⣿⡏⣿⣿⣨⣝⠿⣿⣿⣿⣿⣿⢕⠸⣛⣩⣥⣄⣩⢝⣛⡿⠿⣿⣿⣆⢝
  527. ⣿⣿⢡⣸⣿⣏⣿⣿⣶⣯⣙⠫⢺⣿⣷⡈⣿⣿⣿⣿⡿⠿⢿⣟⣒⣋⣙⠊
  528. ⣿⡏⡿⣛⣍⢿⣮⣿⣿⣿⣿⣿⣿⣿⣶⣶⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿
  529. ⣿⢱⣾⣿⣿⣿⣝⡮⡻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⠛⣋⣻⣿⣿⣿⣿
  530. ⢿⢸⣿⣿⣿⣿⣿⣿⣷⣽⣿⣿⣿⣿⣿⣿⣿⡕⣡⣴⣶⣿⣿⣿⡟⣿⣿⣿
  531. ⣦⡸⣿⣿⣿⣿⣿⣿⡛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⣿⣿⣿
  532. ⢛⠷⡹⣿⠋⣉⣠⣤⣶⣶⣿⣿⣿⣿⣿⣿⡿⠿⢿⣿⣿⣿⣿⣿⣷⢹⣿⣿
  533. ⣷⡝⣿⡞⣿⣿⣿⣿⣿⣿⣿⣿⡟⠋⠁⣠⣤⣤⣦⣽⣿⣿⣿⡿⠋⠘⣿⣿
  534. ⣿⣿⡹⣿⡼⣿⣿⣿⣿⣿⣿⣿⣧⡰⣿⣿⣿⣿⣿⣹⡿⠟⠉⡀⠄⠄⢿⣿
  535. ⣿⣿⣿⣽⣿⣼⣛⠿⠿⣿⣿⣿⣿⣿⣯⣿⠿⢟⣻⡽⢚⣤⡞⠄⠄⠄⢸⣿**'''
  536.         log(msg, message.channel, message.author, cmd)
  537.         await client.send_message(message.channel, msg)
  538.  
  539.     #done       INVITE
  540.     if message.content.startswith('{0}invite'.format(s_id[sid])):
  541.         msg = "*You can invite me to your server using this link:*\nhttps://discordapp.com/oauth2/authorize?client_id=492432534181773313&scope=bot"
  542.         await client.send_message(message.author, msg)
  543.  
  544.     #done       TERRARIA
  545.     if message.content.startswith('{0}terraria'.format(s_id[sid])):
  546.         cmd = 'terraria'
  547.         msg = '''
  548.        **IP:** 95.105.211.38
  549.        **Port:** 6666
  550.        **Password:** *Ask Ana#3140*
  551.        *Server is hosted same way as I am.. That means it runs whenever I am online!!
  552.        Connecting to the server requires* **TModLoader**. *Our mods will get downloaded automatically when connecting!*
  553.        **List of mods:** *RecipeBrowser, WhereIsMyItem, Boss Checklist*
  554.        *You can get TModLoader here: https://tmodloader.net/*
  555.        '''
  556.         color = 4122822
  557.         embed = discord.Embed(title = 'Our Terraria server: ', description = msg, color = color)
  558.         log(msg, message.channel, message.author, cmd)
  559.         await client.send_message(message.channel, embed = embed)
  560.  
  561.     #done       CHOICE
  562.     if message.content.startswith('{0}choice'.format(s_id[sid])):
  563.         cmd = 'choice'
  564.         msg = message.content[8:]
  565.         choice_list = []
  566.         choice_list = msg.split(',')
  567.         msg = "I've randomly chosen this for you: " + str(random.choice(choice_list))
  568.         log(msg, message.channel, message.author, cmd)
  569.         await client.send_message(message.channel, msg)
  570.  
  571.     #done       PATCHNOTES
  572.     if message.content.startswith('{0}patchnotes'.format(s_id[sid])):
  573.         cmd = 'patchnotes'
  574.         p_notes_split = patchnotes.split('<$>')
  575.         #print(p_notes_split)
  576.         log(msg, message.channel, message.author, cmd)
  577.         for i in p_notes_split:
  578.             msg = '```{0}```'.format(i)
  579.             await client.send_message(message.author, msg)
  580.  
  581.     #done       VERSION
  582.     if message.content.startswith('{0}version'.format(s_id[sid])):
  583.         cmd = 'version'
  584.         msg = '`Current version of this bot is: {0}`'.format(version)
  585.         log(msg, message.channel, message.author, cmd)
  586.         await client.send_message(message.channel, msg)
  587.  
  588.     #done       RANDOM NUMBER X Z
  589.     if message.content.startswith('{0}rnf'.format(s_id[sid])):
  590.         cmd = 'random number from <x, z>'
  591.         msg = message.content[5:]
  592.         numbers = []
  593.         numbers = msg.split(' ')
  594.         log(msg, message.channel, message.author, cmd)
  595.         error = ''
  596.         if len(numbers) == (1 or 0):
  597.             msg = 'You need two numbers!'
  598.             await client.send_message(message.channel, msg)
  599.         else:
  600.             try:
  601.                 print(numbers[0], numbers[1])
  602.                 a = int(round(float(numbers[0])))
  603.                 b = int(round(float(numbers[1])))
  604.                 print(a, b)
  605.                
  606.                 if a >= b:
  607.                     c = a
  608.                     a = b
  609.                     b = c
  610.                    
  611.                 if a == b:
  612.                     msg = "Your random number is not really random, but here you go: {0}".format(a)
  613.                 else:
  614.                     num = random.randrange(a, b+1)
  615.                     msg = "Your random number is: " + str(num)
  616.                 await client.send_message(message.channel, msg)
  617.                
  618.             except ValueError as error:
  619.                 print(error)
  620.                 msg = 'Something went wrong!'
  621.                 await client.send_message(message.channel, msg)
  622.  
  623.     #done       INCH to CM
  624.     if message.content.startswith('{0}cm'.format(s_id[sid])):
  625.         mes = str(message.content)[4:]
  626.         thingy = str(mes).split("'")
  627.         a, b = thingy[0], thingy[1]
  628.         try:
  629.             a, b = int(a), float(b)
  630.             msg =  str(round(a * 12 * 2.54 + b * 2.54, 2)) + 'cm'
  631.         except Exception as e:
  632.             msg = 'Error!\n{0}'.format(e)
  633.         await client.send_message(message.channel, msg)
  634.  
  635.     #done       CM TO INCH
  636.     if message.content.startswith('{0}inch'.format(s_id[sid])):
  637.         mes = float(str(message.content)[6:])
  638.         mes = int(round(mes))
  639.         try:
  640.             msg = str(int(mes // (30.48)))
  641.             mes = (mes % 30.48)*100000
  642.             zv = int(round(mes // 2.54))
  643.             zv = round(zv/100000)
  644.             msg += "'{0}".format(zv)
  645.         except Exception as e:
  646.             msg = 'Error!\n{0}'.format(e)
  647.         await client.send_message(message.channel, msg)
  648.            
  649.  
  650.     #done       COINFLIP
  651.     if message.content.startswith('{0}coinflip'.format(s_id[sid])):
  652.         cmd = 'coinflip'
  653.         num = random.randrange(1000)+1
  654.         if num == 741:
  655.             msg = "***It landed on it's side! How lucky!!!***"
  656.         else:
  657.             if num == 274:
  658.                 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..."
  659.             else:
  660.                 if num > 500:
  661.                     msg = 'Heads!' + '!'*random.randrange(4)
  662.                 else:
  663.                     msg = 'Tails!' + '!'*random.randrange(4)
  664.         #log(msg, message.channel, message.author, cmd)
  665.         print("Command '$" + cmd + "' used in " + str(message.channel) + ' by ' + str(message.author) +'! Rolled: ' + str(num))
  666.         await client.send_message(message.channel, msg)
  667.  
  668.     #done       RANDOM COLOUR
  669.     if message.content.startswith('{0}rc'.format(s_id[sid])):
  670.         cmd = 'random colour'
  671.         color = random.randrange(256**3)
  672.         print(color)
  673.         msg = str(f'#{color:06x}')
  674.         embed = discord.Embed(title = 'Your random colour: ', description = msg, color = color)
  675.         log(str(msg), message.channel, message.author, cmd)
  676.         await client.send_message(message.channel, embed = embed)
  677.  
  678.     #done       GUESS MY NUMBER
  679.     if message.content.startswith('{0}gmn'.format(s_id[sid])):
  680.        
  681.         if not str(message.author) in gmn_cp:
  682.             gmn_cp[str(message.author)] = False
  683.             gmn_a[str(message.author)] = 0
  684.             gmn_number[str(message.author)] = 0
  685.            
  686.         if gmn_cp[str(message.author)] == False:
  687.             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..!!")
  688.             time.sleep(0.25)
  689.             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]))
  690.             game_number = random.randrange(100)+1
  691.             gmn_number[str(message.author)] = game_number
  692.             gmn_a[str(message.author)] = 0
  693.             player = str(message.author)
  694.             gmn_cp[str(message.author)] = True
  695.            
  696.         elif gmn_cp[str(message.author)] == True:
  697.             number = message.content[4:]
  698.             try:
  699.                 number = int(number)
  700.                 gmn_cp[str(message.author)] = True
  701.                
  702.                 if gmn_number[str(message.author)] == number:
  703.                     msg = "Y-yes..! That's the number I.. I've been thinking of! Y-you are so good s-senpai! :heart_eyes:"
  704.                     gmn_a[str(message.author)] = 0
  705.                     await client.send_message(message.channel, msg)
  706.                     gmn_a[str(message.author)] = 0
  707.                     gmn_cp[str(message.author)] = False
  708.  
  709.                    
  710.                 elif (gmn_a[str(message.author)] == 0) and (gmn_cp[str(message.author)] == True):
  711.  
  712.                     if gmn_number[str(message.author)] < number:
  713.                         msg = "T-that's not it, s-senpai..! :flushed: Your n-number is too b-big.. T-try again..! *blushes*"
  714.                         await client.send_message(message.channel, msg)
  715.                     else:
  716.                         msg = "T-that's not it, s-senpai..! :flushed: Your n-number is not b-big enough.. T-try again..! *blushes*"
  717.                         await client.send_message(message.channel, msg)
  718.  
  719.                     gmn_a[str(message.author)] = 1
  720.                     print('New game! Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
  721.                    
  722.                 elif (gmn_a[str(message.author)] == 1) and (gmn_cp[str(message.author)] == True):
  723.  
  724.                    
  725.                     if gmn_number[str(message.author)] < number:
  726.                         msg = "N-no senpai... S-still not my number.. It's n-not that big..."
  727.                         await client.send_message(message.channel, msg)
  728.                     else:
  729.                         msg = "N s-senpai... S-still not my special number.. It's even higher..."
  730.                         await client.send_message(message.channel, msg)
  731.                        
  732.                     gmn_a[str(message.author)] = 2
  733.                     print('Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
  734.  
  735.                    
  736.                 elif (gmn_a[str(message.author)] == 2) and (gmn_cp[str(message.author)] == True):
  737.                    
  738.                     if gmn_number[str(message.author)] < number:
  739.                         msg = "That's again n-not my n-number *blushes* T-too big..! Last chance..!"
  740.                         await client.send_message(message.channel, msg)
  741.                     else:
  742.                         msg = "N-not my n-number, senpai..! *blushes* Go h-higher..! L-last attempt..!"
  743.                         await client.send_message(message.channel, msg)
  744.                        
  745.                     gmn_a[str(message.author)] = 3
  746.                     print('Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
  747.                    
  748.                 elif (gmn_a[str(message.author)] == 3) and (gmn_cp[str(message.author)] == True):
  749.                    
  750.                     if gmn_number[str(message.author)] < number:
  751.                         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)])
  752.                         await client.send_message(message.channel, msg)
  753.                     else:
  754.                         msg = "S-senpai..! T-that's not my number..! I was t-thinking of a number " + str(gmn_number[str(message.author)])
  755.                         await client.send_message(message.channel, msg)
  756.                        
  757.                     print('Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
  758.                     gmn_a[str(message.author)] = 0
  759.                     gmn_cp[str(message.author)] = False
  760.                    
  761.             except:
  762.                 await client.send_message(message.channel, "That's not a number, b-baka s-senpai..!!")
  763.         else:
  764.             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:")
  765.  
  766.  
  767.     #done       LEWD
  768.     if message.content.startswith('{0}lewd'.format(s_id[sid])):
  769.         if str(message.author) == 'Ana#3140':
  770.             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..!__***'
  771.         else:
  772.             msg = '**Y-YOU ARE SO L-LEWD, SENPAI**' + '!'*int(random.randrange(9)+3)
  773.         await client.send_message(message.channel, msg)
  774.  
  775.     #done       SERVER PREFIX CHANGE
  776.     if message.content.startswith('{0}prefix set'.format(s_id[sid])):
  777.         if message.author == message.server.owner:
  778.             try:
  779.                 prefix = message.content[12:]
  780.                 if len(prefix) > 1:
  781.                     msg = 'Prefix can consist of only one character!'
  782.                 else:
  783.                     s_id[message.server.id] = str(prefix)
  784.                     save()
  785.                     reload_files()
  786.                     msg = 'Prefix of this server has been changed to {0}'.format(prefix)
  787.             except:
  788.                 msg = 'Something went wrong!'
  789.         else:
  790.             msg = "I'm sorry s-senpai, b-but you are n-not owner of t-this server!"
  791.         await client.send_message(message.channel, msg)
  792.                
  793.  
  794.     #bet reaction
  795.     if (message.content.startswith('bet'))or (message.content.startswith('beet')) or (message.content.startswith('Bet')):
  796.         num = random.randrange(10000)
  797.         if num == 2714:
  798.             msg = 'BEEEEEEEEEEEEEEEEEEEEEEEEEEEET!!!!!'
  799.             await client.send_message(message.channel, msg)
  800.         else:
  801.             if num == 8743:
  802.                 msg = 'No bets allowed to underage trolls (That means you are not allowed to bet if you are not 18+.... B-baka senpai.. >.>)'
  803.                 await client.send_message(message.channel, msg)
  804.             else:
  805.                 msg = "{0}bet{0}".format(edits[random.randrange(5)])
  806.                 await client.send_message(message.channel, msg)
  807.  
  808.     #miku reaction
  809.     await miku_reaction(message)
  810.  
  811.     #Reactions for other bots
  812.     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]))):
  813.         await asyncio.sleep(1)
  814.         msg = 'Awwwwww t-thanks a lot for petting me, {0}! :sparkling_heart: :heart_eyes: ^~^'.format(message.author.mention)
  815.         await client.send_message(message.channel, msg)
  816.  
  817.     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]))):
  818.         await asyncio.sleep(1)
  819.         msg = 'Oh~, thanks s-senpai for hug! *she hugs {0} back tightly, smiling and blushing.*'.format(message.author.mention)
  820.         await client.send_message(message.channel, msg)
  821.  
  822.     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]))):
  823.         await asyncio.sleep(1)
  824.         msg = '*She giggles and cuddles {0} back, slightly stroking their back, still giggling.*'.format(message.author.mention)
  825.         await client.send_message(message.channel, msg)
  826.        
  827.     if (message.content.startswith('{0}poke <@!492432534181773313>'.format(s_id[sid]))) or (message.content.startswith('{0}poke <@492432534181773313>'.format(s_id[sid]))):
  828.         await asyncio.sleep(1)
  829.         msg = "*She looks at {0} curiously, and then she pokes {0} back.*".format(message.author.mention)
  830.         await client.send_message(message.channel, msg)
  831.  
  832.     if (message.content.startswith('{0}slap <@!492432534181773313>'.format(s_id[sid]))) or (message.content.startswith('{0}slap <@492432534181773313>'.format(s_id[sid]))):
  833.         await asyncio.sleep(1)
  834.         msg = '*She slaps {0} back, looking angry, annoyed but dissappointed and sad as well...*'.format(message.author.mention)
  835.         await client.send_message(message.channel, msg)
  836.  
  837.  
  838.     #dev only functions
  839.  
  840.     #done       STOP
  841.     if (message.content.startswith('{0}stop'.format(s_id[message.server.id]))) or (message.content.startswith('{0}bye'.format(s_id[message.server.id]))):
  842.         cmd = 'stop'
  843.         msg = ''
  844.         log(msg, message.channel, message.author, cmd)
  845.         if (str(message.author.id) == '207505077013839883') or (str(mesasge.author.id) == '296301865627287553'):
  846.             msg = 'G-good b-bye, s-senpai~ :heart:!'
  847.             await client.send_message(message.channel, msg)
  848.             print('Good b-bye Ana s-senpai~ <3')
  849.             client.logout()
  850.             save()
  851.             sys.exit(0)
  852.         else:
  853.             msg = 'Insufficient permissions...'
  854.             await client.send_message(message.channel, msg)
  855.  
  856.     #done       RELOAD FILES
  857.     if message.content.startswith('{0}rf'.format(s_id[message.server.id])):
  858.         cmd = 'reload files'
  859.         log(msg, message.channel, message.author, cmd)
  860.         author = str(message.author)
  861.         if author == 'Ana#3140':
  862.             reload_files()
  863.             if success == False:
  864.                 print('Files reloaded successfully...')
  865.             else:
  866.                 print('Reload unsuccessful...')
  867.         else:
  868.             msg = 'Insufficient permissions...'
  869.             await client.send_message(message.channel, msg)
  870.  
  871.     #done       CHANGE GAME STATUS
  872.     if message.content.startswith('{0}game'.format(s_id[message.server.id])):
  873.         cmd = 'game status'
  874.         if (str(message.author.id) == '207505077013839883') or (str(message.author.id) == '296301865627287553'):
  875.             if len(str(message.content)) >6:
  876.                 g = str(message.content)[6:]
  877.                 print(g, str(message.content))
  878.                 me = discord.utils.find(lambda s: s != None, client.servers).me
  879.                 if not me:
  880.                         return
  881.                 elif not me.game:
  882.                         updated_game = discord.Game(name = str(g))
  883.                 else:
  884.                         updated_game = me.game
  885.                         updated_game.name = str(g)
  886.             else:
  887.                 me = discord.utils.find(lambda s: s != None, client.servers).me
  888.                 if not me:
  889.                         return
  890.                 elif not me.game:
  891.                         updated_game = discord.Game(name = random.choice(statuses))
  892.                 else:
  893.                         updated_game = me.game
  894.                         updated_game.name = random.choice(statuses)
  895.             await client.change_presence(game = updated_game)
  896.             print('Changing game to: {0}'.format(str(updated_game)))
  897.            
  898.  
  899.     #done       PATCH CHANGE
  900.     if message.content.startswith('{0}patch set'.format(s_id[message.server.id])):
  901.         author = str(message.author)
  902.         author2 = message.author.id
  903.         cmd = 'patch'
  904.         msg = ''
  905.         patch = ''
  906.         log(msg, message.channel, message.author, cmd)
  907.         if author2 == '207505077013839883':
  908.             try:
  909.                 msg = 'Done!'
  910.                 patch = message.content
  911.                 patch = patch[11:]
  912.                 os.remove('bot_save_files\patch.txt')
  913.                 file = open('bot_save_files\patch.txt', 'w')
  914.                 file.write(str(patch))
  915.                 file.close()
  916.                 version = patch
  917.                 print('Current patch changed to {0}'.format(patch))
  918.                 ctypes.windll.kernel32.SetConsoleTitleW(patch)
  919.                 await client.send_message(message.channel, msg)
  920.             except:
  921.                 print('Something went wrong!')
  922.            
  923.     #WIP        TEST COMMAND
  924.     if message.content.startswith('{0}test'.format(s_id[message.server.id])):
  925.         cmd = 'test'
  926.         msg = str(message.content)[1:-1]
  927.         await client.send_message(message.channel, msg)
  928.  
  929.     #MUSIC LOOP
  930.     if message.content.startswith('{0}loop'.format(s_id[message.server.id])):
  931.         if not message.server.id in loop:
  932.             loop[message.server.id] = True
  933.             msg = 'Looping current song!'
  934.             await client.send_message(message.channel, msg)
  935.            
  936.         elif loop[message.server.id] == True:
  937.             loop[message.server.id] = False
  938.             msg = 'Loop of the current song disabled!'
  939.             await client.send_message(message.channel, msg)
  940.            
  941.         elif loop[message.server.id] == False:
  942.             loop[message.server.id] = True
  943.             msg = 'Looping current song!'
  944.             await client.send_message(message.channel, msg)
  945.  
  946.  
  947.     #MUSIC LOOP PLAYLIST
  948.     if message.content.startswith('{0}lp'.format(s_id[message.server.id])):
  949.         if not message.server.id in lp:
  950.             lp[message.server.id] = True
  951.             msg = 'Looping current playlist!'
  952.             await client.send_message(message.channel, msg)
  953.            
  954.         elif lp[message.server.id] == True:
  955.             lp[message.server.id] = False
  956.             msg = 'Loop of the current playlist disabled!'
  957.             await client.send_message(message.channel, msg)
  958.            
  959.         elif lp[message.server.id] == False:
  960.             lp[message.server.id] = True
  961.             msg = 'Looping current playlist!'
  962.             await client.send_message(message.channel, msg)
  963.            
  964.     #MUSIC CONNECT
  965.     if message.content.startswith("{0}p ".format(s_id[message.server.id])):
  966.         channel = message.author.voice.voice_channel
  967.        
  968.         if not message.server.id in loop:
  969.             loop[message.server.id] = False
  970.  
  971.         if not message.server.id in lp:
  972.             lp[message.server.id] = False
  973.            
  974.         if not channel == None:
  975.             ytdl = YoutubeDL()
  976.             link = ''
  977.             if not message.server.id in playlist:
  978.                 playlist[message.server.id] = []
  979.             if not message.server.id in cp:
  980.                 cp[message.server.id] = 'False'
  981.  
  982.             link = str(message.content)[3:]
  983.             if 'https://www.youtube.com/playlist?list=' in link:
  984.                 troll = 'https://www.youtube.com/playlist?list='
  985.                 link = link[len(troll):]
  986.                 results = youtube.playlistItems().list(playlistId=link, part='contentDetails', maxResults = 50).execute()
  987.                 videoIds = [item['contentDetails']['videoId'] for item in results.get('items', [])]
  988.                 playlist[sid] += videoIds
  989.                 link = playlist[sid][0]
  990.             else:
  991.                 if 'https://youtu.be/' in link:
  992.                     link = link.strip('https://youtu.be/')
  993.                 if 'www.youtube.' in link:
  994.                     link = link[32:]
  995.                 if len(link) > 11:
  996.                     link = link[:11]
  997.                 playlist[message.server.id].append(link)
  998.             await client.add_reaction(message, '\U00002705')
  999.             await music_playlist(message)
  1000.         else:
  1001.             msg = "S-senpai..! You're n-not in a-any voice c-channel!"
  1002.             await client.send_message(message.channel, msg)
  1003.  
  1004.     #MUSIC DISCONENCT
  1005.     if message.content.startswith('{0}dc'.format(s_id[message.server.id])):
  1006.         if client.is_voice_connected(message.server):
  1007.             playlist[message.server.id] = []
  1008.             cp[message.server.id] = 'False'
  1009.             players[message.server.id].stop()
  1010.             loop[message.server.id] = False
  1011.             lp[message.server.id] = False
  1012.             cpsong[message.server.id] = ''
  1013.             msg = 'Bai baaaaai~'
  1014.             await client.send_message(message.channel, msg)
  1015.            
  1016.             await vc.disconnect()
  1017.            
  1018.         else:
  1019.             msg = "S-senpai..! B-but I.. I'm n-not connected y-yet! :flushed:"
  1020.             await client.send_message(message.channel, msg)
  1021.  
  1022.     #MUSIC PLAYLIST
  1023.     if message.content.startswith('{0}playlist'.format(s_id[message.server.id])):
  1024.         mes = str(message.content).strip('{0}playlist'.format(s_id[message.server.id]))
  1025.         if 'del' in mes:
  1026.             mes = mes.strip(' del ')
  1027.             try:
  1028.                 try:
  1029.                     num = int(mes)
  1030.                 except:
  1031.                     print('Couldn\'t convert mes into num')
  1032.                 if not 0 < num <= len(playlist[sid]):
  1033.                     msg =  'B-but s-senpai!! T-that\'s not a... r-right n-number!!'
  1034.                     await client.send_message(message.channel, msg)
  1035.                 else:
  1036.                     del(playlist[message.server.id][num-1])
  1037.                     msg = 'Done..!'
  1038.                     await client.send_message(message.channel, msg)
  1039.             except:
  1040.                 msg = 'O-oh senpai..! I\'m s-sorry, b-but something went w-wrong!'
  1041.                 await client.send_message(message.channel, msg)
  1042.                
  1043.         elif 'delete' in mes:
  1044.             mes = mes.strip(' delete ')
  1045.             try:
  1046.                 try:
  1047.                     num = int(mes)
  1048.                 except:
  1049.                     print('Couldn\'t convert mes into num')
  1050.                 if not 0 < num <= len(playlist[sid]):
  1051.                     msg =  'S-senpai..!! W-wrong number! :flushed:'
  1052.                     await client.send_message(message.channel, msg)
  1053.                 else:
  1054.                     del(playlist[message.server.id][num-1])
  1055.                     msg = 'Done..!'
  1056.                     await client.send_message(message.channel, msg)
  1057.             except:
  1058.                 msg = 'O-oh senpai..! I\'m s-sorry, b-but something went w-wrong!'
  1059.                 await client.send_message(message.channel, msg)
  1060.         elif 'clear' in mes:
  1061.             try:
  1062.                 playlist[sid] = []
  1063.                 playlist[sid].append(cpsong[sid])
  1064.                 msg = 'Cleared playlist! Current song will keep playing.'
  1065.             except Exception as e:
  1066.                 msg = 'Something went wrong!\n{0}'.format(e)
  1067.             await client.send_message(message.channel, msg)
  1068.         else:
  1069.             await music_playlist_print(message)
  1070.  
  1071.  
  1072.     #MUSIC CURRENTLY PLAYING
  1073.     if message.content.startswith('{0}cp'.format(s_id[sid])):
  1074.         msg = '***Currently playing:***\n*{0}*  **Duration:** {1}'.format(info[sid]['title'], datetime.timedelta(seconds=info[sid]['duration']))
  1075.         if loop == True:
  1076.             msg += '\n**Loop of current song is** ***enabled!***'
  1077.         await client.send_message(message.channel, msg)
  1078.  
  1079.  
  1080.     #MUSIC SKIP
  1081.     if (message.content.startswith('{0}skip'.format(s_id[sid]))) or (message.content.startswith('{0}next'.format(s_id[sid]))):
  1082.         await music_skip(message)
  1083.     return None
  1084.        
  1085.  
  1086. async def music_playlist(message):
  1087.     global vc, cp, playlist, urllist, client
  1088.  
  1089.     if playlist[message.server.id] != []:
  1090.         url = playlist[message.server.id][0]
  1091.     else:
  1092.         return
  1093.    
  1094.     if (cp[message.server.id] == 'False') and (playlist[message.server.id] != []):
  1095.         await music_bot(url, message)
  1096.        
  1097.  
  1098. async def music_bot(url, message):
  1099.     global vc, cp, playlist, urllist, loop, ytdl, cpsong, info, client, cpsong_two
  1100.     sid = message.server.id
  1101.    
  1102.     if not message.server.id in cpsong:
  1103.         cpsong[sid] = ''
  1104.     if not sid in cpsong_two:
  1105.         cpsong_two[sid] = ''
  1106.        
  1107.     cpsonglocal = {}
  1108.     timethingy = str(timeit.timeit())
  1109.    
  1110.     cpsong_two[sid] = url
  1111.     cpsong[sid] = timethingy
  1112.     cpsonglocal[sid] = timethingy
  1113.     if not client.is_voice_connected(message.server):
  1114.         while playlist[sid] != []:
  1115.  
  1116.             channel = message.author.voice.voice_channel
  1117.             vc = await client.join_voice_channel(channel)
  1118.             musicplayer = await vc.create_ytdl_player(url, before_options=" -reconnect 1 -reconnect_streamed 1"
  1119.                                                                            " -reconnect_delay_max 5")
  1120.             players[sid] = musicplayer
  1121.             musicplayer.start()
  1122.             cp[sid] = 'True'
  1123.            
  1124.             info[sid] = ytdl.extract_info(url, download = False)
  1125.            
  1126.             await asyncio.sleep(int(info[sid]['duration'])-1)
  1127.             if cpsong[sid] == cpsonglocal[sid]:
  1128.                 cp[sid] = 'False'
  1129.                 await loop_check(url, message)
  1130.             else:
  1131.                 return
  1132.                 print('no')
  1133.                
  1134.     elif client.is_voice_connected(message.server):
  1135.         while playlist[sid] != []:
  1136.             vc = client.voice_client_in(message.server)
  1137.             musicplayer = await vc.create_ytdl_player(url, before_options=" -reconnect 1 -reconnect_streamed 1"
  1138.                                                                            " -reconnect_delay_max 5")
  1139.             players[sid] = musicplayer
  1140.             musicplayer.start()
  1141.             cp[sid] = 'True'
  1142.            
  1143.             info[sid] = ytdl.extract_info(url, download = False)
  1144.            
  1145.             await asyncio.sleep(int(info[sid]['duration'])-1)
  1146.             if cpsong[sid] == cpsonglocal[sid]:
  1147.                 cp[sid] = 'False'
  1148.                 await loop_check(url, message)
  1149.             else:
  1150.                 return
  1151.                 print('no')
  1152.                    
  1153.    
  1154. async def loop_check(url, message):
  1155.     global loop, playlist, urllist, lp, client
  1156.  
  1157.     if lp[message.server.id] == True:
  1158.  
  1159.         playlist[message.server.id].append(url)
  1160.         del(playlist[message.server.id][0])
  1161.    
  1162.         await music_playlist(message)
  1163.        
  1164.     else:
  1165.    
  1166.         if loop[message.server.id] == True:
  1167.             await music_bot(url, message)
  1168.         elif loop[message.server.id] == False:
  1169.             del(playlist[message.server.id][0])
  1170.             await music_playlist(message)
  1171.  
  1172. async def music_skip(message):
  1173.     global players, playlist, urllist, cp, urls, client
  1174.     sid = message.server.id
  1175.  
  1176.     if 'DJ' in message.server.roles:
  1177.         print('SKIP TEST 1')
  1178.         if 'DJ' in message.author.roles:
  1179.  
  1180.             print('SKIP TEST 2')
  1181.             cp[message.server.id] = 'False'
  1182.             players[message.server.id].stop()
  1183.             playlist[message.server.id] = playlist[message.server.id][len(urls[message.server.id])+7:]
  1184.             msg = 'Skipping current song...'
  1185.             await client.send_message(message.channel, msg)
  1186.             await music_playlist(message)
  1187.         else:
  1188.             msg = 'Insufficent permission!'
  1189.             await client.send_message(message.channel, msg)
  1190.             print('SKIP TEST 3')
  1191.     else:
  1192.         if playlist[sid] == []:
  1193.             msg = '***There is no song playing at the moment! Queue some using {0}p url!***'.format(s_id[sid])
  1194.             await client.send_message(message.channel, msg)
  1195.             return
  1196.         else:
  1197.             if lp[sid] == True:
  1198.            
  1199.                 playlist[message.server.id].append(playlist[message.server.id][0])
  1200.                 del(playlist[message.server.id][0])
  1201.                
  1202.             else:
  1203.                 del(playlist[message.server.id][0])
  1204.             cp[message.server.id] = 'False'
  1205.             players[message.server.id].stop()
  1206.             msg = 'Skipping current song...'
  1207.             await client.send_message(message.channel, msg)
  1208.             await music_playlist(message)
  1209.  
  1210. async def music_playlist_print(message):
  1211.     global playlist, youtube, s_id, lp, client
  1212.     sid = message.server.id
  1213.     if not sid in playlist:
  1214.         msg = '**There are no songs in queue at the moment! Queue some using {0}p url!**'.format(s_id[sid])
  1215.         await client.send_message(message.channel, msg)
  1216.     else:
  1217.         urls = playlist[sid]
  1218.         ids = ','.join(urls)  
  1219.         msg = '***Current playlist:***\n'
  1220.  
  1221.         results = {}
  1222.         while results == {}:
  1223.             try:
  1224.                 results = youtube.videos().list(id=ids, part='snippet').execute()
  1225.             except:
  1226.                 print('Youtube results unsucessful, retrying...')
  1227.         msg += '\n'.join(
  1228.             '**{0}**: *{1}*'.format(i, item['snippet']['title'])
  1229.             for i, item in
  1230.             enumerate(results.get('items', []), start=1))
  1231.         if lp[sid] == True:
  1232.             msg += '\n**Loop of the playlist is** ***__enabled!__***'
  1233.         msg += ' \n**You can remove a song from queue by using {0}playlist delete <number_in_queue>!**'.format(s_id[sid])
  1234.         if not '1' in msg:
  1235.             msg = '**There are no songs in queue at the moment! Queue some using {0}p url!**'.format(s_id[sid])
  1236.         await send_message(message, msg)
  1237.     return
  1238.        
  1239. async def send_message(message, msg, *args, **kwargs):
  1240.     global lp, s_id, client
  1241.     sid = message.server.id
  1242.     if len(msg) > 1800:
  1243.         first2k = msg[:1800]
  1244.         last_nl = first2k.rfind('\n')
  1245.         firstMsg = msg[:last_nl]
  1246.         rest = msg[last_nl:]
  1247.         if lp[sid] == True:
  1248.             firstMsg += '\n**Loop of the playlist is** ***__enabled!__***'
  1249.         firstMsg += ' \n**You can remove a song from queue by using {0}playlist delete <number_in_queue>!**'.format(s_id[sid])
  1250.     else:
  1251.         firstMsg = msg
  1252.  
  1253.     await client.send_message(message.channel, firstMsg, *args, **kwargs)
  1254.  
  1255.        
  1256. async def miku_reaction(message):
  1257.     global miku_names, client
  1258.     for i in miku_names:
  1259.         if i in message.content:
  1260.             await asyncio.sleep(0.37)
  1261.             msg = random.choice(miku_message).format(message.author.mention)
  1262.             await client.send_message(message.channel, msg)
  1263.             return
  1264.            
  1265.  
  1266. statuses = ["with Lily", "with Ana", "with Yuno", "with Eri", "with Honoka", "with Nico", "with Nico", "with Nico Nico Niii~",
  1267.             "with Maki", "with herself", "with her toys", "with Nozomi", "with Kotori", "with Umi", "with Rin", "with Hanayo",
  1268.             "with Chika", "with Riko", "with Kanan", "with Dia", "with You-chan", "with Yoshiko", "with Yohanne", "with Hanamaru zuraaa~",
  1269.             "with Mari", "with Ruby", "with Taiga", "with her phone", "with Toastie", "with Ado-kun", "with adorable Ana-chan",
  1270.             "with Mashiro", "with Yuzu", "with Sprii", "with Katalina", "with her creator", "with Angela", "with her hair", "with Aqours", "with µ's",
  1271.             "with Luka", "Doki Doki Literature Club", "with Natsuki..?", "with Yuri", "with Sayori", "with Monika", "with Hana", "with her friends",
  1272.             "with Faerlynn", "nothing... Weird...", "with Satou", "with Shio", "with Livvy", "as Mercy", "as Ana", "as Brigitte", "as Pharah", "as D.Va",
  1273.             "as Mei", "as Sombra", "as Ashe", "as Moira", "as Symmetra", "as Tracer", "as Zarya", "as Miku", "as Luka", "as Athena", "as Echo",
  1274.             "as Efi", "with Katniss", "never have I ever", "with Kyō", "with Evitel", "with Taliesin"]
  1275.  
  1276.  
  1277. async def task_loop(client):
  1278.     while True:
  1279.         me = discord.utils.find(lambda s: s != None, client.servers).me
  1280.         if not me:
  1281.                 return
  1282.         elif not me.game:
  1283.                 updated_game = discord.Game(name = random.choice(statuses))              
  1284.         else:
  1285.                 updated_game = me.game
  1286.                 updated_game.name = random.choice(statuses)              
  1287.         await client.change_presence(game = updated_game)
  1288.         await asyncio.sleep(300 + random.randrange(150))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement