Advertisement
Faerlynn

Miku v0.20.1 (15.1.2019)

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