Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- import random
- import time
- import os
- import timeit
- import sys
- import asyncio
- from youtube_dl import YoutubeDL
- from apiclient.discovery import build
- import datetime
- import ctypes
- client = discord.Client()
- def log(msg, message_channel, message_author, cmd_type):
- if cmd_type == '':
- cmd_type = 'unknown'
- #print("Command '" + cmd_type + "' used in " + str(message_channel) + ' by ' + str(message_author) +'!')
- print('Command \'{0}\' used in {1} by {2}!'.format(cmd_type, str(message_channel), str(message_author)))
- def reload_files():
- global cuddle_message, hug_message, kiss_message, about, patchnotes, pat_message, version, slap_message, s_id, success
- global miku_message, dev_key, youtube
- #Opens file for 'cuddle'
- success = False
- try:
- file = open("bot_save_files\cuddle_messages.txt",'r')
- line = file.readline()
- cuddle_message = []
- while line:
- cuddle_message.append(line)
- line = file.readline()
- file.close()
- except:
- print("File 'cuddle_messages.txt' couldn't be opened!")
- success = True
- #Opens file for 'hug'
- try:
- file = open("bot_save_files\hug_messages.txt",'r')
- line = file.readline()
- hug_message = []
- while line:
- hug_message.append(line)
- line = file.readline()
- file.close()
- except:
- print("File 'hug_messages.txt' couldn't be opened!")
- success = True
- #Opens file for 'pat'
- try:
- file = open("bot_save_files\pat_messages.txt",'r')
- line = file.readline()
- pat_message = []
- while line:
- pat_message.append(line)
- line = file.readline()
- file.close()
- except:
- print("File 'pat_messages.txt' couldn't be opened!")
- success = True
- #Opens file for 'kiss'
- try:
- file = open("bot_save_files\kiss_messages.txt",'r')
- line = file.readline()
- kiss_message = []
- while line:
- kiss_message.append(line)
- line = file.readline()
- file.close()
- except:
- print("File 'kiss_messages.txt' couldn't be opened!")
- success = True
- #Opens file for 'about'
- try:
- about = ''
- file = open("bot_save_files\\about.txt",'r')
- about = file.read()
- file.close()
- except:
- print("File 'about.txt' couldn't be opened!")
- success = True
- #Opens file for 'about'
- try:
- version = ''
- file = open("bot_save_files\\patch.txt",'r')
- version = file.read()
- file.close()
- except:
- print("File 'patch.txt' couldn't be opened!")
- success = True
- #Opens file for 'patchnotes'
- try:
- patchnotes = ''
- file = open("bot_save_files\\patch_notes.txt",'r')
- patchnotes = file.read()
- file.close()
- except:
- print("File 'patch_notes.txt' couldn't be opened!")
- success = True
- #Opens file for 'slap'
- try:
- file = open("bot_save_files\slap_messages.txt",'r')
- line = file.readline()
- slap_message = []
- while line:
- slap_message.append(line)
- line = file.readline()
- file.close()
- except:
- print("File 'slap_messages.txt' couldn't be opened!")
- success = True
- #Opens fire for s_id
- s_id = {}
- try:
- file = open("bot_save_files\server_id.txt",'r')
- line = file.readline()
- while line:
- key, value = line.split(':')
- s_id[key] = value[:1]
- line = file.readline()
- file.close()
- except:
- print("File 'server_id.txt' couldn't be opened!")
- success = True
- #Opens file for 'miku reaction'
- try:
- file = open("bot_save_files\miku_reaction_msg.txt",'r')
- line = file.readline()
- miku_message = []
- while line:
- miku_message.append(line)
- line = file.readline()
- file.close()
- except:
- print("File 'miku_reaction_msg.txt' couldn't be opened!")
- success = True
- #Loads dev_key
- file = open('bot_save_files\dev_key.txt', 'r')
- dev_key = file.readline()
- file.close()
- youtube = build('youtube', 'v3', developerKey=dev_key)
- return success
- def save():
- global s_id
- key, value = '', ''
- s_id_file = ''
- for key, value in s_id.items():
- s_id_file = s_id_file + "{0}:{1}\n".format(key, value)
- os.remove("bot_save_files\server_id.txt")
- file = open("bot_save_files\server_id.txt",'w')
- file.write(str(s_id_file))
- file.close()
- #startup variables
- ydl_opts = {
- 'format': 'bestaudio/best',
- 'outtmpl': 'tmp/%(id)s.%(ext)s',
- 'noplaylist': True,
- 'quiet': True,
- 'prefer_ffmpeg': True,
- 'audioformat': 'wav',
- 'forceduration':True
- }
- game_number = 274**21
- game_active = False
- attempts = 0
- round_active = False
- error = ''
- player = ''
- author = ''
- msg = ''
- gmn_cp = {}
- gmn_number = {}
- gmn_a = {}
- edits = ['*', '__', '~~', '**', '***']
- players = {}
- playlist = {}
- cp = {}
- loop = {}
- lp = {}
- ytdl = YoutubeDL()
- urls = {}
- cpsong = {}
- miku_names = ['miku', 'Miku', 'M I K U', 'MIKU', 'm i k u', 'mIku', 'miKu', 'mikU', 'MIku', 'MiKu',
- 'MikU', 'mIKu', 'mIkU', 'mIKU', 'MiKU', 'MIkU', 'MIKu', 'miKU']
- play_list = {}
- info = {}
- dev_key = ''
- #@client.event
- async def message_in(message, c):
- global game_number, game_active, error, round_active, attempts, about, player, author, msg, version, s_id, gmn_cp, success
- global miku_message, edits, statuses, players, vc, playlist, cp, loop, lp, miku_names, cpsong
- global play_list, ytdl, dev_key, youtube, client
- client = c
- if message.author == client.user:
- return
- sid = message.server.id
- if not message.server.id in s_id:
- s_id[message.server.id] = '$'
- print('Creating a backup...')
- msg = 'Creating a first settings for your server!'
- await client.send_message(message.channel, msg)
- save()
- reload_files()
- return
- #done HELLO
- if message.content.startswith('{0}hello'.format(s_id[sid])):
- cmd = 'hello'
- 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])
- log(msg, message.channel, message.author, cmd)
- await client.send_message(message.channel, msg)
- #done LOVE
- if message.content.startswith('{0}love'.format(s_id[sid])):
- cmd = 'love'
- 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*"
- log(msg, message.channel, message.author, cmd)
- await client.send_message(message.channel, msg)
- #done RANDOM NUMBER
- if message.content.startswith('{0}random'.format(s_id[sid])):
- cmd = 'random'
- msg = ('Randomly generated number: '+str(random.randrange(101)))
- log(msg, message.channel, message.author, cmd)
- await client.send_message(message.channel, msg)
- #done POKE
- if message.content.startswith('{0}poke'.format(s_id[sid])):
- cmd = "poke"
- msg = str(message.content)[6:]
- msg_list = msg.split(' ')
- msg_recipient = ''
- msg_author = str(message.author)[:-5]
- msg_content_test = False
- for i in range(len(msg_list)):
- msg_check = msg_list[i]
- if (('<@!' and '>') in msg_check) == True:
- msg_recipient = msg_check
- msg_content_test = True
- if msg_content_test == False:
- 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.*"
- else:
- msg = '*' + msg_author + " pokes " + msg_recipient + "'s shoulder gently and then just waits for their response patiently.*"
- log(msg, message.channel, message.author, cmd)
- await client.send_message(message.channel, msg)
- if msg_recipient == '<@!492432534181773313>':
- time.sleep(1)
- msg = "*She looks at {0.author.mention} curiously, and after moment she pokes {0.author.mention}'s nose back.*".format(message)
- await client.send_message(message.channel, msg)
- #done CUDDLE
- if message.content.startswith('{0}cuddle'.format(s_id[sid])):
- cmd = 'cuddle'
- try:
- msg = str(message.content)[8:]
- msg_list = msg.split(' ')
- msg_recipient = ''
- msg_author = str(message.author)[:-5]
- msg_content_test = False
- for i in range(len(msg_list)):
- msg_check = msg_list[i]
- if (('<@!' and '>') in msg_check) == True:
- msg_recipient = msg_check
- msg_content_test = True
- if not '!' in msg_recipient:
- msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
- if msg_recipient == str(message.author.mention):
- msg = random.choice(cuddle_message).format('Miku', msg_recipient)
- else:
- if not msg_content_test:
- msg = '*' + msg_author + " cuddles their pillow, smiling but alone.*"
- else:
- msg = random.choice(cuddle_message).format(msg_author, msg_recipient)
- log(msg, message.channel, message.author, cmd)
- await client.send_message(message.channel, msg)
- except ValueError in error:
- print(error)
- await client.send_message(message.channel, 'Something went wrong.... :sob:')
- #done HUG
- if message.content.startswith('{0}hug'.format(s_id[sid])):
- cmd = 'hug'
- msg = str(message.content)[5:]
- msg_list = msg.split(' ')
- msg_recipient = ''
- msg_author = str(message.author)[:-5]
- msg_content_test = False
- for i in range(len(msg_list)):
- msg_check = msg_list[i]
- if (('<@!' and '>') in msg_check) == True:
- msg_recipient = msg_check
- msg_content_test = True
- if not msg_content_test:
- msg_recipient = 'bottle of expensive red wine'
- if not '!' in msg_recipient:
- msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
- if msg_recipient == str(message.author.mention):
- msg = random.choice(hug_message).format('Miku', msg_recipient)
- else:
- msg = random.choice(hug_message).format(msg_author, msg_recipient)
- log(msg, message.channel, message.author, cmd)
- try:
- await client.send_message(message.channel, msg)
- except ValueError in error:
- print(error)
- await client.send_message(message.channel, 'Something went wrong.... :sob:')
- #done KISS
- if message.content.startswith('{0}kiss'.format(s_id[sid])):
- cmd = 'kiss'
- msg = str(message.content)[5:]
- msg_list = msg.split(' ')
- msg_recipient = ''
- msg_author = str(message.author)[:-5]
- msg_content_test = False
- for i in range(len(msg_list)):
- msg_check = msg_list[i]
- if (('<@!' and '>') in msg_check) == True:
- msg_recipient = msg_check
- msg_content_test = True
- if msg_content_test == False:
- msg_recipient = 'bottle of expensive red wine'
- if not '!' in msg_recipient:
- msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
- if msg_recipient == str(message.author.mention):
- msg = random.choice(kiss_message).format('Miku', msg_recipient)
- else:
- msg = random.choice(kiss_message).format(msg_author, msg_recipient)
- log(msg, message.channel, message.author, cmd)
- try:
- await client.send_message(message.channel, msg)
- except ValueError in error:
- print(error)
- await client.send_message(message.channel, 'Something went wrong.... :sob:')
- #done PAT
- if message.content.startswith('{0}pat'.format(s_id[sid])):
- cmd = 'pat'
- if '{0}pat '.format(s_id[sid]) in message.content:
- msg = str(message.content)[4:]
- msg_list = msg.split(' ')
- msg_recipient = ''
- msg_author = str(message.author)[:-5]
- msg_content_test = False
- for i in range(len(msg_list)):
- msg_check = msg_list[i]
- if (('<@!' and '>') in msg_check) == True:
- msg_recipient = msg_check
- msg_content_test = True
- if msg_content_test == False:
- msg_recipient = 'invisible unicorn'
- if not '!' in msg_recipient:
- msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
- if msg_recipient == str(message.author.mention):
- msg = random.choice(pat_message).format('Miku', msg_recipient)
- else:
- msg = random.choice(pat_message).format(msg_author, msg_recipient)
- log(msg, message.channel, message.author, cmd)
- try:
- await client.send_message(message.channel, msg)
- except ValueError in error:
- print(error)
- await client.send_message(message.channel, 'Something went wrong.... :sob:')
- #SLAP
- if message.content.startswith('{0}slap'.format(s_id[sid])):
- cmd = 'slap'
- if '{0}slap '.format(s_id[sid]) in message.content:
- msg = str(message.content)[5:]
- msg_list = msg.split(' ')
- msg_recipient = ''
- msg_author = str(message.author)[:-5]
- msg_content_test = False
- for i in range(len(msg_list)):
- msg_check = msg_list[i]
- if (('<@!' and '>') in msg_check) == True:
- msg_recipient = msg_check
- msg_content_test = True
- if msg_content_test == False:
- msg_recipient = 'air'
- if not '!' in msg_recipient:
- msg_recipient = msg_recipient[:2] + '!' + msg_recipient[2:]
- if msg_recipient == str(message.author.mention):
- msg = random.choice(pat_message).format('Miku', msg_recipient)
- else:
- msg = random.choice(slap_message).format(msg_author, msg_recipient)
- log(msg, message.channel, message.author, cmd)
- try:
- abc = str(message.author.mention).strip('<')
- await client.send_message(message.channel, msg)
- except ValueError in error:
- print(error)
- await client.send_message(message.channel, 'Something went wrong.... :sob:')
- #WIP <-----------------------------------------------------
- if message.content.startswith('{0}help'.format(s_id[sid])):
- cmd = 'help'
- msg = """**{0}hello** - yes, this is my greeting to all of you, my users! ^~^
- **{0}kiss @user** - kisses your lovely friend
- **{0}hug @user** - hugs your hugging-friend
- **{0}poke @user** - pokes your victim
- **{0}cuddle @user** - cuddles your cuddle pillow friend
- **{0}pat @user** - pat your friend's head and make them blush with happiness
- **{0}slap @user** - slap someone who's being rude! Ouch!
- **{0}rnf x z** - gives you random number from between numbers **x** and **z**
- **{0}random** - gives you random number between **0** and **100**
- **{0}choice a, b, c, d, ...** - makes a choice for you from the list words, each one divided with ","
- **{0}rc** - gives you a random colour in hex format
- **{0}p <youtube url>** - plays song in voice channel you're conencted to
- **{0}dc** - disconnects bot from voice channel
- **{0}playlist - shows currently queued songs**
- **{0}cp - shows currently playing song**
- **{0}coinflip** - flips the coin. Try your luck!
- **{0}cm** - converts inches to cm. Example: {0}cm 5'7 -> 170.18cm
- **{0}inch** - converts cm to inches. Example: {0}inch 175.26 -> 5'9
- **{0}gmn** - first minigame! Guess my number! Collect points and get on top of the leaderboard! ***<Rankings And Points Not Yet Implemented>***
- **{0}invite** - sends you a special link with which you can invite this bot to ***your own server***
- **{0}about** - do you want to learn more about me and my creator? Don't wait any longer!
- **{0}chart** - shows you a simple japanese katakana and hiragana chart! *For all weebs who can't type in their mother language..* >.>
- **{0}prefix set <prefix>** - allows owner of the server to change prefix to which my commands will react in that server
- **{0}lewd** - *winks*""".format(s_id[sid])
- color = 4122822
- embed = discord.Embed(title = 'List of my commands:', description = msg, color = color)
- log(msg, message.channel, message.author, cmd)
- await client.send_message(message.author, embed = embed)
- await client.add_reaction(message, '\U00002705')
- #done ABOUT
- if message.content.startswith('{0}about'.format(s_id[sid])):
- cmd = 'about'
- log(msg, message.channel, message.author, cmd)
- await client.send_message(message.channel, about)
- #done CHART
- if message.content.startswith('{0}chart'.format(s_id[sid])):
- cmd = 'chart'
- msg = '''**ę„ ļ½ ļ½ ļ½ ļ½ ļ½ćļ½ ļ½ ļ½ ļ½ ļ½ ę¬
- ć¼ ć¢ ć¤ ć¦ ćØ ćŖćć ć ć ć ć
- ļ½ ć« ć ćÆ ć± ć³ćć ć ć ć ć
- ļ½ ćµ ć· ć¹ ć ć½ćć ć ć ć ć
- ļ½ ćæ ć ć ć ććć ć” ć¤ ć¦ ćØ
- ļ½ ć ć ć ć ćććŖ ć« ć¬ ć ć®
- ļ½ ć ć ć ć” ć¢ćć¾ ćæ ć ć ć
- ļ½ ć© ćŖ ć« ć¬ ććć ć ć ć ć
- ļ½ ć ć ć ć ćććÆ ć² ćµ ćø ć»
- ļ½ ćÆ ć ć ć ć²ćć ćć ć ć
- ļ½ ć¤ ć ć¦ ć ćØćć ćć ć ć
- ļ½ ć³ ć ć ć ććć**'''
- color = 4122822
- embed = discord.Embed(title = 'Katakana and hiragana chart:', description = msg, color = color)
- log(msg, message.channel, message.author, cmd)
- await client.send_message(message.channel, embed = embed)
- #done AYAYA AYAYAAAAAA
- if (message.content.startswith('ayaya')) or (message.content.startswith('AYAYA')):
- cmd = 'ayaya'
- msg = '''**ā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£·ā£¬ā”ā£æā£æā£æā£Æā¢»
- ā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā”ā¢»ā£æā£æā¢ā£»ā£æā£æā£æā£æā£æā£æā£®ā”»ā£æā£æā£§
- ā£æā£æā£æā£æā£æā¢»ā£æā£æā£æā£æā£æā£æā£ā »ā”«ā£¢ā æā£æā£æā£æā£æā£æā£æā£æā£·ā£ā¢»ā£æ
- ā£æā£æā”ā£æā£æā£Øā£ā æā£æā£æā£æā£æā£æā¢ā øā£ā£©ā£„ā£ā£©ā¢ā£ā”æā æā£æā£æā£ā¢
- ā£æā£æā¢”ā£øā£æā£ā£æā£æā£¶ā£Æā£ā «ā¢ŗā£æā£·ā”ā£æā£æā£æā£æā”æā æā¢æā£ā£ā£ā£ā
- ā£æā”ā”æā£ā£ā¢æā£®ā£æā£æā£æā£æā£æā£æā£æā£¶ā£¶ā£¶ā£¶ā£¾ā£æā£æā£æā£æā£æā£æā£æā£æā£æ
- ā£æā¢±ā£¾ā£æā£æā£æā£ā”®ā”»ā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā”æā æā ā£ā£»ā£æā£æā£æā£æ
- ā¢æā¢øā£æā£æā£æā£æā£æā£æā£·ā£½ā£æā£æā£æā£æā£æā£æā£æā”ā£”ā£“ā£¶ā£æā£æā£æā”ā£æā£æā£æ
- ā£¦ā”øā£æā£æā£æā£æā£æā£æā”ā¢æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā£æā”ā£æā£æā£æ
- ā¢ā ·ā”¹ā£æā ā£ā£ ā£¤ā£¶ā£¶ā£æā£æā£æā£æā£æā£æā”æā æā¢æā£æā£æā£æā£æā£æā£·ā¢¹ā£æā£æ
- ā£·ā”ā£æā”ā£æā£æā£æā£æā£æā£æā£æā£æā”ā ā ā£ ā£¤ā£¤ā£¦ā£½ā£æā£æā£æā”æā ā ā£æā£æ
- ā£æā£æā”¹ā£æā”¼ā£æā£æā£æā£æā£æā£æā£æā£§ā”°ā£æā£æā£æā£æā£æā£¹ā”æā ā ā”ā ā ā¢æā£æ
- ā£æā£æā£æā£½ā£æā£¼ā£ā æā æā£æā£æā£æā£æā£æā£Æā£æā æā¢ā£»ā”½ā¢ā£¤ā”ā ā ā ā¢øā£æ**'''
- log(msg, message.channel, message.author, cmd)
- await client.send_message(message.channel, msg)
- #done INVITE
- if message.content.startswith('{0}invite'.format(s_id[sid])):
- msg = "*You can invite me to your server using this link:*\nhttps://discordapp.com/oauth2/authorize?client_id=492432534181773313&scope=bot"
- await client.send_message(message.author, msg)
- #done TERRARIA
- if message.content.startswith('{0}terraria'.format(s_id[sid])):
- cmd = 'terraria'
- msg = '''
- **IP:** 95.105.211.38
- **Port:** 6666
- **Password:** *Ask Ana#3140*
- *Server is hosted same way as I am.. That means it runs whenever I am online!!
- Connecting to the server requires* **TModLoader**. *Our mods will get downloaded automatically when connecting!*
- **List of mods:** *RecipeBrowser, WhereIsMyItem, Boss Checklist*
- *You can get TModLoader here: https://tmodloader.net/*
- '''
- color = 4122822
- embed = discord.Embed(title = 'Our Terraria server: ', description = msg, color = color)
- log(msg, message.channel, message.author, cmd)
- await client.send_message(message.channel, embed = embed)
- #done CHOICE
- if message.content.startswith('{0}choice'.format(s_id[sid])):
- cmd = 'choice'
- msg = message.content[8:]
- choice_list = []
- choice_list = msg.split(',')
- msg = "I've randomly chosen this for you: " + str(random.choice(choice_list))
- log(msg, message.channel, message.author, cmd)
- await client.send_message(message.channel, msg)
- #done PATCHNOTES
- if message.content.startswith('{0}patchnotes'.format(s_id[sid])):
- cmd = 'patchnotes'
- p_notes_split = patchnotes.split('<$>')
- #print(p_notes_split)
- log(msg, message.channel, message.author, cmd)
- for i in p_notes_split:
- msg = '```{0}```'.format(i)
- await client.send_message(message.author, msg)
- #done VERSION
- if message.content.startswith('{0}version'.format(s_id[sid])):
- cmd = 'version'
- msg = '`Current version of this bot is: {0}`'.format(version)
- log(msg, message.channel, message.author, cmd)
- await client.send_message(message.channel, msg)
- #done RANDOM NUMBER X Z
- if message.content.startswith('{0}rnf'.format(s_id[sid])):
- cmd = 'random number from <x, z>'
- msg = message.content[5:]
- numbers = []
- numbers = msg.split(' ')
- log(msg, message.channel, message.author, cmd)
- error = ''
- if len(numbers) == (1 or 0):
- msg = 'You need two numbers!'
- await client.send_message(message.channel, msg)
- else:
- try:
- print(numbers[0], numbers[1])
- a = int(round(float(numbers[0])))
- b = int(round(float(numbers[1])))
- print(a, b)
- if a >= b:
- c = a
- a = b
- b = c
- if a == b:
- msg = "Your random number is not really random, but here you go: {0}".format(a)
- else:
- num = random.randrange(a, b+1)
- msg = "Your random number is: " + str(num)
- await client.send_message(message.channel, msg)
- except ValueError as error:
- print(error)
- msg = 'Something went wrong!'
- await client.send_message(message.channel, msg)
- #done INCH to CM
- if message.content.startswith('{0}cm'.format(s_id[sid])):
- mes = str(message.content)[4:]
- print(mes)
- thingy = str(mes).split("'")
- a, b = thingy[0], thingy[1]
- try:
- a, b = int(a), int(b)
- msg = str(round(a * 12 * 2.54 + b * 2.54, 2)) + 'cm'
- except Exception as e:
- msg = 'Error!\n{0}'.format(e)
- await client.send_message(message.channel, msg)
- #done CM TO INCH
- if message.content.startswith('{0}inch'.format(s_id[sid])):
- mes = float(str(message.content)[6:])
- mes = int(round(mes))
- try:
- msg = str(int(mes // (30.48)))
- mes = (mes % 30.48)*100000
- zv = int(round(mes // 2.54))
- zv = round(zv/100000)
- msg += "'{0}".format(zv)
- except Exception as e:
- msg = 'Error!\n{0}'.format(e)
- await client.send_message(message.channel, msg)
- #done COINFLIP
- if message.content.startswith('{0}coinflip'.format(s_id[sid])):
- cmd = 'coinflip'
- num = random.randrange(1000)+1
- if num == 741:
- msg = "***It landed on it's side! How lucky!!!***"
- else:
- if num == 274:
- 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..."
- else:
- if num > 500:
- msg = 'Heads!' + '!'*random.randrange(4)
- else:
- msg = 'Tails!' + '!'*random.randrange(4)
- #log(msg, message.channel, message.author, cmd)
- print("Command '$" + cmd + "' used in " + str(message.channel) + ' by ' + str(message.author) +'! Rolled: ' + str(num))
- await client.send_message(message.channel, msg)
- #done RANDOM COLOUR
- if message.content.startswith('{0}rc'.format(s_id[sid])):
- cmd = 'random colour'
- color = random.randrange(256**3)
- print(color)
- msg = str(f'#{color:06x}')
- embed = discord.Embed(title = 'Your random colour: ', description = msg, color = color)
- log(str(msg), message.channel, message.author, cmd)
- await client.send_message(message.channel, embed = embed)
- #done GUESS MY NUMBER
- if message.content.startswith('{0}gmn'.format(s_id[sid])):
- if not str(message.author) in gmn_cp:
- gmn_cp[str(message.author)] = False
- gmn_a[str(message.author)] = 0
- gmn_number[str(message.author)] = 0
- if gmn_cp[str(message.author)] == False:
- 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..!!")
- time.sleep(0.25)
- 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]))
- game_number = random.randrange(100)+1
- gmn_number[str(message.author)] = game_number
- gmn_a[str(message.author)] = 0
- player = str(message.author)
- gmn_cp[str(message.author)] = True
- elif gmn_cp[str(message.author)] == True:
- number = message.content[4:]
- try:
- number = int(number)
- gmn_cp[str(message.author)] = True
- if gmn_number[str(message.author)] == number:
- msg = "Y-yes..! That's the number I.. I've been thinking of! Y-you are so good s-senpai! :heart_eyes:"
- gmn_a[str(message.author)] = 0
- await client.send_message(message.channel, msg)
- gmn_a[str(message.author)] = 0
- gmn_cp[str(message.author)] = False
- elif (gmn_a[str(message.author)] == 0) and (gmn_cp[str(message.author)] == True):
- if gmn_number[str(message.author)] < number:
- msg = "T-that's not it, s-senpai..! :flushed: Your n-number is too b-big.. T-try again..! *blushes*"
- await client.send_message(message.channel, msg)
- else:
- msg = "T-that's not it, s-senpai..! :flushed: Your n-number is not b-big enough.. T-try again..! *blushes*"
- await client.send_message(message.channel, msg)
- gmn_a[str(message.author)] = 1
- print('New game! Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
- elif (gmn_a[str(message.author)] == 1) and (gmn_cp[str(message.author)] == True):
- if gmn_number[str(message.author)] < number:
- msg = "N-no senpai... S-still not my number.. It's n-not that big..."
- await client.send_message(message.channel, msg)
- else:
- msg = "N s-senpai... S-still not my special number.. It's even higher..."
- await client.send_message(message.channel, msg)
- gmn_a[str(message.author)] = 2
- print('Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
- elif (gmn_a[str(message.author)] == 2) and (gmn_cp[str(message.author)] == True):
- if gmn_number[str(message.author)] < number:
- msg = "That's again n-not my n-number *blushes* T-too big..! Last chance..!"
- await client.send_message(message.channel, msg)
- else:
- msg = "N-not my n-number, senpai..! *blushes* Go h-higher..! L-last attempt..!"
- await client.send_message(message.channel, msg)
- gmn_a[str(message.author)] = 3
- print('Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
- elif (gmn_a[str(message.author)] == 3) and (gmn_cp[str(message.author)] == True):
- if gmn_number[str(message.author)] < number:
- 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)])
- await client.send_message(message.channel, msg)
- else:
- msg = "S-senpai..! T-that's not my number..! I was t-thinking of a number " + str(gmn_number[str(message.author)])
- await client.send_message(message.channel, msg)
- print('Player: {0}, attempt: {1}, number: {2}'.format(message.author, gmn_a[str(message.author)], gmn_number[str(message.author)]))
- gmn_a[str(message.author)] = 0
- gmn_cp[str(message.author)] = False
- except:
- await client.send_message(message.channel, "That's not a number, b-baka s-senpai..!!")
- else:
- 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:")
- #done LEWD
- if message.content.startswith('{0}lewd'.format(s_id[sid])):
- if str(message.author) == 'Ana#3140':
- 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..!__***'
- else:
- msg = '**Y-YOU ARE SO L-LEWD, SENPAI**' + '!'*int(random.randrange(9)+3)
- await client.send_message(message.channel, msg)
- #done SERVER PREFIX CHANGE
- if message.content.startswith('{0}prefix set'.format(s_id[sid])):
- if message.author == message.server.owner:
- try:
- prefix = message.content[12:]
- if len(prefix) > 1:
- msg = 'Prefix can consist of only one character!'
- else:
- s_id[message.server.id] = str(prefix)
- save()
- reload_files()
- msg = 'Prefix of this server has been changed to {0}'.format(prefix)
- except:
- msg = 'Something went wrong!'
- else:
- msg = "I'm sorry s-senpai, b-but you are n-not owner of t-this server!"
- await client.send_message(message.channel, msg)
- #bet reaction
- if (message.content.startswith('bet'))or (message.content.startswith('beet')) or (message.content.startswith('Bet')):
- num = random.randrange(10000)
- if num == 2714:
- msg = 'BEEEEEEEEEEEEEEEEEEEEEEEEEEEET!!!!!'
- await client.send_message(message.channel, msg)
- else:
- if num == 8743:
- msg = 'No bets allowed to underage trolls (That means you are not allowed to bet if you are not 18+.... B-baka senpai.. >.>)'
- await client.send_message(message.channel, msg)
- else:
- msg = "{0}bet{0}".format(edits[random.randrange(5)])
- await client.send_message(message.channel, msg)
- #miku reaction
- await miku_reaction(message)
- #Reactions for other bots
- 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]))):
- await asyncio.sleep(1)
- msg = 'Awwwwww t-thanks a lot for petting me, {0}! :sparkling_heart: :heart_eyes: ^~^'.format(message.author.mention)
- await client.send_message(message.channel, msg)
- 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]))):
- await asyncio.sleep(1)
- msg = 'Oh~, thanks s-senpai for hug! *she hugs {0} back tightly, smiling and blushing.*'.format(message.author.mention)
- await client.send_message(message.channel, msg)
- 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]))):
- await asyncio.sleep(1)
- msg = '*She giggles and cuddles {0} back, slightly stroking their back, still giggling.*'.format(message.author.mention)
- await client.send_message(message.channel, msg)
- if (message.content.startswith('{0}poke <@!492432534181773313>'.format(s_id[sid]))) or (message.content.startswith('{0}poke <@492432534181773313>'.format(s_id[sid]))):
- await asyncio.sleep(1)
- msg = "*She looks at {0} curiously, and then she pokes {0} back.*".format(message.author.mention)
- await client.send_message(message.channel, msg)
- if (message.content.startswith('{0}slap <@!492432534181773313>'.format(s_id[sid]))) or (message.content.startswith('{0}slap <@492432534181773313>'.format(s_id[sid]))):
- await asyncio.sleep(1)
- msg = '*She slaps {0} back, looking angry, annoyed but dissappointed and sad as well...*'.format(message.author.mention)
- await client.send_message(message.channel, msg)
- #dev only functions
- #done STOP
- if (message.content.startswith('{0}stop'.format(s_id[message.server.id]))) or (message.content.startswith('{0}bye'.format(s_id[message.server.id]))):
- cmd = 'stop'
- msg = ''
- log(msg, message.channel, message.author, cmd)
- if (str(message.author.id) == '207505077013839883') or (str(mesasge.author.id) == '296301865627287553'):
- msg = 'G-good b-bye, s-senpai~ :heart:!'
- await client.send_message(message.channel, msg)
- print('Good b-bye Ana s-senpai~ <3')
- client.logout()
- save()
- sys.exit(0)
- else:
- msg = 'Insufficient permissions...'
- await client.send_message(message.channel, msg)
- #done RELOAD FILES
- if message.content.startswith('{0}rf'.format(s_id[message.server.id])):
- cmd = 'reload files'
- log(msg, message.channel, message.author, cmd)
- author = str(message.author)
- if author == 'Ana#3140':
- reload_files()
- if success == False:
- print('Files reloaded successfully...')
- else:
- print('Reload unsuccessful...')
- else:
- msg = 'Insufficient permissions...'
- await client.send_message(message.channel, msg)
- #done CHANGE GAME STATUS
- if message.content.startswith('{0}game'.format(s_id[message.server.id])):
- cmd = 'game status'
- if (str(message.author.id) == '207505077013839883') or (str(message.author.id) == '296301865627287553'):
- if len(str(message.content)) >6:
- g = str(message.content)[6:]
- print(g, str(message.content))
- me = discord.utils.find(lambda s: s != None, client.servers).me
- if not me:
- return
- elif not me.game:
- updated_game = discord.Game(name = str(g))
- else:
- updated_game = me.game
- updated_game.name = str(g)
- else:
- me = discord.utils.find(lambda s: s != None, client.servers).me
- if not me:
- return
- elif not me.game:
- updated_game = discord.Game(name = random.choice(statuses))
- else:
- updated_game = me.game
- updated_game.name = random.choice(statuses)
- await client.change_presence(game = updated_game)
- print('Changing game to: {0}'.format(str(updated_game)))
- #done PATCH CHANGE
- if message.content.startswith('{0}patch set'.format(s_id[message.server.id])):
- author = str(message.author)
- cmd = 'patch'
- msg = ''
- patch = ''
- log(msg, message.channel, message.author, cmd)
- if author.id == '207505077013839883':
- try:
- msg = 'Done!'
- patch = message.content
- patch = patch[11:]
- os.remove('bot_save_files\patch.txt')
- file = open('bot_save_files\patch.txt', 'w')
- file.write(str(patch))
- file.close()
- version = patch
- print('Current patch changed to {0}'.format(patch))
- ctypes.windll.kernel32.SetConsoleTitleW(patch)
- await client.send_message(message.channel, msg)
- except:
- print('Something went wrong!')
- #WIP TEST COMMAND
- if message.content.startswith('{0}test'.format(s_id[message.server.id])):
- cmd = 'test'
- msg = message.author.id
- await client.send_message(message.channel, msg)
- #MUSIC LOOP
- if message.content.startswith('{0}loop'.format(s_id[message.server.id])):
- if not message.server.id in loop:
- loop[message.server.id] = True
- msg = 'Looping current song!'
- await client.send_message(message.channel, msg)
- elif loop[message.server.id] == True:
- loop[message.server.id] = False
- msg = 'Loop of the current song disabled!'
- await client.send_message(message.channel, msg)
- elif loop[message.server.id] == False:
- loop[message.server.id] = True
- msg = 'Looping current song!'
- await client.send_message(message.channel, msg)
- #MUSIC LOOP PLAYLIST
- if message.content.startswith('{0}lp'.format(s_id[message.server.id])):
- if not message.server.id in lp:
- lp[message.server.id] = True
- msg = 'Looping current playlist!'
- await client.send_message(message.channel, msg)
- elif lp[message.server.id] == True:
- lp[message.server.id] = False
- msg = 'Loop of the current playlist disabled!'
- await client.send_message(message.channel, msg)
- elif lp[message.server.id] == False:
- lp[message.server.id] = True
- msg = 'Looping current playlist!'
- await client.send_message(message.channel, msg)
- #MUSIC CONNECT
- if message.content.startswith("{0}p ".format(s_id[message.server.id])):
- channel = message.author.voice.voice_channel
- if not message.server.id in loop:
- loop[message.server.id] = False
- if not message.server.id in lp:
- lp[message.server.id] = False
- if not channel == None:
- ytdl = YoutubeDL()
- link = ''
- if not message.server.id in playlist:
- playlist[message.server.id] = []
- if not message.server.id in cp:
- cp[message.server.id] = 'False'
- link = str(message.content)[3:]
- if 'https://www.youtube.com/playlist?list=' in link:
- troll = 'https://www.youtube.com/playlist?list='
- link = link[len(troll):]
- results = youtube.playlistItems().list(playlistId=link, part='contentDetails', maxResults = 50).execute()
- videoIds = [item['contentDetails']['videoId'] for item in results.get('items', [])]
- playlist[sid] += videoIds
- link = playlist[sid][0]
- else:
- if 'https://youtu.be/' in link:
- link = link.strip('https://youtu.be/')
- if 'www.youtube.' in link:
- link = link.strip('https://www.youtube.com/watch?v=')
- if len(link) > 11:
- link = link[:11]
- playlist[message.server.id].append(link)
- await client.add_reaction(message, '\U00002705')
- await music_playlist(message) # music_playlist
- else:
- msg = "S-senpai..! You're n-not in a-any voice c-channel!"
- await client.send_message(message.channel, msg)
- #MUSIC DISCONENCT
- if message.content.startswith('{0}dc'.format(s_id[message.server.id])):
- if client.is_voice_connected(message.server):
- playlist[message.server.id] = []
- cp[message.server.id] = 'False'
- players[message.server.id].stop()
- loop[message.server.id] = False
- lp[message.server.id] = False
- cpsong[message.server.id] = ''
- msg = 'Bai baaaaaiļ½'
- await client.send_message(message.channel, msg)
- await vc.disconnect()
- else:
- msg = "S-senpai..! B-but I.. I'm n-not connected y-yet! :flushed:"
- await client.send_message(message.channel, msg)
- #MUSIC PLAYLIST
- if message.content.startswith('{0}playlist'.format(s_id[message.server.id])):
- mes = str(message.content).strip('{0}playlist'.format(s_id[message.server.id]))
- if 'del' in mes:
- mes = mes.strip(' del ')
- try:
- try:
- num = int(mes)
- except:
- print('Couldn\'t convert mes into num')
- if not 0 < num <= len(playlist[sid]):
- msg = 'B-but s-senpai!! T-that\'s not a... r-right n-number!!'
- await client.send_message(message.channel, msg)
- else:
- del(playlist[message.server.id][num-1])
- msg = 'Done..!'
- await client.send_message(message.channel, msg)
- except:
- msg = 'O-oh senpai..! I\'m s-sorry, b-but something went w-wrong!'
- await client.send_message(message.channel, msg)
- elif 'delete' in mes:
- mes = mes.strip(' delete ')
- try:
- try:
- num = int(mes)
- except:
- print('Couldn\'t convert mes into num')
- if not 0 < num <= len(playlist[sid]):
- msg = 'S-senpai..!! W-wrong number! :flushed:'
- await client.send_message(message.channel, msg)
- else:
- del(playlist[message.server.id][num-1])
- msg = 'Done..!'
- await client.send_message(message.channel, msg)
- except:
- msg = 'O-oh senpai..! I\'m s-sorry, b-but something went w-wrong!'
- await client.send_message(message.channel, msg)
- else:
- await music_playlist_print(message)
- #MUSIC CURRENTLY PLAYING
- if message.content.startswith('{0}cp'.format(s_id[sid])):
- msg = '***Currently playing:***\n*{0}* **Duration:** {1}'.format(info[sid]['title'], datetime.timedelta(seconds=info[sid]['duration']))
- if loop == True:
- msg += '\n**Loop of current song is** ***enabled!***'
- await client.send_message(message.channel, msg)
- #MUSIC SKIP
- if (message.content.startswith('{0}skip'.format(s_id[sid]))) or (message.content.startswith('{0}next'.format(s_id[sid]))):
- await music_skip(message)
- return None
- async def music_playlist(message):
- global vc, cp, playlist, urllist, client
- if playlist[message.server.id] != []:
- url = playlist[message.server.id][0]
- else:
- return
- if (cp[message.server.id] == 'False') and (playlist[message.server.id] != []):
- await music_bot(url, message)
- async def music_bot(url, message):
- global vc, cp, playlist, urllist, loop, ytdl, cpsong, info, client
- sid = message.server.id
- if not message.server.id in cpsong:
- cpsong[sid] = ''
- cpsonglocal = {}
- timethingy = str(timeit.timeit())
- cpsong[sid] = timethingy
- cpsonglocal[sid] = timethingy
- if not client.is_voice_connected(message.server):
- while playlist[sid] != []:
- channel = message.author.voice.voice_channel
- vc = await client.join_voice_channel(channel)
- musicplayer = await vc.create_ytdl_player(url, before_options=" -reconnect 1 -reconnect_streamed 1"
- " -reconnect_delay_max 5")
- players[sid] = musicplayer
- musicplayer.start()
- cp[sid] = 'True'
- info[sid] = ytdl.extract_info(url, download = False)
- await asyncio.sleep(int(info[sid]['duration'])-1)
- if cpsong[sid] == cpsonglocal[sid]:
- cp[sid] = 'False'
- await loop_check(url, message)
- else:
- return
- print('no')
- elif client.is_voice_connected(message.server):
- while playlist[sid] != []:
- vc = client.voice_client_in(message.server)
- musicplayer = await vc.create_ytdl_player(url, before_options=" -reconnect 1 -reconnect_streamed 1"
- " -reconnect_delay_max 5")
- players[sid] = musicplayer
- musicplayer.start()
- cp[sid] = 'True'
- info[sid] = ytdl.extract_info(url, download = False)
- await asyncio.sleep(int(info[sid]['duration'])-1)
- if cpsong[sid] == cpsonglocal[sid]:
- cp[sid] = 'False'
- await loop_check(url, message)
- else:
- return
- print('no')
- async def loop_check(url, message):
- global loop, playlist, urllist, lp, client
- if lp[message.server.id] == True:
- playlist[message.server.id].append(url)
- del(playlist[message.server.id][0])
- await music_playlist(message)
- else:
- if loop[message.server.id] == True:
- await music_bot(url, message)
- elif loop[message.server.id] == False:
- del(playlist[message.server.id][0])
- await music_playlist(message)
- async def music_skip(message):
- global players, playlist, urllist, cp, urls, client
- if 'DJ' in message.server.roles:
- print('SKIP TEST 1')
- if 'DJ' in message.author.roles:
- print('SKIP TEST 2')
- cp[message.server.id] = 'False'
- players[message.server.id].stop()
- playlist[message.server.id] = playlist[message.server.id][len(urls[message.server.id])+7:]
- msg = 'Skipping current song...'
- await client.send_message(message.channel, msg)
- await music_playlist(message)
- else:
- msg = 'Insufficent permission!'
- await client.send_message(message.channel, msg)
- print('SKIP TEST 3')
- else:
- if lp[message.server.id] == True:
- playlist[message.server.id].append(playlist[message.server.id][0])
- del(playlist[message.server.id][0])
- else:
- del(playlist[message.server.id][0])
- cp[message.server.id] = 'False'
- players[message.server.id].stop()
- msg = 'Skipping current song...'
- await client.send_message(message.channel, msg)
- await music_playlist(message)
- async def music_playlist_print(message):
- global playlist, youtube, s_id, lp, client
- sid = message.server.id
- if not sid in playlist:
- msg = '**There are no songs in queue at the moment! Queue some using {0}p url!**'.format(s_id[sid])
- await client.send_message(message.channel, msg)
- else:
- urls = playlist[sid]
- ids = ','.join(urls)
- msg = '***Current playlist:***\n'
- results = {}
- while results == {}:
- try:
- results = youtube.videos().list(id=ids, part='snippet').execute()
- except:
- print('Youtube results unsucessful, retrying...')
- msg += '\n'.join(
- '**{0}**: *{1}*'.format(i, item['snippet']['title'])
- for i, item in
- enumerate(results.get('items', []), start=1))
- if lp[sid] == True:
- msg += '\n**Loop of the playlist is** ***__enabled!__***'
- msg += ' \n**You can remove a song from queue by using {0}playlist delete <number_in_queue>!**'.format(s_id[sid])
- if not '1' in msg:
- msg = '**There are no songs in queue at the moment! Queue some using {0}p url!**'.format(s_id[sid])
- await send_message(message, msg)
- return
- async def send_message(message, msg, *args, **kwargs):
- global lp, s_id, client
- sid = message.server.id
- if len(msg) > 1800:
- first2k = msg[:1800]
- last_nl = first2k.rfind('\n')
- firstMsg = msg[:last_nl]
- rest = msg[last_nl:]
- if lp[sid] == True:
- firstMsg += '\n**Loop of the playlist is** ***__enabled!__***'
- firstMsg += ' \n**You can remove a song from queue by using {0}playlist delete <number_in_queue>!**'.format(s_id[sid])
- else:
- firstMsg = msg
- await client.send_message(message.channel, firstMsg, *args, **kwargs)
- async def miku_reaction(message):
- global miku_names, client
- for i in miku_names:
- if i in message.content:
- await asyncio.sleep(0.37)
- msg = random.choice(miku_message).format(message.author.mention)
- await client.send_message(message.channel, msg)
- return
- statuses = ["with Lily", "with Ana", "with Yuno", "with Eri", "with Honoka", "with Nico", "with Nico", "with Nico Nico Niii~",
- "with Maki", "with herself", "with her toys", "with Nozomi", "with Kotori", "with Umi", "with Rin", "with Hanayo",
- "with Chika", "with Riko", "with Kanan", "with Dia", "with You-chan", "with Yoshiko", "with Yohanne", "with Hanamaru zuraaa~",
- "with Mari", "with Ruby", "with Taiga", "with her phone", "with Toastie", "with Ado-kun", "with adorable Ana-chan",
- "with Mashiro", "with Yuzu", "with Sprii", "with Katalina", "with her creator", "with Angela", "with her hair", "with Aqours", "with Āµ's",
- "with Luka", "Doki Doki Literature Club", "with Natsuki..?", "with Yuri", "with Sayori", "with Monika", "with Hana", "with her friends",
- "with Faerlynn", "nothing... Weird...", "with Satou", "with Shio", "with Livvy", "as Mercy", "as Ana", "as Brigitte", "as Pharah", "as D.Va",
- "as Mei", "as Sombra", "as Ashe", "as Moira", "as Symmetra", "as Tracer", "as Zarya", "as Miku", "as Luka", "as Athena", "as Echo",
- "as Efi", "with Katniss", "never have I ever", "with KyÅ"]
- async def task_loop(client):
- while True:
- me = discord.utils.find(lambda s: s != None, client.servers).me
- if not me:
- return
- elif not me.game:
- updated_game = discord.Game(name = random.choice(statuses))
- else:
- updated_game = me.game
- updated_game.name = random.choice(statuses)
- await client.change_presence(game = updated_game)
- await asyncio.sleep(300 + random.randrange(150))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement