Advertisement
Faerlynn

Miku v0.15.1 (10.12.2018)

Dec 10th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 37.52 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.  
  178.  
  179. @client.event
  180. async def on_message(message):
  181.     global game_number, game_active, error, round_active, attempts, about, player, author, msg, version, s_id, gmn_cp, success
  182.     global miku_message, edits, statuses
  183.     if message.author == client.user:
  184.         return
  185.  
  186.     if not message.server.id in s_id:
  187.         s_id[message.server.id] = '$'
  188.         print('Creating a backup...')
  189.         msg = 'Creating a first settings for your server!'
  190.         await client.send_message(message.channel, msg)
  191.         save()
  192.         reload_files()
  193.         return
  194.    
  195.     #done       HELLO
  196.     if message.content.startswith('{0}hello'.format(s_id[message.server.id])):
  197.         cmd = 'hello'
  198.         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])
  199.         log(msg, message.channel, message.author, cmd)
  200.         await client.send_message(message.channel, msg)
  201.  
  202.     #done       LOVE
  203.     if message.content.startswith('{0}love'.format(s_id[message.server.id])):
  204.         cmd = 'love'
  205.         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*"
  206.         log(msg, message.channel, message.author, cmd)
  207.         await client.send_message(message.channel, msg)
  208.  
  209.     #done       RANDOM NUMBER
  210.     if message.content.startswith('{0}random'.format(s_id[message.server.id])):
  211.         cmd = 'random'
  212.         msg = ('Randomly generated number: '+str(random.randrange(101)))
  213.         log(msg, message.channel, message.author, cmd)
  214.         await client.send_message(message.channel, msg)
  215.  
  216.     #done       POKE
  217.     if message.content.startswith('{0}poke'.format(s_id[message.server.id])):
  218.         cmd = "poke"
  219.         msg = str(message.content)[6:]
  220.         msg_list = msg.split(' ')
  221.         msg_recipient = ''
  222.         msg_author = str(message.author)[:-5]
  223.         msg_content_test = False
  224.         for i in range(len(msg_list)):
  225.             msg_check = msg_list[i]
  226.             if (('<@!' and '>') in msg_check) == True:
  227.                 msg_recipient = msg_check
  228.                 msg_content_test = True
  229.         if msg_content_test == False:
  230.             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.*"
  231.         else:
  232.             msg = '*' + msg_author + " pokes " + msg_recipient + "'s shoulder gently and then just waits for their response patiently.*"
  233.         log(msg, message.channel, message.author, cmd)
  234.         await client.send_message(message.channel, msg)
  235.         if msg_recipient == '<@!492432534181773313>':
  236.             time.sleep(1)
  237.             msg = "*She looks at {0.author.mention} curiously, and after moment she pokes {0.author.mention}'s nose back.*".format(message)
  238.             await client.send_message(message.channel, msg)
  239.  
  240.     #done       CUDDLE
  241.     if message.content.startswith('{0}cuddle'.format(s_id[message.server.id])):
  242.         cmd = 'cuddle'
  243.         try:
  244.             msg = str(message.content)[8:]
  245.             msg_list = msg.split(' ')
  246.             msg_recipient = ''
  247.             msg_author = str(message.author)[:-5]
  248.             msg_content_test = False
  249.            
  250.             for i in range(len(msg_list)):
  251.                 msg_check = msg_list[i]
  252.                 if (('<@!' and '>') in msg_check) == True:
  253.                     msg_recipient = msg_check
  254.                     msg_content_test = True
  255.            
  256.             if not msg_content_test:
  257.                 msg = '*' + msg_author + " cuddles their pillow, smiling but alone.*"
  258.             else:
  259.                 msg = random.choice(cuddle_message).format(msg_author, msg_recipient)
  260.             log(msg, message.channel, message.author, cmd)
  261.        
  262.             await client.send_message(message.channel, msg)
  263.         except ValueError in error:
  264.             print(error)
  265.             await client.send_message(message.channel, 'Something went wrong.... :sob:')
  266.        
  267.  
  268.     #done       HUG
  269.     if message.content.startswith('{0}hug'.format(s_id[message.server.id])):
  270.         cmd = 'hug'
  271.         msg = str(message.content)[5:]
  272.         msg_list = msg.split(' ')
  273.         msg_recipient = ''
  274.         msg_author = str(message.author)[:-5]
  275.         msg_content_test = False
  276.         for i in range(len(msg_list)):
  277.             msg_check = msg_list[i]
  278.             if (('<@!' and '>') in msg_check) == True:
  279.                 msg_recipient = msg_check
  280.                 msg_content_test = True
  281.         if not msg_content_test:
  282.             msg_recipient = 'bottle of expensive red wine'
  283.         msg = random.choice(hug_message).format(msg_author, msg_recipient)
  284.         log(msg, message.channel, message.author, cmd)
  285.         try:
  286.             await client.send_message(message.channel, msg)
  287.         except ValueError in error:
  288.             print(error)
  289.             await client.send_message(message.channel, 'Something went wrong.... :sob:')
  290.  
  291.     #done       KISS
  292.     if message.content.startswith('{0}kiss'.format(s_id[message.server.id])):
  293.         cmd = 'kiss'
  294.         msg = str(message.content)[5:]
  295.         msg_list = msg.split(' ')
  296.         msg_recipient = ''
  297.         msg_author = str(message.author)[:-5]
  298.         msg_content_test = False
  299.         for i in range(len(msg_list)):
  300.             msg_check = msg_list[i]
  301.             if (('<@!' and '>') in msg_check) == True:
  302.                 msg_recipient = msg_check
  303.                 msg_content_test = True
  304.         if msg_content_test == False:
  305.             msg_recipient = 'bottle of expensive red wine'
  306.         msg = random.choice(kiss_message).format(msg_author, msg_recipient)
  307.         log(msg, message.channel, message.author, cmd)
  308.         try:
  309.             await client.send_message(message.channel, msg)
  310.         except ValueError in error:
  311.             print(error)
  312.             await client.send_message(message.channel, 'Something went wrong.... :sob:')
  313.  
  314.     #done       PAT
  315.     if message.content.startswith('{0}pat'.format(s_id[message.server.id])):
  316.         cmd = 'pat'
  317.         if '{0}pat '.format(s_id[message.server.id]) in message.content:
  318.             msg = str(message.content)[4:]
  319.             msg_list = msg.split(' ')
  320.             msg_recipient = ''
  321.             msg_author = str(message.author)[:-5]
  322.             msg_content_test = False
  323.             for i in range(len(msg_list)):
  324.                 msg_check = msg_list[i]
  325.                 if (('<@!' and '>') in msg_check) == True:
  326.                     msg_recipient = msg_check
  327.                     msg_content_test = True
  328.             if msg_content_test == False:
  329.                 msg_recipient = 'invisible unicorn'
  330.             msg = random.choice(pat_message).format(msg_author, msg_recipient)
  331.             log(msg, message.channel, message.author, cmd)
  332.             try:        
  333.                 await client.send_message(message.channel, msg)
  334.             except ValueError in error:
  335.                 print(error)
  336.                 await client.send_message(message.channel, 'Something went wrong.... :sob:')
  337.  
  338.     #SLAP
  339.     if message.content.startswith('{0}slap'.format(s_id[message.server.id])):
  340.         cmd = 'slap'
  341.         if '{0}slap '.format(s_id[message.server.id]) in message.content:
  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 msg_content_test == False:
  353.                 msg_recipient = 'air'
  354.             if msg_recipient == str(message.author.mention):
  355.                 msg = random.choice(pat_message).format('Miku', msg_recipient)
  356.             else:
  357.                 msg = random.choice(slap_message).format(msg_author, msg_recipient)
  358.             log(msg, message.channel, message.author, cmd)
  359.             try:
  360.                 await client.send_message(message.channel, msg)
  361.             except ValueError in error:
  362.                 print(error)
  363.                 await client.send_message(message.channel, 'Something went wrong.... :sob:')
  364.    
  365.  
  366.     #WIP               <-----------------------------------------------------
  367.     if message.content.startswith('{0}help'.format(s_id[message.server.id])):
  368.         cmd = 'help'
  369.         msg = """**{0}hello** - yes, this is my greeting to all of you, my users! ^~^
  370.        **{0}kiss @user** - kisses your lovely friend
  371.        **{0}hug @user** - hugs your hugging-friend
  372.        **{0}poke @user** - pokes your victim
  373.        **{0}cuddle @user** - cuddles your cuddle pillow friend
  374.        **{0}pat @user** - pat your friend's head and make them blush with happiness
  375.        **{0}slap @user** - slap someone who's being rude! Ouch!
  376.        **{0}rnf x z** - gives you random number from between numbers **x** and **z**
  377.        **{0}random** - gives you random number between **0** and **100**
  378.        **{0}choice a, b, c, d, ...** - makes a choice for you from the list words, each one divided with ","
  379.        **{0}rc** - gives you a random colour in hex format
  380.        **{0}coinflip** - flips the coin. Try your luck!
  381.        **{0}gmn** - first minigame! Guess my number! Collect points and get on top of the leaderboard! ***<Rankings And Points Not Yet Implemented>***
  382.        **{0}invite** - sends you a special link with which you can invite this bot to ***your own server***
  383.        **{0}about** - do you want to learn more about me and my creator? Don't wait any longer!
  384.        **{0}chart** - shows you a simple japanese katakana and hiragana chart! *For all weebs who can't type in their mother language..* >.>
  385.        **{0}prefix set <prefix>** - allows owner of the server to change prefix to which my commands will react in that server
  386.        **{0}lewd** - *winks*""".format(s_id[message.server.id])
  387.         color = 4122822
  388.         embed = discord.Embed(title = 'List of my commands:', description = msg, color = color)
  389.         log(msg, message.channel, message.author, cmd)
  390.         await client.send_message(message.author, embed = embed)
  391.         await client.add_reaction(message, '\U00002705')
  392.  
  393.     #done       ABOUT
  394.     if message.content.startswith('{0}about'.format(s_id[message.server.id])):
  395.         cmd = 'about'
  396.         log(msg, message.channel, message.author, cmd)
  397.         await client.send_message(message.channel, about)
  398.  
  399.     #done       CHART
  400.     if message.content.startswith('{0}chart'.format(s_id[message.server.id])):
  401.         cmd = 'chart'
  402.         msg = '''**日 a i u e o a i u e o 本
  403.        ー ア イ ウ エ オ あ い う え お
  404.        k カ キ ク ケ コ か き く け こ
  405.        s サ シ ス デ ソ さ し す せ そ
  406.        t タ チ ツ テ ト た ち つ て と
  407.        n ナ ニ ヌ ネ ノ な に ぬ ね の
  408.        m マ ミ ム メ モ ま み む め も
  409.        r ラ リ ル レ ロ ら り る れ ろ
  410.        h ハ ヒ フ ヘ ホ は ひ ふ へ ほ
  411.        w ワ       ヲ わ       を
  412.        y ヤ   ユ   ヨ や   ゆ   よ
  413.        n ン         ん**'''
  414.         color = 4122822
  415.         embed = discord.Embed(title = 'Katakana and hiragana chart:', description = msg, color = color)
  416.         log(msg, message.channel, message.author, cmd)
  417.         await client.send_message(message.channel, embed = embed)
  418.  
  419.     #done       AYAYA AYAYAAAAAA
  420.     if (message.content.startswith('ayaya')) or (message.content.startswith('AYAYA')):
  421.         cmd = 'ayaya'
  422.         msg = '''**⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣬⡛⣿⣿⣿⣯⢻
  423. ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⢻⣿⣿⢟⣻⣿⣿⣿⣿⣿⣿⣮⡻⣿⣿⣧
  424. ⣿⣿⣿⣿⣿⢻⣿⣿⣿⣿⣿⣿⣆⠻⡫⣢⠿⣿⣿⣿⣿⣿⣿⣿⣷⣜⢻⣿
  425. ⣿⣿⡏⣿⣿⣨⣝⠿⣿⣿⣿⣿⣿⢕⠸⣛⣩⣥⣄⣩⢝⣛⡿⠿⣿⣿⣆⢝
  426. ⣿⣿⢡⣸⣿⣏⣿⣿⣶⣯⣙⠫⢺⣿⣷⡈⣿⣿⣿⣿⡿⠿⢿⣟⣒⣋⣙⠊
  427. ⣿⡏⡿⣛⣍⢿⣮⣿⣿⣿⣿⣿⣿⣿⣶⣶⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿
  428. ⣿⢱⣾⣿⣿⣿⣝⡮⡻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⠛⣋⣻⣿⣿⣿⣿
  429. ⢿⢸⣿⣿⣿⣿⣿⣿⣷⣽⣿⣿⣿⣿⣿⣿⣿⡕⣡⣴⣶⣿⣿⣿⡟⣿⣿⣿
  430. ⣦⡸⣿⣿⣿⣿⣿⣿⡛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⣿⣿⣿
  431. ⢛⠷⡹⣿⠋⣉⣠⣤⣶⣶⣿⣿⣿⣿⣿⣿⡿⠿⢿⣿⣿⣿⣿⣿⣷⢹⣿⣿
  432. ⣷⡝⣿⡞⣿⣿⣿⣿⣿⣿⣿⣿⡟⠋⠁⣠⣤⣤⣦⣽⣿⣿⣿⡿⠋⠘⣿⣿
  433. ⣿⣿⡹⣿⡼⣿⣿⣿⣿⣿⣿⣿⣧⡰⣿⣿⣿⣿⣿⣹⡿⠟⠉⡀⠄⠄⢿⣿
  434. ⣿⣿⣿⣽⣿⣼⣛⠿⠿⣿⣿⣿⣿⣿⣯⣿⠿⢟⣻⡽⢚⣤⡞⠄⠄⠄⢸⣿**'''
  435.         log(msg, message.channel, message.author, cmd)
  436.         await client.send_message(message.channel, msg)
  437.  
  438.     #done       INVITE
  439.     if message.content.startswith('{0}invite'.format(s_id[message.server.id])):
  440.         msg = "*You can invite me to your server using this link:*\nhttps://discordapp.com/oauth2/authorize?client_id=492432534181773313&scope=bot"
  441.         await client.send_message(message.author, msg)
  442.  
  443.     #done       CHOICE
  444.     if message.content.startswith('{0}choice'.format(s_id[message.server.id])):
  445.         cmd = 'choice'
  446.         msg = message.content[8:]
  447.         choice_list = []
  448.         choice_list = msg.split(',')
  449.         msg = "I've randomly chosen this for you: " + str(random.choice(choice_list))
  450.         log(msg, message.channel, message.author, cmd)
  451.         await client.send_message(message.channel, msg)
  452.  
  453.     #done       PATCHNOTES
  454.     if message.content.startswith('{0}patchnotes'.format(s_id[message.server.id])):
  455.         cmd = 'patchnotes'
  456.         p_notes_split = patchnotes.split('<$>')
  457.         #print(p_notes_split)
  458.         log(msg, message.channel, message.author, cmd)
  459.         for i in p_notes_split:
  460.             msg = '```{0}```'.format(i)
  461.             await client.send_message(message.author, msg)
  462.  
  463.     #done       VERSION
  464.     if message.content.startswith('{0}version'.format(s_id[message.server.id])):
  465.         cmd = 'version'
  466.         msg = '`Current version of this bot is: {0}`'.format(version)
  467.         log(msg, message.channel, message.author, cmd)
  468.         await client.send_message(message.channel, msg)
  469.  
  470.     #done       RANDOM NUMBER X Z
  471.     if message.content.startswith('{0}rnf'.format(s_id[message.server.id])):
  472.         cmd = 'random number from <x, z>'
  473.         msg = message.content[5:]
  474.         numbers = []
  475.         numbers = msg.split(' ')
  476.         log(msg, message.channel, message.author, cmd)
  477.         error = ''
  478.         if len(numbers) == (1 or 0):
  479.             msg = 'You need two numbers!'
  480.             await client.send_message(message.channel, msg)
  481.         else:
  482.             try:
  483.                 print(numbers[0], numbers[1])
  484.                 a = int(round(float(numbers[0])))
  485.                 b = int(round(float(numbers[1])))
  486.                 print(a, b)
  487.                
  488.                 if a >= b:
  489.                     c = a
  490.                     a = b
  491.                     b = c
  492.                    
  493.                 if a == b:
  494.                     msg = "Your random number is not really random, but here you go: {0}".format(a)
  495.                 else:
  496.                     num = random.randrange(a, b+1)
  497.                     msg = "Your random number is: " + str(num)
  498.                 await client.send_message(message.channel, msg)
  499.                
  500.             except ValueError as error:
  501.                 print(error)
  502.                 msg = 'Something went wrong!'
  503.                 await client.send_message(message.channel, msg)
  504.  
  505.     #done       COINFLIP
  506.     if message.content.startswith('{0}coinflip'.format(s_id[message.server.id])):
  507.         cmd = 'coinflip'
  508.         num = random.randrange(1000)+1
  509.         if num == 741:
  510.             msg = "***It landed on it's side! How lucky!!!***"
  511.         else:
  512.             if num == 274:
  513.                 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..."
  514.             else:
  515.                 if num > 500:
  516.                     msg = 'Heads!' + '!'*random.randrange(4)
  517.                 else:
  518.                     msg = 'Tails!' + '!'*random.randrange(4)
  519.         #log(msg, message.channel, message.author, cmd)
  520.         print("Command '$" + cmd + "' used in " + str(message.channel) + ' by ' + str(message.author) +'! Rolled: ' + str(num))
  521.         await client.send_message(message.channel, msg)
  522.  
  523.     #done       RANDOM COLOUR
  524.     if message.content.startswith('{0}rc'.format(s_id[message.server.id])):
  525.         cmd = 'random colour'
  526.         color = random.randrange(256**3)
  527.         print(color)
  528.         msg = str(f'#{color:06x}')
  529.         embed = discord.Embed(title = 'Your random colour: ', description = msg, color = color)
  530.         log(str(msg), message.channel, message.author, cmd)
  531.         await client.send_message(message.channel, embed = embed)
  532.  
  533.     #done       GUESS MY NUMBER
  534.     if message.content.startswith('{0}gmn'.format(s_id[message.server.id])):
  535.        
  536.         if not str(message.author) in gmn_cp:
  537.             gmn_cp[str(message.author)] = False
  538.             gmn_a[str(message.author)] = 0
  539.             gmn_number[str(message.author)] = 0
  540.            
  541.         if gmn_cp[str(message.author)] == False:
  542.             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..!!")
  543.             time.sleep(0.25)
  544.             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]))
  545.             game_number = random.randrange(100)+1
  546.             gmn_number[str(message.author)] = game_number
  547.             gmn_a[str(message.author)] = 0
  548.             player = str(message.author)
  549.             gmn_cp[str(message.author)] = True
  550.            
  551.         elif gmn_cp[str(message.author)] == True:
  552.             number = message.content[4:]
  553.             try:
  554.                 number = int(number)
  555.                 gmn_cp[str(message.author)] = True
  556.                
  557.                 if gmn_number[str(message.author)] == number:
  558.                     msg = "Y-yes..! That's the number I.. I've been thinking of! Y-you are so good s-senpai! :heart_eyes:"
  559.                     gmn_a[str(message.author)] = 0
  560.                     await client.send_message(message.channel, msg)
  561.                     gmn_a[str(message.author)] = 0
  562.                     gmn_cp[str(message.author)] = False
  563.  
  564.                    
  565.                 elif (gmn_a[str(message.author)] == 0) and (gmn_cp[str(message.author)] == True):
  566.  
  567.                     if gmn_number[str(message.author)] < number:
  568.                         msg = "T-that's not it, s-senpai..! :flushed: Your n-number is too b-big.. T-try again..! *blushes*"
  569.                         await client.send_message(message.channel, msg)
  570.                     else:
  571.                         msg = "T-that's not it, s-senpai..! :flushed: Your n-number is not b-big enough.. T-try again..! *blushes*"
  572.                         await client.send_message(message.channel, msg)
  573.  
  574.                     gmn_a[str(message.author)] = 1
  575.                     print('New game! Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
  576.                    
  577.                 elif (gmn_a[str(message.author)] == 1) and (gmn_cp[str(message.author)] == True):
  578.  
  579.                    
  580.                     if gmn_number[str(message.author)] < number:
  581.                         msg = "N-no senpai... S-still not my number.. It's n-not that big..."
  582.                         await client.send_message(message.channel, msg)
  583.                     else:
  584.                         msg = "N s-senpai... S-still not my special number.. It's even higher..."
  585.                         await client.send_message(message.channel, msg)
  586.                        
  587.                     gmn_a[str(message.author)] = 2
  588.                     print('Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
  589.  
  590.                    
  591.                 elif (gmn_a[str(message.author)] == 2) and (gmn_cp[str(message.author)] == True):
  592.                    
  593.                     if gmn_number[str(message.author)] < number:
  594.                         msg = "That's again n-not my n-number *blushes* T-too big..! Last chance..!"
  595.                         await client.send_message(message.channel, msg)
  596.                     else:
  597.                         msg = "N-not my n-number, senpai..! *blushes* Go h-higher..! L-last attempt..!"
  598.                         await client.send_message(message.channel, msg)
  599.                        
  600.                     gmn_a[str(message.author)] = 3
  601.                     print('Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
  602.                    
  603.                 elif (gmn_a[str(message.author)] == 3) and (gmn_cp[str(message.author)] == True):
  604.                    
  605.                     if gmn_number[str(message.author)] < number:
  606.                         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)])
  607.                         await client.send_message(message.channel, msg)
  608.                     else:
  609.                         msg = "S-senpai..! T-that's not my number..! I was t-thinking of a number " + str(gmn_number[str(message.author)])
  610.                         await client.send_message(message.channel, msg)
  611.                        
  612.                     print('Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
  613.                     gmn_a[str(message.author)] = 0
  614.                     gmn_cp[str(message.author)] = False
  615.                    
  616.             except:
  617.                 await client.send_message(message.channel, "That's not a number, b-baka s-senpai..!!")
  618.         else:
  619.             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:")
  620.  
  621.  
  622.     #done       LEWD
  623.     if message.content.startswith('{0}lewd'.format(s_id[message.server.id])):
  624.         if str(message.author) == 'Ana#3140':
  625.             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..!__***'
  626.         else:
  627.             msg = '**Y-YOU ARE SO L-LEWD, SENPAI**' + '!'*int(random.randrange(9)+3)
  628.         await client.send_message(message.channel, msg)
  629.  
  630.     #done       SERVER PREFIX CHANGE
  631.     if message.content.startswith('{0}prefix set'.format(s_id[message.server.id])):
  632.         if message.author == message.server.owner:
  633.             try:
  634.                 prefix = message.content[12:]
  635.                 if len(prefix) > 1:
  636.                     msg = 'Prefix can consist of only one character!'
  637.                 else:
  638.                     s_id[message.server.id] = str(prefix)
  639.                     save()
  640.                     reload_files()
  641.                     msg = 'Prefix of this server has been changed to {0}'.format(prefix)
  642.             except:
  643.                 msg = 'Something went wrong!'
  644.         else:
  645.             msg = "I'm sorry s-senpai, b-but you are n-not owner of t-this server!"
  646.         await client.send_message(message.channel, msg)
  647.                
  648.  
  649.     #bet reaction
  650.     if (message.content.startswith('bet'))or (message.content.startswith('beet')) or (message.content.startswith('Bet')):
  651.         num = random.randrange(10000)
  652.         if num == 2714:
  653.             msg = 'BEEEEEEEEEEEEEEEEEEEEEEEEEEEET!!!!!'
  654.             await client.send_message(message.channel, msg)
  655.         else:
  656.             if num == 8743:
  657.                 msg = 'No bets allowed to underage trolls (That means you are not allowed to bet if you are not 18+.... B-baka senpai.. >.>)'
  658.                 await client.send_message(message.channel, msg)
  659.             else:
  660.                 msg = "{0}bet{0}".format(edits[random.randrange(5)])
  661.                 await client.send_message(message.channel, msg)
  662.  
  663.     #miku reaction
  664.     if ("Miku" in message.content) or ("miku" in message.content):
  665.         time.sleep(0.37)
  666.         msg = random.choice(miku_message).format(message.author.mention)
  667.         await client.send_message(message.channel, msg)
  668.  
  669.     #Reactions for other bots
  670.     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]))):
  671.         time.sleep(1)
  672.         #print(message.content)
  673.         msg = 'Awwwwww t-thanks a lot for petting me, {0}! :sparkling_heart: :heart_eyes: ^~^'.format(message.author.mention)
  674.         await client.send_message(message.channel, msg)
  675.  
  676.     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]))):
  677.         time.sleep(1)
  678.         msg = 'Oh~, thanks s-senpai for hug! *she hugs {0} back tightly, smiling and blushing.*'.format(message.author.mention)
  679.         await client.send_message(message.channel, msg)
  680.  
  681.     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]))):
  682.         time.sleep(1)
  683.         msg = '*She giggles and cuddles {0} back, slightly stroking their back, still giggling.*'.format(message.author.mention)
  684.         await client.send_message(message.channel, msg)
  685.        
  686.     if message.content.startswith(('{0}poke <@!492432534181773313>'.format(s_id[message.server.id])) or ('{0}poke <@492432534181773313>'.format(s_id[message.server.id]))):
  687.         time.sleep(1)
  688.         msg = "*She looks at {0} curiously, and then she pokes {0} back.*".format(message.author.mention)
  689.         await client.send_message(message.channel, msg)
  690.  
  691.     if message.content.startswith(('{0}slap <@!492432534181773313>'.format(s_id[message.server.id])) or ('{0}slap <@492432534181773313>'.format(s_id[message.server.id]))):
  692.         time.sleep(1)
  693.         msg = '*She slaps {0} back, looking angry, annoyed but dissappointed and sad as well...*'.format(message.author.mention)
  694.         await client.send_message(message.channel, msg)
  695.  
  696.  
  697.     #dev only functions
  698.  
  699.     #done       STOP
  700.     if (message.content.startswith('{0}stop'.format(s_id[message.server.id]))) or (message.content.startswith('{0}bye'.format(s_id[message.server.id]))):
  701.         author = str(message.author)
  702.         cmd = 'stop'
  703.         msg = ''
  704.         log(msg, message.channel, message.author, cmd)
  705.         if (author == 'Ana#3140') or (author == 'Cutie Kitty#0068'):
  706.             msg = 'Good bye!'
  707.             await client.send_message(message.channel, msg)
  708.             print('Good b-bye Ana s-senpai~ <3')
  709.             client.logout()
  710.             save()
  711.             sys.exit(0)
  712.         else:
  713.             msg = 'Insufficient permissions...'
  714.             await client.send_message(message.channel, msg)
  715.  
  716.     #done       RELOAD FILES
  717.     if message.content.startswith('{0}rf'.format(s_id[message.server.id])):
  718.         cmd = 'reload files'
  719.         log(msg, message.channel, message.author, cmd)
  720.         author = str(message.author)
  721.         if author == 'Ana#3140':
  722.             reload_files()
  723.             if success == False:
  724.                 print('Files reloaded successfully...')
  725.             else:
  726.                 print('Reload unsuccessful...')
  727.         else:
  728.             msg = 'Insufficient permissions...'
  729.             await client.send_message(message.channel, msg)
  730.  
  731.     #done       CHANGE GAME STATUS
  732.     if message.content.startswith('{0}game'.format(s_id[message.server.id])):
  733.         cmd = 'game status'
  734.         if (str(message.author) == 'Ana#3140') or (str(message.author) == 'Cutie Kitty#0068'):
  735.             me = discord.utils.find(lambda s: s != None, client.servers).me
  736.             if not me:
  737.                     return
  738.             elif not me.game:
  739.                     updated_game = discord.Game(name = random.choice(statuses))
  740.             else:
  741.                     updated_game = me.game
  742.                     updated_game.name = random.choice(statuses)
  743.             await client.change_presence(game = updated_game)
  744.             print('Changing game to:{0}'.format(str(updated_game)))
  745.            
  746.  
  747.     #done       PATCH CHANGE
  748.     if message.content.startswith('{0}patch set'.format(s_id[message.server.id])):
  749.         author = str(message.author)
  750.         cmd = 'patch'
  751.         msg = ''
  752.         patch = ''
  753.         log(msg, message.channel, message.author, cmd)
  754.         if author == 'Ana#3140':
  755.             try:
  756.                 msg = 'Done!'
  757.                 patch = message.content
  758.                 patch = patch[11:]
  759.                 os.remove('bot_save_files\patch.txt')
  760.                 file = open('bot_save_files\patch.txt', 'w')
  761.                 file.write(str(patch))
  762.                 file.close()
  763.                 version = patch
  764.                 print('Current patch changed to {0}'.format(patch))
  765.                 await client.send_message(message.channel, msg)
  766.             except:
  767.                 print('Something went wrong!')
  768.            
  769.     #WIP        TEST COMMAND
  770.     if message.content.startswith('{0}test'.format(s_id[message.server.id])):
  771.         cmd = 'test'
  772.         file = open('bot_save_files\\server_id.txt', 'a')
  773.         file.write(str(str(s_id.keys()).split("'")))
  774.         file.close()
  775.        
  776.         try:
  777.             print(message.author.id, message.content, message.server, message.server.id)
  778.             await client.send_message(message.channel, message.server.id)
  779.         except:
  780.             print(error)
  781.        
  782.  
  783. statuses = ["with Lily", "with Ana", "with Yuno", "with Eri", "with Honoka", "with Nico", "with Nico", "with Nico Nico Niii~",
  784.             "with Maki", "with herself", "with her toys", "with Nozomi", "with Kotori", "with Umi", "with Rin", "with Hanayo",
  785.             "with Chika", "with Riko", "with Kanan", "with Dia", "with You-chan", "with Yoshiko", "with Yohanne", "with Hanamaru zuraaa~",
  786.             "with Mari", "with Ruby", "with Taiga", "with her phone", "with Toastie", "with daddy Ado", "with adorable Ana-chan",
  787.             "with Mashiro", "with Yuzu", "with Katalina", "with her creator", "with Angela", "with her hair", "with Aqours", "with µ's",
  788.             "with Luka", "Doki Doki Literature Club", "with Natsuki..?", "with Yuri", "with Sayori", "with Hana", "with her friends",
  789.             "with Faerlynn"]
  790.  
  791.  
  792. async def task_loop():
  793.     while True:
  794.         me = discord.utils.find(lambda s: s != None, client.servers).me
  795.         if not me:
  796.                 return
  797.         elif not me.game:
  798.                 updated_game = discord.Game(name = random.choice(statuses))
  799.         else:
  800.                 updated_game = me.game
  801.                 updated_game.name = random.choice(statuses)
  802.         await client.change_presence(game = updated_game)
  803.         print('Setting game to: Playing {0}'.format(str(updated_game)))
  804.         await asyncio.sleep(180)
  805.  
  806.  
  807. @client.event
  808. async def on_ready():
  809.     global start, statuses
  810.     print('Logged in as:', client.user.name)
  811.     print('Client ID:',client.user.id)
  812.     print('Loading files...')
  813.     reload_files()
  814.     if success == False:
  815.         print('Files loaded successfully')
  816.     else:
  817.         print("Loading of files unsuccessfull")
  818.     end = timeit.timeit()
  819.     print('Started up in', round((end - start)*100, 2), 'seconds')
  820.     client.loop.create_task(task_loop())
  821.     await asyncio.sleep(0.5)
  822.     print('------------')
  823.    
  824.    
  825. client.run(TOKEN)
  826.  
  827. #ToDo List: Higher and Lower game... requires ranking system, will work later
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement