Advertisement
Faerlynn

Miku v0.20.0 (14.1.2019)

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