import discord
from discord.ext import commands
from discord.ext.commands.cooldowns import BucketType
import asyncio
import colorsys
import random
import platform
from discord import Game, Embed, Color, Status, ChannelType
import os
import functools
import time
import datetime
import requests
import json
import aiohttp		


Forbidden= discord.Embed(title="Permission Denied", description="1) Please check whether you have permission to perform this action or not. \n2) Please check whether my role has permission to perform this action in this channel or not. \n3) Please check my role position.", color=0x00ff00)
client = commands.Bot(description="MultiVerse Official Bot", command_prefix=commands.when_mentioned_or("!!"), pm_help = True)
client.remove_command('help')



async def status_task():
    while True:
        await client.change_presence(game=discord.Game(name='!!help'))
        await asyncio.sleep(5)
        await client.change_presence(game=discord.Game(name='with '+str(len(set(client.get_all_members())))+' users'))
        await asyncio.sleep(5)
        await client.change_presence(game=discord.Game(name='in '+str(len(client.servers))+' servers'))
        await asyncio.sleep(5)
	

@client.command(pass_context=True)
async def google(ctx, *, message):
    new_message = message.replace(" ", "+")
    url = f"https://www.google.com/search?q={new_message}"
    await client.say(url)

@client.command(pass_context=True)
async def youtube(ctx, *, message: str):
    new_message = message.replace(" ", "+")
    url = f"https://www.youtube.com/results?search_query={new_message}"
    await client.say(url)


@client.command(pass_context=True)
async def skincolor(ctx, user: discord.Member):
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
    random.seed(user.id)
    skins = ["White", "Black", "Blue", "Green", "Rainbow", "Purple", "Brown", "Pink", "Cream", "Orange"]
    if user == ctx.message.author:
        embed2 = discord.Embed(title="You should know your own skin color", color = discord.Color((r << 16) + (g << 8) + b))
        await client.say(embed=embed2)
    else:
        embed = discord.Embed(color=0xcb287a)
        embed.add_field(name=f"{user.name}'s skin color", value=random.choice(skins))
        await client.say(embed=embed)
	
	
@client.command(pass_context=True)
async def unverify(ctx):
    await client.delete_message(ctx.message)
    role = discord.utils.get(ctx.message.server.roles, name='Unverified')
    await client.add_roles(ctx.message.author, role)
    
@client.command(pass_context=True)
async def verify(ctx):
    if ctx.message.author.bot:
      return
    else:
      await client.delete_message(ctx.message)
      role = discord.utils.get(ctx.message.server.roles, name='Verified')
      await client.add_roles(ctx.message.author, role)	
	
 
	
@client.command(pass_context=True)
@commands.check(is_soyal)
async def botdm(ctx, user: discord.Member, *, msg: str):
    await client.send_typing(user)
    await client.send_message(user, msg)
	
@client.command(pass_context = True)
@commands.has_permissions(administrator=True) 
async def announce(ctx, channel: discord.Channel=None, *, msg: str):
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
    embed=discord.Embed(title="Announcement", description="{}".format(msg), color = discord.Color((r << 16) + (g << 8) + b))
    await client.send_message(channel, embed=embed)
    await client.delete_message(ctx.message)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def embed(ctx, *args):
    if ctx.message.author.bot:
      return
    else:
      argstr = " ".join(args)
      r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
      text = argstr
      color = discord.Color((r << 16) + (g << 8) + b)
      await client.send_message(ctx.message.channel, embed=Embed(color = color, description=text))
      await client.delete_message(ctx.message)    

	
	
@client.command(pass_context = True)
@commands.has_permissions(administrator = True)
async def dm(ctx, user: discord.Member, *, msg: str):
    try:
        await client.send_message(user, msg)
        await client.delete_message(ctx.message)          
        await client.say("Success! Your DM has made it! :white_check_mark: ")
    except discord.ext.commands.MissingPermissions:
        await client.say("Aw, come on! You thought you could get away with DM'ing people without permissions.")
    except:
        await client.say("Error :x:. Make sure your message is shaped in this way: ^dm [tag person] [msg]")

		
	
	
@client.command(pass_context = True)
async def botinvite(ctx):
    if ctx.message.author.bot:
      return
    else:
      embed=discord.Embed(title="Click on this link to invite:", description="https://discordapp.com/api/oauth2/authorize?client_id=520267296506249216&permissions=8&scope=bot" , color=0x00fd1b)
      await client.say(embed=embed)


@client.command(pass_context = True)
async def test(ctx):
    if ctx.message.author.bot:
      return
    else:
      await client.send_message(ctx.message.author, 'Hii bro what supp')
      await client.say('Check your dm ')

@client.command(pass_context=True)  
@commands.has_permissions(administrator=True)    
async def kick(ctx,user:discord.member):
    if user.server_permissions.kick_members:
      await client.say('**He is mod/admin and i am unable to kick him/her**')
      return
    else:
      await client.kick(user)
      await client.say(user.name+' was kicked. Good bye '+user.name+'!')
      await client.delete_message(ctx.message)
      for channel in user.server.channels:
        if channel.name == 'Soyal-log':
            embed=discord.Embed(title="User kicked!", description="**{0}** is kicked by **{1}**!".format(user, ctx.message.author), color=0xFDE112)
            await client.send_message(channel, embed=embed)


	
	
@client.command(pass_context = True)
async def play(ctx, *, url):
    author = ctx.message.author
    voice_channel = author.voice_channel
    try:
        vc = await client.join_voice_channel(voice_channel)
        msg = await client.say("Loading...")
        player = await vc.create_ytdl_player("ytsearch:" + url)
        player.start()
        await client.say("Succesfully Loaded ur song!")
        await client.delete_message(msg)
    except Exception as e:
        print(e)
        await client.say("Reconnecting")
        for x in client.voice_clients:
            if(x.server == ctx.message.server):
                await x.disconnect()
                nvc = await client.join_voice_channel(voice_channel)
                msg = await client.say("Loading...")
                player2 = await nvc.create_ytdl_player("ytsearch:" + url)
                player2.start

@client.command(pass_context = True)
async def stop(ctx):
    for x in client.voice_clients:
        if(x.server == ctx.message.server):
            return await x.disconnect()

    return await client.say("I am not playing anyting???!")

        

@client.command(pass_context = True)
async def happybirthday(ctx, *, msg = None):
    if '@here' in msg or '@everyone' in msg:
      return
    if not msg: await client.say("Please specify a user to wish")
    await client.say('Happy birthday have a nice day' + msg + ' http://imgur.com/gallery/PbyNCR2')
    return



@client.command(pass_context = True)
@commands.has_permissions(administrator=True)
async def emojiids(ctx):
  for emoji in ctx.message.author.server.emojis:
    print(f"<:{emoji.name}:{emoji.id}>")
    print(" ")    
			
