Advertisement
Faerlynn

Miku v0.19.3 (5.1.2019)

Jan 5th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 54.09 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.  
  14. start = timeit.timeit()
  15.  
  16. file = open('bot_save_files\patch.txt', 'r')
  17. version = file.readline()
  18. file.close()
  19. print(str(version))
  20. print('------------')
  21. ctypes.windll.kernel32.SetConsoleTitleW(str(version))
  22.  
  23. client = discord.Client()
  24.  
  25. def log(msg, message_channel, message_author, cmd_type):
  26.     if cmd_type == '':
  27.         cmd_type = 'unknown'
  28.     #print("Command '" + cmd_type + "' used in " + str(message_channel) + ' by ' + str(message_author) +'!')
  29.     print('Command \'{0}\' used in {1} by {2}!'.format(cmd_type, str(message_channel), str(message_author)))
  30.  
  31. def reload_files():
  32.     global cuddle_message, hug_message, kiss_message, about, patchnotes, pat_message, version, slap_message, s_id, success
  33.     global miku_message, dev_key, youtube
  34.     #Opens file for 'cuddle'
  35.     success = False
  36.     try:
  37.         file = open("bot_save_files\cuddle_messages.txt",'r')
  38.         line = file.readline()
  39.         cuddle_message = []
  40.         while line:
  41.             cuddle_message.append(line)
  42.             line = file.readline()
  43.         file.close()
  44.     except:
  45.         print("File 'cuddle_messages.txt' couldn't be opened!")
  46.         success = True
  47.  
  48.     #Opens file for 'hug'
  49.     try:
  50.         file = open("bot_save_files\hug_messages.txt",'r')
  51.         line = file.readline()
  52.         hug_message = []
  53.         while line:
  54.             hug_message.append(line)
  55.             line = file.readline()
  56.         file.close()
  57.     except:
  58.         print("File 'hug_messages.txt' couldn't be opened!")
  59.         success = True
  60.  
  61.     #Opens file for 'pat'
  62.     try:
  63.         file = open("bot_save_files\pat_messages.txt",'r')
  64.         line = file.readline()
  65.         pat_message = []
  66.         while line:
  67.             pat_message.append(line)
  68.             line = file.readline()
  69.         file.close()
  70.     except:
  71.         print("File 'pat_messages.txt' couldn't be opened!")
  72.         success = True
  73.        
  74.     #Opens file for 'kiss'
  75.     try:
  76.         file = open("bot_save_files\kiss_messages.txt",'r')
  77.         line = file.readline()
  78.         kiss_message = []
  79.         while line:
  80.             kiss_message.append(line)
  81.             line = file.readline()
  82.         file.close()
  83.     except:
  84.         print("File 'kiss_messages.txt' couldn't be opened!")
  85.         success = True
  86.        
  87.     #Opens file for 'about'
  88.     try:
  89.         about = ''
  90.         file = open("bot_save_files\\about.txt",'r')
  91.         about = file.read()
  92.         file.close()
  93.     except:
  94.         print("File 'about.txt' couldn't be opened!")
  95.         success = True
  96.  
  97.     #Opens file for 'about'
  98.     try:
  99.         version = ''
  100.         file = open("bot_save_files\\patch.txt",'r')
  101.         version = file.read()
  102.         file.close()
  103.     except:
  104.         print("File 'patch.txt' couldn't be opened!")
  105.         success = True
  106.  
  107.     #Opens file for 'patchnotes'
  108.     try:
  109.         patchnotes = ''
  110.         file = open("bot_save_files\\patch_notes.txt",'r')
  111.         patchnotes = file.read()
  112.         file.close()
  113.     except:
  114.         print("File 'patch_notes.txt' couldn't be opened!")
  115.         success = True
  116.  
  117.     #Opens file for 'slap'
  118.     try:
  119.         file = open("bot_save_files\slap_messages.txt",'r')
  120.         line = file.readline()
  121.         slap_message = []
  122.         while line:
  123.             slap_message.append(line)
  124.             line = file.readline()
  125.         file.close()
  126.     except:
  127.         print("File 'slap_messages.txt' couldn't be opened!")
  128.         success = True
  129.  
  130.     #Opens fire for s_id
  131.     s_id = {}
  132.     try:
  133.         file = open("bot_save_files\server_id.txt",'r')
  134.         line = file.readline()
  135.         while line:
  136.             key, value = line.split(':')
  137.             s_id[key] = value[:1]
  138.             line = file.readline()
  139.         file.close()
  140.     except:
  141.         print("File 'server_id.txt' couldn't be opened!")
  142.         success = True
  143.  
  144.     #Opens file for 'miku reaction'
  145.     try:
  146.         file = open("bot_save_files\miku_reaction_msg.txt",'r')
  147.         line = file.readline()
  148.         miku_message = []
  149.         while line:
  150.             miku_message.append(line)
  151.             line = file.readline()
  152.         file.close()
  153.     except:
  154.         print("File 'miku_reaction_msg.txt' couldn't be opened!")
  155.         success = True
  156.     #Loads dev_key
  157.     file = open('bot_save_files\dev_key.txt', 'r')
  158.     dev_key = file.readline()
  159.     file.close()
  160.     youtube = build('youtube', 'v3', developerKey=dev_key)
  161.        
  162.    
  163.  
  164. def save():
  165.     global s_id
  166.     key, value = '', ''
  167.     s_id_file = ''
  168.     for key, value in s_id.items():
  169.         s_id_file = s_id_file + "{0}:{1}\n".format(key, value)
  170.     os.remove("bot_save_files\server_id.txt")
  171.     file = open("bot_save_files\server_id.txt",'w')
  172.     file.write(str(s_id_file))
  173.     file.close()
  174.  
  175.  
  176. #startup variables
  177. ydl_opts = {
  178.     'format': 'bestaudio/best',
  179.     'outtmpl': 'tmp/%(id)s.%(ext)s',
  180.     'noplaylist': True,
  181.     'quiet': True,
  182.     'prefer_ffmpeg': True,
  183.     'audioformat': 'wav',
  184.     'forceduration':True
  185. }
  186.  
  187. game_number = 274**21
  188. game_active = False
  189. attempts = 0
  190. round_active = False
  191. error = ''
  192. player = ''
  193. author = ''
  194. msg = ''
  195. gmn_cp = {}
  196. gmn_number = {}
  197. gmn_a = {}
  198. edits = ['*', '__', '~~', '**', '***']
  199. players = {}
  200. playlist = {}
  201. cp = {}
  202. loop = {}
  203. lp = {}
  204. ytdl = YoutubeDL()
  205. urls = {}
  206. cpsong = {}
  207. miku_names = ['miku', 'Miku', 'M I K U', 'MIKU', 'm i k u', 'mIku', 'miKu', 'mikU', 'MIku', 'MiKu',
  208.               'MikU', 'mIKu', 'mIkU', 'mIKU', 'MiKU', 'MIkU', 'MIKu', 'miKU']
  209. play_list = {}
  210. info = {}
  211. dev_key = ''
  212.  
  213.  
  214. @client.event
  215. async def on_message(message):
  216.     global game_number, game_active, error, round_active, attempts, about, player, author, msg, version, s_id, gmn_cp, success
  217.     global miku_message, edits, statuses, players, vc, playlist, cp, loop, lp, miku_names, cpsong
  218.     global play_list, ytdl, dev_key, youtube
  219.     if message.author == client.user:
  220.         return
  221.     sid = message.server.id
  222.  
  223.     if not message.server.id in s_id:
  224.         s_id[message.server.id] = '$'
  225.         print('Creating a backup...')
  226.         msg = 'Creating a first settings for your server!'
  227.         await client.send_message(message.channel, msg)
  228.         save()
  229.         reload_files()
  230.         return
  231.    
  232.     #done       HELLO
  233.     if message.content.startswith('{0}hello'.format(s_id[sid])):
  234.         cmd = 'hello'
  235.         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])
  236.         log(msg, message.channel, message.author, cmd)
  237.         await client.send_message(message.channel, msg)
  238.  
  239.     #done       LOVE
  240.     if message.content.startswith('{0}love'.format(s_id[sid])):
  241.         cmd = 'love'
  242.         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*"
  243.         log(msg, message.channel, message.author, cmd)
  244.         await client.send_message(message.channel, msg)
  245.  
  246.     #done       RANDOM NUMBER
  247.     if message.content.startswith('{0}random'.format(s_id[sid])):
  248.         cmd = 'random'
  249.         msg = ('Randomly generated number: '+str(random.randrange(101)))
  250.         log(msg, message.channel, message.author, cmd)
  251.         await client.send_message(message.channel, msg)
  252.  
  253.     #done       POKE
  254.     if message.content.startswith('{0}poke'.format(s_id[sid])):
  255.         cmd = "poke"
  256.         msg = str(message.content)[6:]
  257.         msg_list = msg.split(' ')
  258.         msg_recipient = ''
  259.         msg_author = str(message.author)[:-5]
  260.         msg_content_test = False
  261.         for i in range(len(msg_list)):
  262.             msg_check = msg_list[i]
  263.             if (('<@!' and '>') in msg_check) == True:
  264.                 msg_recipient = msg_check
  265.                 msg_content_test = True
  266.         if msg_content_test == False:
  267.             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.*"
  268.         else:
  269.             msg = '*' + msg_author + " pokes " + msg_recipient + "'s shoulder gently and then just waits for their response patiently.*"
  270.         log(msg, message.channel, message.author, cmd)
  271.         await client.send_message(message.channel, msg)
  272.         if msg_recipient == '<@!492432534181773313>':
  273.             time.sleep(1)
  274.             msg = "*She looks at {0.author.mention} curiously, and after moment she pokes {0.author.mention}'s nose back.*".format(message)
  275.             await client.send_message(message.channel, msg)
  276.  
  277.     #done       CUDDLE
  278.     if message.content.startswith('{0}cuddle'.format(s_id[sid])):
  279.         cmd = 'cuddle'
  280.         try:
  281.             msg = str(message.content)[8:]
  282.             msg_list = msg.split(' ')
  283.             msg_recipient = ''
  284.             msg_author = str(message.author)[:-5]
  285.             msg_content_test = False
  286.            
  287.             for i in range(len(msg_list)):
  288.                 msg_check = msg_list[i]
  289.                 if (('<@!' and '>') in msg_check) == True:
  290.                     msg_recipient = msg_check
  291.                     msg_content_test = True
  292.             if not '!' in msg_recipient:
  293.                 msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
  294.             if msg_recipient == str(message.author.mention):
  295.                 msg = random.choice(cuddle_message).format('Miku', msg_recipient)
  296.             else:
  297.            
  298.                 if not msg_content_test:
  299.                     msg = '*' + msg_author + " cuddles their pillow, smiling but alone.*"
  300.                 else:
  301.                     msg = random.choice(cuddle_message).format(msg_author, msg_recipient)
  302.             log(msg, message.channel, message.author, cmd)
  303.        
  304.             await client.send_message(message.channel, msg)
  305.         except ValueError in error:
  306.             print(error)
  307.             await client.send_message(message.channel, 'Something went wrong.... :sob:')
  308.        
  309.  
  310.     #done       HUG
  311.     if message.content.startswith('{0}hug'.format(s_id[sid])):
  312.         cmd = 'hug'
  313.         msg = str(message.content)[5:]
  314.         msg_list = msg.split(' ')
  315.         msg_recipient = ''
  316.         msg_author = str(message.author)[:-5]
  317.         msg_content_test = False
  318.         for i in range(len(msg_list)):
  319.             msg_check = msg_list[i]
  320.             if (('<@!' and '>') in msg_check) == True:
  321.                 msg_recipient = msg_check
  322.                 msg_content_test = True
  323.         if not msg_content_test:
  324.             msg_recipient = 'bottle of expensive red wine'
  325.         if not '!' in msg_recipient:
  326.             msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
  327.         if msg_recipient == str(message.author.mention):
  328.             msg = random.choice(hug_message).format('Miku', msg_recipient)
  329.         else:
  330.             msg = random.choice(hug_message).format(msg_author, msg_recipient)
  331.         log(msg, message.channel, message.author, cmd)
  332.         try:
  333.             await client.send_message(message.channel, msg)
  334.         except ValueError in error:
  335.             print(error)
  336.             await client.send_message(message.channel, 'Something went wrong.... :sob:')
  337.  
  338.     #done       KISS
  339.     if message.content.startswith('{0}kiss'.format(s_id[sid])):
  340.         cmd = 'kiss'
  341.         msg = str(message.content)[5:]
  342.         msg_list = msg.split(' ')
  343.         msg_recipient = ''
  344.         msg_author = str(message.author)[:-5]
  345.         msg_content_test = False
  346.         for i in range(len(msg_list)):
  347.             msg_check = msg_list[i]
  348.             if (('<@!' and '>') in msg_check) == True:
  349.                 msg_recipient = msg_check
  350.                 msg_content_test = True
  351.         if msg_content_test == False:
  352.             msg_recipient = 'bottle of expensive red wine'
  353.         if not '!' in msg_recipient:
  354.                 msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
  355.         if msg_recipient == str(message.author.mention):
  356.             msg = random.choice(kiss_message).format('Miku', msg_recipient)
  357.         else:
  358.             msg = random.choice(kiss_message).format(msg_author, msg_recipient)
  359.         log(msg, message.channel, message.author, cmd)
  360.         try:
  361.             await client.send_message(message.channel, msg)
  362.         except ValueError in error:
  363.             print(error)
  364.             await client.send_message(message.channel, 'Something went wrong.... :sob:')
  365.  
  366.     #done       PAT
  367.     if message.content.startswith('{0}pat'.format(s_id[sid])):
  368.         cmd = 'pat'
  369.         if '{0}pat '.format(s_id[sid]) in message.content:
  370.             msg = str(message.content)[4:]
  371.             msg_list = msg.split(' ')
  372.             msg_recipient = ''
  373.             msg_author = str(message.author)[:-5]
  374.             msg_content_test = False
  375.             for i in range(len(msg_list)):
  376.                 msg_check = msg_list[i]
  377.                 if (('<@!' and '>') in msg_check) == True:
  378.                     msg_recipient = msg_check
  379.                     msg_content_test = True
  380.             if msg_content_test == False:
  381.                 msg_recipient = 'invisible unicorn'
  382.             if not '!' in msg_recipient:
  383.                 msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
  384.             if msg_recipient == str(message.author.mention):
  385.                 msg = random.choice(pat_message).format('Miku', msg_recipient)
  386.             else:
  387.                 msg = random.choice(pat_message).format(msg_author, msg_recipient)
  388.             log(msg, message.channel, message.author, cmd)
  389.             try:        
  390.                 await client.send_message(message.channel, msg)
  391.             except ValueError in error:
  392.                 print(error)
  393.                 await client.send_message(message.channel, 'Something went wrong.... :sob:')
  394.  
  395.     #SLAP
  396.     if message.content.startswith('{0}slap'.format(s_id[sid])):
  397.         cmd = 'slap'
  398.         if '{0}slap '.format(s_id[sid]) in message.content:
  399.             msg = str(message.content)[5:]
  400.             msg_list = msg.split(' ')
  401.             msg_recipient = ''
  402.             msg_author = str(message.author)[:-5]
  403.             msg_content_test = False
  404.             for i in range(len(msg_list)):
  405.                 msg_check = msg_list[i]
  406.                 if (('<@!' and '>') in msg_check) == True:
  407.                     msg_recipient = msg_check
  408.                     msg_content_test = True
  409.             if msg_content_test == False:
  410.                 msg_recipient = 'air'
  411.             if not '!' in msg_recipient:
  412.                 msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
  413.             if msg_recipient == str(message.author.mention):
  414.                 msg = random.choice(pat_message).format('Miku', msg_recipient)
  415.             else:
  416.                 msg = random.choice(slap_message).format(msg_author, msg_recipient)
  417.             log(msg, message.channel, message.author, cmd)
  418.             try:
  419.                 abc = str(message.author.mention).strip('<')
  420.                 await client.send_message(message.channel, msg)
  421.                
  422.             except ValueError in error:
  423.                 print(error)
  424.                 await client.send_message(message.channel, 'Something went wrong.... :sob:')
  425.    
  426.  
  427.     #WIP               <-----------------------------------------------------
  428.     if message.content.startswith('{0}help'.format(s_id[sid])):
  429.         cmd = 'help'
  430.         msg = """**{0}hello** - yes, this is my greeting to all of you, my users! ^~^
  431.        **{0}kiss @user** - kisses your lovely friend
  432.        **{0}hug @user** - hugs your hugging-friend
  433.        **{0}poke @user** - pokes your victim
  434.        **{0}cuddle @user** - cuddles your cuddle pillow friend
  435.        **{0}pat @user** - pat your friend's head and make them blush with happiness
  436.        **{0}slap @user** - slap someone who's being rude! Ouch!
  437.        **{0}rnf x z** - gives you random number from between numbers **x** and **z**
  438.        **{0}random** - gives you random number between **0** and **100**
  439.        **{0}choice a, b, c, d, ...** - makes a choice for you from the list words, each one divided with ","
  440.        **{0}rc** - gives you a random colour in hex format
  441.        **{0}p <youtube url>** - plays song in voice channel you're conencted to
  442.        **{0}dc** - disconnects bot from voice channel
  443.        **{0}playlist - shows currently queued songs**
  444.        **{0}cp - shows currently playing song**
  445.        **{0}coinflip** - flips the coin. Try your luck!
  446.        **{0}gmn** - first minigame! Guess my number! Collect points and get on top of the leaderboard! ***<Rankings And Points Not Yet Implemented>***
  447.        **{0}invite** - sends you a special link with which you can invite this bot to ***your own server***
  448.        **{0}about** - do you want to learn more about me and my creator? Don't wait any longer!
  449.        **{0}chart** - shows you a simple japanese katakana and hiragana chart! *For all weebs who can't type in their mother language..* >.>
  450.        **{0}prefix set <prefix>** - allows owner of the server to change prefix to which my commands will react in that server
  451.        **{0}lewd** - *winks*""".format(s_id[sid])
  452.         color = 4122822
  453.         embed = discord.Embed(title = 'List of my commands:', description = msg, color = color)
  454.         log(msg, message.channel, message.author, cmd)
  455.         await client.send_message(message.author, embed = embed)
  456.         await client.add_reaction(message, '\U00002705')
  457.  
  458.     #done       ABOUT
  459.     if message.content.startswith('{0}about'.format(s_id[sid])):
  460.         cmd = 'about'
  461.         log(msg, message.channel, message.author, cmd)
  462.         await client.send_message(message.channel, about)
  463.  
  464.     #done       CHART
  465.     if message.content.startswith('{0}chart'.format(s_id[sid])):
  466.         cmd = 'chart'
  467.         msg = '''**ę—„ ļ½ ļ½‰ ļ½• ļ½… ļ½ć€€ļ½ ļ½‰ ļ½• ļ½… ļ½ ęœ¬
  468.        ćƒ¼ ć‚¢ 悤 悦 ć‚Ø ć‚Ŗ怀恂 恄 恆 恈 恊
  469.        ļ½‹ ć‚« 悭 ć‚Æ 悱 ć‚³ć€€ć‹ 恍 恏 恑 恓
  470.        ļ½“ 悵 ć‚· ć‚¹ 惇 ć‚½ć€€ć• 恗 恙 恛 恝
  471.        ļ½” ć‚æ 惁 惄 惆 惈怀恟 恔 恤 恦 ćØ
  472.        ļ½Ž 惊 惋 惌 惍 惎怀ćŖ 恫 恬 恭 恮
  473.        ļ½ 惞 惟 惠 惔 ćƒ¢ć€€ć¾ ćæ 悀 悁 悂
  474.        ļ½’ 惩 ćƒŖ 惫 惬 惭怀悉 悊 悋 悌 悍
  475.        ļ½ˆ 惏 惒 惕 惘 惛怀ćÆ ć² 恵 ćø 恻
  476.        ļ½— ćƒÆ 怀 怀 怀 ćƒ²ć€€ć‚  ć€€ć€€ 怀 悒
  477.        ļ½™ 惤 怀 惦 怀 ćƒØ怀悄  ć€€ć‚† 怀 悈
  478.        ļ½Ž ćƒ³ 怀 怀 怀 怀怀悓**'''
  479.         color = 4122822
  480.         embed = discord.Embed(title = 'Katakana and hiragana chart:', description = msg, color = color)
  481.         log(msg, message.channel, message.author, cmd)
  482.         await client.send_message(message.channel, embed = embed)
  483.  
  484.     #done       AYAYA AYAYAAAAAA
  485.     if (message.content.startswith('ayaya')) or (message.content.startswith('AYAYA')):
  486.         cmd = 'ayaya'
  487.         msg = '''**ā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£·ā£¬ā”›ā£æā£æā£æā£Æā¢»
  488. ā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā”Ÿā¢»ā£æā£æā¢Ÿā£»ā£æā£æā£æā£æā£æā£æā£®ā”»ā£æā£æā£§
  489. ā£æā£æā£æā£æā£æā¢»ā£æā£æā£æā£æā£æā£æā£†ā »ā”«ā£¢ā æā£æā£æā£æā£æā£æā£æā£æā£·ā£œā¢»ā£æ
  490. ā£æā£æā”ā£æā£æā£Øā£ā æā£æā£æā£æā£æā£æā¢•ā øā£›ā£©ā£„ā£„ā£©ā¢ā£›ā”æā æā£æā£æā£†ā¢
  491. ā£æā£æā¢”ā£øā£æā£ā£æā£æā£¶ā£Æā£™ā «ā¢ŗā£æā£·ā”ˆā£æā£æā£æā£æā”æā æā¢æā£Ÿā£’ā£‹ā£™ā Š
  492. ā£æā”ā”æā£›ā£ā¢æā£®ā£æā£æā£æā£æā£æā£æā£æā£¶ā£¶ā£¶ā£¶ā£¾ā£æā£æā£æā£æā£æā£æā£æā£æā£æ
  493. ā£æā¢±ā£¾ā£æā£æā£æā£ā”®ā”»ā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā”æā æā ›ā£‹ā£»ā£æā£æā£æā£æ
  494. ā¢æā¢øā£æā£æā£æā£æā£æā£æā£·ā£½ā£æā£æā£æā£æā£æā£æā£æā”•ā£”ā£“ā£¶ā£æā£æā£æā”Ÿā£æā£æā£æ
  495. ā£¦ā”øā£æā£æā£æā£æā£æā£æā”›ā¢æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā”‡ā£æā£æā£æ
  496. ā¢›ā ·ā”¹ā£æā ‹ā£‰ā£ ā£¤ā£¶ā£¶ā£æā£æā£æā£æā£æā£æā”æā æā¢æā£æā£æā£æā£æā£æā£·ā¢¹ā£æā£æ
  497. ā£·ā”ā£æā”žā£æā£æā£æā£æā£æā£æā£æā£æā”Ÿā ‹ā ā£ ā£¤ā£¤ā£¦ā£½ā£æā£æā£æā”æā ‹ā ˜ā£æā£æ
  498. ā£æā£æā”¹ā£æā”¼ā£æā£æā£æā£æā£æā£æā£æā£§ā”°ā£æā£æā£æā£æā£æā£¹ā”æā Ÿā ‰ā”€ā „ā „ā¢æā£æ
  499. ā£æā£æā£æā£½ā£æā£¼ā£›ā æā æā£æā£æā£æā£æā£æā£Æā£æā æā¢Ÿā£»ā”½ā¢šā£¤ā”žā „ā „ā „ā¢øā£æ**'''
  500.         log(msg, message.channel, message.author, cmd)
  501.         await client.send_message(message.channel, msg)
  502.  
  503.     #done       INVITE
  504.     if message.content.startswith('{0}invite'.format(s_id[sid])):
  505.         msg = "*You can invite me to your server using this link:*\nhttps://discordapp.com/oauth2/authorize?client_id=492432534181773313&scope=bot"
  506.         await client.send_message(message.author, msg)
  507.  
  508.     #done       TERRARIA
  509.     if message.content.startswith('{0}terraria'.format(s_id[sid])):
  510.         cmd = 'terraria'
  511.         msg = '''
  512.        **IP:** 95.105.211.38
  513.        **Port:** 6666
  514.        **Password:** *Ask Ana#3140*
  515.        *Server is hosted same way as I am.. That means it runs whenever I am online!!
  516.        Connecting to the server requires* **TModLoader**. *Our mods will get downloaded automatically when connecting!*
  517.        **List of mods:** *RecipeBrowser, WhereIsMyItem, Boss Checklist*
  518.        *You can get TModLoader here: https://tmodloader.net/*
  519.        '''
  520.         color = 4122822
  521.         embed = discord.Embed(title = 'Our Terraria server: ', description = msg, color = color)
  522.         log(msg, message.channel, message.author, cmd)
  523.         await client.send_message(message.channel, embed = embed)
  524.  
  525.     #done       CHOICE
  526.     if message.content.startswith('{0}choice'.format(s_id[sid])):
  527.         cmd = 'choice'
  528.         msg = message.content[8:]
  529.         choice_list = []
  530.         choice_list = msg.split(',')
  531.         msg = "I've randomly chosen this for you: " + str(random.choice(choice_list))
  532.         log(msg, message.channel, message.author, cmd)
  533.         await client.send_message(message.channel, msg)
  534.  
  535.     #done       PATCHNOTES
  536.     if message.content.startswith('{0}patchnotes'.format(s_id[sid])):
  537.         cmd = 'patchnotes'
  538.         p_notes_split = patchnotes.split('<$>')
  539.         #print(p_notes_split)
  540.         log(msg, message.channel, message.author, cmd)
  541.         for i in p_notes_split:
  542.             msg = '```{0}```'.format(i)
  543.             await client.send_message(message.author, msg)
  544.  
  545.     #done       VERSION
  546.     if message.content.startswith('{0}version'.format(s_id[sid])):
  547.         cmd = 'version'
  548.         msg = '`Current version of this bot is: {0}`'.format(version)
  549.         log(msg, message.channel, message.author, cmd)
  550.         await client.send_message(message.channel, msg)
  551.  
  552.     #done       RANDOM NUMBER X Z
  553.     if message.content.startswith('{0}rnf'.format(s_id[sid])):
  554.         cmd = 'random number from <x, z>'
  555.         msg = message.content[5:]
  556.         numbers = []
  557.         numbers = msg.split(' ')
  558.         log(msg, message.channel, message.author, cmd)
  559.         error = ''
  560.         if len(numbers) == (1 or 0):
  561.             msg = 'You need two numbers!'
  562.             await client.send_message(message.channel, msg)
  563.         else:
  564.             try:
  565.                 print(numbers[0], numbers[1])
  566.                 a = int(round(float(numbers[0])))
  567.                 b = int(round(float(numbers[1])))
  568.                 print(a, b)
  569.                
  570.                 if a >= b:
  571.                     c = a
  572.                     a = b
  573.                     b = c
  574.                    
  575.                 if a == b:
  576.                     msg = "Your random number is not really random, but here you go: {0}".format(a)
  577.                 else:
  578.                     num = random.randrange(a, b+1)
  579.                     msg = "Your random number is: " + str(num)
  580.                 await client.send_message(message.channel, msg)
  581.                
  582.             except ValueError as error:
  583.                 print(error)
  584.                 msg = 'Something went wrong!'
  585.                 await client.send_message(message.channel, msg)
  586.  
  587.     #done       COINFLIP
  588.     if message.content.startswith('{0}coinflip'.format(s_id[sid])):
  589.         cmd = 'coinflip'
  590.         num = random.randrange(1000)+1
  591.         if num == 741:
  592.             msg = "***It landed on it's side! How lucky!!!***"
  593.         else:
  594.             if num == 274:
  595.                 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..."
  596.             else:
  597.                 if num > 500:
  598.                     msg = 'Heads!' + '!'*random.randrange(4)
  599.                 else:
  600.                     msg = 'Tails!' + '!'*random.randrange(4)
  601.         #log(msg, message.channel, message.author, cmd)
  602.         print("Command '$" + cmd + "' used in " + str(message.channel) + ' by ' + str(message.author) +'! Rolled: ' + str(num))
  603.         await client.send_message(message.channel, msg)
  604.  
  605.     #done       RANDOM COLOUR
  606.     if message.content.startswith('{0}rc'.format(s_id[sid])):
  607.         cmd = 'random colour'
  608.         color = random.randrange(256**3)
  609.         print(color)
  610.         msg = str(f'#{color:06x}')
  611.         embed = discord.Embed(title = 'Your random colour: ', description = msg, color = color)
  612.         log(str(msg), message.channel, message.author, cmd)
  613.         await client.send_message(message.channel, embed = embed)
  614.  
  615.     #done       GUESS MY NUMBER
  616.     if message.content.startswith('{0}gmn'.format(s_id[sid])):
  617.        
  618.         if not str(message.author) in gmn_cp:
  619.             gmn_cp[str(message.author)] = False
  620.             gmn_a[str(message.author)] = 0
  621.             gmn_number[str(message.author)] = 0
  622.            
  623.         if gmn_cp[str(message.author)] == False:
  624.             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..!!")
  625.             time.sleep(0.25)
  626.             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]))
  627.             game_number = random.randrange(100)+1
  628.             gmn_number[str(message.author)] = game_number
  629.             gmn_a[str(message.author)] = 0
  630.             player = str(message.author)
  631.             gmn_cp[str(message.author)] = True
  632.            
  633.         elif gmn_cp[str(message.author)] == True:
  634.             number = message.content[4:]
  635.             try:
  636.                 number = int(number)
  637.                 gmn_cp[str(message.author)] = True
  638.                
  639.                 if gmn_number[str(message.author)] == number:
  640.                     msg = "Y-yes..! That's the number I.. I've been thinking of! Y-you are so good s-senpai! :heart_eyes:"
  641.                     gmn_a[str(message.author)] = 0
  642.                     await client.send_message(message.channel, msg)
  643.                     gmn_a[str(message.author)] = 0
  644.                     gmn_cp[str(message.author)] = False
  645.  
  646.                    
  647.                 elif (gmn_a[str(message.author)] == 0) and (gmn_cp[str(message.author)] == True):
  648.  
  649.                     if gmn_number[str(message.author)] < number:
  650.                         msg = "T-that's not it, s-senpai..! :flushed: Your n-number is too b-big.. T-try again..! *blushes*"
  651.                         await client.send_message(message.channel, msg)
  652.                     else:
  653.                         msg = "T-that's not it, s-senpai..! :flushed: Your n-number is not b-big enough.. T-try again..! *blushes*"
  654.                         await client.send_message(message.channel, msg)
  655.  
  656.                     gmn_a[str(message.author)] = 1
  657.                     print('New game! Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
  658.                    
  659.                 elif (gmn_a[str(message.author)] == 1) and (gmn_cp[str(message.author)] == True):
  660.  
  661.                    
  662.                     if gmn_number[str(message.author)] < number:
  663.                         msg = "N-no senpai... S-still not my number.. It's n-not that big..."
  664.                         await client.send_message(message.channel, msg)
  665.                     else:
  666.                         msg = "N s-senpai... S-still not my special number.. It's even higher..."
  667.                         await client.send_message(message.channel, msg)
  668.                        
  669.                     gmn_a[str(message.author)] = 2
  670.                     print('Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
  671.  
  672.                    
  673.                 elif (gmn_a[str(message.author)] == 2) and (gmn_cp[str(message.author)] == True):
  674.                    
  675.                     if gmn_number[str(message.author)] < number:
  676.                         msg = "That's again n-not my n-number *blushes* T-too big..! Last chance..!"
  677.                         await client.send_message(message.channel, msg)
  678.                     else:
  679.                         msg = "N-not my n-number, senpai..! *blushes* Go h-higher..! L-last attempt..!"
  680.                         await client.send_message(message.channel, msg)
  681.                        
  682.                     gmn_a[str(message.author)] = 3
  683.                     print('Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
  684.                    
  685.                 elif (gmn_a[str(message.author)] == 3) and (gmn_cp[str(message.author)] == True):
  686.                    
  687.                     if gmn_number[str(message.author)] < number:
  688.                         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)])
  689.                         await client.send_message(message.channel, msg)
  690.                     else:
  691.                         msg = "S-senpai..! T-that's not my number..! I was t-thinking of a number " + str(gmn_number[str(message.author)])
  692.                         await client.send_message(message.channel, msg)
  693.                        
  694.                     print('Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
  695.                     gmn_a[str(message.author)] = 0
  696.                     gmn_cp[str(message.author)] = False
  697.                    
  698.             except:
  699.                 await client.send_message(message.channel, "That's not a number, b-baka s-senpai..!!")
  700.         else:
  701.             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:")
  702.  
  703.  
  704.     #done       LEWD
  705.     if message.content.startswith('{0}lewd'.format(s_id[sid])):
  706.         if str(message.author) == 'Ana#3140':
  707.             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..!__***'
  708.         else:
  709.             msg = '**Y-YOU ARE SO L-LEWD, SENPAI**' + '!'*int(random.randrange(9)+3)
  710.         await client.send_message(message.channel, msg)
  711.  
  712.     #done       SERVER PREFIX CHANGE
  713.     if message.content.startswith('{0}prefix set'.format(s_id[sid])):
  714.         if message.author == message.server.owner:
  715.             try:
  716.                 prefix = message.content[12:]
  717.                 if len(prefix) > 1:
  718.                     msg = 'Prefix can consist of only one character!'
  719.                 else:
  720.                     s_id[message.server.id] = str(prefix)
  721.                     save()
  722.                     reload_files()
  723.                     msg = 'Prefix of this server has been changed to {0}'.format(prefix)
  724.             except:
  725.                 msg = 'Something went wrong!'
  726.         else:
  727.             msg = "I'm sorry s-senpai, b-but you are n-not owner of t-this server!"
  728.         await client.send_message(message.channel, msg)
  729.                
  730.  
  731.     #bet reaction
  732.     if (message.content.startswith('bet'))or (message.content.startswith('beet')) or (message.content.startswith('Bet')):
  733.         num = random.randrange(10000)
  734.         if num == 2714:
  735.             msg = 'BEEEEEEEEEEEEEEEEEEEEEEEEEEEET!!!!!'
  736.             await client.send_message(message.channel, msg)
  737.         else:
  738.             if num == 8743:
  739.                 msg = 'No bets allowed to underage trolls (That means you are not allowed to bet if you are not 18+.... B-baka senpai.. >.>)'
  740.                 await client.send_message(message.channel, msg)
  741.             else:
  742.                 msg = "{0}bet{0}".format(edits[random.randrange(5)])
  743.                 await client.send_message(message.channel, msg)
  744.  
  745.     #miku reaction
  746.     #if ('miku' in message.content) or ('Miku' in message.content) or ('m i k u' in message.content) or ('M I K U' in message.content):
  747.         #print(miku_names)
  748.         #time.sleep(0.37)
  749.         #msg = random.choice(miku_message).format(message.author.mention)
  750.         #await client.send_message(message.channel, msg)
  751.     await miku_reaction(message)
  752.  
  753.     #Reactions for other bots
  754.     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]))):
  755.         await asyncio.sleep(1)
  756.         #print(message.content)
  757.         msg = 'Awwwwww t-thanks a lot for petting me, {0}! :sparkling_heart: :heart_eyes: ^~^'.format(message.author.mention)
  758.         await client.send_message(message.channel, msg)
  759.  
  760.     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]))):
  761.         await asyncio.sleep(1)
  762.         msg = 'Oh~, thanks s-senpai for hug! *she hugs {0} back tightly, smiling and blushing.*'.format(message.author.mention)
  763.         await client.send_message(message.channel, msg)
  764.  
  765.     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]))):
  766.         await asyncio.sleep(1)
  767.         msg = '*She giggles and cuddles {0} back, slightly stroking their back, still giggling.*'.format(message.author.mention)
  768.         await client.send_message(message.channel, msg)
  769.        
  770.     if (message.content.startswith('{0}poke <@!492432534181773313>'.format(s_id[sid]))) or (message.content.startswith('{0}poke <@492432534181773313>'.format(s_id[sid]))):
  771.         await asyncio.sleep(1)
  772.         msg = "*She looks at {0} curiously, and then she pokes {0} back.*".format(message.author.mention)
  773.         await client.send_message(message.channel, msg)
  774.  
  775.     if (message.content.startswith('{0}slap <@!492432534181773313>'.format(s_id[sid]))) or (message.content.startswith('{0}slap <@492432534181773313>'.format(s_id[sid]))):
  776.         await asyncio.sleep(1)
  777.         msg = '*She slaps {0} back, looking angry, annoyed but dissappointed and sad as well...*'.format(message.author.mention)
  778.         await client.send_message(message.channel, msg)
  779.  
  780.  
  781.     #dev only functions
  782.  
  783.     #done       STOP
  784.     if (message.content.startswith('{0}stop'.format(s_id[message.server.id]))) or (message.content.startswith('{0}bye'.format(s_id[message.server.id]))):
  785.         author = str(message.author)
  786.         cmd = 'stop'
  787.         msg = ''
  788.         log(msg, message.channel, message.author, cmd)
  789.         if (author == 'Ana#3140') or (author == 'Cutie Kitty#0068'):
  790.             msg = 'Good bye!'
  791.             await client.send_message(message.channel, msg)
  792.             print('Good b-bye Ana s-senpai~ <3')
  793.             client.logout()
  794.             save()
  795.             sys.exit(0)
  796.         else:
  797.             msg = 'Insufficient permissions...'
  798.             await client.send_message(message.channel, msg)
  799.  
  800.     #done       RELOAD FILES
  801.     if message.content.startswith('{0}rf'.format(s_id[message.server.id])):
  802.         cmd = 'reload files'
  803.         log(msg, message.channel, message.author, cmd)
  804.         author = str(message.author)
  805.         if author == 'Ana#3140':
  806.             reload_files()
  807.             if success == False:
  808.                 print('Files reloaded successfully...')
  809.             else:
  810.                 print('Reload unsuccessful...')
  811.         else:
  812.             msg = 'Insufficient permissions...'
  813.             await client.send_message(message.channel, msg)
  814.  
  815.     #done       CHANGE GAME STATUS
  816.     if message.content.startswith('{0}game'.format(s_id[message.server.id])):
  817.         cmd = 'game status'
  818.         if (str(message.author) == 'Ana#3140') or (str(message.author) == 'Cutie Kitty#0068'):
  819.             if len(str(message.content)) >6:
  820.                 g = str(message.content)[6:]
  821.                 print(g, str(message.content))
  822.                 me = discord.utils.find(lambda s: s != None, client.servers).me
  823.                 if not me:
  824.                         return
  825.                 elif not me.game:
  826.                         updated_game = discord.Game(name = str(g))
  827.                 else:
  828.                         updated_game = me.game
  829.                         updated_game.name = str(g)
  830.             else:
  831.                 me = discord.utils.find(lambda s: s != None, client.servers).me
  832.                 if not me:
  833.                         return
  834.                 elif not me.game:
  835.                         updated_game = discord.Game(name = random.choice(statuses))
  836.                 else:
  837.                         updated_game = me.game
  838.                         updated_game.name = random.choice(statuses)
  839.             await client.change_presence(game = updated_game)
  840.             print('Changing game to: {0}'.format(str(updated_game)))
  841.            
  842.  
  843.     #done       PATCH CHANGE
  844.     if message.content.startswith('{0}patch set'.format(s_id[message.server.id])):
  845.         author = str(message.author)
  846.         cmd = 'patch'
  847.         msg = ''
  848.         patch = ''
  849.         log(msg, message.channel, message.author, cmd)
  850.         if author == 'Ana#3140':
  851.             try:
  852.                 msg = 'Done!'
  853.                 patch = message.content
  854.                 patch = patch[11:]
  855.                 os.remove('bot_save_files\patch.txt')
  856.                 file = open('bot_save_files\patch.txt', 'w')
  857.                 file.write(str(patch))
  858.                 file.close()
  859.                 version = patch
  860.                 print('Current patch changed to {0}'.format(patch))
  861.                 ctypes.windll.kernel32.SetConsoleTitleW(patch)
  862.                 await client.send_message(message.channel, msg)
  863.             except:
  864.                 print('Something went wrong!')
  865.            
  866.     #WIP        TEST COMMAND
  867.     if message.content.startswith('{0}test'.format(s_id[message.server.id])):
  868.         cmd = 'test'
  869.         #file = open('bot_save_files\\server_id.txt', 'a')
  870.         #file.write(str(str(s_id.keys()).split("'")))
  871.         #file.close()
  872.        
  873.         try:
  874.             print(message.author.id, message.content, message.server, message.server.id)
  875.             await client.send_message(message.channel, message.server.id)
  876.         except:
  877.             print(error)
  878.  
  879.     #MUSIC LOOP
  880.     if message.content.startswith('{0}loop'.format(s_id[message.server.id])):
  881.         if not message.server.id in loop:
  882.             loop[message.server.id] = True
  883.             msg = 'Looping current song!'
  884.             await client.send_message(message.channel, msg)
  885.            
  886.         elif loop[message.server.id] == True:
  887.             loop[message.server.id] = False
  888.             msg = 'Loop of the current song disabled!'
  889.             await client.send_message(message.channel, msg)
  890.            
  891.         elif loop[message.server.id] == False:
  892.             loop[message.server.id] = True
  893.             msg = 'Looping current song!'
  894.             await client.send_message(message.channel, msg)
  895.  
  896.  
  897.     #MUSIC LOOP PLAYLIST
  898.     if message.content.startswith('{0}lp'.format(s_id[message.server.id])):
  899.         if not message.server.id in lp:
  900.             lp[message.server.id] = True
  901.             msg = 'Looping current playlist!'
  902.             await client.send_message(message.channel, msg)
  903.            
  904.         elif lp[message.server.id] == True:
  905.             lp[message.server.id] = False
  906.             msg = 'Loop of the current playlist disabled!'
  907.             await client.send_message(message.channel, msg)
  908.            
  909.         elif lp[message.server.id] == False:
  910.             lp[message.server.id] = True
  911.             msg = 'Looping current playlist!'
  912.             await client.send_message(message.channel, msg)
  913.            
  914.     #MUSIC CONNECT
  915.     if message.content.startswith("{0}p ".format(s_id[message.server.id])):
  916.         channel = message.author.voice.voice_channel
  917.        
  918.         if not message.server.id in loop:
  919.             loop[message.server.id] = False
  920.  
  921.         if not message.server.id in lp:
  922.             lp[message.server.id] = False
  923.            
  924.         if not channel == None:
  925.             ytdl = YoutubeDL()
  926.             link = ''
  927.             if not message.server.id in playlist:
  928.                 playlist[message.server.id] = []
  929.             if not message.server.id in cp:
  930.                 cp[message.server.id] = 'False'
  931.  
  932.             link = str(message.content).strip('{0}p '.format(s_id[message.server.id]))
  933.             if 'https://www.youtube.com/playlist?list=' in link:
  934.                 troll = 'https://www.youtube.com/playlist?list='
  935.                 link = link[len(troll):]
  936.                 results = youtube.playlistItems().list(playlistId=link, part='contentDetails', maxResults = 50).execute()
  937.                 videoIds = [item['contentDetails']['videoId'] for item in results.get('items', [])]
  938.                 playlist[sid] += videoIds
  939.                 link = playlist[sid][0]
  940.             else:
  941.                 if 'https://youtu.be/' in link:
  942.                     link = link.strip('https://youtu.be/')
  943.                 if 'www.youtube.' in link:
  944.                     link = link.strip('https://www.youtube.com/watch?v=')
  945.                 if len(link) > 11:
  946.                     link = link[:11]
  947.                 playlist[message.server.id].append(link)
  948.             await client.add_reaction(message, '\U00002705')
  949.             await music_playlist(message)        # music_playlist
  950.         else:
  951.             msg = "S-senpai..! You're n-not in a-any voice c-channel!"
  952.             await client.send_message(message.channel, msg)
  953.  
  954.     #MUSIC DISCONENCT
  955.     if message.content.startswith('{0}dc'.format(s_id[message.server.id])):
  956.         if client.is_voice_connected(message.server):
  957.             playlist[message.server.id] = []
  958.             cp[message.server.id] = 'False'
  959.             players[message.server.id].stop()
  960.             loop[message.server.id] = False
  961.             lp[message.server.id] = False
  962.             cpsong[message.server.id] = ''
  963.             msg = 'Bai baaaaaiļ½ž'
  964.             await client.send_message(message.channel, msg)
  965.            
  966.             await vc.disconnect()
  967.            
  968.         else:
  969.             msg = "S-senpai..! B-but I.. I'm n-not connected y-yet! :flushed:"
  970.             await client.send_message(message.channel, msg)
  971.  
  972.     #MUSIC PLAYLIST
  973.     if message.content.startswith('{0}playlist'.format(s_id[message.server.id])):
  974.         mes = str(message.content).strip('{0}playlist'.format(s_id[message.server.id]))
  975.         if 'del' in mes:
  976.             mes = mes.strip(' del ')
  977.             try:
  978.                 try:
  979.                     num = int(mes)
  980.                 except:
  981.                     print('Couldn\'t convert mes into num')
  982.                 if not 0 < num <= len(playlist[sid]):
  983.                     msg =  'B-but s-senpai!! T-that\'s not a... r-right n-number!!'
  984.                     await client.send_message(message.channel, msg)
  985.                 else:
  986.                     del(playlist[message.server.id][num-1])
  987.                     msg = 'Done..!'
  988.                     await client.send_message(message.channel, msg)
  989.             except:
  990.                 msg = 'O-oh senpai..! I\'m s-sorry, b-but something went w-wrong!'
  991.                 await client.send_message(message.channel, msg)
  992.                
  993.         elif 'delete' in mes:
  994.             mes = mes.strip(' delete ')
  995.             try:
  996.                 try:
  997.                     num = int(mes)
  998.                 except:
  999.                     print('Couldn\'t convert mes into num')
  1000.                 if not 0 < num <= len(playlist[sid]):
  1001.                     msg =  'S-senpai..!! W-wrong number! :flushed:'
  1002.                     await client.send_message(message.channel, msg)
  1003.                 else:
  1004.                     del(playlist[message.server.id][num-1])
  1005.                     msg = 'Done..!'
  1006.                     await client.send_message(message.channel, msg)
  1007.             except:
  1008.                 msg = 'O-oh senpai..! I\'m s-sorry, b-but something went w-wrong!'
  1009.                 await client.send_message(message.channel, msg)
  1010.         else:
  1011.             await music_playlist_print(message)
  1012.  
  1013.  
  1014.     #MUSIC CURRENTLY PLAYING
  1015.     if message.content.startswith('{0}cp'.format(s_id[sid])):
  1016.         msg = '***Currently playing:***\n*{0}*  Duration: {1}'.format(info[sid]['title'], datetime.timedelta(seconds=info[sid]['duration']))
  1017.         if loop == True:
  1018.             msg += '\n**Loop of current song is** ***enabled!***'
  1019.         await client.send_message(message.channel, msg)
  1020.  
  1021.  
  1022.     #MUSIC SKIP
  1023.     if (message.content.startswith('{0}skip'.format(s_id[sid]))) or (message.content.startswith('{0}next'.format(s_id[sid]))):
  1024.         await music_skip(message)
  1025.        
  1026.  
  1027. async def music_playlist(message):
  1028.     global vc, cp, playlist, urllist
  1029.  
  1030.     if playlist[message.server.id] != []:
  1031.         url = playlist[message.server.id][0]
  1032.     else:
  1033.         return
  1034.    
  1035.     if (cp[message.server.id] == 'False') and (playlist[message.server.id] != []):
  1036.         await music_bot(url, message)
  1037.        
  1038.  
  1039. async def music_bot(url, message):
  1040.     global vc, cp, playlist, urllist, loop, ytdl, cpsong, info
  1041.     sid = message.server.id
  1042.    
  1043.     if not message.server.id in cpsong:
  1044.         cpsong[sid] = ''
  1045.     cpsonglocal = {}
  1046.  
  1047.     cpsong[sid] = str(url)
  1048.     cpsonglocal[sid] = str(url)
  1049.     if not client.is_voice_connected(message.server):
  1050.         while playlist[sid] != []:
  1051.  
  1052.             channel = message.author.voice.voice_channel
  1053.             vc = await client.join_voice_channel(channel)
  1054.             musicplayer = await vc.create_ytdl_player(url, before_options=" -reconnect 1 -reconnect_streamed 1"
  1055.                                                                            " -reconnect_delay_max 5")
  1056.             players[sid] = musicplayer
  1057.             musicplayer.start()
  1058.             cp[sid] = 'True'
  1059.            
  1060.             info[sid] = ytdl.extract_info(url, download = False)
  1061.            
  1062.             await asyncio.sleep(int(info[sid]['duration'])-1)
  1063.             if cpsong[sid] == cpsonglocal[sid]:
  1064.                 cp[sid] = 'False'
  1065.                 await loop_check(url, message)
  1066.             else:
  1067.                 return
  1068.                 print('no')
  1069.                
  1070.     elif client.is_voice_connected(message.server):
  1071.         while playlist[sid] != []:
  1072.             vc = client.voice_client_in(message.server)
  1073.             musicplayer = await vc.create_ytdl_player(url, before_options=" -reconnect 1 -reconnect_streamed 1"
  1074.                                                                            " -reconnect_delay_max 5")
  1075.             players[sid] = musicplayer
  1076.             musicplayer.start()
  1077.             cp[sid] = 'True'
  1078.            
  1079.             info[sid] = ytdl.extract_info(url, download = False)
  1080.            
  1081.             await asyncio.sleep(int(info[sid]['duration'])-1)
  1082.             if cpsong[sid] == cpsonglocal[sid]:
  1083.                 cp[sid] = 'False'
  1084.                 await loop_check(url, message)
  1085.             else:
  1086.                 return
  1087.                 print('no')
  1088.                    
  1089.    
  1090. async def loop_check(url, message):
  1091.     global loop, playlist, urllist, lp
  1092.  
  1093.     if lp[message.server.id] == True:
  1094.  
  1095.         playlist[message.server.id].append(url)
  1096.         del(playlist[message.server.id][0])
  1097.    
  1098.         await music_playlist(message)
  1099.        
  1100.     else:
  1101.    
  1102.         if loop[message.server.id] == True:
  1103.             await music_bot(url, message)
  1104.         elif loop[message.server.id] == False:
  1105.             del(playlist[message.server.id][0])
  1106.             await music_playlist(message)
  1107.  
  1108. async def music_skip(message):
  1109.     global players, playlist, urllist, cp, urls
  1110.  
  1111.     if 'DJ' in message.server.roles:
  1112.         print('SKIP TEST 1')
  1113.         if 'DJ' in message.author.roles:
  1114.  
  1115.             print('SKIP TEST 2')
  1116.             cp[message.server.id] = 'False'
  1117.             players[message.server.id].stop()
  1118.             playlist[message.server.id] = playlist[message.server.id][len(urls[message.server.id])+7:]
  1119.             msg = 'Skipping current song...'
  1120.             await client.send_message(message.channel, msg)
  1121.             await music_playlist(message)
  1122.         else:
  1123.             msg = 'Insufficent permission!'
  1124.             await client.send_message(message.channel, msg)
  1125.             print('SKIP TEST 3')
  1126.     else:
  1127.         if lp[message.server.id] == True:
  1128.        
  1129.             playlist[message.server.id].append(playlist[message.server.id][0])
  1130.             del(playlist[message.server.id][0])
  1131.            
  1132.         else:
  1133.             del(playlist[message.server.id][0])
  1134.         cp[message.server.id] = 'False'
  1135.         players[message.server.id].stop()
  1136.         msg = 'Skipping current song...'
  1137.         await client.send_message(message.channel, msg)
  1138.         await music_playlist(message)
  1139.  
  1140. async def music_playlist_print(message):
  1141.     global playlist, youtube, s_id, lp
  1142.     sid = message.server.id
  1143.     if not sid in playlist:
  1144.         msg = '**Error1__There are no songs in queue at the moment! Queue some using {0}p url!**'.format(s_id[sid])
  1145.         await client.send_message(message.channel, msg)
  1146.     else:
  1147.         urls = playlist[sid]
  1148.         ids = ','.join(urls)  
  1149.         msg = '***Current playlist:***\n'
  1150.  
  1151.         results = {}
  1152.         while results == {}:
  1153.             try:
  1154.                 results = youtube.videos().list(id=ids, part='snippet').execute()
  1155.             except:
  1156.                 print('Youtube results unsucessful, retrying...')
  1157.         msg += '\n'.join(
  1158.             '**{0}**: *{1}*'.format(i, item['snippet']['title'])
  1159.             for i, item in
  1160.             enumerate(results.get('items', []), start=1))
  1161.         if lp[sid] == True:
  1162.             msg += '\n**Loop of the playlist is** ***__enabled!__***'
  1163.         msg += ' \n**You can remove a song from queue by using {0}playlist delete <number_in_queue>!**'.format(s_id[sid])
  1164.         if not '1' in msg:
  1165.             msg = '**Error2__There are no songs in queue at the moment! Queue some using {0}p url!**'.format(s_id[sid])
  1166.         await send_message(message, msg)
  1167.     return
  1168.        
  1169. async def send_message(message, msg, *args, **kwargs):
  1170.     global lp, s_id
  1171.     sid = message.server.id
  1172.     if len(msg) > 1800:
  1173.         first2k = msg[:1800]
  1174.         last_nl = first2k.rfind('\n')
  1175.         firstMsg = msg[:last_nl]
  1176.         rest = msg[last_nl:]
  1177.         if lp[sid] == True:
  1178.             firstMsg += '\n**Loop of the playlist is** ***__enabled!__***'
  1179.         firstMsg += ' \n**You can remove a song from queue by using {0}playlist delete <number_in_queue>!**'.format(s_id[sid])
  1180.     else:
  1181.         firstMsg = msg
  1182.  
  1183.     await client.send_message(message.channel, firstMsg, *args, **kwargs)
  1184.  
  1185.        
  1186. async def miku_reaction(message):
  1187.     global miku_names
  1188.     for i in miku_names:
  1189.         if i in message.content:
  1190.             await asyncio.sleep(0.37)
  1191.             msg = random.choice(miku_message).format(message.author.mention)
  1192.             await client.send_message(message.channel, msg)
  1193.             return
  1194.            
  1195.  
  1196. statuses = ["with Lily", "with Ana", "with Yuno", "with Eri", "with Honoka", "with Nico", "with Nico", "with Nico Nico Niii~",
  1197.             "with Maki", "with herself", "with her toys", "with Nozomi", "with Kotori", "with Umi", "with Rin", "with Hanayo",
  1198.             "with Chika", "with Riko", "with Kanan", "with Dia", "with You-chan", "with Yoshiko", "with Yohanne", "with Hanamaru zuraaa~",
  1199.             "with Mari", "with Ruby", "with Taiga", "with her phone", "with Toastie", "with Ado-kun", "with adorable Ana-chan",
  1200.             "with Mashiro", "with Yuzu", "with Sprii", "with Katalina", "with her creator", "with Angela", "with her hair", "with Aqours", "with Āµ's",
  1201.             "with Luka", "Doki Doki Literature Club", "with Natsuki..?", "with Yuri", "with Sayori", "with Monika", "with Hana", "with her friends",
  1202.             "with Faerlynn", "nothing... Weird...", "with Satou", "with Shio", "with Livvy", "as Mercy", "as Ana", "as Brigitte", "as Pharah", "as D.Va",
  1203.             "as Mei", "as Sombra", "as Ashe", "as Moira", "as Symmetra", "as Tracer", "as Zarya", "as Miku", "as Luka", "as Athena", "as Echo",
  1204.             "as Efi", "with Katniss", "never have I ever", "with Kyō"]
  1205.  
  1206.  
  1207. async def task_loop():
  1208.     while True:
  1209.         me = discord.utils.find(lambda s: s != None, client.servers).me
  1210.         if not me:
  1211.                 return
  1212.         elif not me.game:
  1213.                 updated_game = discord.Game(name = random.choice(statuses))              
  1214.         else:
  1215.                 updated_game = me.game
  1216.                 updated_game.name = random.choice(statuses)              
  1217.         await client.change_presence(game = updated_game)
  1218.         await asyncio.sleep(300 + random.randrange(150))
  1219.  
  1220.  
  1221. @client.event
  1222. async def on_ready():
  1223.     global start, statuses
  1224.     print('Logged in as:', client.user.name)
  1225.     print('Client ID:',client.user.id)
  1226.     print('Loading files...')
  1227.     reload_files()
  1228.     if success == False:
  1229.         print('Files loaded successfully')
  1230.     else:
  1231.         print("Loading of files unsuccessfull")
  1232.     end = timeit.timeit()
  1233.     print('Started up in', round((end - start)*100, 2), 'seconds')
  1234.     client.loop.create_task(task_loop())
  1235.     await asyncio.sleep(0.5)
  1236.     print('------------')
  1237.  
  1238. TOKEN = '<removed>'
  1239. client.run(TOKEN)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement