Пример #1
0
 def usercard(self, roles, user, ava, bg):
     name = user.name
     foreground_col = self.invert(bg)
     avatar = self.imagefromURL(ava).resize((100, 100))
     self.add_corners(avatar, round(avatar.width / 2))
     details_text = 'Created account {}\nJoined server {}'.format(
         myself.time_encode(t.now().timestamp() -
                            user.created_at.timestamp()) + ' ago',
         myself.time_encode(t.now().timestamp() -
                            user.joined_at.timestamp()) + ' ago')
     rect_y_pos = 180 + ((self.getFont(self.fontpath, "Ubuntu-M",
                                       50).getsize(details_text)[1] + 20))
     canvas_height = rect_y_pos + len(roles * 50) + 30
     if self.getFont(self.fontpath, "Ubuntu-M", 50).getsize(name)[0] > 600:
         main = Image.new(mode='RGB',
                          color=bg,
                          size=(self.getFont(self.fontpath, 'Ubuntu-M',
                                             50).getsize(name)[0] + 200,
                                canvas_height))
     else:
         main = Image.new(mode='RGB', color=bg, size=(600, canvas_height))
     draw = ImageDraw.Draw(main)
     margin_right, margin_left = main.width - 40, 40
     draw.text((170, 30),
               name,
               fill=foreground_col,
               font=self.getFont(self.fontpath, "Ubuntu-M", 50))
     draw.text((170, 80),
               f'ID: {user.id}',
               fill=foreground_col,
               font=self.getFont(self.fontpath, "Ubuntu-M", 25))
     draw.text((40, 150),
               details_text,
               fill=foreground_col,
               font=self.getFont(self.fontpath, "Ubuntu-M", 25))
     for i in roles:
         draw.rectangle([(margin_left, rect_y_pos),
                         (margin_right, rect_y_pos + 50)],
                        fill=i['color'])
         draw.text((margin_left + 10, rect_y_pos + 10),
                   i['name'],
                   fill=self.invert(i['color']),
                   font=self.getFont(self.fontpath, "Ubuntu-M", 25))
         rect_y_pos += 50
     try:
         main.paste(avatar, (40, 30), avatar)
     except:
         main.paste(avatar, (40, 30))
     return self.buffer(main)
Пример #2
0
 async def slowmode(self, ctx, *args):
     if len(list(args)) == 0:
         await ctx.send(
             str(self.client.get_emoji(BotEmotes.error)) +
             " | How long in seconds?")
     else:
         cd = list(args)[0]
         if ctx.message.author.guild_permissions.manage_channels:
             if not cd.isnumeric():
                 await ctx.send(
                     str(self.client.get_emoji(BotEmotes.error)) +
                     " | That cooldown is not a number!")
             else:
                 if int(cd) < 0:
                     await ctx.send(
                         str(self.client.get_emoji(BotEmotes.error)) +
                         " | Minus slowmode? Did you mean slowmode 0 seconds?"
                     )
                 elif int(cd) > 21600:
                     await ctx.send(
                         str(self.client.get_emoji(BotEmotes.error)) +
                         " | That is too hecking sloow....")
                 else:
                     await ctx.message.channel.edit(slowmode_delay=cd)
                     await ctx.send(
                         str(self.client.get_emoji(BotEmotes.success)) +
                         " | Channel slowmode cooldown has been set to " +
                         str(myself.time_encode(int(cd))))
         else:
             await ctx.send(
                 str(self.client.get_emoji(BotEmotes.error)) +
                 " | You need the manage channels permission to do this command!"
             )
Пример #3
0
 async def spotify(self, ctx):
     if len(ctx.message.mentions) == 0: source = ctx.message.author.activity
     else: source = ctx.message.mentions[0].activity
     if str(source).lower() != 'spotify':
         await ctx.send(
             str(self.client.get_emoji(BotEmotes.error)) +
             ' | Nope, not listening to spotify.')
     else:
         embed = discord.Embed(
             url='https://open.spotify.com/track/{}'.format(
                 source.track_id),
             title=source.title,
             description='Track ID: `' + str(source.track_id) +
             '`\nStarted listening since ' +
             str(myself.time_encode(
                 (t.now() - source.created_at).seconds)) + ' ago',
             color=source.color)
         embed.add_field(name='Artists',
                         value=myself.dearray(source.artists))
         embed.add_field(name='Album', value=source.album)
         embed.set_author(
             name='Spotify',
             icon_url=
             'https://images-ext-1.discordapp.net/external/myh_a7c2mTDfnh31SP2539AL_a1bhAYpafwZL5gQ99I/https/www.freepnglogos.com/uploads/spotify-logo-png/spotify-download-logo-30.png'
         )
         embed.set_thumbnail(url=source.album_cover_url)
         await ctx.send(embed=embed)
Пример #4
0
 async def servercard(self, ctx):
     if 'servericon' in ctx.message.content:
         if ctx.message.guild.is_icon_animated(): link = 'https://cdn.discordapp.com/icons/'+str(ctx.message.guild.id)+'/'+str(ctx.message.guild.icon)+'.gif?size=1024'
         else: link = 'https://cdn.discordapp.com/icons/'+str(ctx.message.guild.id)+'/'+str(ctx.message.guild.icon)+'.png?size=1024'
         theEm = discord.Embed(title=ctx.message.guild.name+'\'s Icon', url=link, colour=discord.Colour.from_rgb(201, 160, 112))
         theEm.set_image(url=link)
         await ctx.send(embed=theEm)
     else:
         humans = len([i for i in ctx.guild.members if not i.bot])
         bots = len([i for i in ctx.guild.members if i.bot])
         online = len([i for i in ctx.guild.members if i.status.value!='offline'])
         date = myself.time_encode(round(t.now().timestamp() - ctx.guild.created_at.timestamp()))
         image = self.canvas.servercard("/home/runner/hosting601/assets/pics/card.jpg", str(ctx.message.guild.icon_url).replace('.gif', '.webp').replace(".webp?size=1024", ".jpg?size=128"), ctx.message.guild.name, date+' ago', ctx.message.guild.owner.name, str(humans), str(bots), str(len(ctx.message.guild.channels)), str(len(ctx.message.guild.roles)), str(ctx.message.guild.premium_subscription_count), str(ctx.message.guild.premium_tier), str(online))
         await ctx.send(content='Here is the '+ctx.message.guild.name+'\'s server card.', file=discord.File(image, ctx.message.guild.name+'.png'))
Пример #5
0
 async def roleinfo(self, ctx, *args):
     if len(list(args)) == 0:
         await ctx.send(
             str(self.client.get_emoji(BotEmotes.error)) +
             " | Please send a role name or a role mention! (don\'t)")
     else:
         data = None
         if '<@&' in ''.join(list(args)):
             data = ctx.message.guild.get_role(
                 int(
                     str(ctx.message.content).split('<@&')[1].split('>')
                     [0]))
         else:
             for i in ctx.message.guild.roles:
                 if ' '.join(list(args)).lower() == str(i.name).lower():
                     data = i
         if data == None:
             await ctx.send(
                 str(self.client.get_emoji(BotEmotes.error)) +
                 ' | Role not found!')
         else:
             if data.permissions.administrator:
                 perm = ':white_check_mark: Server Administrator'
             else:
                 perm = ':x: Server Administrator'
             if data.mentionable == True:
                 men = ':warning: You can mention this role and they can get pinged.'
             else:
                 men = ':v: You can mention this role and they will not get pinged! ;)'
             embedrole = discord.Embed(
                 title='Role info for role: ' + str(data.name),
                 description='**Role ID: **' + str(data.id) +
                 '\n**Role created at: **' + myself.time_encode(
                     (t.now() - data.created_at).seconds) +
                 ' ago\n**Role position: **' + str(data.position) +
                 '\n**Members having this role: **' +
                 str(len(data.members)) + '\n' + str(men) +
                 '\nPermissions Value: ' + str(data.permissions.value) +
                 '\n' + str(perm),
                 colour=data.colour)
             embedrole.add_field(
                 name='Role Colour',
                 value='**Color hex: **#' +
                 str(myself.tohex(data.color.value)) +
                 '\n**Color integer: **' + str(data.color.value) +
                 '\n**Color RGB: **' +
                 str(myself.dearray(list(data.color.to_rgb()))))
             await ctx.send(embed=embedrole)
Пример #6
0
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
        await ctx.send(
            "You are on cooldown. You can do the command again in {}.".format(
                myself.time_encode(round(error.retry_after))))
    elif isinstance(error, commands.CommandNotFound):
        return
    elif 'missing permissions' in str(error).lower():
        await ctx.send(
            "I don't have the permission required to use that command!")
    elif 'cannot identify image file' in str(error).lower():
        await ctx.send(
            str(client.get_emoji(BotEmotes.error)) +
            ' | Error, it seemed i can\'t load/send the image! Check your arguments and try again. Else, report this to the bot owner using `'
            + Config.prefix + 'feedback.`')
    else:
        print("ERROR on [{}]: {}".format(ctx.message.content, str(error)))