@client.command(pass_context = True)
async def wow(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:WOW:515854429485006848>')
	
@client.command(pass_context = True)
async def dank(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:OnThaCoco:515853700682743809>')

@client.command(pass_context = True)
async def santa(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:santa:517232271678504970>')
	
@client.command(pass_context = True)
async def hi(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:hi:517232279148429313>')
	
@client.command(pass_context = True)
async def lol(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:lol:517232283670020096>')
	
@client.command(pass_context = True)
async def love(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:love:517232300912672774>')
	
@client.command(pass_context = True)
async def mad(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:mad:517232301176913951>')
	
@client.command(pass_context = True)
async def alien(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:alien:517232332663422986>')

@client.command(pass_context = True)
async def fearfromme(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:shiroeglassespush:516174320532193289>')
	   	
@client.command(pass_context = True)
async def angry(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:angear:516174316950388772>')
	
@client.command(pass_context = True)
async def surprised(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:eyebigger:516174315058626560>')
		
@client.command(pass_context = True)
async def cat(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:agooglecat:516174312294842389>')
		
@client.command(pass_context = True)
async def thinking1(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:thinking:516183328613990400>')
	







@client.command(pass_context = True)
@commands.has_permissions(administrator=True)
async def setuplog(ctx):
    if ctx.message.author.bot:
      return
    else:
      server = ctx.message.server
      everyone_perms = discord.PermissionOverwrite(send_messages=False, read_messages=True)
      everyone = discord.ChannelPermissions(target=server.default_role, overwrite=everyone_perms)
      await client.create_channel(server, 'information-log',everyone)

	

@client.command(pass_context = True)
@commands.has_permissions(administrator=True)
async def setupwelcome(ctx):
    if ctx.message.author.bot:
      return
    else:
      server = ctx.message.server
      everyone_perms = discord.PermissionOverwrite(send_messages=False, read_messages=True)
      everyone = discord.ChannelPermissions(target=server.default_role, overwrite=everyone_perms)
      await client.create_channel(server, 'welcome_swagat',everyone)
	
	
@client.event
async def on_member_join(member):
    for channel in member.server.channels:
        if channel.name == 'welcome_swagat':
            r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
            embed = discord.Embed(title=f'Welcome {member.name} to {member.server.name}', description='Do not forget to check rules and never try to break any one of them', color = discord.Color((r << 16) + (g << 8) + b))
            embed.add_field(name='__Thanks for joining__', value='**Hope you will be active here.**', inline=True)
            embed.set_thumbnail(url='https://cdn.discordapp.com/attachments/486489391083159574/520207004334292992/Loading.gif') 
            embed.set_image(url = member.avatar_url)
            embed.add_field(name='__Join position__', value='{}'.format(str(member.server.member_count)), inline=True)
            embed.add_field(name='Time of joining', value=member.joined_at)
            await client.send_message(channel, embed=embed)	
		

@client.event
async def on_member_remove(member):
    for channel in member.server.channels:
        if channel.name == 'welcome_swagat':
            r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
            embed = discord.Embed(title=f'{member.name} just left {member.server.name}', description='Bye bye 👋! We will miss you 😢', color = discord.Color((r << 16) + (g << 8) + b))
            embed.add_field(name='__User left__', value='**Hope you will be back soon 😕.**', inline=True)
            embed.add_field(name='Your join position was', value=member.joined_at)
            embed.set_thumbnail(url=member.avatar_url)
            await client.send_message(channel, embed=embed)

@client.command(pass_context = True)
@commands.has_permissions(administrator=True)
async def rolesetup(ctx):
    author = ctx.message.author
    server = ctx.message.server
    mod_perms = discord.Permissions(manage_messages=True, kick_members=True, manage_nicknames =True,mute_members=True)
    admin_perms = discord.Permissions(ADMINISTRATOR=True)

    await client.create_role(author.server, name="Owner", permissions=admin_perms)
    await client.create_role(author.server, name="Admin", permissions=admin_perms)
    await client.create_role(author.server, name="Senior Moderator", permissions=mod_perms)
    await client.create_role(author.server, name="G.O.H")
    await client.create_role(author.server, name="Moderator", permissions=mod_perms)
    await client.create_role(author.server, name="Muted")
    await client.create_role(author.server, name="Friend of Owner")


@commands.has_permissions(manage_roles=True)     
async def role(ctx, user: discord.Member, *, role: discord.Role = None):
        if role is None:
            return await client.say("You haven't specified a role! ")

        if role not in user.roles:
            await client.add_roles(user, role)
            return await client.say("{} role has been added to {}.".format(role, user))

        if role in user.roles:
            await client.remove_roles(user, role)
            return await client.say("{} role has been removed from {}.".format(role, user))
 
@client.command(pass_context = True)
@commands.has_permissions(kick_members=True)
async def warn(ctx, userName: discord.User, *, message:str): 
    await client.send_message(userName, "You have been warned for: **{}**".format(message))
    await client.say(":warning: __**{0} Has Been Warned!**__ :warning: ** Reason:{1}** ".format(userName,message))
    pass


@client.command(pass_context = True)
@commands.has_permissions(administrator=True)
async def say(ctx, *, msg = None):
    await client.delete_message(ctx.message)

    if not msg: await client.say("Please specify a message to send")
    else: await client.say(msg)
    return

@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def friend(ctx, user:discord.Member,):
    await client.delete_message(ctx.message)
    role = discord.utils.get(ctx.message.server.roles, name='Friend of Owner')
    await client.add_roles(ctx.message.mentions[0], role)


@client.command(pass_context=True)
async def ownerinfo(ctx):
    embed = discord.Embed(title="Information about owner", description="Bot Name- MARCOS", color=0x00ff00)
    embed.set_footer(text="MARCOS")
    embed.set_author(name=" Bot Owner Name- MARCOS")
    embed.add_field(name="Site- coming soon...", value="Thanks for adding our bot", inline=True)
    await client.say(embed=embed)		



@client.command(pass_context=True)  
@commands.has_permissions(kick_members=True)
async def getuser(ctx, role: discord.Role = None):
    if role is None:
        await client.say('There is no "STAFF" role on this server!')
        return
    empty = True
    for member in ctx.message.server.members:
        if role in member.roles:
            await client.say("{0.name}: {0.id}".format(member))
            empty = False
    if empty:
        await client.say("Nobody has the role {}".format(role.mention))


@client.command(pass_context = True)
@commands.has_permissions(kick_members=True)     
async def userinfo(ctx, user: discord.Member):
    if ctx.message.author.bot:
      return
    else:
      r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
      embed = discord.Embed(title="{}'s info".format(user.name), description="Here's what I could find.", color = discord.Color((r << 16) + (g << 8) + b))
      embed.add_field(name="Name", value=user.name, inline=True)
      embed.add_field(name="ID", value=user.id, inline=True)
      embed.add_field(name="Status", value=user.status, inline=True)
      embed.add_field(name="Highest role", value=user.top_role)
      embed.add_field(name="Joined", value=user.joined_at)
      embed.set_thumbnail(url=user.avatar_url)
      await client.say(embed=embed)




@client.command(pass_context = True)
@commands.has_permissions(kick_members=True) 
@commands.cooldown(rate=5,per=86400,type=BucketType.user) 
async def access(ctx, member: discord.Member):
    if ctx.message.author.bot:
      return
    else:
      role = discord.utils.get(member.server.roles, name='access')
      await client.add_roles(member, role)
      await client.say("Gave access to {}".format(member))
      for channel in member.server.channels:
        if channel.name == 'soyal-log':
            embed=discord.Embed(title="User Got Access!", description="**{0}** got access from **{1}**!".format(member, ctx.message.author), color=0x020202)
            await client.send_message(channel, embed=embed)
            await asyncio.sleep(45*60)
            await client.remove_roles(member, role)


@client.command(pass_context = True)
@commands.has_permissions(manage_nicknames=True)     
async def setnick(ctx, user: discord.Member, *, nickname):
    await client.change_nickname(user, nickname)
    await client.delete_message(ctx.message)
    for channel in user.server.channels:
      if channel.name == 'soyal-log':
          embed=discord.Embed(title="Changed Nickname of User!", description="**{0}** nickname was changed by **{1}**!".format(member, ctx.message.author), color=0x0521F6)
          await client.send_message(channel, embed=embed)



@client.command(pass_context=True)
async def poll(ctx, question, *options: str):
        if len(options) <= 1:
            await client.say('You need more than one option to make a poll!')
            return
        if len(options) > 10:
            await client.say('You cannot make a poll for more than 10 things!')
            return

        if len(options) == 2 and options[0] == 'yes' and options[1] == 'no':
            reactions = ['👍', '👎']
        else:
            reactions = ['1\u20e3', '2\u20e3', '3\u20e3', '4\u20e3', '5\u20e3', '6\u20e3', '7\u20e3', '8\u20e3', '9\u20e3', '\U0001f51f']

        description = []
        for x, option in enumerate(options):
            description += '\n {} {}'.format(reactions[x], option)
            r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
        embed = discord.Embed(title=question, description=''.join(description), color = discord.Color((r << 16) + (g << 8) + b))
        react_message = await client.say(embed=embed)
        for reaction in reactions[:len(options)]:
            await client.add_reaction(react_message, reaction)
        embed.set_footer(text='Poll ID: {}'.format(react_message.id))
        await client.edit_message(react_message, embed=embed)


@client.command(pass_context=True)  
@commands.has_permissions(ban_members=True)      
async def ban(ctx,user:discord.Member):
    if user.server_permissions.ban_members:
      await client.say('**He is mod/admin and i am unable to ban him/her**')
      return
    else:
      await client.ban(user)
      await client.say(user.name+' was banned. Good bye '+user.name+'!')
      for channel in member.server.channels:
        if channel.name == 'information-log':
            embed=discord.Embed(title="User banned!", description="**{0}** banned by **{1}**!".format(member, ctx.message.author), color=0x38761D)
            await client.send_message(channel, embed=embed)


@client.command(pass_context=True)  
@commands.has_permissions(ban_members=True)     
async def unban(ctx):
    ban_list = await client.get_bans(ctx.message.server)

    # Show banned users
    await client.say("Ban list:\n{}".format("\n".join([user.name for user in ban_list])))

    # Unban last banned user
    if not ban_list:
      await client.say('Ban list is empty.')
      return
    else:
      await client.unban(ctx.message.server, ban_list[-1])
      await client.say('Unbanned user: `{}`'.format(ban_list[-1].name))
      for channel in member.server.channels:
        if channel.name == 'soyal-log':
            embed=discord.Embed(title="User unbanned!", description="**{0}** unbanned by **{1}**!".format(ban_list[-1].name, ctx.message.author), color=0x38761D)
            await client.send_message(channel, embed=embed)


@client.command(pass_context=True)  
@commands.has_permissions(kick_members=True)     

async def serverinfo(ctx):
    '''Displays Info About The Server!'''

    server = ctx.message.server
    roles = [x.name for x in server.role_hierarchy]
    role_length = len(roles)

    if role_length > 50: #Just in case there are too many roles...
        roles = roles[:50]
        roles.append('>>>> Displaying[50/%s] Roles'%len(roles))

    roles = ', '.join(roles);
    channelz = len(server.channels);
    time = str(server.created_at); time = time.split(' '); time= time[0];
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
    join = discord.Embed(description= '%s '%(str(server)),title = 'Server Name', color = discord.Color((r << 16) + (g << 8) + b));
    join.set_thumbnail(url = server.icon_url);
    join.add_field(name = '__Owner__', value = str(server.owner) + '\n' + server.owner.id);
    join.add_field(name = '__ID__', value = str(server.id))
    join.add_field(name = '__Member Count__', value = str(server.member_count));
    join.add_field(name = '__Text/Voice Channels__', value = str(channelz));
    join.add_field(name = '__Roles (%s)__'%str(role_length), value = roles);
    join.set_footer(text ='Created: %s'%time);

    return await client.say(embed = join);


@client.command(pass_context=True)
async def apply(ctx, *, msg: str):
    channel = client.get_channel('520830825021964305')
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
    embed = discord.Embed(color = discord.Color((r << 16) + (g << 8) + b))
    embed.add_field(name='Application for bot', value='-------------------',inline = False) 
    embed.add_field(name='User ID:', value='{}'.format(ctx.message.author.id),inline = False)
    embed.add_field(name='User Name:', value='{}'.format(ctx.message.author.name),inline = False)
    embed.add_field(name='Server Name:', value='{}'.format(ctx.message.server.name),inline = False)
    embed.add_field(name='Bot information:', value=msg, inline=False)
    await client.send_message(channel, embed=embed) 
    await client.delete_message(ctx.message)


@client.command(pass_context = True)
@commands.has_permissions(administrator=True)     
async def makemod(ctx, user: discord.Member):
    nickname = '[̲̅M̲̅]' + user.name
    await client.change_nickname(user, nickname=nickname)
    role = discord.utils.get(ctx.message.server.roles, name='Moderator')
    await client.add_roles(user, role)
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
    embed = discord.Embed(color = discord.Color((r << 16) + (g << 8) + b))
    embed.set_author(name='Congratulations Message')
    embed.add_field(name = '__Congratulations__',value ='**Congratulations for mod.Hope you will be more active here. Thanks for your help and support.**',inline = False)
    embed.set_image(url = 'https://preview.ibb.co/i1izTz/ezgif_5_e20b665628.gif')
    await client.send_message(user,embed=embed)
    await client.delete_message(ctx.message)


@client.command(pass_context = True)
@commands.has_permissions(administrator=True)     
async def makeadmin(ctx, user: discord.Member):
    nickname = 'Ѧ'+ user.name
    await client.change_nickname(user, nickname=nickname)
    role = discord.utils.get(ctx.message.server.roles, name='Admin')
    await client.add_roles(user, role)
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
    embed = discord.Embed(color = discord.Color((r << 16) + (g << 8) + b))
    embed.set_author(name='Congratulations Message')
    embed.add_field(name = '__Congratulations__',value ='**Congratulations for Admin.Hope you will be more active here. Thanks for your help and support.**',inline = False)
    embed.set_image(url = 'https://preview.ibb.co/i1izTz/ezgif_5_e20b665628.gif')
    await client.send_message(user,embed=embed)
    await client.delete_message(ctx.message)


@client.command(pass_context = True)
async def sorry(ctx, *, msg = None):
    if '@here' in msg or '@everyone' in msg:
      return
    if not msg: await client.say("Please Sorry")
    await client.say('Sorry ' + msg + ' http://imgur.com/gallery/Dif2lYI')
    return


@client.command(pass_context = True)
@commands.has_permissions(manage_messages=True)  
async def clear(ctx, number):
 
    if ctx.message.author.server_permissions.manage_messages:
         mgs = [] #Empty list to put all the messages in the log
         number = int(number) #Converting the amount of messages to delete to an integer
    async for x in client.logs_from(ctx.message.channel, limit = number+1):
        mgs.append(x)            
       
    try:
        await client.delete_messages(mgs)          
        await client.say(str(number)+' messages deleted')
     
    except discord.Forbidden:
        await client.say(embed=Forbidden)
        return
    except discord.HTTPException:
        await client.say('clear failed.')
        return         
   
 
    await client.delete_messages(mgs)      

 
@client.event
async def on_message_delete(message):
    if not message.author.bot:
      channelname = 'information-log'
      logchannel=None
      for channel in message.server.channels:
        if channel.name == channelname:
          user = message.author
      for channel in user.server.channels:
        if channel.name == 'soyal-log':
          logchannel = channel
          r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
          embed = discord.Embed(color = discord.Color((r << 16) + (g << 8) + b))
          embed.set_author(name='Message deleted')
          embed.add_field(name = 'User: **{0}**'.format(user.name),value ='UserID: **{}**'.format(user.id),inline = False)
          embed.add_field(name = 'Message:',value ='{}'.format(message.content),inline = False)
          embed.add_field(name = 'Channel:',value ='{}'.format(message.channel.name),inline = False)
          await client.send_message(logchannel,  embed=embed)	
		
@client.command(pass_context = True)
async def avatar(ctx, user: discord.Member=None):
    if user is None:
        r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
        embed = discord.Embed(title=f'Avatar', description='Avatar is profile picture of a user in discord', color = discord.Color((r << 16) + (g << 8) + b))
        embed.add_field(name='User: {}'.format(ctx.message.author.name), value='Avatar:', inline=True)
        embed.set_thumbnail(url='https://cdn.discordapp.com/attachments/520159870448566287/520829749095038977/pubg.png') 
        embed.set_image(url = ctx.message.author.avatar_url)
        await client.say(embed=embed)
    else:
        r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
        embed = discord.Embed(title=f'Avatar', description='Avatar is profile picture of a user in discord', color = discord.Color((r << 16) + (g << 8) + b))
        embed.add_field(name='User: {}'.format(user.name), value='Avatar:', inline=True)
        embed.set_thumbnail(url='https://cdn.discordapp.com/attachments/520159870448566287/520829749095038977/pubg.png') 
        embed.set_image(url = user.avatar_url)
        await client.say(embed=embed)

@client.command(pass_context = True)
async def meme(ctx):
    choices = ['https://cheezburger.com/6946821/37-funny-random-memes-and-tweets-thatll-make-your-abs-sore', 'https://img.memecdn.com/english_o_869587.webp', 'https://i.imgur.com/E45OMsz.png', 'https://i.imgur.com/ONhilpQ.png', 'https://imgur.com/gallery/MzzrUWL', 'https://imgur.com/gallery/wrDxd43', 'https://imgur.com/gallery/HmQvoyP', 'https://imgur.com/gallery/JZIYuUZ', 'https://imgur.com/gallery/CTJKXOk', 'https://imgur.com/gallery/otW0j4u', 'https://imgur.com/gallery/OwILYdb', 'https://img.memecdn.com/everybody-knows-muricans-don-amp-039-t-speak-english-the-same-way-mexicans-don-amp-039-t-speak-spanish_c_7233205.webp', 'https://img.memecdn.com/english-reaction-when-they-heard-about-eu_c_6994013.webp', 'https://images3.memedroid.com/images/UPLOADED393/5b0c3ee92799f.jpeg' , 'https://images7.memedroid.com/images/UPLOADED850/5b0c2d7dd6049.jpeg', 'https://images7.memedroid.com/images/UPLOADED905/5b0c30c468fa8.jpeg', 'https://images7.memedroid.com/images/UPLOADED726/5b0c2d4c5f288.jpeg', 'https://images7.memedroid.com/images/UPLOADED936/5b0c2a90adbe7.jpeg', 'https://images7.memedroid.com/images/UPLOADED764/5b0c1e491c669.jpeg', 'https://images3.memedroid.com/images/UPLOADED922/5b0c284b71cd0.jpeg', 'https://images3.memedroid.com/images/UPLOADED207/5b0c265a58cf4.jpeg', 'https://images7.memedroid.com/images/UPLOADED920/5b0c06813741a.jpeg', 'https://images3.memedroid.com/images/UPLOADED46/5a91c871e61f1.jpeg', 'https://images7.memedroid.com/images/UPLOADED737/5a91c7f234bd2.jpeg', 'https://images7.memedroid.com/images/UPLOADED757/5a91bd39e1323.jpeg', 'https://images7.memedroid.com/images/UPLOADED963/5a91b4f7aba7e.jpeg', 'https://images7.memedroid.com/images/UPLOADED794/5a91ac0900506.jpeg', 'https://images3.memedroid.com/images/UPLOADED188/5a91aa326ad4e.jpeg', 'https://www.google.co.in/search?q=meme&rlz=1C1CHBF_enIN808IN808&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjR59bhhZPfAhUZEnIKHRzUAvkQ_AUIDigB&biw=1366&bih=664']
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
    embed = discord.Embed(title='Random Meme', description=':upside_down:', color = discord.Color((r << 16) + (g << 8) + b))
    embed.set_thumbnail(url='https://cdn.discordapp.com/attachments/520159870448566287/520829749095038977/pubg.png') 
    embed.set_image(url = random.choice(choices))
    await client.send_typing(ctx.message.channel)
    await client.send_message(ctx.message.channel, embed=embed) 

@client.command(pass_context=True, aliases=['server'])
@commands.has_permissions(kick_members=True)
async def membercount(ctx, *args):
    """
    Shows stats and information about current guild.
    ATTENTION: Please only use this on your own guilds or with explicit
    permissions of the guilds administrators!
    """
    if ctx.message.channel.is_private:
        await bot.delete_message(ctx.message)
        return

    g = ctx.message.server

    gid = g.id
    membs = str(len(g.members))
    membs_on = str(len([m for m in g.members if not m.status == Status.offline]))
    users = str(len([m for m in g.members if not m.bot]))
    users_on = str(len([m for m in g.members if not m.bot and not m.status == Status.offline]))
    bots = str(len([m for m in g.members if m.bot]))
    bots_on = str(len([m for m in g.members if m.bot and not m.status == Status.offline]))
    created = str(g.created_at)
    
    em = Embed(title="Membercount")
    em.description =    "```\n" \
                        "Members:   %s (%s)\n" \
                        "  Users:   %s (%s)\n" \
                        "  Bots:    %s (%s)\n" \
                        "Created:   %s\n" \
                        "```" % (membs, membs_on, users, users_on, bots, bots_on, created)

    await client.send_message(ctx.message.channel, embed=em)
    await client.delete_message(ctx.message)
	
	
@client.command(pass_context = True)
@commands.has_permissions(administrator=True)
async def channelsetup(ctx):
    author = ctx.message.author
    server = ctx.message.server
    mod_perms = discord.Permissions(manage_messages=True, kick_members=True, manage_nicknames =True,mute_members=True)
    admin_perms = discord.Permissions(ADMINISTRATOR=True)

    await client.create_role(author.server, name="Owner", permissions=admin_perms)
    await client.create_role(author.server, name="Admin", permissions=admin_perms)
    await client.create_role(author.server, name="Moderator", permissions=mod_perms)
    await client.create_role(author.server, name="Muted")
    
    await client.create_role(author.server, name="Friend of Owner")
    await client.create_role(author.server, name="Verified")
    everyone_perms = discord.PermissionOverwrite(send_messages=False, read_messages=True)
    everyone = discord.ChannelPermissions(target=server.default_role, overwrite=everyone_perms)
    user_perms = discord.PermissionOverwrite(read_messages=True)
    user = discord.ChannelPermissions(target=server.default_role, overwrite=user_perms)
    private_perms = discord.PermissionOverwrite(read_messages=False)
    private = discord.ChannelPermissions(target=server.default_role, overwrite=private_perms)    
    await client.create_channel(server, 'welcome_suagat',everyone)
    await client.create_channel(server, 'left_mat-ja-yar',everyone)
    await client.create_channel(server, 'announcement',everyone)
    await client.create_channel(server, 'give_away',everyone)
    await client.create_channel(server, 'self_assignable_roles',everyone)
    await client.create_channel(server, 'g_e_n_e_r_a_l',user)
    await client.create_channel(server, 'screenshot_image',user)
    await client.create_channel(server, 'promote_links',user)
    await client.create_channel(server, 'dark_memers',user)
    await client.create_channel(server, 'aki__play',user)
    await client.create_channel(server, 'spam_here',user)
    await client.create_channel(server, 'bot_commands',user)
    await client.create_channel(server, 'private_chat',private)
    await client.create_channel(server, 'General', type=discord.ChannelType.voice)
    await client.create_channel(server, 'music_commands',user)
    await client.create_channel(server, 'music', type=discord.ChannelType.voice)
    await client.create_channel(server, 'pokémon_catching',user)
    await client.create_channel(server, 'pokémon_dueling',user)
    await client.create_channel(server, 'pokémon_commands',user)
    await client.create_channel(server, 'A_F_K', type=discord.ChannelType.voice)




client.run(os.getenv('Token')) 

df114f993d3495f7b4b451725e94a294bdf7feee
<mask token>

<mask token>
client.remove_command('help')


async def status_task():
    while True:
        await client.change_presence(game=discord.Game(name='!!help'))
        await asyncio.sleep(5)
        await client.change_presence(game=discord.Game(name='with ' + str(
            len(set(client.get_all_members()))) + ' users'))
        await asyncio.sleep(5)
        await client.change_presence(game=discord.Game(name='in ' + str(len
            (client.servers)) + ' servers'))
        await asyncio.sleep(5)


@client.command(pass_context=True)
async def google(ctx, *, message):
    new_message = message.replace(' ', '+')
    url = f'https://www.google.com/search?q={new_message}'
    await client.say(url)


@client.command(pass_context=True)
async def youtube(ctx, *, message: str):
    new_message = message.replace(' ', '+')
    url = f'https://www.youtube.com/results?search_query={new_message}'
    await client.say(url)


@client.command(pass_context=True)
async def skincolor(ctx, user: discord.Member):
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random
        (), 1, 1))
    random.seed(user.id)
    skins = ['White', 'Black', 'Blue', 'Green', 'Rainbow', 'Purple',
        'Brown', 'Pink', 'Cream', 'Orange']
    if user == ctx.message.author:
        embed2 = discord.Embed(title='You should know your own skin color',
            color=discord.Color((r << 16) + (g << 8) + b))
        await client.say(embed=embed2)
    else:
        embed = discord.Embed(color=13314170)
        embed.add_field(name=f"{user.name}'s skin color", value=random.
            choice(skins))
        await client.say(embed=embed)


@client.command(pass_context=True)
async def unverify(ctx):
    await client.delete_message(ctx.message)
    role = discord.utils.get(ctx.message.server.roles, name='Unverified')
    await client.add_roles(ctx.message.author, role)


@client.command(pass_context=True)
async def verify(ctx):
    if ctx.message.author.bot:
        return
    else:
        await client.delete_message(ctx.message)
        role = discord.utils.get(ctx.message.server.roles, name='Verified')
        await client.add_roles(ctx.message.author, role)


@client.command(pass_context=True)
@commands.check(is_soyal)
async def botdm(ctx, user: discord.Member, *, msg: str):
    await client.send_typing(user)
    await client.send_message(user, msg)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def announce(ctx, channel: discord.Channel=None, *, msg: str):
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random
        (), 1, 1))
    embed = discord.Embed(title='Announcement', description='{}'.format(msg
        ), color=discord.Color((r << 16) + (g << 8) + b))
    await client.send_message(channel, embed=embed)
    await client.delete_message(ctx.message)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def embed(ctx, *args):
    if ctx.message.author.bot:
        return
    else:
        argstr = ' '.join(args)
        r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.
            random(), 1, 1))
        text = argstr
        color = discord.Color((r << 16) + (g << 8) + b)
        await client.send_message(ctx.message.channel, embed=Embed(color=
            color, description=text))
        await client.delete_message(ctx.message)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def dm(ctx, user: discord.Member, *, msg: str):
    try:
        await client.send_message(user, msg)
        await client.delete_message(ctx.message)
        await client.say('Success! Your DM has made it! :white_check_mark: ')
    except discord.ext.commands.MissingPermissions:
        await client.say(
            "Aw, come on! You thought you could get away with DM'ing people without permissions."
            )
    except:
        await client.say(
            'Error :x:. Make sure your message is shaped in this way: ^dm [tag person] [msg]'
            )


@client.command(pass_context=True)
async def botinvite(ctx):
    if ctx.message.author.bot:
        return
    else:
        embed = discord.Embed(title='Click on this link to invite:',
            description=
            'https://discordapp.com/api/oauth2/authorize?client_id=520267296506249216&permissions=8&scope=bot'
            , color=64795)
        await client.say(embed=embed)


@client.command(pass_context=True)
async def test(ctx):
    if ctx.message.author.bot:
        return
    else:
        await client.send_message(ctx.message.author, 'Hii bro what supp')
        await client.say('Check your dm ')


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def kick(ctx, user: discord.member):
    if user.server_permissions.kick_members:
        await client.say('**He is mod/admin and i am unable to kick him/her**')
        return
    else:
        await client.kick(user)
        await client.say(user.name + ' was kicked. Good bye ' + user.name + '!'
            )
        await client.delete_message(ctx.message)
        for channel in user.server.channels:
            if channel.name == 'Soyal-log':
                embed = discord.Embed(title='User kicked!', description=
                    '**{0}** is kicked by **{1}**!'.format(user, ctx.
                    message.author), color=16638226)
                await client.send_message(channel, embed=embed)


@client.command(pass_context=True)
async def play(ctx, *, url):
    author = ctx.message.author
    voice_channel = author.voice_channel
    try:
        vc = await client.join_voice_channel(voice_channel)
        msg = await client.say('Loading...')
        player = await vc.create_ytdl_player('ytsearch:' + url)
        player.start()
        await client.say('Succesfully Loaded ur song!')
        await client.delete_message(msg)
    except Exception as e:
        print(e)
        await client.say('Reconnecting')
        for x in client.voice_clients:
            if x.server == ctx.message.server:
                await x.disconnect()
                nvc = await client.join_voice_channel(voice_channel)
                msg = await client.say('Loading...')
                player2 = await nvc.create_ytdl_player('ytsearch:' + url)
                player2.start


@client.command(pass_context=True)
async def stop(ctx):
    for x in client.voice_clients:
        if x.server == ctx.message.server:
            return await x.disconnect()
    return await client.say('I am not playing anyting???!')


@client.command(pass_context=True)
async def happybirthday(ctx, *, msg=None):
    if '@here' in msg or '@everyone' in msg:
        return
    if not msg:
        await client.say('Please specify a user to wish')
    await client.say('Happy birthday have a nice day' + msg +
        ' http://imgur.com/gallery/PbyNCR2')
    return


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def emojiids(ctx):
    for emoji in ctx.message.author.server.emojis:
        print(f'<:{emoji.name}:{emoji.id}>')
        print(' ')


@client.command(pass_context=True)
async def wow(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:WOW:515854429485006848>')


@client.command(pass_context=True)
async def dank(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:OnThaCoco:515853700682743809>')


@client.command(pass_context=True)
async def santa(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:santa:517232271678504970>')


@client.command(pass_context=True)
async def hi(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:hi:517232279148429313>')


@client.command(pass_context=True)
async def lol(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:lol:517232283670020096>')


@client.command(pass_context=True)
async def love(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:love:517232300912672774>')


@client.command(pass_context=True)
async def mad(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:mad:517232301176913951>')


@client.command(pass_context=True)
async def alien(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:alien:517232332663422986>')


@client.command(pass_context=True)
async def fearfromme(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:shiroeglassespush:516174320532193289>')


@client.command(pass_context=True)
async def angry(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:angear:516174316950388772>')


@client.command(pass_context=True)
async def surprised(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:eyebigger:516174315058626560>')


@client.command(pass_context=True)
async def cat(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:agooglecat:516174312294842389>')


@client.command(pass_context=True)
async def thinking1(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:thinking:516183328613990400>')


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def setuplog(ctx):
    if ctx.message.author.bot:
        return
    else:
        server = ctx.message.server
        everyone_perms = discord.PermissionOverwrite(send_messages=False,
            read_messages=True)
        everyone = discord.ChannelPermissions(target=server.default_role,
            overwrite=everyone_perms)
        await client.create_channel(server, 'information-log', everyone)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def setupwelcome(ctx):
    if ctx.message.author.bot:
        return
    else:
        server = ctx.message.server
        everyone_perms = discord.PermissionOverwrite(send_messages=False,
            read_messages=True)
        everyone = discord.ChannelPermissions(target=server.default_role,
            overwrite=everyone_perms)
        await client.create_channel(server, 'welcome_swagat', everyone)


@client.event
async def on_member_join(member):
    for channel in member.server.channels:
        if channel.name == 'welcome_swagat':
            r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(
                random.random(), 1, 1))
            embed = discord.Embed(title=
                f'Welcome {member.name} to {member.server.name}',
                description=
                'Do not forget to check rules and never try to break any one of them'
                , color=discord.Color((r << 16) + (g << 8) + b))
            embed.add_field(name='__Thanks for joining__', value=
                '**Hope you will be active here.**', inline=True)
            embed.set_thumbnail(url=
                'https://cdn.discordapp.com/attachments/486489391083159574/520207004334292992/Loading.gif'
                )
            embed.set_image(url=member.avatar_url)
            embed.add_field(name='__Join position__', value='{}'.format(str
                (member.server.member_count)), inline=True)
            embed.add_field(name='Time of joining', value=member.joined_at)
            await client.send_message(channel, embed=embed)


@client.event
async def on_member_remove(member):
    for channel in member.server.channels:
        if channel.name == 'welcome_swagat':
            r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(
                random.random(), 1, 1))
            embed = discord.Embed(title=
                f'{member.name} just left {member.server.name}',
                description='Bye bye 👋! We will miss you 😢', color=discord.
                Color((r << 16) + (g << 8) + b))
            embed.add_field(name='__User left__', value=
                '**Hope you will be back soon 😕.**', inline=True)
            embed.add_field(name='Your join position was', value=member.
                joined_at)
            embed.set_thumbnail(url=member.avatar_url)
            await client.send_message(channel, embed=embed)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def rolesetup(ctx):
    author = ctx.message.author
    server = ctx.message.server
    mod_perms = discord.Permissions(manage_messages=True, kick_members=True,
        manage_nicknames=True, mute_members=True)
    admin_perms = discord.Permissions(ADMINISTRATOR=True)
    await client.create_role(author.server, name='Owner', permissions=
        admin_perms)
    await client.create_role(author.server, name='Admin', permissions=
        admin_perms)
    await client.create_role(author.server, name='Senior Moderator',
        permissions=mod_perms)
    await client.create_role(author.server, name='G.O.H')
    await client.create_role(author.server, name='Moderator', permissions=
        mod_perms)
    await client.create_role(author.server, name='Muted')
    await client.create_role(author.server, name='Friend of Owner')


@commands.has_permissions(manage_roles=True)
async def role(ctx, user: discord.Member, *, role: discord.Role=None):
    if role is None:
        return await client.say("You haven't specified a role! ")
    if role not in user.roles:
        await client.add_roles(user, role)
        return await client.say('{} role has been added to {}.'.format(role,
            user))
    if role in user.roles:
        await client.remove_roles(user, role)
        return await client.say('{} role has been removed from {}.'.format(
            role, user))


@client.command(pass_context=True)
@commands.has_permissions(kick_members=True)
async def warn(ctx, userName: discord.User, *, message: str):
    await client.send_message(userName, 'You have been warned for: **{}**'.
        format(message))
    await client.say(
        ':warning: __**{0} Has Been Warned!**__ :warning: ** Reason:{1}** '
        .format(userName, message))
    pass


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def say(ctx, *, msg=None):
    await client.delete_message(ctx.message)
    if not msg:
        await client.say('Please specify a message to send')
    else:
        await client.say(msg)
    return


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def friend(ctx, user: discord.Member):
    await client.delete_message(ctx.message)
    role = discord.utils.get(ctx.message.server.roles, name='Friend of Owner')
    await client.add_roles(ctx.message.mentions[0], role)


@client.command(pass_context=True)
async def ownerinfo(ctx):
    embed = discord.Embed(title='Information about owner', description=
        'Bot Name- MARCOS', color=65280)
    embed.set_footer(text='MARCOS')
    embed.set_author(name=' Bot Owner Name- MARCOS')
    embed.add_field(name='Site- coming soon...', value=
        'Thanks for adding our bot', inline=True)
    await client.say(embed=embed)


@client.command(pass_context=True)
@commands.has_permissions(kick_members=True)
async def getuser(ctx, role: discord.Role=None):
    if role is None:
        await client.say('There is no "STAFF" role on this server!')
        return
    empty = True
    for member in ctx.message.server.members:
        if role in member.roles:
            await client.say('{0.name}: {0.id}'.format(member))
            empty = False
    if empty:
        await client.say('Nobody has the role {}'.format(role.mention))


@client.command(pass_context=True)
@commands.has_permissions(kick_members=True)
async def userinfo(ctx, user: discord.Member):
    if ctx.message.author.bot:
        return
    else:
        r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.
            random(), 1, 1))
        embed = discord.Embed(title="{}'s info".format(user.name),
            description="Here's what I could find.", color=discord.Color((r <<
            16) + (g << 8) + b))
        embed.add_field(name='Name', value=user.name, inline=True)
        embed.add_field(name='ID', value=user.id, inline=True)
        embed.add_field(name='Status', value=user.status, inline=True)
        embed.add_field(name='Highest role', value=user.top_role)
        embed.add_field(name='Joined', value=user.joined_at)
        embed.set_thumbnail(url=user.avatar_url)
        await client.say(embed=embed)


@client.command(pass_context=True)
@commands.has_permissions(kick_members=True)
@commands.cooldown(rate=5, per=86400, type=BucketType.user)
async def access(ctx, member: discord.Member):
    if ctx.message.author.bot:
        return
    else:
        role = discord.utils.get(member.server.roles, name='access')
        await client.add_roles(member, role)
        await client.say('Gave access to {}'.format(member))
        for channel in member.server.channels:
            if channel.name == 'soyal-log':
                embed = discord.Embed(title='User Got Access!', description
                    ='**{0}** got access from **{1}**!'.format(member, ctx.
                    message.author), color=131586)
                await client.send_message(channel, embed=embed)
                await asyncio.sleep(45 * 60)
                await client.remove_roles(member, role)


@client.command(pass_context=True)
@commands.has_permissions(manage_nicknames=True)
async def setnick(ctx, user: discord.Member, *, nickname):
    await client.change_nickname(user, nickname)
    await client.delete_message(ctx.message)
    for channel in user.server.channels:
        if channel.name == 'soyal-log':
            embed = discord.Embed(title='Changed Nickname of User!',
                description='**{0}** nickname was changed by **{1}**!'.
                format(member, ctx.message.author), color=336374)
            await client.send_message(channel, embed=embed)


@client.command(pass_context=True)
async def poll(ctx, question, *options: str):
    if len(options) <= 1:
        await client.say('You need more than one option to make a poll!')
        return
    if len(options) > 10:
        await client.say('You cannot make a poll for more than 10 things!')
        return
    if len(options) == 2 and options[0] == 'yes' and options[1] == 'no':
        reactions = ['👍', '👎']
    else:
        reactions = ['1⃣', '2⃣', '3⃣', '4⃣', '5⃣', '6⃣', '7⃣', '8⃣', '9⃣', '🔟']
    description = []
    for x, option in enumerate(options):
        description += '\n {} {}'.format(reactions[x], option)
        r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.
            random(), 1, 1))
    embed = discord.Embed(title=question, description=''.join(description),
        color=discord.Color((r << 16) + (g << 8) + b))
    react_message = await client.say(embed=embed)
    for reaction in reactions[:len(options)]:
        await client.add_reaction(react_message, reaction)
    embed.set_footer(text='Poll ID: {}'.format(react_message.id))
    await client.edit_message(react_message, embed=embed)


@client.command(pass_context=True)
@commands.has_permissions(ban_members=True)
async def ban(ctx, user: discord.Member):
    if user.server_permissions.ban_members:
        await client.say('**He is mod/admin and i am unable to ban him/her**')
        return
    else:
        await client.ban(user)
        await client.say(user.name + ' was banned. Good bye ' + user.name + '!'
            )
        for channel in member.server.channels:
            if channel.name == 'information-log':
                embed = discord.Embed(title='User banned!', description=
                    '**{0}** banned by **{1}**!'.format(member, ctx.message
                    .author), color=3700253)
                await client.send_message(channel, embed=embed)


@client.command(pass_context=True)
@commands.has_permissions(ban_members=True)
async def unban(ctx):
    ban_list = await client.get_bans(ctx.message.server)
    await client.say('Ban list:\n{}'.format('\n'.join([user.name for user in
        ban_list])))
    if not ban_list:
        await client.say('Ban list is empty.')
        return
    else:
        await client.unban(ctx.message.server, ban_list[-1])
        await client.say('Unbanned user: `{}`'.format(ban_list[-1].name))
        for channel in member.server.channels:
            if channel.name == 'soyal-log':
                embed = discord.Embed(title='User unbanned!', description=
                    '**{0}** unbanned by **{1}**!'.format(ban_list[-1].name,
                    ctx.message.author), color=3700253)
                await client.send_message(channel, embed=embed)


@client.command(pass_context=True)
@commands.has_permissions(kick_members=True)
async def serverinfo(ctx):
    """Displays Info About The Server!"""
    server = ctx.message.server
    roles = [x.name for x in server.role_hierarchy]
    role_length = len(roles)
    if role_length > 50:
        roles = roles[:50]
        roles.append('>>>> Displaying[50/%s] Roles' % len(roles))
    roles = ', '.join(roles)
    channelz = len(server.channels)
    time = str(server.created_at)
    time = time.split(' ')
    time = time[0]
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random
        (), 1, 1))
    join = discord.Embed(description='%s ' % str(server), title=
        'Server Name', color=discord.Color((r << 16) + (g << 8) + b))
    join.set_thumbnail(url=server.icon_url)
    join.add_field(name='__Owner__', value=str(server.owner) + '\n' +
        server.owner.id)
    join.add_field(name='__ID__', value=str(server.id))
    join.add_field(name='__Member Count__', value=str(server.member_count))
    join.add_field(name='__Text/Voice Channels__', value=str(channelz))
    join.add_field(name='__Roles (%s)__' % str(role_length), value=roles)
    join.set_footer(text='Created: %s' % time)
    return await client.say(embed=join)


@client.command(pass_context=True)
async def apply(ctx, *, msg: str):
    channel = client.get_channel('520830825021964305')
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random
        (), 1, 1))
    embed = discord.Embed(color=discord.Color((r << 16) + (g << 8) + b))
    embed.add_field(name='Application for bot', value='-------------------',
        inline=False)
    embed.add_field(name='User ID:', value='{}'.format(ctx.message.author.
        id), inline=False)
    embed.add_field(name='User Name:', value='{}'.format(ctx.message.author
        .name), inline=False)
    embed.add_field(name='Server Name:', value='{}'.format(ctx.message.
        server.name), inline=False)
    embed.add_field(name='Bot information:', value=msg, inline=False)
    await client.send_message(channel, embed=embed)
    await client.delete_message(ctx.message)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def makemod(ctx, user: discord.Member):
    nickname = '[̲̅M̲̅]' + user.name
    await client.change_nickname(user, nickname=nickname)
    role = discord.utils.get(ctx.message.server.roles, name='Moderator')
    await client.add_roles(user, role)
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random
        (), 1, 1))
    embed = discord.Embed(color=discord.Color((r << 16) + (g << 8) + b))
    embed.set_author(name='Congratulations Message')
    embed.add_field(name='__Congratulations__', value=
        '**Congratulations for mod.Hope you will be more active here. Thanks for your help and support.**'
        , inline=False)
    embed.set_image(url='https://preview.ibb.co/i1izTz/ezgif_5_e20b665628.gif')
    await client.send_message(user, embed=embed)
    await client.delete_message(ctx.message)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def makeadmin(ctx, user: discord.Member):
    nickname = 'Ѧ' + user.name
    await client.change_nickname(user, nickname=nickname)
    role = discord.utils.get(ctx.message.server.roles, name='Admin')
    await client.add_roles(user, role)
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random
        (), 1, 1))
    embed = discord.Embed(color=discord.Color((r << 16) + (g << 8) + b))
    embed.set_author(name='Congratulations Message')
    embed.add_field(name='__Congratulations__', value=
        '**Congratulations for Admin.Hope you will be more active here. Thanks for your help and support.**'
        , inline=False)
    embed.set_image(url='https://preview.ibb.co/i1izTz/ezgif_5_e20b665628.gif')
    await client.send_message(user, embed=embed)
    await client.delete_message(ctx.message)


@client.command(pass_context=True)
async def sorry(ctx, *, msg=None):
    if '@here' in msg or '@everyone' in msg:
        return
    if not msg:
        await client.say('Please Sorry')
    await client.say('Sorry ' + msg + ' http://imgur.com/gallery/Dif2lYI')
    return


@client.command(pass_context=True)
@commands.has_permissions(manage_messages=True)
async def clear(ctx, number):
    if ctx.message.author.server_permissions.manage_messages:
        mgs = []
        number = int(number)
    async for x in client.logs_from(ctx.message.channel, limit=number + 1):
        mgs.append(x)
    try:
        await client.delete_messages(mgs)
        await client.say(str(number) + ' messages deleted')
    except discord.Forbidden:
        await client.say(embed=Forbidden)
        return
    except discord.HTTPException:
        await client.say('clear failed.')
        return
    await client.delete_messages(mgs)


@client.event
async def on_message_delete(message):
    if not message.author.bot:
        channelname = 'information-log'
        logchannel = None
        for channel in message.server.channels:
            if channel.name == channelname:
                user = message.author
        for channel in user.server.channels:
            if channel.name == 'soyal-log':
                logchannel = channel
                r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(
                    random.random(), 1, 1))
                embed = discord.Embed(color=discord.Color((r << 16) + (g <<
                    8) + b))
                embed.set_author(name='Message deleted')
                embed.add_field(name='User: **{0}**'.format(user.name),
                    value='UserID: **{}**'.format(user.id), inline=False)
                embed.add_field(name='Message:', value='{}'.format(message.
                    content), inline=False)
                embed.add_field(name='Channel:', value='{}'.format(message.
                    channel.name), inline=False)
                await client.send_message(logchannel, embed=embed)


@client.command(pass_context=True)
async def avatar(ctx, user: discord.Member=None):
    if user is None:
        r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.
            random(), 1, 1))
        embed = discord.Embed(title=f'Avatar', description=
            'Avatar is profile picture of a user in discord', color=discord
            .Color((r << 16) + (g << 8) + b))
        embed.add_field(name='User: {}'.format(ctx.message.author.name),
            value='Avatar:', inline=True)
        embed.set_thumbnail(url=
            'https://cdn.discordapp.com/attachments/520159870448566287/520829749095038977/pubg.png'
            )
        embed.set_image(url=ctx.message.author.avatar_url)
        await client.say(embed=embed)
    else:
        r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.
            random(), 1, 1))
        embed = discord.Embed(title=f'Avatar', description=
            'Avatar is profile picture of a user in discord', color=discord
            .Color((r << 16) + (g << 8) + b))
        embed.add_field(name='User: {}'.format(user.name), value='Avatar:',
            inline=True)
        embed.set_thumbnail(url=
            'https://cdn.discordapp.com/attachments/520159870448566287/520829749095038977/pubg.png'
            )
        embed.set_image(url=user.avatar_url)
        await client.say(embed=embed)


@client.command(pass_context=True)
async def meme(ctx):
    choices = [
        'https://cheezburger.com/6946821/37-funny-random-memes-and-tweets-thatll-make-your-abs-sore'
        , 'https://img.memecdn.com/english_o_869587.webp',
        'https://i.imgur.com/E45OMsz.png',
        'https://i.imgur.com/ONhilpQ.png',
        'https://imgur.com/gallery/MzzrUWL',
        'https://imgur.com/gallery/wrDxd43',
        'https://imgur.com/gallery/HmQvoyP',
        'https://imgur.com/gallery/JZIYuUZ',
        'https://imgur.com/gallery/CTJKXOk',
        'https://imgur.com/gallery/otW0j4u',
        'https://imgur.com/gallery/OwILYdb',
        'https://img.memecdn.com/everybody-knows-muricans-don-amp-039-t-speak-english-the-same-way-mexicans-don-amp-039-t-speak-spanish_c_7233205.webp'
        ,
        'https://img.memecdn.com/english-reaction-when-they-heard-about-eu_c_6994013.webp'
        ,
        'https://images3.memedroid.com/images/UPLOADED393/5b0c3ee92799f.jpeg',
        'https://images7.memedroid.com/images/UPLOADED850/5b0c2d7dd6049.jpeg',
        'https://images7.memedroid.com/images/UPLOADED905/5b0c30c468fa8.jpeg',
        'https://images7.memedroid.com/images/UPLOADED726/5b0c2d4c5f288.jpeg',
        'https://images7.memedroid.com/images/UPLOADED936/5b0c2a90adbe7.jpeg',
        'https://images7.memedroid.com/images/UPLOADED764/5b0c1e491c669.jpeg',
        'https://images3.memedroid.com/images/UPLOADED922/5b0c284b71cd0.jpeg',
        'https://images3.memedroid.com/images/UPLOADED207/5b0c265a58cf4.jpeg',
        'https://images7.memedroid.com/images/UPLOADED920/5b0c06813741a.jpeg',
        'https://images3.memedroid.com/images/UPLOADED46/5a91c871e61f1.jpeg',
        'https://images7.memedroid.com/images/UPLOADED737/5a91c7f234bd2.jpeg',
        'https://images7.memedroid.com/images/UPLOADED757/5a91bd39e1323.jpeg',
        'https://images7.memedroid.com/images/UPLOADED963/5a91b4f7aba7e.jpeg',
        'https://images7.memedroid.com/images/UPLOADED794/5a91ac0900506.jpeg',
        'https://images3.memedroid.com/images/UPLOADED188/5a91aa326ad4e.jpeg',
        'https://www.google.co.in/search?q=meme&rlz=1C1CHBF_enIN808IN808&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjR59bhhZPfAhUZEnIKHRzUAvkQ_AUIDigB&biw=1366&bih=664'
        ]
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random
        (), 1, 1))
    embed = discord.Embed(title='Random Meme', description=':upside_down:',
        color=discord.Color((r << 16) + (g << 8) + b))
    embed.set_thumbnail(url=
        'https://cdn.discordapp.com/attachments/520159870448566287/520829749095038977/pubg.png'
        )
    embed.set_image(url=random.choice(choices))
    await client.send_typing(ctx.message.channel)
    await client.send_message(ctx.message.channel, embed=embed)


