Advertisement
Faerlynn

Miku v0.16 (16.12.2018)

Dec 16th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 39.73 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.  
  9. start = timeit.timeit()
  10. TOKEN = '<removed>'
  11.  
  12. file = open('bot_save_files\patch.txt', 'r')
  13. version = file.read()
  14. file.close()
  15. print(str(version))
  16. print('------------')
  17.  
  18. client = discord.Client()
  19.  
  20. def log(msg, message_channel, message_author, cmd_type):
  21.     if cmd_type == '':
  22.         cmd_type = 'unknown'
  23.     #print("Command '" + cmd_type + "' used in " + str(message_channel) + ' by ' + str(message_author) +'!')
  24.     print('Command \'{0}\' used in {1} by {2}!'.format(cmd_type, str(message_channel), str(message_author)))
  25.  
  26. def reload_files():
  27.     global cuddle_message, hug_message, kiss_message, about, patchnotes, pat_message, version, slap_message, s_id, success
  28.     global miku_message
  29.     #Opens file for 'cuddle'
  30.     success = False
  31.     try:
  32.         file = open("bot_save_files\cuddle_messages.txt",'r')
  33.         line = file.readline()
  34.         cuddle_message = []
  35.         while line:
  36.             cuddle_message.append(line)
  37.             line = file.readline()
  38.         file.close()
  39.     except:
  40.         print("File 'cuddle_messages.txt' couldn't be opened!")
  41.         success = True
  42.  
  43.     #Opens file for 'hug'
  44.     try:
  45.         file = open("bot_save_files\hug_messages.txt",'r')
  46.         line = file.readline()
  47.         hug_message = []
  48.         while line:
  49.             hug_message.append(line)
  50.             line = file.readline()
  51.         file.close()
  52.     except:
  53.         print("File 'hug_messages.txt' couldn't be opened!")
  54.         success = True
  55.  
  56.     #Opens file for 'pat'
  57.     try:
  58.         file = open("bot_save_files\pat_messages.txt",'r')
  59.         line = file.readline()
  60.         pat_message = []
  61.         while line:
  62.             pat_message.append(line)
  63.             line = file.readline()
  64.         file.close()
  65.     except:
  66.         print("File 'pat_messages.txt' couldn't be opened!")
  67.         success = True
  68.        
  69.     #Opens file for 'kiss'
  70.     try:
  71.         file = open("bot_save_files\kiss_messages.txt",'r')
  72.         line = file.readline()
  73.         kiss_message = []
  74.         while line:
  75.             kiss_message.append(line)
  76.             line = file.readline()
  77.         file.close()
  78.     except:
  79.         print("File 'kiss_messages.txt' couldn't be opened!")
  80.         success = True
  81.        
  82.     #Opens file for 'about'
  83.     try:
  84.         about = ''
  85.         file = open("bot_save_files\\about.txt",'r')
  86.         about = file.read()
  87.         file.close()
  88.     except:
  89.         print("File 'about.txt' couldn't be opened!")
  90.         success = True
  91.  
  92.     #Opens file for 'about'
  93.     try:
  94.         version = ''
  95.         file = open("bot_save_files\\patch.txt",'r')
  96.         version = file.read()
  97.         file.close()
  98.     except:
  99.         print("File 'patch.txt' couldn't be opened!")
  100.         success = True
  101.  
  102.     #Opens file for 'patchnotes'
  103.     try:
  104.         patchnotes = ''
  105.         file = open("bot_save_files\\patch_notes.txt",'r')
  106.         patchnotes = file.read()
  107.         file.close()
  108.     except:
  109.         print("File 'patch_notes.txt' couldn't be opened!")
  110.         success = True
  111.  
  112.     #Opens file for 'slap'
  113.     try:
  114.         file = open("bot_save_files\slap_messages.txt",'r')
  115.         line = file.readline()
  116.         slap_message = []
  117.         while line:
  118.             slap_message.append(line)
  119.             line = file.readline()
  120.         file.close()
  121.     except:
  122.         print("File 'slap_messages.txt' couldn't be opened!")
  123.         success = True
  124.  
  125.     #Opens fire for s_id
  126.     s_id = {}
  127.     try:
  128.         file = open("bot_save_files\server_id.txt",'r')
  129.         line = file.readline()
  130.         while line:
  131.             key, value = line.split(':')
  132.             s_id[key] = value[:1]
  133.             line = file.readline()
  134.         file.close()
  135.     except:
  136.         print("File 'server_id.txt' couldn't be opened!")
  137.         success = True
  138.  
  139.     #Opens file for 'miku reaction'
  140.     try:
  141.         file = open("bot_save_files\miku_reaction_msg.txt",'r')
  142.         line = file.readline()
  143.         miku_message = []
  144.         while line:
  145.             miku_message.append(line)
  146.             line = file.readline()
  147.         file.close()
  148.     except:
  149.         print("File 'miku_reaction_msg.txt' couldn't be opened!")
  150.         success = True
  151.  
  152. def save():
  153.     global s_id
  154.     key, value = '', ''
  155.     s_id_file = ''
  156.     for key, value in s_id.items():
  157.         s_id_file = s_id_file + "{0}:{1}\n".format(key, value)
  158.     os.remove("bot_save_files\server_id.txt")
  159.     file = open("bot_save_files\server_id.txt",'w')
  160.     file.write(str(s_id_file))
  161.     file.close()
  162.  
  163.  
  164. #startup variables
  165. game_number = 274**21
  166. game_active = False
  167. attempts = 0
  168. round_active = False
  169. error = ''
  170. player = ''
  171. author = ''
  172. msg = ''
  173. gmn_cp = {}
  174. gmn_number = {}
  175. gmn_a = {}
  176. edits = ['*', '__', '~~', '**', '***']
  177. players = {}
  178.  
  179.  
  180. @client.event
  181. async def on_message(message):
  182.     global game_number, game_active, error, round_active, attempts, about, player, author, msg, version, s_id, gmn_cp, success
  183.     global miku_message, edits, statuses, players, vc
  184.     if message.author == client.user:
  185.         return
  186.  
  187.     if not message.server.id in s_id:
  188.         s_id[message.server.id] = '$'
  189.         print('Creating a backup...')
  190.         msg = 'Creating a first settings for your server!'
  191.         await client.send_message(message.channel, msg)
  192.         save()
  193.         reload_files()
  194.         return
  195.    
  196.     #done       HELLO
  197.     if message.content.startswith('{0}hello'.format(s_id[message.server.id])):
  198.         cmd = 'hello'
  199.         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])
  200.         log(msg, message.channel, message.author, cmd)
  201.         await client.send_message(message.channel, msg)
  202.  
  203.     #done       LOVE
  204.     if message.content.startswith('{0}love'.format(s_id[message.server.id])):
  205.         cmd = 'love'
  206.         msg = "Soo.. Umm.. I know that umm.. This command is not listed.. because it is actually a *secret one!*  Umm.. Back to topic.. Yeah.. ***I love Lily Snow Aisaka ^~^***  Pfew... It's out now.. *giggles and blushes*"
  207.         log(msg, message.channel, message.author, cmd)
  208.         await client.send_message(message.channel, msg)
  209.  
  210.     #done       RANDOM NUMBER
  211.     if message.content.startswith('{0}random'.format(s_id[message.server.id])):
  212.         cmd = 'random'
  213.         msg = ('Randomly generated number: '+str(random.randrange(101)))
  214.         log(msg, message.channel, message.author, cmd)
  215.         await client.send_message(message.channel, msg)
  216.  
  217.     #done       POKE
  218.     if message.content.startswith('{0}poke'.format(s_id[message.server.id])):
  219.         cmd = "poke"
  220.         msg = str(message.content)[6:]
  221.         msg_list = msg.split(' ')
  222.         msg_recipient = ''
  223.         msg_author = str(message.author)[:-5]
  224.         msg_content_test = False
  225.         for i in range(len(msg_list)):
  226.             msg_check = msg_list[i]
  227.             if (('<@!' and '>') in msg_check) == True:
  228.                 msg_recipient = msg_check
  229.                 msg_content_test = True
  230.         if msg_content_test == False:
  231.             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.*"
  232.         else:
  233.             msg = '*' + msg_author + " pokes " + msg_recipient + "'s shoulder gently and then just waits for their response patiently.*"
  234.         log(msg, message.channel, message.author, cmd)
  235.         await client.send_message(message.channel, msg)
  236.         if msg_recipient == '<@!492432534181773313>':
  237.             time.sleep(1)
  238.             msg = "*She looks at {0.author.mention} curiously, and after moment she pokes {0.author.mention}'s nose back.*".format(message)
  239.             await client.send_message(message.channel, msg)
  240.  
  241.     #done       CUDDLE
  242.     if message.content.startswith('{0}cuddle'.format(s_id[message.server.id])):
  243.         cmd = 'cuddle'
  244.         try:
  245.             msg = str(message.content)[8:]
  246.             msg_list = msg.split(' ')
  247.             msg_recipient = ''
  248.             msg_author = str(message.author)[:-5]
  249.             msg_content_test = False
  250.            
  251.             for i in range(len(msg_list)):
  252.                 msg_check = msg_list[i]
  253.                 if (('<@!' and '>') in msg_check) == True:
  254.                     msg_recipient = msg_check
  255.                     msg_content_test = True
  256.            
  257.             if not msg_content_test:
  258.                 msg = '*' + msg_author + " cuddles their pillow, smiling but alone.*"
  259.             else:
  260.                 msg = random.choice(cuddle_message).format(msg_author, msg_recipient)
  261.             log(msg, message.channel, message.author, cmd)
  262.        
  263.             await client.send_message(message.channel, msg)
  264.         except ValueError in error:
  265.             print(error)
  266.             await client.send_message(message.channel, 'Something went wrong.... :sob:')
  267.        
  268.  
  269.     #done       HUG
  270.     if message.content.startswith('{0}hug'.format(s_id[message.server.id])):
  271.         cmd = 'hug'
  272.         msg = str(message.content)[5:]
  273.         msg_list = msg.split(' ')
  274.         msg_recipient = ''
  275.         msg_author = str(message.author)[:-5]
  276.         msg_content_test = False
  277.         for i in range(len(msg_list)):
  278.             msg_check = msg_list[i]
  279.             if (('<@!' and '>') in msg_check) == True:
  280.                 msg_recipient = msg_check
  281.                 msg_content_test = True
  282.         if not msg_content_test:
  283.             msg_recipient = 'bottle of expensive red wine'
  284.         msg = random.choice(hug_message).format(msg_author, msg_recipient)
  285.         log(msg, message.channel, message.author, cmd)
  286.         try:
  287.             await client.send_message(message.channel, msg)
  288.         except ValueError in error:
  289.             print(error)
  290.             await client.send_message(message.channel, 'Something went wrong.... :sob:')
  291.  
  292.     #done       KISS
  293.     if message.content.startswith('{0}kiss'.format(s_id[message.server.id])):
  294.         cmd = 'kiss'
  295.         msg = str(message.content)[5:]
  296.         msg_list = msg.split(' ')
  297.         msg_recipient = ''
  298.         msg_author = str(message.author)[:-5]
  299.         msg_content_test = False
  300.         for i in range(len(msg_list)):
  301.             msg_check = msg_list[i]
  302.             if (('<@!' and '>') in msg_check) == True:
  303.                 msg_recipient = msg_check
  304.                 msg_content_test = True
  305.         if msg_content_test == False:
  306.             msg_recipient = 'bottle of expensive red wine'
  307.         msg = random.choice(kiss_message).format(msg_author, msg_recipient)
  308.         log(msg, message.channel, message.author, cmd)
  309.         try:
  310.             await client.send_message(message.channel, msg)
  311.         except ValueError in error:
  312.             print(error)
  313.             await client.send_message(message.channel, 'Something went wrong.... :sob:')
  314.  
  315.     #done       PAT
  316.     if message.content.startswith('{0}pat'.format(s_id[message.server.id])):
  317.         cmd = 'pat'
  318.         if '{0}pat '.format(s_id[message.server.id]) in message.content:
  319.             msg = str(message.content)[4:]
  320.             msg_list = msg.split(' ')
  321.             msg_recipient = ''
  322.             msg_author = str(message.author)[:-5]
  323.             msg_content_test = False
  324.             for i in range(len(msg_list)):
  325.                 msg_check = msg_list[i]
  326.                 if (('<@!' and '>') in msg_check) == True:
  327.                     msg_recipient = msg_check
  328.                     msg_content_test = True
  329.             if msg_content_test == False:
  330.                 msg_recipient = 'invisible unicorn'
  331.             msg = random.choice(pat_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 ValueError in error:
  336.                 print(error)
  337.                 await client.send_message(message.channel, 'Something went wrong.... :sob:')
  338.  
  339.     #SLAP
  340.     if message.content.startswith('{0}slap'.format(s_id[message.server.id])):
  341.         cmd = 'slap'
  342.         if '{0}slap '.format(s_id[message.server.id]) in message.content:
  343.             msg = str(message.content)[5:]
  344.             msg_list = msg.split(' ')
  345.             msg_recipient = ''
  346.             msg_author = str(message.author)[:-5]
  347.             msg_content_test = False
  348.             for i in range(len(msg_list)):
  349.                 msg_check = msg_list[i]
  350.                 if (('<@!' and '>') in msg_check) == True:
  351.                     msg_recipient = msg_check
  352.                     msg_content_test = True
  353.             if msg_content_test == False:
  354.                 msg_recipient = 'air'
  355.             if msg_recipient == str(message.author.mention):
  356.                 msg = random.choice(pat_message).format('Miku', msg_recipient)
  357.             else:
  358.                 msg = random.choice(slap_message).format(msg_author, msg_recipient)
  359.             log(msg, message.channel, message.author, cmd)
  360.             try:
  361.                 await client.send_message(message.channel, msg)
  362.             except ValueError in error:
  363.                 print(error)
  364.                 await client.send_message(message.channel, 'Something went wrong.... :sob:')
  365.    
  366.  
  367.     #WIP               <-----------------------------------------------------
  368.     if message.content.startswith('{0}help'.format(s_id[message.server.id])):
  369.         cmd = 'help'
  370.         msg = """**{0}hello** - yes, this is my greeting to all of you, my users! ^~^
  371.        **{0}kiss @user** - kisses your lovely friend
  372.        **{0}hug @user** - hugs your hugging-friend
  373.        **{0}poke @user** - pokes your victim
  374.        **{0}cuddle @user** - cuddles your cuddle pillow friend
  375.        **{0}pat @user** - pat your friend's head and make them blush with happiness
  376.        **{0}slap @user** - slap someone who's being rude! Ouch!
  377.        **{0}rnf x z** - gives you random number from between numbers **x** and **z**
  378.        **{0}random** - gives you random number between **0** and **100**
  379.        **{0}choice a, b, c, d, ...** - makes a choice for you from the list words, each one divided with ","
  380.        **{0}rc** - gives you a random colour in hex format
  381.        **{0}p <youtube url>** - plays song in voice channel you're conencted to
  382.        **{0}dc** - disconnects bot from voice channel
  383.        **{0}coinflip** - flips the coin. Try your luck!
  384.        **{0}gmn** - first minigame! Guess my number! Collect points and get on top of the leaderboard! ***<Rankings And Points Not Yet Implemented>***
  385.        **{0}invite** - sends you a special link with which you can invite this bot to ***your own server***
  386.        **{0}about** - do you want to learn more about me and my creator? Don't wait any longer!
  387.        **{0}chart** - shows you a simple japanese katakana and hiragana chart! *For all weebs who can't type in their mother language..* >.>
  388.        **{0}prefix set <prefix>** - allows owner of the server to change prefix to which my commands will react in that server
  389.        **{0}lewd** - *winks*""".format(s_id[message.server.id])
  390.         color = 4122822
  391.         embed = discord.Embed(title = 'List of my commands:', description = msg, color = color)
  392.         log(msg, message.channel, message.author, cmd)
  393.         await client.send_message(message.author, embed = embed)
  394.         await client.add_reaction(message, '\U00002705')
  395.  
  396.     #done       ABOUT
  397.     if message.content.startswith('{0}about'.format(s_id[message.server.id])):
  398.         cmd = 'about'
  399.         log(msg, message.channel, message.author, cmd)
  400.         await client.send_message(message.channel, about)
  401.  
  402.     #done       CHART
  403.     if message.content.startswith('{0}chart'.format(s_id[message.server.id])):
  404.         cmd = 'chart'
  405.         msg = '''**ๆ—ฅ ๏ฝ ๏ฝ‰ ๏ฝ• ๏ฝ… ๏ฝใ€€๏ฝ ๏ฝ‰ ๏ฝ• ๏ฝ… ๏ฝ ๆœฌ
  406.        ใƒผ ใ‚ข ใ‚ค ใ‚ฆ ใ‚จ ใ‚ชใ€€ใ‚ ใ„ ใ† ใˆ ใŠ
  407.        ๏ฝ‹ ใ‚ซ ใ‚ญ ใ‚ฏ ใ‚ฑ ใ‚ณใ€€ใ‹ ใ ใ ใ‘ ใ“
  408.        ๏ฝ“ ใ‚ต ใ‚ท ใ‚น ใƒ‡ ใ‚ฝใ€€ใ• ใ— ใ™ ใ› ใ
  409.        ๏ฝ” ใ‚ฟ ใƒ ใƒ„ ใƒ† ใƒˆใ€€ใŸ ใก ใค ใฆ ใจ
  410.        ๏ฝŽ ใƒŠ ใƒ‹ ใƒŒ ใƒ ใƒŽใ€€ใช ใซ ใฌ ใญ ใฎ
  411.        ๏ฝ ใƒž ใƒŸ ใƒ  ใƒก ใƒขใ€€ใพ ใฟ ใ‚€ ใ‚ ใ‚‚
  412.        ๏ฝ’ ใƒฉ ใƒช ใƒซ ใƒฌ ใƒญใ€€ใ‚‰ ใ‚Š ใ‚‹ ใ‚Œ ใ‚
  413.        ๏ฝˆ ใƒ ใƒ’ ใƒ• ใƒ˜ ใƒ›ใ€€ใฏ ใฒ ใต ใธ ใป
  414.        ๏ฝ— ใƒฏ ใ€€ ใ€€ ใ€€ ใƒฒใ€€ใ‚  ใ€€ใ€€ ใ€€ ใ‚’
  415.        ๏ฝ™ ใƒค ใ€€ ใƒฆ ใ€€ ใƒจใ€€ใ‚„  ใ€€ใ‚† ใ€€ ใ‚ˆ
  416.        ๏ฝŽ ใƒณ ใ€€ ใ€€ ใ€€ ใ€€ใ€€ใ‚“**'''
  417.         color = 4122822
  418.         embed = discord.Embed(title = 'Katakana and hiragana chart:', description = msg, color = color)
  419.         log(msg, message.channel, message.author, cmd)
  420.         await client.send_message(message.channel, embed = embed)
  421.  
  422.     #done       AYAYA AYAYAAAAAA
  423.     if (message.content.startswith('ayaya')) or (message.content.startswith('AYAYA')):
  424.         cmd = 'ayaya'
  425.         msg = '''**โฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃทโฃฌโก›โฃฟโฃฟโฃฟโฃฏโขป
  426. โฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโกŸโขปโฃฟโฃฟโขŸโฃปโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฎโกปโฃฟโฃฟโฃง
  427. โฃฟโฃฟโฃฟโฃฟโฃฟโขปโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃ†โ ปโกซโฃขโ ฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃทโฃœโขปโฃฟ
  428. โฃฟโฃฟโกโฃฟโฃฟโฃจโฃโ ฟโฃฟโฃฟโฃฟโฃฟโฃฟโข•โ ธโฃ›โฃฉโฃฅโฃ„โฃฉโขโฃ›โกฟโ ฟโฃฟโฃฟโฃ†โข
  429. โฃฟโฃฟโขกโฃธโฃฟโฃโฃฟโฃฟโฃถโฃฏโฃ™โ ซโขบโฃฟโฃทโกˆโฃฟโฃฟโฃฟโฃฟโกฟโ ฟโขฟโฃŸโฃ’โฃ‹โฃ™โ Š
  430. โฃฟโกโกฟโฃ›โฃโขฟโฃฎโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃถโฃถโฃถโฃถโฃพโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟ
  431. โฃฟโขฑโฃพโฃฟโฃฟโฃฟโฃโกฎโกปโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโกฟโ ฟโ ›โฃ‹โฃปโฃฟโฃฟโฃฟโฃฟ
  432. โขฟโขธโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃทโฃฝโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโก•โฃกโฃดโฃถโฃฟโฃฟโฃฟโกŸโฃฟโฃฟโฃฟ
  433. โฃฆโกธโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโก›โขฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโก‡โฃฟโฃฟโฃฟ
  434. โข›โ ทโกนโฃฟโ ‹โฃ‰โฃ โฃคโฃถโฃถโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโกฟโ ฟโขฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃทโขนโฃฟโฃฟ
  435. โฃทโกโฃฟโกžโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโกŸโ ‹โ โฃ โฃคโฃคโฃฆโฃฝโฃฟโฃฟโฃฟโกฟโ ‹โ ˜โฃฟโฃฟ
  436. โฃฟโฃฟโกนโฃฟโกผโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃงโกฐโฃฟโฃฟโฃฟโฃฟโฃฟโฃนโกฟโ Ÿโ ‰โก€โ „โ „โขฟโฃฟ
  437. โฃฟโฃฟโฃฟโฃฝโฃฟโฃผโฃ›โ ฟโ ฟโฃฟโฃฟโฃฟโฃฟโฃฟโฃฏโฃฟโ ฟโขŸโฃปโกฝโขšโฃคโกžโ „โ „โ „โขธโฃฟ**'''
  438.         log(msg, message.channel, message.author, cmd)
  439.         await client.send_message(message.channel, msg)
  440.  
  441.     #done       INVITE
  442.     if message.content.startswith('{0}invite'.format(s_id[message.server.id])):
  443.         msg = "*You can invite me to your server using this link:*\nhttps://discordapp.com/oauth2/authorize?client_id=492432534181773313&scope=bot"
  444.         await client.send_message(message.author, msg)
  445.  
  446.     #done       CHOICE
  447.     if message.content.startswith('{0}choice'.format(s_id[message.server.id])):
  448.         cmd = 'choice'
  449.         msg = message.content[8:]
  450.         choice_list = []
  451.         choice_list = msg.split(',')
  452.         msg = "I've randomly chosen this for you: " + str(random.choice(choice_list))
  453.         log(msg, message.channel, message.author, cmd)
  454.         await client.send_message(message.channel, msg)
  455.  
  456.     #done       PATCHNOTES
  457.     if message.content.startswith('{0}patchnotes'.format(s_id[message.server.id])):
  458.         cmd = 'patchnotes'
  459.         p_notes_split = patchnotes.split('<$>')
  460.         #print(p_notes_split)
  461.         log(msg, message.channel, message.author, cmd)
  462.         for i in p_notes_split:
  463.             msg = '```{0}```'.format(i)
  464.             await client.send_message(message.author, msg)
  465.  
  466.     #done       VERSION
  467.     if message.content.startswith('{0}version'.format(s_id[message.server.id])):
  468.         cmd = 'version'
  469.         msg = '`Current version of this bot is: {0}`'.format(version)
  470.         log(msg, message.channel, message.author, cmd)
  471.         await client.send_message(message.channel, msg)
  472.  
  473.     #done       RANDOM NUMBER X Z
  474.     if message.content.startswith('{0}rnf'.format(s_id[message.server.id])):
  475.         cmd = 'random number from <x, z>'
  476.         msg = message.content[5:]
  477.         numbers = []
  478.         numbers = msg.split(' ')
  479.         log(msg, message.channel, message.author, cmd)
  480.         error = ''
  481.         if len(numbers) == (1 or 0):
  482.             msg = 'You need two numbers!'
  483.             await client.send_message(message.channel, msg)
  484.         else:
  485.             try:
  486.                 print(numbers[0], numbers[1])
  487.                 a = int(round(float(numbers[0])))
  488.                 b = int(round(float(numbers[1])))
  489.                 print(a, b)
  490.                
  491.                 if a >= b:
  492.                     c = a
  493.                     a = b
  494.                     b = c
  495.                    
  496.                 if a == b:
  497.                     msg = "Your random number is not really random, but here you go: {0}".format(a)
  498.                 else:
  499.                     num = random.randrange(a, b+1)
  500.                     msg = "Your random number is: " + str(num)
  501.                 await client.send_message(message.channel, msg)
  502.                
  503.             except ValueError as error:
  504.                 print(error)
  505.                 msg = 'Something went wrong!'
  506.                 await client.send_message(message.channel, msg)
  507.  
  508.     #done       COINFLIP
  509.     if message.content.startswith('{0}coinflip'.format(s_id[message.server.id])):
  510.         cmd = 'coinflip'
  511.         num = random.randrange(1000)+1
  512.         if num == 741:
  513.             msg = "***It landed on it's side! How lucky!!!***"
  514.         else:
  515.             if num == 274:
  516.                 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..."
  517.             else:
  518.                 if num > 500:
  519.                     msg = 'Heads!' + '!'*random.randrange(4)
  520.                 else:
  521.                     msg = 'Tails!' + '!'*random.randrange(4)
  522.         #log(msg, message.channel, message.author, cmd)
  523.         print("Command '$" + cmd + "' used in " + str(message.channel) + ' by ' + str(message.author) +'! Rolled: ' + str(num))
  524.         await client.send_message(message.channel, msg)
  525.  
  526.     #done       RANDOM COLOUR
  527.     if message.content.startswith('{0}rc'.format(s_id[message.server.id])):
  528.         cmd = 'random colour'
  529.         color = random.randrange(256**3)
  530.         print(color)
  531.         msg = str(f'#{color:06x}')
  532.         embed = discord.Embed(title = 'Your random colour: ', description = msg, color = color)
  533.         log(str(msg), message.channel, message.author, cmd)
  534.         await client.send_message(message.channel, embed = embed)
  535.  
  536.     #done       GUESS MY NUMBER
  537.     if message.content.startswith('{0}gmn'.format(s_id[message.server.id])):
  538.        
  539.         if not str(message.author) in gmn_cp:
  540.             gmn_cp[str(message.author)] = False
  541.             gmn_a[str(message.author)] = 0
  542.             gmn_number[str(message.author)] = 0
  543.            
  544.         if gmn_cp[str(message.author)] == False:
  545.             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..!!")
  546.             time.sleep(0.25)
  547.             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]))
  548.             game_number = random.randrange(100)+1
  549.             gmn_number[str(message.author)] = game_number
  550.             gmn_a[str(message.author)] = 0
  551.             player = str(message.author)
  552.             gmn_cp[str(message.author)] = True
  553.            
  554.         elif gmn_cp[str(message.author)] == True:
  555.             number = message.content[4:]
  556.             try:
  557.                 number = int(number)
  558.                 gmn_cp[str(message.author)] = True
  559.                
  560.                 if gmn_number[str(message.author)] == number:
  561.                     msg = "Y-yes..! That's the number I.. I've been thinking of! Y-you are so good s-senpai! :heart_eyes:"
  562.                     gmn_a[str(message.author)] = 0
  563.                     await client.send_message(message.channel, msg)
  564.                     gmn_a[str(message.author)] = 0
  565.                     gmn_cp[str(message.author)] = False
  566.  
  567.                    
  568.                 elif (gmn_a[str(message.author)] == 0) and (gmn_cp[str(message.author)] == True):
  569.  
  570.                     if gmn_number[str(message.author)] < number:
  571.                         msg = "T-that's not it, s-senpai..! :flushed: Your n-number is too b-big.. T-try again..! *blushes*"
  572.                         await client.send_message(message.channel, msg)
  573.                     else:
  574.                         msg = "T-that's not it, s-senpai..! :flushed: Your n-number is not b-big enough.. T-try again..! *blushes*"
  575.                         await client.send_message(message.channel, msg)
  576.  
  577.                     gmn_a[str(message.author)] = 1
  578.                     print('New game! Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
  579.                    
  580.                 elif (gmn_a[str(message.author)] == 1) and (gmn_cp[str(message.author)] == True):
  581.  
  582.                    
  583.                     if gmn_number[str(message.author)] < number:
  584.                         msg = "N-no senpai... S-still not my number.. It's n-not that big..."
  585.                         await client.send_message(message.channel, msg)
  586.                     else:
  587.                         msg = "N s-senpai... S-still not my special number.. It's even higher..."
  588.                         await client.send_message(message.channel, msg)
  589.                        
  590.                     gmn_a[str(message.author)] = 2
  591.                     print('Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
  592.  
  593.                    
  594.                 elif (gmn_a[str(message.author)] == 2) and (gmn_cp[str(message.author)] == True):
  595.                    
  596.                     if gmn_number[str(message.author)] < number:
  597.                         msg = "That's again n-not my n-number *blushes* T-too big..! Last chance..!"
  598.                         await client.send_message(message.channel, msg)
  599.                     else:
  600.                         msg = "N-not my n-number, senpai..! *blushes* Go h-higher..! L-last attempt..!"
  601.                         await client.send_message(message.channel, msg)
  602.                        
  603.                     gmn_a[str(message.author)] = 3
  604.                     print('Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
  605.                    
  606.                 elif (gmn_a[str(message.author)] == 3) and (gmn_cp[str(message.author)] == True):
  607.                    
  608.                     if gmn_number[str(message.author)] < number:
  609.                         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)])
  610.                         await client.send_message(message.channel, msg)
  611.                     else:
  612.                         msg = "S-senpai..! T-that's not my number..! I was t-thinking of a number " + str(gmn_number[str(message.author)])
  613.                         await client.send_message(message.channel, msg)
  614.                        
  615.                     print('Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
  616.                     gmn_a[str(message.author)] = 0
  617.                     gmn_cp[str(message.author)] = False
  618.                    
  619.             except:
  620.                 await client.send_message(message.channel, "That's not a number, b-baka s-senpai..!!")
  621.         else:
  622.             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:")
  623.  
  624.  
  625.     #done       LEWD
  626.     if message.content.startswith('{0}lewd'.format(s_id[message.server.id])):
  627.         if str(message.author) == 'Ana#3140':
  628.             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..!__***'
  629.         else:
  630.             msg = '**Y-YOU ARE SO L-LEWD, SENPAI**' + '!'*int(random.randrange(9)+3)
  631.         await client.send_message(message.channel, msg)
  632.  
  633.     #done       SERVER PREFIX CHANGE
  634.     if message.content.startswith('{0}prefix set'.format(s_id[message.server.id])):
  635.         if message.author == message.server.owner:
  636.             try:
  637.                 prefix = message.content[12:]
  638.                 if len(prefix) > 1:
  639.                     msg = 'Prefix can consist of only one character!'
  640.                 else:
  641.                     s_id[message.server.id] = str(prefix)
  642.                     save()
  643.                     reload_files()
  644.                     msg = 'Prefix of this server has been changed to {0}'.format(prefix)
  645.             except:
  646.                 msg = 'Something went wrong!'
  647.         else:
  648.             msg = "I'm sorry s-senpai, b-but you are n-not owner of t-this server!"
  649.         await client.send_message(message.channel, msg)
  650.                
  651.  
  652.     #bet reaction
  653.     if (message.content.startswith('bet'))or (message.content.startswith('beet')) or (message.content.startswith('Bet')):
  654.         num = random.randrange(10000)
  655.         if num == 2714:
  656.             msg = 'BEEEEEEEEEEEEEEEEEEEEEEEEEEEET!!!!!'
  657.             await client.send_message(message.channel, msg)
  658.         else:
  659.             if num == 8743:
  660.                 msg = 'No bets allowed to underage trolls (That means you are not allowed to bet if you are not 18+.... B-baka senpai.. >.>)'
  661.                 await client.send_message(message.channel, msg)
  662.             else:
  663.                 msg = "{0}bet{0}".format(edits[random.randrange(5)])
  664.                 await client.send_message(message.channel, msg)
  665.  
  666.     #miku reaction
  667.     if ("Miku" in message.content) or ("miku" in message.content):
  668.         time.sleep(0.37)
  669.         msg = random.choice(miku_message).format(message.author.mention)
  670.         await client.send_message(message.channel, msg)
  671.  
  672.     #Reactions for other bots
  673.     if (message.content.startswith('+pat <@!492432534181773313>')) or (message.content.startswith('{0}pat <@!492432534181773313>'.format(s_id[message.server.id]))) or (message.content.startswith('{0}pat <@492432534181773313>'.format(s_id[message.server.id]))):
  674.         time.sleep(1)
  675.         #print(message.content)
  676.         msg = 'Awwwwww t-thanks a lot for petting me, {0}! :sparkling_heart: :heart_eyes: ^~^'.format(message.author.mention)
  677.         await client.send_message(message.channel, msg)
  678.  
  679.     if (message.content.startswith('+hug <@!492432534181773313>')) or (message.content.startswith('{0}hug <@!492432534181773313>'.format(s_id[message.server.id]))) or (message.content.startswith('{0}hug <@492432534181773313>'.format(s_id[message.server.id]))):
  680.         time.sleep(1)
  681.         msg = 'Oh~, thanks s-senpai for hug! *she hugs {0} back tightly, smiling and blushing.*'.format(message.author.mention)
  682.         await client.send_message(message.channel, msg)
  683.  
  684.     if (message.content.startswith('+cuddle <@!492432534181773313>')) or (message.content.startswith('{0}cuddle <@!492432534181773313>'.format(s_id[message.server.id]))) or (message.content.startswith('{0}cuddle <@492432534181773313>'.format(s_id[message.server.id]))):
  685.         time.sleep(1)
  686.         msg = '*She giggles and cuddles {0} back, slightly stroking their back, still giggling.*'.format(message.author.mention)
  687.         await client.send_message(message.channel, msg)
  688.        
  689.     if (message.content.startswith('{0}poke <@!492432534181773313>'.format(s_id[message.server.id]))) or (message.content.startswith('{0}poke <@492432534181773313>'.format(s_id[message.server.id]))):
  690.         time.sleep(1)
  691.         msg = "*She looks at {0} curiously, and then she pokes {0} back.*".format(message.author.mention)
  692.         await client.send_message(message.channel, msg)
  693.  
  694.     if (message.content.startswith('{0}slap <@!492432534181773313>'.format(s_id[message.server.id]))) or (message.content.startswith('{0}slap <@492432534181773313>'.format(s_id[message.server.id]))):
  695.         time.sleep(1)
  696.         msg = '*She slaps {0} back, looking angry, annoyed but dissappointed and sad as well...*'.format(message.author.mention)
  697.         await client.send_message(message.channel, msg)
  698.  
  699.  
  700.     #dev only functions
  701.  
  702.     #done       STOP
  703.     if (message.content.startswith('{0}stop'.format(s_id[message.server.id]))) or (message.content.startswith('{0}bye'.format(s_id[message.server.id]))):
  704.         author = str(message.author)
  705.         cmd = 'stop'
  706.         msg = ''
  707.         log(msg, message.channel, message.author, cmd)
  708.         if (author == 'Ana#3140') or (author == 'Cutie Kitty#0068'):
  709.             msg = 'Good bye!'
  710.             await client.send_message(message.channel, msg)
  711.             print('Good b-bye Ana s-senpai~ <3')
  712.             client.logout()
  713.             save()
  714.             sys.exit(0)
  715.         else:
  716.             msg = 'Insufficient permissions...'
  717.             await client.send_message(message.channel, msg)
  718.  
  719.     #done       RELOAD FILES
  720.     if message.content.startswith('{0}rf'.format(s_id[message.server.id])):
  721.         cmd = 'reload files'
  722.         log(msg, message.channel, message.author, cmd)
  723.         author = str(message.author)
  724.         if author == 'Ana#3140':
  725.             reload_files()
  726.             if success == False:
  727.                 print('Files reloaded successfully...')
  728.             else:
  729.                 print('Reload unsuccessful...')
  730.         else:
  731.             msg = 'Insufficient permissions...'
  732.             await client.send_message(message.channel, msg)
  733.  
  734.     #done       CHANGE GAME STATUS
  735.     if message.content.startswith('{0}game'.format(s_id[message.server.id])):
  736.         cmd = 'game status'
  737.         if (str(message.author) == 'Ana#3140') or (str(message.author) == 'Cutie Kitty#0068'):
  738.             me = discord.utils.find(lambda s: s != None, client.servers).me
  739.             if not me:
  740.                     return
  741.             elif not me.game:
  742.                     updated_game = discord.Game(name = random.choice(statuses))
  743.             else:
  744.                     updated_game = me.game
  745.                     updated_game.name = random.choice(statuses)
  746.             await client.change_presence(game = updated_game)
  747.             print('Changing game to:{0}'.format(str(updated_game)))
  748.            
  749.  
  750.     #done       PATCH CHANGE
  751.     if message.content.startswith('{0}patch set'.format(s_id[message.server.id])):
  752.         author = str(message.author)
  753.         cmd = 'patch'
  754.         msg = ''
  755.         patch = ''
  756.         log(msg, message.channel, message.author, cmd)
  757.         if author == 'Ana#3140':
  758.             try:
  759.                 msg = 'Done!'
  760.                 patch = message.content
  761.                 patch = patch[11:]
  762.                 os.remove('bot_save_files\patch.txt')
  763.                 file = open('bot_save_files\patch.txt', 'w')
  764.                 file.write(str(patch))
  765.                 file.close()
  766.                 version = patch
  767.                 print('Current patch changed to {0}'.format(patch))
  768.                 await client.send_message(message.channel, msg)
  769.             except:
  770.                 print('Something went wrong!')
  771.            
  772.     #WIP        TEST COMMAND
  773.     if message.content.startswith('{0}test'.format(s_id[message.server.id])):
  774.         cmd = 'test'
  775.         file = open('bot_save_files\\server_id.txt', 'a')
  776.         file.write(str(str(s_id.keys()).split("'")))
  777.         file.close()
  778.        
  779.         try:
  780.             print(message.author.id, message.content, message.server, message.server.id)
  781.             await client.send_message(message.channel, message.server.id)
  782.         except:
  783.             print(error)
  784.  
  785.     #MUSIC CONNECT
  786.     if message.content.startswith("{0}p ".format(s_id[message.server.id])):
  787.         try:
  788.             url = str(message.content).strip('{0}p '.format(s_id[message.server.id]))
  789.             if client.is_voice_connected(message.server):
  790.                 try:
  791.                     vc = client.voice_client_in(message.server)
  792.                     players[message.server.id].stop()
  793.                     musicplayer = await vc.create_ytdl_player(url, before_options=" -reconnect 1 -reconnect_streamed 1"
  794.                                                                                    " -reconnect_delay_max 5")
  795.                     players[message.server.id] = musicplayer
  796.                     musicplayer.start()
  797.                 except Exception as e:
  798.                     await client.send_message(message.server, "Error2______[{0}]".format(e))
  799.  
  800.             if not client.is_voice_connected(message.server):
  801.                 try:
  802.                     channel = message.author.voice.voice_channel
  803.                     vc = await client.join_voice_channel(channel)
  804.                     musicplayer = await vc.create_ytdl_player(url, before_options=" -reconnect 1 -reconnect_streamed 1"
  805.                                                                                    " -reconnect_delay_max 5")
  806.                     players[message.server.id] = musicplayer
  807.                     musicplayer.start()
  808.                 except Exception as e:
  809.                     await client.send_message(message.channel, "Error3____[{0}]".format(e))
  810.         except Exception as e:
  811.             await client.send_message(message.channel, "Error4________[{0}]".format(e))
  812.  
  813.     #MUSIC DISCONENCT
  814.     if message.content.startswith('{0}dc'.format(s_id[message.server.id])):
  815.         if client.is_voice_connected(message.server):
  816.             await vc.disconnect()
  817.         else:
  818.             msg = "I'm not connected!"
  819.             await client.send_message(message.channel, msg)
  820.        
  821.  
  822.  
  823. statuses = ["with Lily", "with Ana", "with Yuno", "with Eri", "with Honoka", "with Nico", "with Nico", "with Nico Nico Niii~",
  824.             "with Maki", "with herself", "with her toys", "with Nozomi", "with Kotori", "with Umi", "with Rin", "with Hanayo",
  825.             "with Chika", "with Riko", "with Kanan", "with Dia", "with You-chan", "with Yoshiko", "with Yohanne", "with Hanamaru zuraaa~",
  826.             "with Mari", "with Ruby", "with Taiga", "with her phone", "with Toastie", "with daddy Ado", "with adorable Ana-chan",
  827.             "with Mashiro", "with Yuzu", "with Katalina", "with her creator", "with Angela", "with her hair", "with Aqours", "with ยต's",
  828.             "with Luka", "Doki Doki Literature Club", "with Natsuki..?", "with Yuri", "with Sayori", "with Hana", "with her friends",
  829.             "with Faerlynn", "nothing... Weird...", "with Satou", "with Shio"]
  830.  
  831.  
  832. async def task_loop():
  833.     while True:
  834.         me = discord.utils.find(lambda s: s != None, client.servers).me
  835.         if not me:
  836.                 return
  837.         elif not me.game:
  838.                 updated_game = discord.Game(name = random.choice(statuses))
  839.         else:
  840.                 updated_game = me.game
  841.                 updated_game.name = random.choice(statuses)
  842.         await client.change_presence(game = updated_game)
  843.         print('Setting game to: Playing {0}'.format(str(updated_game)))
  844.         await asyncio.sleep(300)
  845.  
  846.  
  847. @client.event
  848. async def on_ready():
  849.     global start, statuses
  850.     print('Logged in as:', client.user.name)
  851.     print('Client ID:',client.user.id)
  852.     print('Loading files...')
  853.     reload_files()
  854.     if success == False:
  855.         print('Files loaded successfully')
  856.     else:
  857.         print("Loading of files unsuccessfull")
  858.     end = timeit.timeit()
  859.     print('Started up in', round((end - start)*100, 2), 'seconds')
  860.     client.loop.create_task(task_loop())
  861.     await asyncio.sleep(0.5)
  862.     print('------------')
  863.    
  864.    
  865. client.run(TOKEN)
  866.  
  867. #ToDo List: Higher and Lower game... requires ranking system, will work later
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement