コード例 #1
0
async def permissions(_cmd, pld):
    """
    :param _cmd: The command object referenced in the command.
    :type _cmd: sigma.core.mechanics.command.SigmaCommand
    :param pld: The payload with execution data and details.
    :type pld: sigma.core.mechanics.payload.CommandPayload
    """
    allowed_list = []
    disallowed_list = []
    if pld.msg.mentions:
        user_q = pld.msg.mentions[0]
    else:
        user_q = pld.msg.author
    response = info(f'{user_q.name}\'s Permissions')
    for permission in user_q.guild_permissions:
        if permission[1]:
            allowed_list.append(permission[0].replace('_', ' ').title())
        else:
            disallowed_list.append(permission[0].replace('_', ' ').title())
    if len(allowed_list) == 0:
        allowed_list = ['None']
    if len(disallowed_list) == 0:
        disallowed_list = ['None']
    response.add_field(name='Allowed',
                       value='```yml\n - ' +
                       '\n - '.join(sorted(allowed_list)) + '\n```')
    response.add_field(name='Disallowed',
                       value='```yml\n - ' +
                       '\n - '.join(sorted(disallowed_list)) + '\n```')
    in_ch = ok('Permission list sent to you.')
    await pld.msg.author.send(embed=response)
    await pld.msg.channel.send(embed=in_ch)
コード例 #2
0
async def unhardblockwords(cmd, pld):
    """
    :param cmd: The command object referenced in the command.
    :type cmd: sigma.core.mechanics.command.SigmaCommand
    :param pld: The payload with execution data and details.
    :type pld: sigma.core.mechanics.payload.CommandPayload
    """
    if pld.msg.author.permissions_in(pld.msg.channel).manage_guild:
        if pld.args:
            blocked_words = pld.settings.get('hardblocked_words')
            if blocked_words is None:
                blocked_words = []
            removed_words = []
            if pld.args[-1].lower() == '--all':
                removed_words = blocked_words
                blocked_words = []
            else:
                for word in pld.args:
                    if word.lower() in blocked_words:
                        blocked_words.remove(word.lower())
                        removed_words.append(word.lower())
            await cmd.db.set_guild_settings(pld.msg.guild.id,
                                            'hardblocked_words', blocked_words)
            if removed_words:
                response = ok(
                    f'I have removed {len(removed_words)} words from the heavy blacklist.'
                )
            else:
                response = info('No words were removed.')
        else:
            response = error('Nothing inputted.')
    else:
        response = denied('Access Denied. Manage Server needed.')
    await pld.msg.channel.send(embed=response)
コード例 #3
0
async def unblocknames(cmd, pld):
    """
    :param cmd: The command object referenced in the command.
    :type cmd: sigma.core.mechanics.command.SigmaCommand
    :param pld: The payload with execution data and details.
    :type pld: sigma.core.mechanics.payload.CommandPayload
    """
    if pld.msg.author.permissions_in(pld.msg.channel).manage_guild:
        if pld.args:
            blocked_names = pld.settings.get('blocked_names') or []
            removed_names = []
            if pld.args[-1].lower() == '--all':
                removed_names = blocked_names
                blocked_names = []
            else:
                for name in pld.args:
                    if name.lower() in blocked_names:
                        blocked_names.remove(name.lower())
                        removed_names.append(name.lower())
            await cmd.db.set_guild_settings(pld.msg.guild.id, 'blocked_names', blocked_names)
            if removed_names:
                ender = 's' if len(removed_names) > 1 else ''
                response = ok(f'I have removed {len(removed_names)} name{ender} from the blacklist.')
            else:
                response = info('No name were removed.')
        else:
            response = error('Nothing inputted.')
    else:
        response = denied('Access Denied. Manage Server needed.')
    await pld.msg.channel.send(embed=response)