@client.command(pass_context=True, aliases=['server'])
@commands.has_permissions(kick_members=True)
async def membercount(ctx, *args):
    """
    Shows stats and information about current guild.
    ATTENTION: Please only use this on your own guilds or with explicit
    permissions of the guilds administrators!
    """
    if ctx.message.channel.is_private:
        await bot.delete_message(ctx.message)
        return
    g = ctx.message.server
    gid = g.id
    membs = str(len(g.members))
    membs_on = str(len([m for m in g.members if not m.status == Status.
        offline]))
    users = str(len([m for m in g.members if not m.bot]))
    users_on = str(len([m for m in g.members if not m.bot and not m.status ==
        Status.offline]))
    bots = str(len([m for m in g.members if m.bot]))
    bots_on = str(len([m for m in g.members if m.bot and not m.status ==
        Status.offline]))
    created = str(g.created_at)
    em = Embed(title='Membercount')
    em.description = (
        """```
Members:   %s (%s)
  Users:   %s (%s)
  Bots:    %s (%s)
Created:   %s
```"""
         % (membs, membs_on, users, users_on, bots, bots_on, created))
    await client.send_message(ctx.message.channel, embed=em)
    await client.delete_message(ctx.message)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def channelsetup(ctx):
    author = ctx.message.author
    server = ctx.message.server
    mod_perms = discord.Permissions(manage_messages=True, kick_members=True,
        manage_nicknames=True, mute_members=True)
    admin_perms = discord.Permissions(ADMINISTRATOR=True)
    await client.create_role(author.server, name='Owner', permissions=
        admin_perms)
    await client.create_role(author.server, name='Admin', permissions=
        admin_perms)
    await client.create_role(author.server, name='Moderator', permissions=
        mod_perms)
    await client.create_role(author.server, name='Muted')
    await client.create_role(author.server, name='Friend of Owner')
    await client.create_role(author.server, name='Verified')
    everyone_perms = discord.PermissionOverwrite(send_messages=False,
        read_messages=True)
    everyone = discord.ChannelPermissions(target=server.default_role,
        overwrite=everyone_perms)
    user_perms = discord.PermissionOverwrite(read_messages=True)
    user = discord.ChannelPermissions(target=server.default_role, overwrite
        =user_perms)
    private_perms = discord.PermissionOverwrite(read_messages=False)
    private = discord.ChannelPermissions(target=server.default_role,
        overwrite=private_perms)
    await client.create_channel(server, 'welcome_suagat', everyone)
    await client.create_channel(server, 'left_mat-ja-yar', everyone)
    await client.create_channel(server, 'announcement', everyone)
    await client.create_channel(server, 'give_away', everyone)
    await client.create_channel(server, 'self_assignable_roles', everyone)
    await client.create_channel(server, 'g_e_n_e_r_a_l', user)
    await client.create_channel(server, 'screenshot_image', user)
    await client.create_channel(server, 'promote_links', user)
    await client.create_channel(server, 'dark_memers', user)
    await client.create_channel(server, 'aki__play', user)
    await client.create_channel(server, 'spam_here', user)
    await client.create_channel(server, 'bot_commands', user)
    await client.create_channel(server, 'private_chat', private)
    await client.create_channel(server, 'General', type=discord.ChannelType
        .voice)
    await client.create_channel(server, 'music_commands', user)
    await client.create_channel(server, 'music', type=discord.ChannelType.voice
        )
    await client.create_channel(server, 'pokémon_catching', user)
    await client.create_channel(server, 'pokémon_dueling', user)
    await client.create_channel(server, 'pokémon_commands', user)
    await client.create_channel(server, 'A_F_K', type=discord.ChannelType.voice
        )


