Exemplo n.º 1
0
    async def _about_command(self, ctx, command: commands.Command):
        e = discord.Embed(title=command.qualified_name + ' ' +
                          command.signature,
                          description=command.description or command.help)

        e.add_field(name='Qualified name', value=command.qualified_name)

        try:
            can_run = await command.can_run(ctx)
        except commands.CommandError:
            can_run = False

        e.add_field(name='Can you run it?', value=yesno(can_run))

        e.add_field(name='Enabled', value=yesno(command.enabled))

        invokes = await self.db.fetchval(
            'SELECT COUNT(*) FROM log WHERE command=$1',
            command.qualified_name)
        e.add_field(name='Total invokes', value='{0:,d}'.format(invokes))

        here_invokes = await self.db.fetchval(
            'SELECT COUNT(*) FROM log WHERE command=$1 AND guild_id=$2',
            command.qualified_name, ctx.guild.id)
        e.add_field(name='Invokes in this server',
                    value='{0:,d}'.format(here_invokes))

        if command.aliases:
            e.set_footer(text='Also known as: ' + ', '.join(command.aliases))

        await ctx.send(embed=e)
Exemplo n.º 2
0
    async def info(self, ctx, *, message: StarConverter()):
        '''Show info about a starred message.'''

        row = message

        star_ret = await self.db.fetchval(
            'SELECT COUNT(id) FROM starrers WHERE star_id=$1', row.get('id'))

        author = await ctx.guild.fetch_member(row.get('user_id'))
        stars = star_ret + 1

        e = discord.Embed()
        e.set_author(name=author.display_name, icon_url=author.avatar_url)

        e.add_field(name='Stars',
                    value=self.star_emoji(stars) + ' ' + str(stars))
        e.add_field(name='Starred in',
                    value='<#{}>'.format(row.get('channel_id')))
        e.add_field(name='Author', value=f'<@{author.id}>')
        e.add_field(name='Starrer',
                    value='<@{}>'.format(row.get('starrer_id')))
        e.add_field(name='Posted',
                    value=yesno(row.get('star_message_id') is not None))
        e.add_field(
            name='Context',
            value='[Click here!](https://discordapp.com/channels/{}/{}/{})'.
            format(row.get('guild_id'), row.get('channel_id'),
                   row.get('message_id')))

        e.set_footer(text='ID: {}'.format(row.get('message_id')))
        e.timestamp = row.get('starred_at')

        await ctx.send(embed=e)