示例#1
0
    def version(self, event):
        """
        Shows versioning information for this bot.
        """

        embed = message.MessageEmbed()

        embed.title = f'{katconfig.config.my_name.title()} is brought to you by:'

        embed.description = (
            f'Katherine v{__version__}r{__revision__} {__status__}.\n\nReleased on {__date__}.\n\n'
            f'Repository: {__repository__}')

        embed.set_image(url=self.state.me.avatar_url)

        for key in version_meta.keys():
            value = version_meta[key]
            if not value:
                value = '_Not specified_'
            embed.add_field(name=key, value=value, inline=False)

        for key in system_meta.keys():
            value = system_meta[key]
            if not value:
                value = '_Not specified_'
            embed.add_field(name=key, value=value, inline=True)

        # Purrloin purple.
        embed.color = 0xD200FF

        event.channel.send_message(embed=embed)
        event.msg.delete()
示例#2
0
    def where_am_i(self, event):
        """
        Shows a list of guilds I am a member in.

        This is only runnable by a valid commander.
        """

        guild_count = len(self.state.guilds.values())

        embed = message.MessageEmbed()

        embed.title = 'Guilds I am a member in'
        embed.description = (
            'These are all the guilds I am a member of. Run the `kick` command to '
            'make me leave one of these guilds!\n\n'
            f'I am currently in {guild_count} '
            f'guild{"s" if len(self.state.guilds.values()) != 1 else ""}.')

        # Pull a random colour
        embed.color = random.randint(0x0, 0xFFFFFF)

        for guild in self.state.guilds.values():
            info_list = (
                f'- ID: `{guild.id}`\n'
                f'- Owner: `{guild.owner}`\n'
                f'- Channels¹: `{len(guild.channels)}`\n'
                f'- Visible Members²: `{len(guild.members)}`\n'
                f'- Total Members²: `{guild.member_count}`\n'
                f'- Roles: `{len(guild.roles)}`\n'
                f'- Region³: `{guild.region.upper()}`\n'
                f'- Custom Emojis⁴: `{len(guild.emojis)}`\n'
                f'- V\'fn Level⁵: `{guild.verification_level.name.upper()}`\n'
                f'- MFA Level⁶: `{"NONE" if not guild.mfa_level else "2FA"}`')

            embed.add_field(name=guild.name, value=info_list, inline=True)

        embed.set_footer(
            text='1. These are the channels that you have access to. \n'
            '2. These will be the same unless the server does not show offline members. \n'
            '3. The voice region that is set. \n'
            '4. This should be maximum of 50... but... Discord. \n'
            '5. How strict the server settings are. \n'
            '6. Whether multiple-factor authorisation is set or not.')

        try:
            event.channel.send_message(embed=embed)
        except APIException:  # e.g. missing permissions
            event.author.open_dm().send_message(embed=embed)
        finally:
            event.msg.delete()
示例#3
0
    def __help_detail(self, event, command):
        self.log.debug(f'Detailing help for command {command}.')

        actual_command = helpers.find(
            lambda c: c.name.lower() == command.lower(), self.bot.commands)

        if actual_command is None:
            event.channel.send_message(
                f'Could not find any command named `{command}`')
        else:
            embed = message.MessageEmbed()
            embed.title = f'Documentation for `{command}`'

            # I learnt that this is a thing.
            description = inspect.cleandoc(actual_command.get_docstring())

            embed.description = description

            # Add random accent colour.
            embed.color = random.randint(0x0, 0xFFFFFF)

            event.channel.send_message(embed=embed)
示例#4
0
    def __help_outline(self, event):
        self.log.debug('Outlining help.')

        embed = message.MessageEmbed()
        embed.title = 'Available commands'
        embed.description = (
            'These commands may not be accessible by you.\n\n'
            'To find out more, run `help <command>` where `<command>` is a valid command name.'
        )

        command_list = ''

        for command in sorted(self.bot.commands, key=lambda c: c.name):
            command_list += f'- `{command.name}`\n'

        if not command_list.strip():
            command_list = 'No commands implemented or found!'

        embed.add_field(name='Commands', value=command_list)

        # Add random accent colour.
        embed.color = random.randint(0x0, 0xFFFFFF)

        event.channel.send_message(embed=embed)
示例#5
0
    def perms(self, event):
        """
        Shows the permissions for the guild you are calling this from for my user.

        If I don't have permission to send messages in the channel you call this from, I will just DM you instead
        (hopefully).

        ~~This is only runnable by a valid commander.~~
        ***__Edit in v7.0.2:__*** This command is now runnable by anyone in the guild.

        This is only runnable in a guild.
        """

        my_perms = event.guild.get_permissions(self.state.me)
        my_perms_dict = my_perms.to_dict()
        my_perms_value = my_perms.value

        role_ids = event.guild.get_member(self.state.me).roles
        roles = []
        for role_id in event.guild.roles.keys():
            if role_id in role_ids:
                roles.append(event.guild.roles[role_id])

        embed = message.MessageEmbed()

        embed.title = f'Permissions for {event.guild.name}'
        embed.description = 'The contents of this embed'
        embed.set_footer(
            text=f'Current bitfield permissions value: 2:{bin(my_perms_value)}; '
            f'8:{oct(my_perms_value)}; 10:{my_perms_value}; 16:{hex(my_perms_value)}  .'
        )

        # Pull a random colour
        embed.color = random.randint(0x0, 0xFFFFFF)

        main_perms_str = ''

        for key in my_perms_dict.keys():
            clean_key = key.title()
            clean_key = clean_key.replace('_', ' ')

            main_perms_str += (
                f'{":white_check_mark:" if my_perms_dict[key] else ":red_circle:"}'
                f' {clean_key}\n')

        embed.add_field(name='Overall permissions',
                        value=main_perms_str,
                        inline=False)

        for key in my_perms_dict.keys():

            role_list = ''

            is_first = True

            for role in roles:
                if role.permissions.to_dict()[key]:
                    if is_first:
                        is_first = False
                    else:
                        role_list += '\n'

                    ''.title()

                    role_list += f'- {role.name}'

            if not role_list:
                role_list = '- @\u200beveryone'

            clean_key = key.title()
            clean_key = clean_key.replace('_', ' ')

            embed.add_field(name=f'{clean_key}', value=role_list, inline=True)

        try:
            event.channel.send_message(embed=embed)
        except APIException:  # e.g. missing permissions
            event.author.open_dm().send_message(embed=embed)
        finally:
            event.msg.delete()