client.run(os.getenv('Token'))

<mask token>
Forbidden = discord.Embed(title='Permission Denied', description=
    """1) Please check whether you have permission to perform this action or not. 
2) Please check whether my role has permission to perform this action in this channel or not. 
3) Please check my role position."""
    , color=65280)
client = commands.Bot(description='MultiVerse Official Bot', command_prefix
    =commands.when_mentioned_or('!!'), pm_help=True)
client.remove_command('help')


async def status_task():
    while True:
        await client.change_presence(game=discord.Game(name='!!help'))
        await asyncio.sleep(5)
        await client.change_presence(game=discord.Game(name='with ' + str(
            len(set(client.get_all_members()))) + ' users'))
        await asyncio.sleep(5)
        await client.change_presence(game=discord.Game(name='in ' + str(len
            (client.servers)) + ' servers'))
        await asyncio.sleep(5)


@client.command(pass_context=True)
async def google(ctx, *, message):
    new_message = message.replace(' ', '+')
    url = f'https://www.google.com/search?q={new_message}'
    await client.say(url)


@client.command(pass_context=True)
async def youtube(ctx, *, message: str):
    new_message = message.replace(' ', '+')
    url = f'https://www.youtube.com/results?search_query={new_message}'
    await client.say(url)


@client.command(pass_context=True)
async def skincolor(ctx, user: discord.Member):
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random
        (), 1, 1))
    random.seed(user.id)
    skins = ['White', 'Black', 'Blue', 'Green', 'Rainbow', 'Purple',
        'Brown', 'Pink', 'Cream', 'Orange']
    if user == ctx.message.author:
        embed2 = discord.Embed(title='You should know your own skin color',
            color=discord.Color((r << 16) + (g << 8) + b))
        await client.say(embed=embed2)
    else:
        embed = discord.Embed(color=13314170)
        embed.add_field(name=f"{user.name}'s skin color", value=random.
            choice(skins))
        await client.say(embed=embed)


@client.command(pass_context=True)
async def unverify(ctx):
    await client.delete_message(ctx.message)
    role = discord.utils.get(ctx.message.server.roles, name='Unverified')
    await client.add_roles(ctx.message.author, role)


@client.command(pass_context=True)
async def verify(ctx):
    if ctx.message.author.bot:
        return
    else:
        await client.delete_message(ctx.message)
        role = discord.utils.get(ctx.message.server.roles, name='Verified')
        await client.add_roles(ctx.message.author, role)


@client.command(pass_context=True)
@commands.check(is_soyal)
async def botdm(ctx, user: discord.Member, *, msg: str):
    await client.send_typing(user)
    await client.send_message(user, msg)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def announce(ctx, channel: discord.Channel=None, *, msg: str):
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random
        (), 1, 1))
    embed = discord.Embed(title='Announcement', description='{}'.format(msg
        ), color=discord.Color((r << 16) + (g << 8) + b))
    await client.send_message(channel, embed=embed)
    await client.delete_message(ctx.message)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def embed(ctx, *args):
    if ctx.message.author.bot:
        return
    else:
        argstr = ' '.join(args)
        r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.
            random(), 1, 1))
        text = argstr
        color = discord.Color((r << 16) + (g << 8) + b)
        await client.send_message(ctx.message.channel, embed=Embed(color=
            color, description=text))
        await client.delete_message(ctx.message)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def dm(ctx, user: discord.Member, *, msg: str):
    try:
        await client.send_message(user, msg)
        await client.delete_message(ctx.message)
        await client.say('Success! Your DM has made it! :white_check_mark: ')
    except discord.ext.commands.MissingPermissions:
        await client.say(
            "Aw, come on! You thought you could get away with DM'ing people without permissions."
            )
    except:
        await client.say(
            'Error :x:. Make sure your message is shaped in this way: ^dm [tag person] [msg]'
            )


@client.command(pass_context=True)
async def botinvite(ctx):
    if ctx.message.author.bot:
        return
    else:
        embed = discord.Embed(title='Click on this link to invite:',
            description=
            'https://discordapp.com/api/oauth2/authorize?client_id=520267296506249216&permissions=8&scope=bot'
            , color=64795)
        await client.say(embed=embed)


@client.command(pass_context=True)
async def test(ctx):
    if ctx.message.author.bot:
        return
    else:
        await client.send_message(ctx.message.author, 'Hii bro what supp')
        await client.say('Check your dm ')


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def kick(ctx, user: discord.member):
    if user.server_permissions.kick_members:
        await client.say('**He is mod/admin and i am unable to kick him/her**')
        return
    else:
        await client.kick(user)
        await client.say(user.name + ' was kicked. Good bye ' + user.name + '!'
            )
        await client.delete_message(ctx.message)
        for channel in user.server.channels:
            if channel.name == 'Soyal-log':
                embed = discord.Embed(title='User kicked!', description=
                    '**{0}** is kicked by **{1}**!'.format(user, ctx.
                    message.author), color=16638226)
                await client.send_message(channel, embed=embed)


@client.command(pass_context=True)
async def play(ctx, *, url):
    author = ctx.message.author
    voice_channel = author.voice_channel
    try:
        vc = await client.join_voice_channel(voice_channel)
        msg = await client.say('Loading...')
        player = await vc.create_ytdl_player('ytsearch:' + url)
        player.start()
        await client.say('Succesfully Loaded ur song!')
        await client.delete_message(msg)
    except Exception as e:
        print(e)
        await client.say('Reconnecting')
        for x in client.voice_clients:
            if x.server == ctx.message.server:
                await x.disconnect()
                nvc = await client.join_voice_channel(voice_channel)
                msg = await client.say('Loading...')
                player2 = await nvc.create_ytdl_player('ytsearch:' + url)
                player2.start


@client.command(pass_context=True)
async def stop(ctx):
    for x in client.voice_clients:
        if x.server == ctx.message.server:
            return await x.disconnect()
    return await client.say('I am not playing anyting???!')


@client.command(pass_context=True)
async def happybirthday(ctx, *, msg=None):
    if '@here' in msg or '@everyone' in msg:
        return
    if not msg:
        await client.say('Please specify a user to wish')
    await client.say('Happy birthday have a nice day' + msg +
        ' http://imgur.com/gallery/PbyNCR2')
    return


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def emojiids(ctx):
    for emoji in ctx.message.author.server.emojis:
        print(f'<:{emoji.name}:{emoji.id}>')
        print(' ')


@client.command(pass_context=True)
async def wow(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:WOW:515854429485006848>')


@client.command(pass_context=True)
async def dank(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:OnThaCoco:515853700682743809>')


@client.command(pass_context=True)
async def santa(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:santa:517232271678504970>')


@client.command(pass_context=True)
async def hi(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:hi:517232279148429313>')


@client.command(pass_context=True)
async def lol(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:lol:517232283670020096>')


@client.command(pass_context=True)
async def love(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:love:517232300912672774>')


@client.command(pass_context=True)
async def mad(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:mad:517232301176913951>')


@client.command(pass_context=True)
async def alien(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:alien:517232332663422986>')


@client.command(pass_context=True)
async def fearfromme(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:shiroeglassespush:516174320532193289>')


@client.command(pass_context=True)
async def angry(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:angear:516174316950388772>')


@client.command(pass_context=True)
async def surprised(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:eyebigger:516174315058626560>')


@client.command(pass_context=True)
async def cat(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:agooglecat:516174312294842389>')


@client.command(pass_context=True)
async def thinking1(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:thinking:516183328613990400>')


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def setuplog(ctx):
    if ctx.message.author.bot:
        return
    else:
        server = ctx.message.server
        everyone_perms = discord.PermissionOverwrite(send_messages=False,
            read_messages=True)
        everyone = discord.ChannelPermissions(target=server.default_role,
            overwrite=everyone_perms)
        await client.create_channel(server, 'information-log', everyone)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def setupwelcome(ctx):
    if ctx.message.author.bot:
        return
    else:
        server = ctx.message.server
        everyone_perms = discord.PermissionOverwrite(send_messages=False,
            read_messages=True)
        everyone = discord.ChannelPermissions(target=server.default_role,
            overwrite=everyone_perms)
        await client.create_channel(server, 'welcome_swagat', everyone)


@client.event
async def on_member_join(member):
    for channel in member.server.channels:
        if channel.name == 'welcome_swagat':
            r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(
                random.random(), 1, 1))
            embed = discord.Embed(title=
                f'Welcome {member.name} to {member.server.name}',
                description=
                'Do not forget to check rules and never try to break any one of them'
                , color=discord.Color((r << 16) + (g << 8) + b))
            embed.add_field(name='__Thanks for joining__', value=
                '**Hope you will be active here.**', inline=True)
            embed.set_thumbnail(url=
                'https://cdn.discordapp.com/attachments/486489391083159574/520207004334292992/Loading.gif'
                )
            embed.set_image(url=member.avatar_url)
            embed.add_field(name='__Join position__', value='{}'.format(str
                (member.server.member_count)), inline=True)
            embed.add_field(name='Time of joining', value=member.joined_at)
            await client.send_message(channel, embed=embed)


@client.event
async def on_member_remove(member):
    for channel in member.server.channels:
        if channel.name == 'welcome_swagat':
            r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(
                random.random(), 1, 1))
            embed = discord.Embed(title=
                f'{member.name} just left {member.server.name}',
                description='Bye bye 👋! We will miss you 😢', color=discord.
                Color((r << 16) + (g << 8) + b))
            embed.add_field(name='__User left__', value=
                '**Hope you will be back soon 😕.**', inline=True)
            embed.add_field(name='Your join position was', value=member.
                joined_at)
            embed.set_thumbnail(url=member.avatar_url)
            await client.send_message(channel, embed=embed)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def rolesetup(ctx):
    author = ctx.message.author
    server = ctx.message.server
    mod_perms = discord.Permissions(manage_messages=True, kick_members=True,
        manage_nicknames=True, mute_members=True)
    admin_perms = discord.Permissions(ADMINISTRATOR=True)
    await client.create_role(author.server, name='Owner', permissions=
        admin_perms)
    await client.create_role(author.server, name='Admin', permissions=
        admin_perms)
    await client.create_role(author.server, name='Senior Moderator',
        permissions=mod_perms)
    await client.create_role(author.server, name='G.O.H')
    await client.create_role(author.server, name='Moderator', permissions=
        mod_perms)
    await client.create_role(author.server, name='Muted')
    await client.create_role(author.server, name='Friend of Owner')


@commands.has_permissions(manage_roles=True)
async def role(ctx, user: discord.Member, *, role: discord.Role=None):
    if role is None:
        return await client.say("You haven't specified a role! ")
    if role not in user.roles:
        await client.add_roles(user, role)
        return await client.say('{} role has been added to {}.'.format(role,
            user))
    if role in user.roles:
        await client.remove_roles(user, role)
        return await client.say('{} role has been removed from {}.'.format(
            role, user))


@client.command(pass_context=True)
@commands.has_permissions(kick_members=True)
async def warn(ctx, userName: discord.User, *, message: str):
    await client.send_message(userName, 'You have been warned for: **{}**'.
        format(message))
    await client.say(
        ':warning: __**{0} Has Been Warned!**__ :warning: ** Reason:{1}** '
        .format(userName, message))
    pass


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def say(ctx, *, msg=None):
    await client.delete_message(ctx.message)
    if not msg:
        await client.say('Please specify a message to send')
    else:
        await client.say(msg)
    return


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def friend(ctx, user: discord.Member):
    await client.delete_message(ctx.message)
    role = discord.utils.get(ctx.message.server.roles, name='Friend of Owner')
    await client.add_roles(ctx.message.mentions[0], role)


@client.command(pass_context=True)
async def ownerinfo(ctx):
    embed = discord.Embed(title='Information about owner', description=
        'Bot Name- MARCOS', color=65280)
    embed.set_footer(text='MARCOS')
    embed.set_author(name=' Bot Owner Name- MARCOS')
    embed.add_field(name='Site- coming soon...', value=
        'Thanks for adding our bot', inline=True)
    await client.say(embed=embed)


@client.command(pass_context=True)
@commands.has_permissions(kick_members=True)
async def getuser(ctx, role: discord.Role=None):
    if role is None:
        await client.say('There is no "STAFF" role on this server!')
        return
    empty = True
    for member in ctx.message.server.members:
        if role in member.roles:
            await client.say('{0.name}: {0.id}'.format(member))
            empty = False
    if empty:
        await client.say('Nobody has the role {}'.format(role.mention))


@client.command(pass_context=True)
@commands.has_permissions(kick_members=True)
async def userinfo(ctx, user: discord.Member):
    if ctx.message.author.bot:
        return
    else:
        r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.
            random(), 1, 1))
        embed = discord.Embed(title="{}'s info".format(user.name),
            description="Here's what I could find.", color=discord.Color((r <<
            16) + (g << 8) + b))
        embed.add_field(name='Name', value=user.name, inline=True)
        embed.add_field(name='ID', value=user.id, inline=True)
        embed.add_field(name='Status', value=user.status, inline=True)
        embed.add_field(name='Highest role', value=user.top_role)
        embed.add_field(name='Joined', value=user.joined_at)
        embed.set_thumbnail(url=user.avatar_url)
        await client.say(embed=embed)


@client.command(pass_context=True)
@commands.has_permissions(kick_members=True)
@commands.cooldown(rate=5, per=86400, type=BucketType.user)
async def access(ctx, member: discord.Member):
    if ctx.message.author.bot:
        return
    else:
        role = discord.utils.get(member.server.roles, name='access')
        await client.add_roles(member, role)
        await client.say('Gave access to {}'.format(member))
        for channel in member.server.channels:
            if channel.name == 'soyal-log':
                embed = discord.Embed(title='User Got Access!', description
                    ='**{0}** got access from **{1}**!'.format(member, ctx.
                    message.author), color=131586)
                await client.send_message(channel, embed=embed)
                await asyncio.sleep(45 * 60)
                await client.remove_roles(member, role)


@client.command(pass_context=True)
@commands.has_permissions(manage_nicknames=True)
async def setnick(ctx, user: discord.Member, *, nickname):
    await client.change_nickname(user, nickname)
    await client.delete_message(ctx.message)
    for channel in user.server.channels:
        if channel.name == 'soyal-log':
            embed = discord.Embed(title='Changed Nickname of User!',
                description='**{0}** nickname was changed by **{1}**!'.
                format(member, ctx.message.author), color=336374)
            await client.send_message(channel, embed=embed)


@client.command(pass_context=True)
async def poll(ctx, question, *options: str):
    if len(options) <= 1:
        await client.say('You need more than one option to make a poll!')
        return
    if len(options) > 10:
        await client.say('You cannot make a poll for more than 10 things!')
        return
    if len(options) == 2 and options[0] == 'yes' and options[1] == 'no':
        reactions = ['👍', '👎']
    else:
        reactions = ['1⃣', '2⃣', '3⃣', '4⃣', '5⃣', '6⃣', '7⃣', '8⃣', '9⃣', '🔟']
    description = []
    for x, option in enumerate(options):
        description += '\n {} {}'.format(reactions[x], option)
        r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.
            random(), 1, 1))
    embed = discord.Embed(title=question, description=''.join(description),
        color=discord.Color((r << 16) + (g << 8) + b))
    react_message = await client.say(embed=embed)
    for reaction in reactions[:len(options)]:
        await client.add_reaction(react_message, reaction)
    embed.set_footer(text='Poll ID: {}'.format(react_message.id))
    await client.edit_message(react_message, embed=embed)


@client.command(pass_context=True)
@commands.has_permissions(ban_members=True)
async def ban(ctx, user: discord.Member):
    if user.server_permissions.ban_members:
        await client.say('**He is mod/admin and i am unable to ban him/her**')
        return
    else:
        await client.ban(user)
        await client.say(user.name + ' was banned. Good bye ' + user.name + '!'
            )
        for channel in member.server.channels:
            if channel.name == 'information-log':
                embed = discord.Embed(title='User banned!', description=
                    '**{0}** banned by **{1}**!'.format(member, ctx.message
                    .author), color=3700253)
                await client.send_message(channel, embed=embed)


@client.command(pass_context=True)
@commands.has_permissions(ban_members=True)
async def unban(ctx):
    ban_list = await client.get_bans(ctx.message.server)
    await client.say('Ban list:\n{}'.format('\n'.join([user.name for user in
        ban_list])))
    if not ban_list:
        await client.say('Ban list is empty.')
        return
    else:
        await client.unban(ctx.message.server, ban_list[-1])
        await client.say('Unbanned user: `{}`'.format(ban_list[-1].name))
        for channel in member.server.channels:
            if channel.name == 'soyal-log':
                embed = discord.Embed(title='User unbanned!', description=
                    '**{0}** unbanned by **{1}**!'.format(ban_list[-1].name,
                    ctx.message.author), color=3700253)
                await client.send_message(channel, embed=embed)


@client.command(pass_context=True)
@commands.has_permissions(kick_members=True)
async def serverinfo(ctx):
    """Displays Info About The Server!"""
    server = ctx.message.server
    roles = [x.name for x in server.role_hierarchy]
    role_length = len(roles)
    if role_length > 50:
        roles = roles[:50]
        roles.append('>>>> Displaying[50/%s] Roles' % len(roles))
    roles = ', '.join(roles)
    channelz = len(server.channels)
    time = str(server.created_at)
    time = time.split(' ')
    time = time[0]
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random
        (), 1, 1))
    join = discord.Embed(description='%s ' % str(server), title=
        'Server Name', color=discord.Color((r << 16) + (g << 8) + b))
    join.set_thumbnail(url=server.icon_url)
    join.add_field(name='__Owner__', value=str(server.owner) + '\n' +
        server.owner.id)
    join.add_field(name='__ID__', value=str(server.id))
    join.add_field(name='__Member Count__', value=str(server.member_count))
    join.add_field(name='__Text/Voice Channels__', value=str(channelz))
    join.add_field(name='__Roles (%s)__' % str(role_length), value=roles)
    join.set_footer(text='Created: %s' % time)
    return await client.say(embed=join)


@client.command(pass_context=True)
async def apply(ctx, *, msg: str):
    channel = client.get_channel('520830825021964305')
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random
        (), 1, 1))
    embed = discord.Embed(color=discord.Color((r << 16) + (g << 8) + b))
    embed.add_field(name='Application for bot', value='-------------------',
        inline=False)
    embed.add_field(name='User ID:', value='{}'.format(ctx.message.author.
        id), inline=False)
    embed.add_field(name='User Name:', value='{}'.format(ctx.message.author
        .name), inline=False)
    embed.add_field(name='Server Name:', value='{}'.format(ctx.message.
        server.name), inline=False)
    embed.add_field(name='Bot information:', value=msg, inline=False)
    await client.send_message(channel, embed=embed)
    await client.delete_message(ctx.message)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def makemod(ctx, user: discord.Member):
    nickname = '[̲̅M̲̅]' + user.name
    await client.change_nickname(user, nickname=nickname)
    role = discord.utils.get(ctx.message.server.roles, name='Moderator')
    await client.add_roles(user, role)
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random
        (), 1, 1))
    embed = discord.Embed(color=discord.Color((r << 16) + (g << 8) + b))
    embed.set_author(name='Congratulations Message')
    embed.add_field(name='__Congratulations__', value=
        '**Congratulations for mod.Hope you will be more active here. Thanks for your help and support.**'
        , inline=False)
    embed.set_image(url='https://preview.ibb.co/i1izTz/ezgif_5_e20b665628.gif')
    await client.send_message(user, embed=embed)
    await client.delete_message(ctx.message)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def makeadmin(ctx, user: discord.Member):
    nickname = 'Ѧ' + user.name
    await client.change_nickname(user, nickname=nickname)
    role = discord.utils.get(ctx.message.server.roles, name='Admin')
    await client.add_roles(user, role)
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random
        (), 1, 1))
    embed = discord.Embed(color=discord.Color((r << 16) + (g << 8) + b))
    embed.set_author(name='Congratulations Message')
    embed.add_field(name='__Congratulations__', value=
        '**Congratulations for Admin.Hope you will be more active here. Thanks for your help and support.**'
        , inline=False)
    embed.set_image(url='https://preview.ibb.co/i1izTz/ezgif_5_e20b665628.gif')
    await client.send_message(user, embed=embed)
    await client.delete_message(ctx.message)


@client.command(pass_context=True)
async def sorry(ctx, *, msg=None):
    if '@here' in msg or '@everyone' in msg:
        return
    if not msg:
        await client.say('Please Sorry')
    await client.say('Sorry ' + msg + ' http://imgur.com/gallery/Dif2lYI')
    return


@client.command(pass_context=True)
@commands.has_permissions(manage_messages=True)
async def clear(ctx, number):
    if ctx.message.author.server_permissions.manage_messages:
        mgs = []
        number = int(number)
    async for x in client.logs_from(ctx.message.channel, limit=number + 1):
        mgs.append(x)
    try:
        await client.delete_messages(mgs)
        await client.say(str(number) + ' messages deleted')
    except discord.Forbidden:
        await client.say(embed=Forbidden)
        return
    except discord.HTTPException:
        await client.say('clear failed.')
        return
    await client.delete_messages(mgs)


@client.event
async def on_message_delete(message):
    if not message.author.bot:
        channelname = 'information-log'
        logchannel = None
        for channel in message.server.channels:
            if channel.name == channelname:
                user = message.author
        for channel in user.server.channels:
            if channel.name == 'soyal-log':
                logchannel = channel
                r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(
                    random.random(), 1, 1))
                embed = discord.Embed(color=discord.Color((r << 16) + (g <<
                    8) + b))
                embed.set_author(name='Message deleted')
                embed.add_field(name='User: **{0}**'.format(user.name),
                    value='UserID: **{}**'.format(user.id), inline=False)
                embed.add_field(name='Message:', value='{}'.format(message.
                    content), inline=False)
                embed.add_field(name='Channel:', value='{}'.format(message.
                    channel.name), inline=False)
                await client.send_message(logchannel, embed=embed)


@client.command(pass_context=True)
async def avatar(ctx, user: discord.Member=None):
    if user is None:
        r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.
            random(), 1, 1))
        embed = discord.Embed(title=f'Avatar', description=
            'Avatar is profile picture of a user in discord', color=discord
            .Color((r << 16) + (g << 8) + b))
        embed.add_field(name='User: {}'.format(ctx.message.author.name),
            value='Avatar:', inline=True)
        embed.set_thumbnail(url=
            'https://cdn.discordapp.com/attachments/520159870448566287/520829749095038977/pubg.png'
            )
        embed.set_image(url=ctx.message.author.avatar_url)
        await client.say(embed=embed)
    else:
        r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.
            random(), 1, 1))
        embed = discord.Embed(title=f'Avatar', description=
            'Avatar is profile picture of a user in discord', color=discord
            .Color((r << 16) + (g << 8) + b))
        embed.add_field(name='User: {}'.format(user.name), value='Avatar:',
            inline=True)
        embed.set_thumbnail(url=
            'https://cdn.discordapp.com/attachments/520159870448566287/520829749095038977/pubg.png'
            )
        embed.set_image(url=user.avatar_url)
        await client.say(embed=embed)


@client.command(pass_context=True)
async def meme(ctx):
    choices = [
        'https://cheezburger.com/6946821/37-funny-random-memes-and-tweets-thatll-make-your-abs-sore'
        , 'https://img.memecdn.com/english_o_869587.webp',
        'https://i.imgur.com/E45OMsz.png',
        'https://i.imgur.com/ONhilpQ.png',
        'https://imgur.com/gallery/MzzrUWL',
        'https://imgur.com/gallery/wrDxd43',
        'https://imgur.com/gallery/HmQvoyP',
        'https://imgur.com/gallery/JZIYuUZ',
        'https://imgur.com/gallery/CTJKXOk',
        'https://imgur.com/gallery/otW0j4u',
        'https://imgur.com/gallery/OwILYdb',
        'https://img.memecdn.com/everybody-knows-muricans-don-amp-039-t-speak-english-the-same-way-mexicans-don-amp-039-t-speak-spanish_c_7233205.webp'
        ,
        'https://img.memecdn.com/english-reaction-when-they-heard-about-eu_c_6994013.webp'
        ,
        'https://images3.memedroid.com/images/UPLOADED393/5b0c3ee92799f.jpeg',
        'https://images7.memedroid.com/images/UPLOADED850/5b0c2d7dd6049.jpeg',
        'https://images7.memedroid.com/images/UPLOADED905/5b0c30c468fa8.jpeg',
        'https://images7.memedroid.com/images/UPLOADED726/5b0c2d4c5f288.jpeg',
        'https://images7.memedroid.com/images/UPLOADED936/5b0c2a90adbe7.jpeg',
        'https://images7.memedroid.com/images/UPLOADED764/5b0c1e491c669.jpeg',
        'https://images3.memedroid.com/images/UPLOADED922/5b0c284b71cd0.jpeg',
        'https://images3.memedroid.com/images/UPLOADED207/5b0c265a58cf4.jpeg',
        'https://images7.memedroid.com/images/UPLOADED920/5b0c06813741a.jpeg',
        'https://images3.memedroid.com/images/UPLOADED46/5a91c871e61f1.jpeg',
        'https://images7.memedroid.com/images/UPLOADED737/5a91c7f234bd2.jpeg',
        'https://images7.memedroid.com/images/UPLOADED757/5a91bd39e1323.jpeg',
        'https://images7.memedroid.com/images/UPLOADED963/5a91b4f7aba7e.jpeg',
        'https://images7.memedroid.com/images/UPLOADED794/5a91ac0900506.jpeg',
        'https://images3.memedroid.com/images/UPLOADED188/5a91aa326ad4e.jpeg',
        'https://www.google.co.in/search?q=meme&rlz=1C1CHBF_enIN808IN808&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjR59bhhZPfAhUZEnIKHRzUAvkQ_AUIDigB&biw=1366&bih=664'
        ]
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random
        (), 1, 1))
    embed = discord.Embed(title='Random Meme', description=':upside_down:',
        color=discord.Color((r << 16) + (g << 8) + b))
    embed.set_thumbnail(url=
        'https://cdn.discordapp.com/attachments/520159870448566287/520829749095038977/pubg.png'
        )
    embed.set_image(url=random.choice(choices))
    await client.send_typing(ctx.message.channel)
    await client.send_message(ctx.message.channel, embed=embed)


@client.command(pass_context=True, aliases=['server'])
@commands.has_permissions(kick_members=True)
async def membercount(ctx, *args):
    """
    Shows stats and information about current guild.
    ATTENTION: Please only use this on your own guilds or with explicit
    permissions of the guilds administrators!
    """
    if ctx.message.channel.is_private:
        await bot.delete_message(ctx.message)
        return
    g = ctx.message.server
    gid = g.id
    membs = str(len(g.members))
    membs_on = str(len([m for m in g.members if not m.status == Status.
        offline]))
    users = str(len([m for m in g.members if not m.bot]))
    users_on = str(len([m for m in g.members if not m.bot and not m.status ==
        Status.offline]))
    bots = str(len([m for m in g.members if m.bot]))
    bots_on = str(len([m for m in g.members if m.bot and not m.status ==
        Status.offline]))
    created = str(g.created_at)
    em = Embed(title='Membercount')
    em.description = (
        """```
Members:   %s (%s)
  Users:   %s (%s)
  Bots:    %s (%s)
Created:   %s
```"""
         % (membs, membs_on, users, users_on, bots, bots_on, created))
    await client.send_message(ctx.message.channel, embed=em)
    await client.delete_message(ctx.message)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def channelsetup(ctx):
    author = ctx.message.author
    server = ctx.message.server
    mod_perms = discord.Permissions(manage_messages=True, kick_members=True,
        manage_nicknames=True, mute_members=True)
    admin_perms = discord.Permissions(ADMINISTRATOR=True)
    await client.create_role(author.server, name='Owner', permissions=
        admin_perms)
    await client.create_role(author.server, name='Admin', permissions=
        admin_perms)
    await client.create_role(author.server, name='Moderator', permissions=
        mod_perms)
    await client.create_role(author.server, name='Muted')
    await client.create_role(author.server, name='Friend of Owner')
    await client.create_role(author.server, name='Verified')
    everyone_perms = discord.PermissionOverwrite(send_messages=False,
        read_messages=True)
    everyone = discord.ChannelPermissions(target=server.default_role,
        overwrite=everyone_perms)
    user_perms = discord.PermissionOverwrite(read_messages=True)
    user = discord.ChannelPermissions(target=server.default_role, overwrite
        =user_perms)
    private_perms = discord.PermissionOverwrite(read_messages=False)
    private = discord.ChannelPermissions(target=server.default_role,
        overwrite=private_perms)
    await client.create_channel(server, 'welcome_suagat', everyone)
    await client.create_channel(server, 'left_mat-ja-yar', everyone)
    await client.create_channel(server, 'announcement', everyone)
    await client.create_channel(server, 'give_away', everyone)
    await client.create_channel(server, 'self_assignable_roles', everyone)
    await client.create_channel(server, 'g_e_n_e_r_a_l', user)
    await client.create_channel(server, 'screenshot_image', user)
    await client.create_channel(server, 'promote_links', user)
    await client.create_channel(server, 'dark_memers', user)
    await client.create_channel(server, 'aki__play', user)
    await client.create_channel(server, 'spam_here', user)
    await client.create_channel(server, 'bot_commands', user)
    await client.create_channel(server, 'private_chat', private)
    await client.create_channel(server, 'General', type=discord.ChannelType
        .voice)
    await client.create_channel(server, 'music_commands', user)
    await client.create_channel(server, 'music', type=discord.ChannelType.voice
        )
    await client.create_channel(server, 'pokémon_catching', user)
    await client.create_channel(server, 'pokémon_dueling', user)
    await client.create_channel(server, 'pokémon_commands', user)
    await client.create_channel(server, 'A_F_K', type=discord.ChannelType.voice
        )


client.run(os.getenv('Token'))

import discord
from discord.ext import commands
from discord.ext.commands.cooldowns import BucketType
import asyncio
import colorsys
import random
import platform
from discord import Game, Embed, Color, Status, ChannelType
import os
import functools
import time
import datetime
import requests
import json
import aiohttp
Forbidden = discord.Embed(title='Permission Denied', description=
    """1) Please check whether you have permission to perform this action or not. 
2) Please check whether my role has permission to perform this action in this channel or not. 
3) Please check my role position."""
    , color=65280)
client = commands.Bot(description='MultiVerse Official Bot', command_prefix
    =commands.when_mentioned_or('!!'), pm_help=True)
client.remove_command('help')


async def status_task():
    while True:
        await client.change_presence(game=discord.Game(name='!!help'))
        await asyncio.sleep(5)
        await client.change_presence(game=discord.Game(name='with ' + str(
            len(set(client.get_all_members()))) + ' users'))
        await asyncio.sleep(5)
        await client.change_presence(game=discord.Game(name='in ' + str(len
            (client.servers)) + ' servers'))
        await asyncio.sleep(5)


@client.command(pass_context=True)
async def google(ctx, *, message):
    new_message = message.replace(' ', '+')
    url = f'https://www.google.com/search?q={new_message}'
    await client.say(url)


@client.command(pass_context=True)
async def youtube(ctx, *, message: str):
    new_message = message.replace(' ', '+')
    url = f'https://www.youtube.com/results?search_query={new_message}'
    await client.say(url)


@client.command(pass_context=True)
async def skincolor(ctx, user: discord.Member):
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random
        (), 1, 1))
    random.seed(user.id)
    skins = ['White', 'Black', 'Blue', 'Green', 'Rainbow', 'Purple',
        'Brown', 'Pink', 'Cream', 'Orange']
    if user == ctx.message.author:
        embed2 = discord.Embed(title='You should know your own skin color',
            color=discord.Color((r << 16) + (g << 8) + b))
        await client.say(embed=embed2)
    else:
        embed = discord.Embed(color=13314170)
        embed.add_field(name=f"{user.name}'s skin color", value=random.
            choice(skins))
        await client.say(embed=embed)


@client.command(pass_context=True)
async def unverify(ctx):
    await client.delete_message(ctx.message)
    role = discord.utils.get(ctx.message.server.roles, name='Unverified')
    await client.add_roles(ctx.message.author, role)


@client.command(pass_context=True)
async def verify(ctx):
    if ctx.message.author.bot:
        return
    else:
        await client.delete_message(ctx.message)
        role = discord.utils.get(ctx.message.server.roles, name='Verified')
        await client.add_roles(ctx.message.author, role)


@client.command(pass_context=True)
@commands.check(is_soyal)
async def botdm(ctx, user: discord.Member, *, msg: str):
    await client.send_typing(user)
    await client.send_message(user, msg)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def announce(ctx, channel: discord.Channel=None, *, msg: str):
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random
        (), 1, 1))
    embed = discord.Embed(title='Announcement', description='{}'.format(msg
        ), color=discord.Color((r << 16) + (g << 8) + b))
    await client.send_message(channel, embed=embed)
    await client.delete_message(ctx.message)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def embed(ctx, *args):
    if ctx.message.author.bot:
        return
    else:
        argstr = ' '.join(args)
        r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.
            random(), 1, 1))
        text = argstr
        color = discord.Color((r << 16) + (g << 8) + b)
        await client.send_message(ctx.message.channel, embed=Embed(color=
            color, description=text))
        await client.delete_message(ctx.message)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def dm(ctx, user: discord.Member, *, msg: str):
    try:
        await client.send_message(user, msg)
        await client.delete_message(ctx.message)
        await client.say('Success! Your DM has made it! :white_check_mark: ')
    except discord.ext.commands.MissingPermissions:
        await client.say(
            "Aw, come on! You thought you could get away with DM'ing people without permissions."
            )
    except:
        await client.say(
            'Error :x:. Make sure your message is shaped in this way: ^dm [tag person] [msg]'
            )


@client.command(pass_context=True)
async def botinvite(ctx):
    if ctx.message.author.bot:
        return
    else:
        embed = discord.Embed(title='Click on this link to invite:',
            description=
            'https://discordapp.com/api/oauth2/authorize?client_id=520267296506249216&permissions=8&scope=bot'
            , color=64795)
        await client.say(embed=embed)


@client.command(pass_context=True)
async def test(ctx):
    if ctx.message.author.bot:
        return
    else:
        await client.send_message(ctx.message.author, 'Hii bro what supp')
        await client.say('Check your dm ')


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def kick(ctx, user: discord.member):
    if user.server_permissions.kick_members:
        await client.say('**He is mod/admin and i am unable to kick him/her**')
        return
    else:
        await client.kick(user)
        await client.say(user.name + ' was kicked. Good bye ' + user.name + '!'
            )
        await client.delete_message(ctx.message)
        for channel in user.server.channels:
            if channel.name == 'Soyal-log':
                embed = discord.Embed(title='User kicked!', description=
                    '**{0}** is kicked by **{1}**!'.format(user, ctx.
                    message.author), color=16638226)
                await client.send_message(channel, embed=embed)


@client.command(pass_context=True)
async def play(ctx, *, url):
    author = ctx.message.author
    voice_channel = author.voice_channel
    try:
        vc = await client.join_voice_channel(voice_channel)
        msg = await client.say('Loading...')
        player = await vc.create_ytdl_player('ytsearch:' + url)
        player.start()
        await client.say('Succesfully Loaded ur song!')
        await client.delete_message(msg)
    except Exception as e:
        print(e)
        await client.say('Reconnecting')
        for x in client.voice_clients:
            if x.server == ctx.message.server:
                await x.disconnect()
                nvc = await client.join_voice_channel(voice_channel)
                msg = await client.say('Loading...')
                player2 = await nvc.create_ytdl_player('ytsearch:' + url)
                player2.start


@client.command(pass_context=True)
async def stop(ctx):
    for x in client.voice_clients:
        if x.server == ctx.message.server:
            return await x.disconnect()
    return await client.say('I am not playing anyting???!')


@client.command(pass_context=True)
async def happybirthday(ctx, *, msg=None):
    if '@here' in msg or '@everyone' in msg:
        return
    if not msg:
        await client.say('Please specify a user to wish')
    await client.say('Happy birthday have a nice day' + msg +
        ' http://imgur.com/gallery/PbyNCR2')
    return


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def emojiids(ctx):
    for emoji in ctx.message.author.server.emojis:
        print(f'<:{emoji.name}:{emoji.id}>')
        print(' ')


@client.command(pass_context=True)
async def wow(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:WOW:515854429485006848>')


@client.command(pass_context=True)
async def dank(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:OnThaCoco:515853700682743809>')


@client.command(pass_context=True)
async def santa(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:santa:517232271678504970>')


@client.command(pass_context=True)
async def hi(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:hi:517232279148429313>')


@client.command(pass_context=True)
async def lol(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:lol:517232283670020096>')


@client.command(pass_context=True)
async def love(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:love:517232300912672774>')


@client.command(pass_context=True)
async def mad(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:mad:517232301176913951>')


@client.command(pass_context=True)
async def alien(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:alien:517232332663422986>')


@client.command(pass_context=True)
async def fearfromme(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:shiroeglassespush:516174320532193289>')


@client.command(pass_context=True)
async def angry(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:angear:516174316950388772>')


@client.command(pass_context=True)
async def surprised(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:eyebigger:516174315058626560>')


@client.command(pass_context=True)
async def cat(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:agooglecat:516174312294842389>')


@client.command(pass_context=True)
async def thinking1(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:thinking:516183328613990400>')


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def setuplog(ctx):
    if ctx.message.author.bot:
        return
    else:
        server = ctx.message.server
        everyone_perms = discord.PermissionOverwrite(send_messages=False,
            read_messages=True)
        everyone = discord.ChannelPermissions(target=server.default_role,
            overwrite=everyone_perms)
        await client.create_channel(server, 'information-log', everyone)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def setupwelcome(ctx):
    if ctx.message.author.bot:
        return
    else:
        server = ctx.message.server
        everyone_perms = discord.PermissionOverwrite(send_messages=False,
            read_messages=True)
        everyone = discord.ChannelPermissions(target=server.default_role,
            overwrite=everyone_perms)
        await client.create_channel(server, 'welcome_swagat', everyone)


@client.event
async def on_member_join(member):
    for channel in member.server.channels:
        if channel.name == 'welcome_swagat':
            r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(
                random.random(), 1, 1))
            embed = discord.Embed(title=
                f'Welcome {member.name} to {member.server.name}',
                description=
                'Do not forget to check rules and never try to break any one of them'
                , color=discord.Color((r << 16) + (g << 8) + b))
            embed.add_field(name='__Thanks for joining__', value=
                '**Hope you will be active here.**', inline=True)
            embed.set_thumbnail(url=
                'https://cdn.discordapp.com/attachments/486489391083159574/520207004334292992/Loading.gif'
                )
            embed.set_image(url=member.avatar_url)
            embed.add_field(name='__Join position__', value='{}'.format(str
                (member.server.member_count)), inline=True)
            embed.add_field(name='Time of joining', value=member.joined_at)
            await client.send_message(channel, embed=embed)


@client.event
async def on_member_remove(member):
    for channel in member.server.channels:
        if channel.name == 'welcome_swagat':
            r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(
                random.random(), 1, 1))
            embed = discord.Embed(title=
                f'{member.name} just left {member.server.name}',
                description='Bye bye 👋! We will miss you 😢', color=discord.
                Color((r << 16) + (g << 8) + b))
            embed.add_field(name='__User left__', value=
                '**Hope you will be back soon 😕.**', inline=True)
            embed.add_field(name='Your join position was', value=member.
                joined_at)
            embed.set_thumbnail(url=member.avatar_url)
            await client.send_message(channel, embed=embed)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def rolesetup(ctx):
    author = ctx.message.author
    server = ctx.message.server
    mod_perms = discord.Permissions(manage_messages=True, kick_members=True,
        manage_nicknames=True, mute_members=True)
    admin_perms = discord.Permissions(ADMINISTRATOR=True)
    await client.create_role(author.server, name='Owner', permissions=
        admin_perms)
    await client.create_role(author.server, name='Admin', permissions=
        admin_perms)
    await client.create_role(author.server, name='Senior Moderator',
        permissions=mod_perms)
    await client.create_role(author.server, name='G.O.H')
    await client.create_role(author.server, name='Moderator', permissions=
        mod_perms)
    await client.create_role(author.server, name='Muted')
    await client.create_role(author.server, name='Friend of Owner')


@commands.has_permissions(manage_roles=True)
async def role(ctx, user: discord.Member, *, role: discord.Role=None):
    if role is None:
        return await client.say("You haven't specified a role! ")
    if role not in user.roles:
        await client.add_roles(user, role)
        return await client.say('{} role has been added to {}.'.format(role,
            user))
    if role in user.roles:
        await client.remove_roles(user, role)
        return await client.say('{} role has been removed from {}.'.format(
            role, user))


@client.command(pass_context=True)
@commands.has_permissions(kick_members=True)
async def warn(ctx, userName: discord.User, *, message: str):
    await client.send_message(userName, 'You have been warned for: **{}**'.
        format(message))
    await client.say(
        ':warning: __**{0} Has Been Warned!**__ :warning: ** Reason:{1}** '
        .format(userName, message))
    pass


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def say(ctx, *, msg=None):
    await client.delete_message(ctx.message)
    if not msg:
        await client.say('Please specify a message to send')
    else:
        await client.say(msg)
    return


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def friend(ctx, user: discord.Member):
    await client.delete_message(ctx.message)
    role = discord.utils.get(ctx.message.server.roles, name='Friend of Owner')
    await client.add_roles(ctx.message.mentions[0], role)


@client.command(pass_context=True)
async def ownerinfo(ctx):
    embed = discord.Embed(title='Information about owner', description=
        'Bot Name- MARCOS', color=65280)
    embed.set_footer(text='MARCOS')
    embed.set_author(name=' Bot Owner Name- MARCOS')
    embed.add_field(name='Site- coming soon...', value=
        'Thanks for adding our bot', inline=True)
    await client.say(embed=embed)


@client.command(pass_context=True)
@commands.has_permissions(kick_members=True)
async def getuser(ctx, role: discord.Role=None):
    if role is None:
        await client.say('There is no "STAFF" role on this server!')
        return
    empty = True
    for member in ctx.message.server.members:
        if role in member.roles:
            await client.say('{0.name}: {0.id}'.format(member))
            empty = False
    if empty:
        await client.say('Nobody has the role {}'.format(role.mention))


@client.command(pass_context=True)
@commands.has_permissions(kick_members=True)
async def userinfo(ctx, user: discord.Member):
    if ctx.message.author.bot:
        return
    else:
        r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.
            random(), 1, 1))
        embed = discord.Embed(title="{}'s info".format(user.name),
            description="Here's what I could find.", color=discord.Color((r <<
            16) + (g << 8) + b))
        embed.add_field(name='Name', value=user.name, inline=True)
        embed.add_field(name='ID', value=user.id, inline=True)
        embed.add_field(name='Status', value=user.status, inline=True)
        embed.add_field(name='Highest role', value=user.top_role)
        embed.add_field(name='Joined', value=user.joined_at)
        embed.set_thumbnail(url=user.avatar_url)
        await client.say(embed=embed)


@client.command(pass_context=True)
@commands.has_permissions(kick_members=True)
@commands.cooldown(rate=5, per=86400, type=BucketType.user)
async def access(ctx, member: discord.Member):
    if ctx.message.author.bot:
        return
    else:
        role = discord.utils.get(member.server.roles, name='access')
        await client.add_roles(member, role)
        await client.say('Gave access to {}'.format(member))
        for channel in member.server.channels:
            if channel.name == 'soyal-log':
                embed = discord.Embed(title='User Got Access!', description
                    ='**{0}** got access from **{1}**!'.format(member, ctx.
                    message.author), color=131586)
                await client.send_message(channel, embed=embed)
                await asyncio.sleep(45 * 60)
                await client.remove_roles(member, role)


@client.command(pass_context=True)
@commands.has_permissions(manage_nicknames=True)
async def setnick(ctx, user: discord.Member, *, nickname):
    await client.change_nickname(user, nickname)
    await client.delete_message(ctx.message)
    for channel in user.server.channels:
        if channel.name == 'soyal-log':
            embed = discord.Embed(title='Changed Nickname of User!',
                description='**{0}** nickname was changed by **{1}**!'.
                format(member, ctx.message.author), color=336374)
            await client.send_message(channel, embed=embed)


@client.command(pass_context=True)
async def poll(ctx, question, *options: str):
    if len(options) <= 1:
        await client.say('You need more than one option to make a poll!')
        return
    if len(options) > 10:
        await client.say('You cannot make a poll for more than 10 things!')
        return
    if len(options) == 2 and options[0] == 'yes' and options[1] == 'no':
        reactions = ['👍', '👎']
    else:
        reactions = ['1⃣', '2⃣', '3⃣', '4⃣', '5⃣', '6⃣', '7⃣', '8⃣', '9⃣', '🔟']
    description = []
    for x, option in enumerate(options):
        description += '\n {} {}'.format(reactions[x], option)
        r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.
            random(), 1, 1))
    embed = discord.Embed(title=question, description=''.join(description),
        color=discord.Color((r << 16) + (g << 8) + b))
    react_message = await client.say(embed=embed)
    for reaction in reactions[:len(options)]:
        await client.add_reaction(react_message, reaction)
    embed.set_footer(text='Poll ID: {}'.format(react_message.id))
    await client.edit_message(react_message, embed=embed)


@client.command(pass_context=True)
@commands.has_permissions(ban_members=True)
async def ban(ctx, user: discord.Member):
    if user.server_permissions.ban_members:
        await client.say('**He is mod/admin and i am unable to ban him/her**')
        return
    else:
        await client.ban(user)
        await client.say(user.name + ' was banned. Good bye ' + user.name + '!'
            )
        for channel in member.server.channels:
            if channel.name == 'information-log':
                embed = discord.Embed(title='User banned!', description=
                    '**{0}** banned by **{1}**!'.format(member, ctx.message
                    .author), color=3700253)
                await client.send_message(channel, embed=embed)


@client.command(pass_context=True)
@commands.has_permissions(ban_members=True)
async def unban(ctx):
    ban_list = await client.get_bans(ctx.message.server)
    await client.say('Ban list:\n{}'.format('\n'.join([user.name for user in
        ban_list])))
    if not ban_list:
        await client.say('Ban list is empty.')
        return
    else:
        await client.unban(ctx.message.server, ban_list[-1])
        await client.say('Unbanned user: `{}`'.format(ban_list[-1].name))
        for channel in member.server.channels:
            if channel.name == 'soyal-log':
                embed = discord.Embed(title='User unbanned!', description=
                    '**{0}** unbanned by **{1}**!'.format(ban_list[-1].name,
                    ctx.message.author), color=3700253)
                await client.send_message(channel, embed=embed)


@client.command(pass_context=True)
@commands.has_permissions(kick_members=True)
async def serverinfo(ctx):
    """Displays Info About The Server!"""
    server = ctx.message.server
    roles = [x.name for x in server.role_hierarchy]
    role_length = len(roles)
    if role_length > 50:
        roles = roles[:50]
        roles.append('>>>> Displaying[50/%s] Roles' % len(roles))
    roles = ', '.join(roles)
    channelz = len(server.channels)
    time = str(server.created_at)
    time = time.split(' ')
    time = time[0]
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random
        (), 1, 1))
    join = discord.Embed(description='%s ' % str(server), title=
        'Server Name', color=discord.Color((r << 16) + (g << 8) + b))
    join.set_thumbnail(url=server.icon_url)
    join.add_field(name='__Owner__', value=str(server.owner) + '\n' +
        server.owner.id)
    join.add_field(name='__ID__', value=str(server.id))
    join.add_field(name='__Member Count__', value=str(server.member_count))
    join.add_field(name='__Text/Voice Channels__', value=str(channelz))
    join.add_field(name='__Roles (%s)__' % str(role_length), value=roles)
    join.set_footer(text='Created: %s' % time)
    return await client.say(embed=join)


@client.command(pass_context=True)
async def apply(ctx, *, msg: str):
    channel = client.get_channel('520830825021964305')
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random
        (), 1, 1))
    embed = discord.Embed(color=discord.Color((r << 16) + (g << 8) + b))
    embed.add_field(name='Application for bot', value='-------------------',
        inline=False)
    embed.add_field(name='User ID:', value='{}'.format(ctx.message.author.
        id), inline=False)
    embed.add_field(name='User Name:', value='{}'.format(ctx.message.author
        .name), inline=False)
    embed.add_field(name='Server Name:', value='{}'.format(ctx.message.
        server.name), inline=False)
    embed.add_field(name='Bot information:', value=msg, inline=False)
    await client.send_message(channel, embed=embed)
    await client.delete_message(ctx.message)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def makemod(ctx, user: discord.Member):
    nickname = '[̲̅M̲̅]' + user.name
    await client.change_nickname(user, nickname=nickname)
    role = discord.utils.get(ctx.message.server.roles, name='Moderator')
    await client.add_roles(user, role)
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random
        (), 1, 1))
    embed = discord.Embed(color=discord.Color((r << 16) + (g << 8) + b))
    embed.set_author(name='Congratulations Message')
    embed.add_field(name='__Congratulations__', value=
        '**Congratulations for mod.Hope you will be more active here. Thanks for your help and support.**'
        , inline=False)
    embed.set_image(url='https://preview.ibb.co/i1izTz/ezgif_5_e20b665628.gif')
    await client.send_message(user, embed=embed)
    await client.delete_message(ctx.message)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def makeadmin(ctx, user: discord.Member):
    nickname = 'Ѧ' + user.name
    await client.change_nickname(user, nickname=nickname)
    role = discord.utils.get(ctx.message.server.roles, name='Admin')
    await client.add_roles(user, role)
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random
        (), 1, 1))
    embed = discord.Embed(color=discord.Color((r << 16) + (g << 8) + b))
    embed.set_author(name='Congratulations Message')
    embed.add_field(name='__Congratulations__', value=
        '**Congratulations for Admin.Hope you will be more active here. Thanks for your help and support.**'
        , inline=False)
    embed.set_image(url='https://preview.ibb.co/i1izTz/ezgif_5_e20b665628.gif')
    await client.send_message(user, embed=embed)
    await client.delete_message(ctx.message)


@client.command(pass_context=True)
async def sorry(ctx, *, msg=None):
    if '@here' in msg or '@everyone' in msg:
        return
    if not msg:
        await client.say('Please Sorry')
    await client.say('Sorry ' + msg + ' http://imgur.com/gallery/Dif2lYI')
    return


@client.command(pass_context=True)
@commands.has_permissions(manage_messages=True)
async def clear(ctx, number):
    if ctx.message.author.server_permissions.manage_messages:
        mgs = []
        number = int(number)
    async for x in client.logs_from(ctx.message.channel, limit=number + 1):
        mgs.append(x)
    try:
        await client.delete_messages(mgs)
        await client.say(str(number) + ' messages deleted')
    except discord.Forbidden:
        await client.say(embed=Forbidden)
        return
    except discord.HTTPException:
        await client.say('clear failed.')
        return
    await client.delete_messages(mgs)


@client.event
async def on_message_delete(message):
    if not message.author.bot:
        channelname = 'information-log'
        logchannel = None
        for channel in message.server.channels:
            if channel.name == channelname:
                user = message.author
        for channel in user.server.channels:
            if channel.name == 'soyal-log':
                logchannel = channel
                r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(
                    random.random(), 1, 1))
                embed = discord.Embed(color=discord.Color((r << 16) + (g <<
                    8) + b))
                embed.set_author(name='Message deleted')
                embed.add_field(name='User: **{0}**'.format(user.name),
                    value='UserID: **{}**'.format(user.id), inline=False)
                embed.add_field(name='Message:', value='{}'.format(message.
                    content), inline=False)
                embed.add_field(name='Channel:', value='{}'.format(message.
                    channel.name), inline=False)
                await client.send_message(logchannel, embed=embed)


@client.command(pass_context=True)
async def avatar(ctx, user: discord.Member=None):
    if user is None:
        r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.
            random(), 1, 1))
        embed = discord.Embed(title=f'Avatar', description=
            'Avatar is profile picture of a user in discord', color=discord
            .Color((r << 16) + (g << 8) + b))
        embed.add_field(name='User: {}'.format(ctx.message.author.name),
            value='Avatar:', inline=True)
        embed.set_thumbnail(url=
            'https://cdn.discordapp.com/attachments/520159870448566287/520829749095038977/pubg.png'
            )
        embed.set_image(url=ctx.message.author.avatar_url)
        await client.say(embed=embed)
    else:
        r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.
            random(), 1, 1))
        embed = discord.Embed(title=f'Avatar', description=
            'Avatar is profile picture of a user in discord', color=discord
            .Color((r << 16) + (g << 8) + b))
        embed.add_field(name='User: {}'.format(user.name), value='Avatar:',
            inline=True)
        embed.set_thumbnail(url=
            'https://cdn.discordapp.com/attachments/520159870448566287/520829749095038977/pubg.png'
            )
        embed.set_image(url=user.avatar_url)
        await client.say(embed=embed)