コード例 #4
0
async def greetdmmessage(cmd, pld):
    """
    :param cmd: The command object referenced in the command.
    :type cmd: sigma.core.mechanics.command.SigmaCommand
    :param pld: The payload with execution data and details.
    :type pld: sigma.core.mechanics.payload.CommandPayload
    """
    if pld.msg.author.permissions_in(pld.msg.channel).manage_guild:
        if pld.args:
            greeting_text = ' '.join(pld.args)
            await cmd.db.set_guild_settings(pld.msg.guild.id, 'greet_dm_message', greeting_text)
            response = ok('New DM Greeting Message set.')
        else:
            current_greeting = pld.settings.get('greet_dm_message')
            if not current_greeting:
                current_greeting = 'Hello {user_mention}, welcome to {server_name}.'
            greet_embed = pld.settings.get('greet_dm_embed') or {}
            if greet_embed.get('active'):
                response = await make_greet_embed(greet_embed, current_greeting, pld.msg.guild)
            else:
                response = info('Current DM Greeting Message')
                response.description = current_greeting
    else:
        response = denied('Access Denied. Manage Server needed.')
    await pld.msg.channel.send(embed=response)
コード例 #5
0
async def byemessage(cmd, pld):
    """
    :param cmd: The command object referenced in the command.
    :type cmd: sigma.core.mechanics.command.SigmaCommand
    :param pld: The payload with execution data and details.
    :type pld: sigma.core.mechanics.payload.CommandPayload
    """
    if pld.msg.author.permissions_in(pld.msg.channel).manage_guild:
        if pld.args:
            goodbye_text = ' '.join(pld.args)
            await cmd.db.set_guild_settings(pld.msg.guild.id, 'bye_message',
                                            goodbye_text)
            response = ok('New Goodbye Message set.')
        else:
            current_goodbye = pld.settings.get('bye_message')
            if not current_goodbye:
                current_goodbye = '{user_name} has left {server_name}.'
            bye_embed = pld.settings.get('bye_embed') or {}
            if bye_embed.get('active'):
                response = await make_bye_embed(bye_embed, current_goodbye,
                                                pld.msg.guild)
            else:
                response = info('Current Goodbye Message')
                response.description = current_goodbye
    else:
        response = denied('Access Denied. Manage Server needed.')
    await pld.msg.channel.send(embed=response)
コード例 #6
0
async def blockwords(cmd, pld):
    """
    :param cmd: The command object referenced in the command.
    :type cmd: sigma.core.mechanics.command.SigmaCommand
    :param pld: The payload with execution data and details.
    :type pld: sigma.core.mechanics.payload.CommandPayload
    """
    if pld.msg.author.permissions_in(pld.msg.channel).manage_guild:
        if pld.args:
            blocked_words = pld.settings.get('blocked_words', [])
            added_words = []
            for word in pld.args:
                if word.lower() not in blocked_words:
                    blocked_words.append(word.lower())
                    added_words.append(word.lower())
            await cmd.db.set_guild_settings(pld.msg.guild.id, 'blocked_words',
                                            blocked_words)
            if added_words:
                response = ok(
                    f'I have added {len(added_words)} words to the blacklist.')
            else:
                response = info('No new words were added.')
        else:
            response = error('Nothing inputted.')
    else:
        response = denied('Access Denied. Manage Server needed.')
    await pld.msg.channel.send(embed=response)
コード例 #7
0
async def prefix(cmd, pld):
    """
    :param cmd: The command object referenced in the command.
    :type cmd: sigma.core.mechanics.command.SigmaCommand
    :param pld: The payload with execution data and details.
    :type pld: sigma.core.mechanics.payload.CommandPayload
    """
    current_prefix = cmd.db.get_prefix(pld.settings)
    if pld.args:
        if pld.msg.author.permissions_in(pld.msg.channel).manage_guild:
            new_prefix = ''.join(pld.args)
            if new_prefix != current_prefix:
                prefix_text = new_prefix
                if new_prefix == cmd.bot.cfg.pref.prefix:
                    new_prefix = None
                    prefix_text = cmd.bot.cfg.pref.prefix
                await cmd.db.set_guild_settings(pld.msg.guild.id, 'prefix', new_prefix)
                response = ok(f'**{prefix_text}** has been set as the new prefix.')
            else:
                response = error('The current prefix and the new one are the same.')
        else:
            response = denied('Access Denied. Manage Server needed.')
    else:
        response = info(f'**{current_prefix}** is the current prefix.')
    await pld.msg.channel.send(embed=response)
コード例 #8
0
async def blockedextensions(_cmd, pld):
    """
    :param _cmd: The command object referenced in the command.
    :type _cmd: sigma.core.mechanics.command.SigmaCommand
    :param pld: The payload with execution data and details.
    :type pld: sigma.core.mechanics.payload.CommandPayload
    """
    blocked_words = pld.settings.get('blocked_extensions')
    if not blocked_words:
        response = info('There are no blocked extensions.')
    else:
        total_count = len(blocked_words)
        blocked_words, page = PaginatorCore.paginate(blocked_words, pld.args[0] if pld.args else 1, 20)
        blocked_words = [f'.{bw}' for bw in blocked_words]
        showing_count = len(blocked_words)
        response = info(f'Extensions blocked on {pld.msg.guild.name}')
        response.description = ' '.join(blocked_words)
        response.set_footer(text=f'[Page {page}] Total: {total_count} | Showing: {showing_count}')
    await pld.msg.channel.send(embed=response)
コード例 #9
0
async def afk_comeback_check(ev, pld):
    """
    :param ev: The event object referenced in the event.
    :type ev: sigma.core.mechanics.event.SigmaEvent
    :param pld: The event payload data to process.
    :type pld: sigma.core.mechanics.payload.MessagePayload
    """
    if pld.msg.guild:
        pfx = ev.db.get_prefix(pld.settings)
        if not pld.msg.content.startswith(pfx):
            afk_data = await ev.db[ev.db.db_nam].AwayUsers.find_one_and_delete(
                {'user_id': pld.msg.author.id})
            if afk_data:
                await ev.db.cache.del_cache(f'afk_{pld.msg.author.id}')
                response = info('I have removed your AFK status.')
                removal = await pld.msg.channel.send(embed=response)
                await asyncio.sleep(5)
                try:
                    await removal.delete()
                except discord.ClientException:
                    pass
コード例 #10
0
async def listselfroles(_cmd, pld):
    """
    :param _cmd: The command object referenced in the command.
    :type _cmd: sigma.core.mechanics.command.SigmaCommand
    :param pld: The payload with execution data and details.
    :type pld: sigma.core.mechanics.payload.CommandPayload
    """
    self_roles = pld.settings.get('self_roles')
    if self_roles is None:
        self_roles = []
    role_list = []
    for srv_role in pld.msg.guild.roles:
        for role in self_roles:
            if role == srv_role.id:
                role_list.append(srv_role.name)
    if not role_list:
        response = info('No self assignable roles set.')
    else:
        role_count = len(role_list)
        role_list = sorted(role_list)
        page = pld.args[0] if pld.args else 1
        role_list, page = PaginatorCore.paginate(role_list, page)
        ender = 's' if role_count > 1 else ''
        summary = f'Showing **{len(role_list)}** role{ender} from Page **#{page}**.'
        summary += f'\n{pld.msg.guild.name} has **{role_count}** self assignable role{ender}.'
        rl_out = ''
        for role in role_list:
            rl_out += '\n- ' + role
        guild_icon = str(pld.msg.guild.icon_url
                         ) if pld.msg.guild.icon_url else discord.Embed.Empty
        response = discord.Embed(color=await get_image_colors(guild_icon))
        response.set_author(name=pld.msg.guild.name, icon_url=guild_icon)
        response.add_field(name='Self Assignable Role Stats',
                           value=summary,
                           inline=False)
        response.add_field(name='List of Self Assignable Roles',
                           value=f'{rl_out}',
                           inline=False)
    await pld.msg.channel.send(embed=response)