Advertisement
Faerlynn

Miku v0.19.0 (3.1.2019)

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