@client.command(pass_context=True)
async def meme(ctx):
    choices = [
        'https://cheezburger.com/6946821/37-funny-random-memes-and-tweets-thatll-make-your-abs-sore'
        , 'https://img.memecdn.com/english_o_869587.webp',
        'https://i.imgur.com/E45OMsz.png',
        'https://i.imgur.com/ONhilpQ.png',
        'https://imgur.com/gallery/MzzrUWL',
        'https://imgur.com/gallery/wrDxd43',
        'https://imgur.com/gallery/HmQvoyP',
        'https://imgur.com/gallery/JZIYuUZ',
        'https://imgur.com/gallery/CTJKXOk',
        'https://imgur.com/gallery/otW0j4u',
        'https://imgur.com/gallery/OwILYdb',
        'https://img.memecdn.com/everybody-knows-muricans-don-amp-039-t-speak-english-the-same-way-mexicans-don-amp-039-t-speak-spanish_c_7233205.webp'
        ,
        'https://img.memecdn.com/english-reaction-when-they-heard-about-eu_c_6994013.webp'
        ,
        'https://images3.memedroid.com/images/UPLOADED393/5b0c3ee92799f.jpeg',
        'https://images7.memedroid.com/images/UPLOADED850/5b0c2d7dd6049.jpeg',
        'https://images7.memedroid.com/images/UPLOADED905/5b0c30c468fa8.jpeg',
        'https://images7.memedroid.com/images/UPLOADED726/5b0c2d4c5f288.jpeg',
        'https://images7.memedroid.com/images/UPLOADED936/5b0c2a90adbe7.jpeg',
        'https://images7.memedroid.com/images/UPLOADED764/5b0c1e491c669.jpeg',
        'https://images3.memedroid.com/images/UPLOADED922/5b0c284b71cd0.jpeg',
        'https://images3.memedroid.com/images/UPLOADED207/5b0c265a58cf4.jpeg',
        'https://images7.memedroid.com/images/UPLOADED920/5b0c06813741a.jpeg',
        'https://images3.memedroid.com/images/UPLOADED46/5a91c871e61f1.jpeg',
        'https://images7.memedroid.com/images/UPLOADED737/5a91c7f234bd2.jpeg',
        'https://images7.memedroid.com/images/UPLOADED757/5a91bd39e1323.jpeg',
        'https://images7.memedroid.com/images/UPLOADED963/5a91b4f7aba7e.jpeg',
        'https://images7.memedroid.com/images/UPLOADED794/5a91ac0900506.jpeg',
        'https://images3.memedroid.com/images/UPLOADED188/5a91aa326ad4e.jpeg',
        'https://www.google.co.in/search?q=meme&rlz=1C1CHBF_enIN808IN808&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjR59bhhZPfAhUZEnIKHRzUAvkQ_AUIDigB&biw=1366&bih=664'
        ]
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random
        (), 1, 1))
    embed = discord.Embed(title='Random Meme', description=':upside_down:',
        color=discord.Color((r << 16) + (g << 8) + b))
    embed.set_thumbnail(url=
        'https://cdn.discordapp.com/attachments/520159870448566287/520829749095038977/pubg.png'
        )
    embed.set_image(url=random.choice(choices))
    await client.send_typing(ctx.message.channel)
    await client.send_message(ctx.message.channel, embed=embed)


@client.command(pass_context=True, aliases=['server'])
@commands.has_permissions(kick_members=True)
async def membercount(ctx, *args):
    """
    Shows stats and information about current guild.
    ATTENTION: Please only use this on your own guilds or with explicit
    permissions of the guilds administrators!
    """
    if ctx.message.channel.is_private:
        await bot.delete_message(ctx.message)
        return
    g = ctx.message.server
    gid = g.id
    membs = str(len(g.members))
    membs_on = str(len([m for m in g.members if not m.status == Status.
        offline]))
    users = str(len([m for m in g.members if not m.bot]))
    users_on = str(len([m for m in g.members if not m.bot and not m.status ==
        Status.offline]))
    bots = str(len([m for m in g.members if m.bot]))
    bots_on = str(len([m for m in g.members if m.bot and not m.status ==
        Status.offline]))
    created = str(g.created_at)
    em = Embed(title='Membercount')
    em.description = (
        """```
Members:   %s (%s)
  Users:   %s (%s)
  Bots:    %s (%s)
Created:   %s
```"""
         % (membs, membs_on, users, users_on, bots, bots_on, created))
    await client.send_message(ctx.message.channel, embed=em)
    await client.delete_message(ctx.message)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def channelsetup(ctx):
    author = ctx.message.author
    server = ctx.message.server
    mod_perms = discord.Permissions(manage_messages=True, kick_members=True,
        manage_nicknames=True, mute_members=True)
    admin_perms = discord.Permissions(ADMINISTRATOR=True)
    await client.create_role(author.server, name='Owner', permissions=
        admin_perms)
    await client.create_role(author.server, name='Admin', permissions=
        admin_perms)
    await client.create_role(author.server, name='Moderator', permissions=
        mod_perms)
    await client.create_role(author.server, name='Muted')
    await client.create_role(author.server, name='Friend of Owner')
    await client.create_role(author.server, name='Verified')
    everyone_perms = discord.PermissionOverwrite(send_messages=False,
        read_messages=True)
    everyone = discord.ChannelPermissions(target=server.default_role,
        overwrite=everyone_perms)
    user_perms = discord.PermissionOverwrite(read_messages=True)
    user = discord.ChannelPermissions(target=server.default_role, overwrite
        =user_perms)
    private_perms = discord.PermissionOverwrite(read_messages=False)
    private = discord.ChannelPermissions(target=server.default_role,
        overwrite=private_perms)
    await client.create_channel(server, 'welcome_suagat', everyone)
    await client.create_channel(server, 'left_mat-ja-yar', everyone)
    await client.create_channel(server, 'announcement', everyone)
    await client.create_channel(server, 'give_away', everyone)
    await client.create_channel(server, 'self_assignable_roles', everyone)
    await client.create_channel(server, 'g_e_n_e_r_a_l', user)
    await client.create_channel(server, 'screenshot_image', user)
    await client.create_channel(server, 'promote_links', user)
    await client.create_channel(server, 'dark_memers', user)
    await client.create_channel(server, 'aki__play', user)
    await client.create_channel(server, 'spam_here', user)
    await client.create_channel(server, 'bot_commands', user)
    await client.create_channel(server, 'private_chat', private)
    await client.create_channel(server, 'General', type=discord.ChannelType
        .voice)
    await client.create_channel(server, 'music_commands', user)
    await client.create_channel(server, 'music', type=discord.ChannelType.voice
        )
    await client.create_channel(server, 'pokémon_catching', user)
    await client.create_channel(server, 'pokémon_dueling', user)
    await client.create_channel(server, 'pokémon_commands', user)
    await client.create_channel(server, 'A_F_K', type=discord.ChannelType.voice
        )


client.run(os.getenv('Token'))

import discord
from discord.ext import commands
from discord.ext.commands.cooldowns import BucketType
import asyncio
import colorsys
import random
import platform
from discord import Game, Embed, Color, Status, ChannelType
import os
import functools
import time
import datetime
import requests
import json
import aiohttp		


Forbidden= discord.Embed(title="Permission Denied", description="1) Please check whether you have permission to perform this action or not. \n2) Please check whether my role has permission to perform this action in this channel or not. \n3) Please check my role position.", color=0x00ff00)
client = commands.Bot(description="MultiVerse Official Bot", command_prefix=commands.when_mentioned_or("!!"), pm_help = True)
client.remove_command('help')



async def status_task():
    while True:
        await client.change_presence(game=discord.Game(name='!!help'))
        await asyncio.sleep(5)
        await client.change_presence(game=discord.Game(name='with '+str(len(set(client.get_all_members())))+' users'))
        await asyncio.sleep(5)
        await client.change_presence(game=discord.Game(name='in '+str(len(client.servers))+' servers'))
        await asyncio.sleep(5)
	

@client.command(pass_context=True)
async def google(ctx, *, message):
    new_message = message.replace(" ", "+")
    url = f"https://www.google.com/search?q={new_message}"
    await client.say(url)

@client.command(pass_context=True)
async def youtube(ctx, *, message: str):
    new_message = message.replace(" ", "+")
    url = f"https://www.youtube.com/results?search_query={new_message}"
    await client.say(url)


@client.command(pass_context=True)
async def skincolor(ctx, user: discord.Member):
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
    random.seed(user.id)
    skins = ["White", "Black", "Blue", "Green", "Rainbow", "Purple", "Brown", "Pink", "Cream", "Orange"]
    if user == ctx.message.author:
        embed2 = discord.Embed(title="You should know your own skin color", color = discord.Color((r << 16) + (g << 8) + b))
        await client.say(embed=embed2)
    else:
        embed = discord.Embed(color=0xcb287a)
        embed.add_field(name=f"{user.name}'s skin color", value=random.choice(skins))
        await client.say(embed=embed)
	
	
@client.command(pass_context=True)
async def unverify(ctx):
    await client.delete_message(ctx.message)
    role = discord.utils.get(ctx.message.server.roles, name='Unverified')
    await client.add_roles(ctx.message.author, role)
    
@client.command(pass_context=True)
async def verify(ctx):
    if ctx.message.author.bot:
      return
    else:
      await client.delete_message(ctx.message)
      role = discord.utils.get(ctx.message.server.roles, name='Verified')
      await client.add_roles(ctx.message.author, role)	
	
 
	
@client.command(pass_context=True)
@commands.check(is_soyal)
async def botdm(ctx, user: discord.Member, *, msg: str):
    await client.send_typing(user)
    await client.send_message(user, msg)
	
@client.command(pass_context = True)
@commands.has_permissions(administrator=True) 
async def announce(ctx, channel: discord.Channel=None, *, msg: str):
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
    embed=discord.Embed(title="Announcement", description="{}".format(msg), color = discord.Color((r << 16) + (g << 8) + b))
    await client.send_message(channel, embed=embed)
    await client.delete_message(ctx.message)


@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def embed(ctx, *args):
    if ctx.message.author.bot:
      return
    else:
      argstr = " ".join(args)
      r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
      text = argstr
      color = discord.Color((r << 16) + (g << 8) + b)
      await client.send_message(ctx.message.channel, embed=Embed(color = color, description=text))
      await client.delete_message(ctx.message)    

	
	
@client.command(pass_context = True)
@commands.has_permissions(administrator = True)
async def dm(ctx, user: discord.Member, *, msg: str):
    try:
        await client.send_message(user, msg)
        await client.delete_message(ctx.message)          
        await client.say("Success! Your DM has made it! :white_check_mark: ")
    except discord.ext.commands.MissingPermissions:
        await client.say("Aw, come on! You thought you could get away with DM'ing people without permissions.")
    except:
        await client.say("Error :x:. Make sure your message is shaped in this way: ^dm [tag person] [msg]")

		
	
	
@client.command(pass_context = True)
async def botinvite(ctx):
    if ctx.message.author.bot:
      return
    else:
      embed=discord.Embed(title="Click on this link to invite:", description="https://discordapp.com/api/oauth2/authorize?client_id=520267296506249216&permissions=8&scope=bot" , color=0x00fd1b)
      await client.say(embed=embed)


@client.command(pass_context = True)
async def test(ctx):
    if ctx.message.author.bot:
      return
    else:
      await client.send_message(ctx.message.author, 'Hii bro what supp')
      await client.say('Check your dm ')

@client.command(pass_context=True)  
@commands.has_permissions(administrator=True)    
async def kick(ctx,user:discord.member):
    if user.server_permissions.kick_members:
      await client.say('**He is mod/admin and i am unable to kick him/her**')
      return
    else:
      await client.kick(user)
      await client.say(user.name+' was kicked. Good bye '+user.name+'!')
      await client.delete_message(ctx.message)
      for channel in user.server.channels:
        if channel.name == 'Soyal-log':
            embed=discord.Embed(title="User kicked!", description="**{0}** is kicked by **{1}**!".format(user, ctx.message.author), color=0xFDE112)
            await client.send_message(channel, embed=embed)


	
	
@client.command(pass_context = True)
async def play(ctx, *, url):
    author = ctx.message.author
    voice_channel = author.voice_channel
    try:
        vc = await client.join_voice_channel(voice_channel)
        msg = await client.say("Loading...")
        player = await vc.create_ytdl_player("ytsearch:" + url)
        player.start()
        await client.say("Succesfully Loaded ur song!")
        await client.delete_message(msg)
    except Exception as e:
        print(e)
        await client.say("Reconnecting")
        for x in client.voice_clients:
            if(x.server == ctx.message.server):
                await x.disconnect()
                nvc = await client.join_voice_channel(voice_channel)
                msg = await client.say("Loading...")
                player2 = await nvc.create_ytdl_player("ytsearch:" + url)
                player2.start

@client.command(pass_context = True)
async def stop(ctx):
    for x in client.voice_clients:
        if(x.server == ctx.message.server):
            return await x.disconnect()

    return await client.say("I am not playing anyting???!")

        

@client.command(pass_context = True)
async def happybirthday(ctx, *, msg = None):
    if '@here' in msg or '@everyone' in msg:
      return
    if not msg: await client.say("Please specify a user to wish")
    await client.say('Happy birthday have a nice day' + msg + ' http://imgur.com/gallery/PbyNCR2')
    return



@client.command(pass_context = True)
@commands.has_permissions(administrator=True)
async def emojiids(ctx):
  for emoji in ctx.message.author.server.emojis:
    print(f"<:{emoji.name}:{emoji.id}>")
    print(" ")    
			