Пример #7
0
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
        return await ctx.send(
            "You are on cooldown. You can do the command again in {}.".format(
                myself.time_encode(round(error.retry_after))))
    elif isinstance(error, commands.CommandNotFound):
        return
    elif 'noarguments' in str(error).lower():
        return await ctx.send(
            '{} | Please insert arguments! `Like insert your name as a parameter.`'
            .format(client.get_emoji(BotEmotes.error)))
    elif 'nouserfound' in str(error).lower():
        return await ctx.send('{} | No user found.'.format(
            client.get_emoji(BotEmotes.error)))
    elif 'noprofile' in str(error).lower():
        return await ctx.send(
            '{} | You do not have any profile...\nYou can create one with `{}new`.'
            .format(client.get_emoji(BotEmotes.error), Config.prefix))
    elif 'missing permissions' in str(error).lower():
        return await ctx.send(
            "I don't have the permission required to use that command!")
    elif 'cannot identify image file' in str(error).lower():
        return await ctx.send(
            str(client.get_emoji(BotEmotes.error)) +
            ' | Error, it seemed i can\'t load/send the image! Check your arguments and try again. Else, report this to the bot owner using `'
            + Config.prefix + 'feedback.`')
    elif 'cannot send messages to this user' in str(error).lower():
        return await ctx.send(
            str(client.get_emoji(BotEmotes.error)) +
            ' | Oops! Your DMs are disabled!')
    else:
        await client.get_channel(Config.SupportServer.feedback).send(
            content=f'<@{Config.owner.id}> there was an error!',
            embed=discord.Embed(
                title='Error',
                color=discord.Colour.red(),
                description=
                f'Content:\n```{ctx.message.content}```\n\nError:\n```{str(error)}```'
            ).set_footer(text='Bug made by user: {} (ID of {})'.format(
                str(ctx.author), ctx.author.id)))
        await ctx.send(
            'There was an error. Error reported to the developer! sorry for the inconvenience...'
        )
Пример #8
0
 async def uptime(self, ctx):
     up, cmds = selfDB.get_uptime(), username601Stats.retrieveData()
     imageurl = myself.urlify(myself.uptimerobot())
     bot_uptime = up.split('|')[0].split(':')[0] + ' Hours, ' + up.split(
         '|')[0].split(':')[1] + ' minutes, ' + up.split('|')[0].split(
             ':')[2] + ' seconds.'
     embed = discord.Embed(
         description=
         'Bot uptime: {}\nOS uptime: {}\nLast downtime: {} UTC\n\nCommands run in the past {}: {}'
         .format(
             bot_uptime,
             str(myself.terminal('uptime -p'))[3:],
             up.split('|')[1],
             myself.time_encode(
                 round(t.now().timestamp()) - round(cmds['lastreset'])),
             str(cmds['count'])),
         color=discord.Colour.from_rgb(201, 160, 112))
     embed.set_image(url='https://quickchart.io/chart?c=' + imageurl)
     await ctx.send(embed=embed)
Пример #9
0
 def can_vote(userid):
     data = requests.get(
         'https://api.ksoft.si/webhook/dbl/check?bot={}&user={}'.format(
             str(Config.id), str(userid)),
         headers={
             'authorization': 'Bearer ' + str(os.environ['KSOFT_TOKEN'])
         }).json()
     if data['voted'] == False:
         return {'bool': True, 'time': None}
     else:
         raw = data['data']['expiry'].replace('T', ' ')
         raw = [
             int(raw.split('-')[0]),
             int(raw.split('-')[1].split('-')[0]),
             int(raw.split('-')[2].split(' ')[0]),
             int(raw.split(' ')[1].split(':')[0]),
             int(raw.split(':')[1].split(':')[0]),
             int(raw.split(':')[2].split('.')[0])
         ]
         time = t(raw[0], raw[1], raw[2], raw[3], raw[4], raw[5])
         return {
             'bool': False,
             'time': myself.time_encode((time - t.now()).seconds)
         }
Пример #10
0
 async def joinposition(self, ctx, *args):
     current_time = t.now().timestamp()
     user = myself.getUser(ctx, args)
     wait = await ctx.send('{} | Iterating through {} members...'.format(self.client.get_emoji(BotEmotes.loading), len(ctx.guild.members)))
     sortedJoins = sorted([current_time-i.joined_at.timestamp() for i in ctx.guild.members])[::-1]
     num, users = [i for i in range(len(sortedJoins)) if (current_time-user.joined_at.timestamp())==sortedJoins[i]][0], []
     for i in range(-10, 11):
         try:
             placement = (num + i) + 1
             if placement < 1: continue
             locate = sortedJoins[num + i]
             username = [str(i) for i in ctx.guild.members if (current_time-i.joined_at.timestamp())==locate][0]
             if i == 0: username = f'**{username}**'
             users.append({
                 'user': username,
                 'time': locate,
                 'order': str(placement)
             })
         except IndexError:
             pass
     em = discord.Embed(title='Your join position', description='\n'.join([
         '{}. {} ({} ago)'.format(i['order'], i['user'], myself.time_encode(round(i['time']))) for i in users
     ]), color=discord.Colour.from_rgb(201, 160, 112))
     await wait.edit(content='', embed=em)