@client.command(pass_context = True)
async def wow(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:WOW:515854429485006848>')
	
@client.command(pass_context = True)
async def dank(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:OnThaCoco:515853700682743809>')

@client.command(pass_context = True)
async def santa(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:santa:517232271678504970>')
	
@client.command(pass_context = True)
async def hi(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:hi:517232279148429313>')
	
@client.command(pass_context = True)
async def lol(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:lol:517232283670020096>')
	
@client.command(pass_context = True)
async def love(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:love:517232300912672774>')
	
@client.command(pass_context = True)
async def mad(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:mad:517232301176913951>')
	
@client.command(pass_context = True)
async def alien(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:alien:517232332663422986>')

@client.command(pass_context = True)
async def fearfromme(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:shiroeglassespush:516174320532193289>')
	   	
@client.command(pass_context = True)
async def angry(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:angear:516174316950388772>')
	
@client.command(pass_context = True)
async def surprised(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:eyebigger:516174315058626560>')
		
@client.command(pass_context = True)
async def cat(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:agooglecat:516174312294842389>')
		
@client.command(pass_context = True)
async def thinking1(ctx):
    await client.delete_message(ctx.message)
    await client.say('<a:thinking:516183328613990400>')
	







@client.command(pass_context = True)
@commands.has_permissions(administrator=True)
async def setuplog(ctx):
    if ctx.message.author.bot:
      return
    else:
      server = ctx.message.server
      everyone_perms = discord.PermissionOverwrite(send_messages=False, read_messages=True)
      everyone = discord.ChannelPermissions(target=server.default_role, overwrite=everyone_perms)
      await client.create_channel(server, 'information-log',everyone)

	

@client.command(pass_context = True)
@commands.has_permissions(administrator=True)
async def setupwelcome(ctx):
    if ctx.message.author.bot:
      return
    else:
      server = ctx.message.server
      everyone_perms = discord.PermissionOverwrite(send_messages=False, read_messages=True)
      everyone = discord.ChannelPermissions(target=server.default_role, overwrite=everyone_perms)
      await client.create_channel(server, 'welcome_swagat',everyone)
	
	
@client.event
async def on_member_join(member):
    for channel in member.server.channels:
        if channel.name == 'welcome_swagat':
            r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
            embed = discord.Embed(title=f'Welcome {member.name} to {member.server.name}', description='Do not forget to check rules and never try to break any one of them', color = discord.Color((r << 16) + (g << 8) + b))
            embed.add_field(name='__Thanks for joining__', value='**Hope you will be active here.**', inline=True)
            embed.set_thumbnail(url='https://cdn.discordapp.com/attachments/486489391083159574/520207004334292992/Loading.gif') 
            embed.set_image(url = member.avatar_url)
            embed.add_field(name='__Join position__', value='{}'.format(str(member.server.member_count)), inline=True)
            embed.add_field(name='Time of joining', value=member.joined_at)
            await client.send_message(channel, embed=embed)	
		

@client.event
async def on_member_remove(member):
    for channel in member.server.channels:
        if channel.name == 'welcome_swagat':
            r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
            embed = discord.Embed(title=f'{member.name} just left {member.server.name}', description='Bye bye 👋! We will miss you 😢', color = discord.Color((r << 16) + (g << 8) + b))
            embed.add_field(name='__User left__', value='**Hope you will be back soon 😕.**', inline=True)
            embed.add_field(name='Your join position was', value=member.joined_at)
            embed.set_thumbnail(url=member.avatar_url)
            await client.send_message(channel, embed=embed)

@client.command(pass_context = True)
@commands.has_permissions(administrator=True)
async def rolesetup(ctx):
    author = ctx.message.author
    server = ctx.message.server
    mod_perms = discord.Permissions(manage_messages=True, kick_members=True, manage_nicknames =True,mute_members=True)
    admin_perms = discord.Permissions(ADMINISTRATOR=True)

    await client.create_role(author.server, name="Owner", permissions=admin_perms)
    await client.create_role(author.server, name="Admin", permissions=admin_perms)
    await client.create_role(author.server, name="Senior Moderator", permissions=mod_perms)
    await client.create_role(author.server, name="G.O.H")
    await client.create_role(author.server, name="Moderator", permissions=mod_perms)
    await client.create_role(author.server, name="Muted")
    await client.create_role(author.server, name="Friend of Owner")


@commands.has_permissions(manage_roles=True)     
async def role(ctx, user: discord.Member, *, role: discord.Role = None):
        if role is None:
            return await client.say("You haven't specified a role! ")

        if role not in user.roles:
            await client.add_roles(user, role)
            return await client.say("{} role has been added to {}.".format(role, user))

        if role in user.roles:
            await client.remove_roles(user, role)
            return await client.say("{} role has been removed from {}.".format(role, user))
 
@client.command(pass_context = True)
@commands.has_permissions(kick_members=True)
async def warn(ctx, userName: discord.User, *, message:str): 
    await client.send_message(userName, "You have been warned for: **{}**".format(message))
    await client.say(":warning: __**{0} Has Been Warned!**__ :warning: ** Reason:{1}** ".format(userName,message))
    pass


@client.command(pass_context = True)
@commands.has_permissions(administrator=True)
async def say(ctx, *, msg = None):
    await client.delete_message(ctx.message)

    if not msg: await client.say("Please specify a message to send")
    else: await client.say(msg)
    return

@client.command(pass_context=True)
@commands.has_permissions(administrator=True)
async def friend(ctx, user:discord.Member,):
    await client.delete_message(ctx.message)
    role = discord.utils.get(ctx.message.server.roles, name='Friend of Owner')
    await client.add_roles(ctx.message.mentions[0], role)


@client.command(pass_context=True)
async def ownerinfo(ctx):
    embed = discord.Embed(title="Information about owner", description="Bot Name- MARCOS", color=0x00ff00)
    embed.set_footer(text="MARCOS")
    embed.set_author(name=" Bot Owner Name- MARCOS")
    embed.add_field(name="Site- coming soon...", value="Thanks for adding our bot", inline=True)
    await client.say(embed=embed)		



@client.command(pass_context=True)  
@commands.has_permissions(kick_members=True)
async def getuser(ctx, role: discord.Role = None):
    if role is None:
        await client.say('There is no "STAFF" role on this server!')
        return
    empty = True
    for member in ctx.message.server.members:
        if role in member.roles:
            await client.say("{0.name}: {0.id}".format(member))
            empty = False
    if empty:
        await client.say("Nobody has the role {}".format(role.mention))


@client.command(pass_context = True)
@commands.has_permissions(kick_members=True)     
async def userinfo(ctx, user: discord.Member):
    if ctx.message.author.bot:
      return
    else:
      r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
      embed = discord.Embed(title="{}'s info".format(user.name), description="Here's what I could find.", color = discord.Color((r << 16) + (g << 8) + b))
      embed.add_field(name="Name", value=user.name, inline=True)
      embed.add_field(name="ID", value=user.id, inline=True)
      embed.add_field(name="Status", value=user.status, inline=True)
      embed.add_field(name="Highest role", value=user.top_role)
      embed.add_field(name="Joined", value=user.joined_at)
      embed.set_thumbnail(url=user.avatar_url)
      await client.say(embed=embed)




@client.command(pass_context = True)
@commands.has_permissions(kick_members=True) 
@commands.cooldown(rate=5,per=86400,type=BucketType.user) 
async def access(ctx, member: discord.Member):
    if ctx.message.author.bot:
      return
    else:
      role = discord.utils.get(member.server.roles, name='access')
      await client.add_roles(member, role)
      await client.say("Gave access to {}".format(member))
      for channel in member.server.channels:
        if channel.name == 'soyal-log':
            embed=discord.Embed(title="User Got Access!", description="**{0}** got access from **{1}**!".format(member, ctx.message.author), color=0x020202)
            await client.send_message(channel, embed=embed)
            await asyncio.sleep(45*60)
            await client.remove_roles(member, role)


@client.command(pass_context = True)
@commands.has_permissions(manage_nicknames=True)     
async def setnick(ctx, user: discord.Member, *, nickname):
    await client.change_nickname(user, nickname)
    await client.delete_message(ctx.message)
    for channel in user.server.channels:
      if channel.name == 'soyal-log':
          embed=discord.Embed(title="Changed Nickname of User!", description="**{0}** nickname was changed by **{1}**!".format(member, ctx.message.author), color=0x0521F6)
          await client.send_message(channel, embed=embed)



@client.command(pass_context=True)
async def poll(ctx, question, *options: str):
        if len(options) <= 1:
            await client.say('You need more than one option to make a poll!')
            return
        if len(options) > 10:
            await client.say('You cannot make a poll for more than 10 things!')
            return

        if len(options) == 2 and options[0] == 'yes' and options[1] == 'no':
            reactions = ['👍', '👎']
        else:
            reactions = ['1\u20e3', '2\u20e3', '3\u20e3', '4\u20e3', '5\u20e3', '6\u20e3', '7\u20e3', '8\u20e3', '9\u20e3', '\U0001f51f']

        description = []
        for x, option in enumerate(options):
            description += '\n {} {}'.format(reactions[x], option)
            r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
        embed = discord.Embed(title=question, description=''.join(description), color = discord.Color((r << 16) + (g << 8) + b))
        react_message = await client.say(embed=embed)
        for reaction in reactions[:len(options)]:
            await client.add_reaction(react_message, reaction)
        embed.set_footer(text='Poll ID: {}'.format(react_message.id))
        await client.edit_message(react_message, embed=embed)


@client.command(pass_context=True)  
@commands.has_permissions(ban_members=True)      
async def ban(ctx,user:discord.Member):
    if user.server_permissions.ban_members:
      await client.say('**He is mod/admin and i am unable to ban him/her**')
      return
    else:
      await client.ban(user)
      await client.say(user.name+' was banned. Good bye '+user.name+'!')
      for channel in member.server.channels:
        if channel.name == 'information-log':
            embed=discord.Embed(title="User banned!", description="**{0}** banned by **{1}**!".format(member, ctx.message.author), color=0x38761D)
            await client.send_message(channel, embed=embed)


@client.command(pass_context=True)  
@commands.has_permissions(ban_members=True)     
async def unban(ctx):
    ban_list = await client.get_bans(ctx.message.server)

    # Show banned users
    await client.say("Ban list:\n{}".format("\n".join([user.name for user in ban_list])))

    # Unban last banned user
    if not ban_list:
      await client.say('Ban list is empty.')
      return
    else:
      await client.unban(ctx.message.server, ban_list[-1])
      await client.say('Unbanned user: `{}`'.format(ban_list[-1].name))
      for channel in member.server.channels:
        if channel.name == 'soyal-log':
            embed=discord.Embed(title="User unbanned!", description="**{0}** unbanned by **{1}**!".format(ban_list[-1].name, ctx.message.author), color=0x38761D)
            await client.send_message(channel, embed=embed)


@client.command(pass_context=True)  
@commands.has_permissions(kick_members=True)     

async def serverinfo(ctx):
    '''Displays Info About The Server!'''

    server = ctx.message.server
    roles = [x.name for x in server.role_hierarchy]
    role_length = len(roles)

    if role_length > 50: #Just in case there are too many roles...
        roles = roles[:50]
        roles.append('>>>> Displaying[50/%s] Roles'%len(roles))

    roles = ', '.join(roles);
    channelz = len(server.channels);
    time = str(server.created_at); time = time.split(' '); time= time[0];
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
    join = discord.Embed(description= '%s '%(str(server)),title = 'Server Name', color = discord.Color((r << 16) + (g << 8) + b));
    join.set_thumbnail(url = server.icon_url);
    join.add_field(name = '__Owner__', value = str(server.owner) + '\n' + server.owner.id);
    join.add_field(name = '__ID__', value = str(server.id))
    join.add_field(name = '__Member Count__', value = str(server.member_count));
    join.add_field(name = '__Text/Voice Channels__', value = str(channelz));
    join.add_field(name = '__Roles (%s)__'%str(role_length), value = roles);
    join.set_footer(text ='Created: %s'%time);

    return await client.say(embed = join);


@client.command(pass_context=True)
async def apply(ctx, *, msg: str):
    channel = client.get_channel('520830825021964305')
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
    embed = discord.Embed(color = discord.Color((r << 16) + (g << 8) + b))
    embed.add_field(name='Application for bot', value='-------------------',inline = False) 
    embed.add_field(name='User ID:', value='{}'.format(ctx.message.author.id),inline = False)
    embed.add_field(name='User Name:', value='{}'.format(ctx.message.author.name),inline = False)
    embed.add_field(name='Server Name:', value='{}'.format(ctx.message.server.name),inline = False)
    embed.add_field(name='Bot information:', value=msg, inline=False)
    await client.send_message(channel, embed=embed) 
    await client.delete_message(ctx.message)


@client.command(pass_context = True)
@commands.has_permissions(administrator=True)     
async def makemod(ctx, user: discord.Member):
    nickname = '[̲̅M̲̅]' + user.name
    await client.change_nickname(user, nickname=nickname)
    role = discord.utils.get(ctx.message.server.roles, name='Moderator')
    await client.add_roles(user, role)
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
    embed = discord.Embed(color = discord.Color((r << 16) + (g << 8) + b))
    embed.set_author(name='Congratulations Message')
    embed.add_field(name = '__Congratulations__',value ='**Congratulations for mod.Hope you will be more active here. Thanks for your help and support.**',inline = False)
    embed.set_image(url = 'https://preview.ibb.co/i1izTz/ezgif_5_e20b665628.gif')
    await client.send_message(user,embed=embed)
    await client.delete_message(ctx.message)


@client.command(pass_context = True)
@commands.has_permissions(administrator=True)     
async def makeadmin(ctx, user: discord.Member):
    nickname = 'Ѧ'+ user.name
    await client.change_nickname(user, nickname=nickname)
    role = discord.utils.get(ctx.message.server.roles, name='Admin')
    await client.add_roles(user, role)
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
    embed = discord.Embed(color = discord.Color((r << 16) + (g << 8) + b))
    embed.set_author(name='Congratulations Message')
    embed.add_field(name = '__Congratulations__',value ='**Congratulations for Admin.Hope you will be more active here. Thanks for your help and support.**',inline = False)
    embed.set_image(url = 'https://preview.ibb.co/i1izTz/ezgif_5_e20b665628.gif')
    await client.send_message(user,embed=embed)
    await client.delete_message(ctx.message)


@client.command(pass_context = True)
async def sorry(ctx, *, msg = None):
    if '@here' in msg or '@everyone' in msg:
      return
    if not msg: await client.say("Please Sorry")
    await client.say('Sorry ' + msg + ' http://imgur.com/gallery/Dif2lYI')
    return


@client.command(pass_context = True)
@commands.has_permissions(manage_messages=True)  
async def clear(ctx, number):
 
    if ctx.message.author.server_permissions.manage_messages:
         mgs = [] #Empty list to put all the messages in the log
         number = int(number) #Converting the amount of messages to delete to an integer
    async for x in client.logs_from(ctx.message.channel, limit = number+1):
        mgs.append(x)            
       
    try:
        await client.delete_messages(mgs)          
        await client.say(str(number)+' messages deleted')
     
    except discord.Forbidden:
        await client.say(embed=Forbidden)
        return
    except discord.HTTPException:
        await client.say('clear failed.')
        return         
   
 
    await client.delete_messages(mgs)      

 
@client.event
async def on_message_delete(message):
    if not message.author.bot:
      channelname = 'information-log'
      logchannel=None
      for channel in message.server.channels:
        if channel.name == channelname:
          user = message.author
      for channel in user.server.channels:
        if channel.name == 'soyal-log':
          logchannel = channel
          r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
          embed = discord.Embed(color = discord.Color((r << 16) + (g << 8) + b))
          embed.set_author(name='Message deleted')
          embed.add_field(name = 'User: **{0}**'.format(user.name),value ='UserID: **{}**'.format(user.id),inline = False)
          embed.add_field(name = 'Message:',value ='{}'.format(message.content),inline = False)
          embed.add_field(name = 'Channel:',value ='{}'.format(message.channel.name),inline = False)
          await client.send_message(logchannel,  embed=embed)	
		
@client.command(pass_context = True)
async def avatar(ctx, user: discord.Member=None):
    if user is None:
        r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
        embed = discord.Embed(title=f'Avatar', description='Avatar is profile picture of a user in discord', color = discord.Color((r << 16) + (g << 8) + b))
        embed.add_field(name='User: {}'.format(ctx.message.author.name), value='Avatar:', inline=True)
        embed.set_thumbnail(url='https://cdn.discordapp.com/attachments/520159870448566287/520829749095038977/pubg.png') 
        embed.set_image(url = ctx.message.author.avatar_url)
        await client.say(embed=embed)
    else:
        r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
        embed = discord.Embed(title=f'Avatar', description='Avatar is profile picture of a user in discord', color = discord.Color((r << 16) + (g << 8) + b))
        embed.add_field(name='User: {}'.format(user.name), value='Avatar:', inline=True)
        embed.set_thumbnail(url='https://cdn.discordapp.com/attachments/520159870448566287/520829749095038977/pubg.png') 
        embed.set_image(url = user.avatar_url)
        await client.say(embed=embed)

@client.command(pass_context = True)
async def meme(ctx):
    choices = ['https://cheezburger.com/6946821/37-funny-random-memes-and-tweets-thatll-make-your-abs-sore', 'https://img.memecdn.com/english_o_869587.webp', 'https://i.imgur.com/E45OMsz.png', 'https://i.imgur.com/ONhilpQ.png', 'https://imgur.com/gallery/MzzrUWL', 'https://imgur.com/gallery/wrDxd43', 'https://imgur.com/gallery/HmQvoyP', 'https://imgur.com/gallery/JZIYuUZ', 'https://imgur.com/gallery/CTJKXOk', 'https://imgur.com/gallery/otW0j4u', 'https://imgur.com/gallery/OwILYdb', 'https://img.memecdn.com/everybody-knows-muricans-don-amp-039-t-speak-english-the-same-way-mexicans-don-amp-039-t-speak-spanish_c_7233205.webp', 'https://img.memecdn.com/english-reaction-when-they-heard-about-eu_c_6994013.webp', 'https://images3.memedroid.com/images/UPLOADED393/5b0c3ee92799f.jpeg' , 'https://images7.memedroid.com/images/UPLOADED850/5b0c2d7dd6049.jpeg', 'https://images7.memedroid.com/images/UPLOADED905/5b0c30c468fa8.jpeg', 'https://images7.memedroid.com/images/UPLOADED726/5b0c2d4c5f288.jpeg', 'https://images7.memedroid.com/images/UPLOADED936/5b0c2a90adbe7.jpeg', 'https://images7.memedroid.com/images/UPLOADED764/5b0c1e491c669.jpeg', 'https://images3.memedroid.com/images/UPLOADED922/5b0c284b71cd0.jpeg', 'https://images3.memedroid.com/images/UPLOADED207/5b0c265a58cf4.jpeg', 'https://images7.memedroid.com/images/UPLOADED920/5b0c06813741a.jpeg', 'https://images3.memedroid.com/images/UPLOADED46/5a91c871e61f1.jpeg', 'https://images7.memedroid.com/images/UPLOADED737/5a91c7f234bd2.jpeg', 'https://images7.memedroid.com/images/UPLOADED757/5a91bd39e1323.jpeg', 'https://images7.memedroid.com/images/UPLOADED963/5a91b4f7aba7e.jpeg', 'https://images7.memedroid.com/images/UPLOADED794/5a91ac0900506.jpeg', 'https://images3.memedroid.com/images/UPLOADED188/5a91aa326ad4e.jpeg', 'https://www.google.co.in/search?q=meme&rlz=1C1CHBF_enIN808IN808&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjR59bhhZPfAhUZEnIKHRzUAvkQ_AUIDigB&biw=1366&bih=664']
    r, g, b = tuple(int(x * 255) for x in colorsys.hsv_to_rgb(random.random(), 1, 1))
    embed = discord.Embed(title='Random Meme', description=':upside_down:', color = discord.Color((r << 16) + (g << 8) + b))
    embed.set_thumbnail(url='https://cdn.discordapp.com/attachments/520159870448566287/520829749095038977/pubg.png') 
    embed.set_image(url = random.choice(choices))
    await client.send_typing(ctx.message.channel)
    await client.send_message(ctx.message.channel, embed=embed) 

@client.command(pass_context=True, aliases=['server'])
@commands.has_permissions(kick_members=True)
async def membercount(ctx, *args):
    """
    Shows stats and information about current guild.
    ATTENTION: Please only use this on your own guilds or with explicit
    permissions of the guilds administrators!
    """
    if ctx.message.channel.is_private:
        await bot.delete_message(ctx.message)
        return

    g = ctx.message.server

    gid = g.id
    membs = str(len(g.members))
    membs_on = str(len([m for m in g.members if not m.status == Status.offline]))
    users = str(len([m for m in g.members if not m.bot]))
    users_on = str(len([m for m in g.members if not m.bot and not m.status == Status.offline]))
    bots = str(len([m for m in g.members if m.bot]))
    bots_on = str(len([m for m in g.members if m.bot and not m.status == Status.offline]))
    created = str(g.created_at)
    
    em = Embed(title="Membercount")
    em.description =    "```\n" \
                        "Members:   %s (%s)\n" \
                        "  Users:   %s (%s)\n" \
                        "  Bots:    %s (%s)\n" \
                        "Created:   %s\n" \
                        "```" % (membs, membs_on, users, users_on, bots, bots_on, created)

    await client.send_message(ctx.message.channel, embed=em)
    await client.delete_message(ctx.message)
	
	
@client.command(pass_context = True)
@commands.has_permissions(administrator=True)
async def channelsetup(ctx):
    author = ctx.message.author
    server = ctx.message.server
    mod_perms = discord.Permissions(manage_messages=True, kick_members=True, manage_nicknames =True,mute_members=True)
    admin_perms = discord.Permissions(ADMINISTRATOR=True)

    await client.create_role(author.server, name="Owner", permissions=admin_perms)
    await client.create_role(author.server, name="Admin", permissions=admin_perms)
    await client.create_role(author.server, name="Moderator", permissions=mod_perms)
    await client.create_role(author.server, name="Muted")
    
    await client.create_role(author.server, name="Friend of Owner")
    await client.create_role(author.server, name="Verified")
    everyone_perms = discord.PermissionOverwrite(send_messages=False, read_messages=True)
    everyone = discord.ChannelPermissions(target=server.default_role, overwrite=everyone_perms)
    user_perms = discord.PermissionOverwrite(read_messages=True)
    user = discord.ChannelPermissions(target=server.default_role, overwrite=user_perms)
    private_perms = discord.PermissionOverwrite(read_messages=False)
    private = discord.ChannelPermissions(target=server.default_role, overwrite=private_perms)    
    await client.create_channel(server, 'welcome_suagat',everyone)
    await client.create_channel(server, 'left_mat-ja-yar',everyone)
    await client.create_channel(server, 'announcement',everyone)
    await client.create_channel(server, 'give_away',everyone)
    await client.create_channel(server, 'self_assignable_roles',everyone)
    await client.create_channel(server, 'g_e_n_e_r_a_l',user)
    await client.create_channel(server, 'screenshot_image',user)
    await client.create_channel(server, 'promote_links',user)
    await client.create_channel(server, 'dark_memers',user)
    await client.create_channel(server, 'aki__play',user)
    await client.create_channel(server, 'spam_here',user)
    await client.create_channel(server, 'bot_commands',user)
    await client.create_channel(server, 'private_chat',private)
    await client.create_channel(server, 'General', type=discord.ChannelType.voice)
    await client.create_channel(server, 'music_commands',user)
    await client.create_channel(server, 'music', type=discord.ChannelType.voice)
    await client.create_channel(server, 'pokémon_catching',user)
    await client.create_channel(server, 'pokémon_dueling',user)
    await client.create_channel(server, 'pokémon_commands',user)
    await client.create_channel(server, 'A_F_K', type=discord.ChannelType.voice)




client.run(os.getenv('Token')) 
