Ejemplo n.º 1
0
async def removereaction(_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_messages:
        if len(pld.args) == 2:
            mid, emote = pld.args
            if mid.isdigit():
                message = await message_search(mid, pld.msg)
                if message:
                    if pld.msg.guild.me.permissions_in(message.channel).manage_messages:
                        removed = await remove_emote(message, emote)
                        if removed:
                            response = ok('Reaction removed.')
                        else:
                            response = not_found('Emote not found on that message.')
                    else:
                        response = error('I can\'t remove reactions in that channel.')
                else:
                    response = not_found('Message not found.')
            else:
                response = error('Invalid message ID.')
        else:
            response = error('Invalid number of arguments.')
    else:
        response = denied('Access Denied. Manage Messages needed.')
    await pld.msg.channel.send(embed=response)
Ejemplo n.º 2
0
async def azurlaneskin(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
    """
    qry = ' '.join(pld.args) if pld.args else ''
    if qry and ';' in qry:
        ship_qry, skin_qry = [qix.strip() for qix in qry.split(';')[:2]]
        ship = await get_ship(cmd.db, ship_qry)
        if ship:
            ship = AzurLaneShip(ship)
            skin = ship.images.get_skin(skin_qry)
            if skin:
                skin_url = f'{ship.url}#{skin.name.replace(" ", "%20")}'
                title = f'{ship.name}: {skin.name}'
                response = discord.Embed(color=ship.rarity_color)
                response.set_author(name=title, icon_url=ship.images.small, url=skin_url)
                response.set_image(url=skin.url)
            else:
                response = not_found(f'Couldn\'t find that skin for {ship.name}.')
        else:
            response = not_found('Ship not found.')
    else:
        response = error('Invalid input. Please follow the usage example.')
    await pld.msg.channel.send(embed=response)
Ejemplo n.º 3
0
async def azurlaneskins(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
    """
    lookup = ' '.join(pld.args) if pld.args else None
    if lookup:
        ship = await get_ship(cmd.db, lookup)
        if ship:
            ship = AzurLaneShip(ship)
            skin_names = [skin.name for skin in ship.images.skins]
            if skin_names:
                skin_names = ', '.join(skin_names)
                pfx = cmd.db.get_prefix(pld.settings)
                response = discord.Embed(color=ship.rarity_color)
                response.set_author(name=f'Azur Lane: {ship.name} Skins',
                                    icon_url=ship.images.small,
                                    url=ship.url)
                response.description = skin_names
                response.set_footer(
                    text=
                    f'You can view a skin with the "{pfx}azurlaneskin" command.'
                )
            else:
                response = not_found(f'No skin data found for {ship.name}.')
        else:
            response = not_found('Ship not found.')
    else:
        response = error('Nothing inputted.')
    await pld.msg.channel.send(embed=response)
Ejemplo n.º 4
0
async def filterignore(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:
            if len(pld.args) >= 3:
                filter_name = pld.args[1].lower()
                target_type = get_target_type(pld.args[0].lower())
                if target_type:
                    if filter_name in filter_names:
                        targets, valid = get_targets(pld.msg, pld.args, target_type)
                        if valid:
                            overrides = pld.settings.get('filter_overrides') or {}
                            override_data = overrides.get(filter_name)
                            if not override_data:
                                override_data = {'users': [], 'channels': [], 'roles': []}
                            override = override_data.get(target_type) or []
                            error_response = None
                            for target in targets:
                                if target.id not in override:
                                    override.append(target.id)
                                else:
                                    error_response = error(f'{target.name} already has an override for that filter.')
                                    break
                            if not error_response:
                                override_data.update({target_type: override})
                                overrides.update({filter_name: override_data})
                                await cmd.db.set_guild_settings(pld.msg.guild.id, 'filter_overrides', overrides)
                                if len(targets) > 1:
                                    starter = f'{len(targets)} {target_type}'
                                    response = ok(f'{starter} are no longer affected by `blocked{filter_name}`.')
                                else:
                                    pnd = '#' if target_type == 'channels' else ''
                                    starter = f'{pnd}{targets[0].name}'
                                    response = ok(f'{starter} is no longer affected by `blocked{filter_name}`.')
                            else:
                                await pld.msg.channel.send(embed=error_response)
                                return
                        else:
                            if targets:
                                response = not_found(f'{targets} not found.')
                            else:
                                ender = 'specified' if target_type == 'roles' else 'targeted'
                                response = not_found(f'No {target_type} {ender}.')
                    else:
                        response = error('Invalid filter.')
                else:
                    response = error('Invalid target type.')
            else:
                response = error('Not enough arguments.')
        else:
            response = error('Nothing inputted.')
    else:
        response = denied('Access Denied. Manage Server needed.')
    await pld.msg.channel.send(embed=response)
Ejemplo n.º 5
0
async def wfpricecheck(_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
    """
    init_response = discord.Embed(color=0xFFCC66, title='🔬 Processing...')
    init_message = await pld.msg.channel.send(embed=init_response)
    if pld.args:
        lookup = '_'.join(pld.args).lower()
        lookup_url = api_url + lookup
        orders_url = f'{lookup_url}/orders'
        async with aiohttp.ClientSession() as session:
            async with session.get(lookup_url) as data:
                page_data = await data.read()
                try:
                    data = json.loads(page_data)
                except json.decoder.JSONDecodeError:
                    data = None
        if data:
            if not data.get('error'):
                item = None
                items_in_set = data['payload']['item']['items_in_set']
                for set_item in items_in_set:
                    if set_item['url_name'] == lookup:
                        item = set_item
                if item:
                    sellers = await get_lowest_trader(orders_url)
                    if sellers:
                        seller_lines = []
                        for seller in sellers:
                            seller_line = f'Name: **{seller["user"]["ingame_name"]}**'
                            seller_line += f' | Price: **{int(seller["platinum"])}**p'
                            seller_lines.append(seller_line)
                        seller_text = '\n'.join(seller_lines)
                    else:
                        seller_text = 'No sellers found.'
                    page_url = items_url + lookup
                    thumb = assets_url + item['icon']
                    name = item['en']['item_name']
                    response = discord.Embed(color=0xFFCC66)
                    response.description = seller_text
                    response.set_author(name=f'Warframe Market: {name}', icon_url=plat_img, url=page_url)
                    response.set_thumbnail(url=thumb)
                else:
                    response = not_found('Item not found.')
            else:
                response = not_found('Item not found.')
        else:
            response = error('Could not retrieve Warframe Market data.')
    else:
        response = error('Nothing inputted.')
    try:
        await init_message.edit(embed=response)
    except discord.NotFound:
        pass
async def makeemotetoggles(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.guild_permissions.manage_guild:
        if pld.args:
            group_id = pld.args[0].lower()
            has_desc = False if pld.args[-1].lower() == 'nodesc' else True
            target_ch = pld.msg.channel_mentions[
                0] if pld.msg.channel_mentions else pld.msg.channel
            emote_groups = pld.settings.get('emote_role_groups') or {}
            if group_id in emote_groups:
                role_items = []
                group_roles = emote_groups.get(group_id)
                if group_roles:
                    for group_role in group_roles:
                        role_item = pld.msg.guild.get_role(group_role)
                        if role_item:
                            role_items.append(role_item)
                        else:
                            group_roles.remove(group_role)
                    emote_groups.update({group_id: group_roles})
                    await cmd.db.set_guild_settings(pld.msg.guild.id,
                                                    'emote_role_groups',
                                                    emote_groups)
                    binding_data = make_binding_data(role_items)
                    toggler_response = await make_binding_message(
                        binding_data, pld.msg.guild, group_id, has_desc)
                    toggler_message = await target_ch.send(
                        embed=toggler_response)
                    await fill_toggler_emotes(toggler_message,
                                              list(binding_data.keys()))
                    guild_togglers = pld.settings.get(
                        'emote_role_togglers') or {}
                    guild_togglers.update(
                        {str(toggler_message.id): binding_data})
                    await cmd.db.set_guild_settings(pld.msg.guild.id,
                                                    'emote_role_togglers',
                                                    guild_togglers)
                    response = ok(
                        f'Toggler {group_id} created in {target_ch.name}.')
                else:
                    response = not_found('No groups in the Emote group!')
            else:
                response = not_found(f'Group {group_id} not found.')
        else:
            response = error('Missing group ID.')
    else:
        response = denied('Access Denied. Manage Server needed.')
    await pld.msg.channel.send(embed=response)
Ejemplo n.º 7
0
async def shadowpollexpires(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.args:
        if len(pld.args) == 2:
            poll_id = pld.args[0].lower()
            time_input = pld.args[1]
            try:
                exp_in = convert_to_seconds(time_input)
                poll_file = await cmd.db[cmd.db.db_nam].ShadowPolls.find_one({'id': poll_id})
                if poll_file:
                    if poll_file['origin']['author'] == pld.msg.author.id:
                        end_stamp = arrow.utcnow().float_timestamp + exp_in
                        end_human = arrow.get(end_stamp).humanize()
                        end_datet = arrow.get(end_stamp).datetime
                        poll_file['settings'].update({'expires': end_stamp})
                        poll_coll = cmd.db[cmd.db.db_nam].ShadowPolls
                        await poll_coll.update_one({'id': poll_id}, {'$set': poll_file})
                        title = f'⏰ Poll set to expire {end_human}.'
                        response = discord.Embed(color=0xff3333, title=title, timestamp=end_datet)
                    else:
                        response = denied('You didn\'t make this poll.')
                else:
                    response = not_found('Poll not found.')
            except (LookupError, ValueError):
                response = error('Please use the format HH:MM:SS.')
        else:
            response = error('Missing arguments.')
    else:
        response = error('Missing poll ID and expiration time.')
    await pld.msg.channel.send(embed=response)
Ejemplo n.º 8
0
async def viewlists(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
    """
    lookup_data = {'server_id': pld.msg.guild.id}
    list_coll = cmd.db[cmd.db.db_nam].CustomLists
    list_files = await list_coll.find(lookup_data).to_list(None)
    if list_files:
        list_lines = []
        for list_file in list_files:
            author_id = list_file.get('user_id')
            author = await cmd.bot.get_user(author_id)
            list_name = list_file.get('name')
            creator = f'{author.name}#{author.discriminator}' if author else author_id
            mode, icon = list_file.get('mode'), ''
            if mode in ['private', 'locked']:
                icon = '⛔' if mode == 'private' else '🔏'
            list_line = f'`{list_file.get("list_id")}` - {list_name} - {creator} `{icon}`'
            list_lines.append(list_line)
        page = pld.args[0] if pld.args else 1
        list_lines, page = PaginatorCore.paginate(list_lines, page)
        response = discord.Embed(color=0xF9F9F9,
                                 title=f':books: Custom Lists | Page {page}')
        list_list = '\n'.join(list_lines)
        response.description = list_list
    else:
        response = not_found('There are no lists on this server.')
    await pld.msg.channel.send(embed=response)
Ejemplo n.º 9
0
async def giphy(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 cmd.cfg.api_key:
        if pld.args:
            qry = ' '.join(pld.args)
            url = f'https://api.giphy.com/v1/gifs/search?q={qry}&api_key={cmd.cfg.api_key}'
            async with aiohttp.ClientSession() as session:
                async with session.get(url) as data_response:
                    search_data = await data_response.read()
                    search_data = json.loads(search_data)
            data = search_data.get('data')
            if data:
                data = secrets.choice(data)
                gif_id = data.get('id')
                gif_url = f'https://media.giphy.com/media/{gif_id}/giphy.gif'
                response = discord.Embed(color=0x262626)
                response.set_image(url=gif_url)
                response.set_footer(icon_url=giphy_icon,
                                    text='Powered By GIPHY.')
            else:
                response = not_found('No results')
        else:
            response = error('Nothing inputted.')
    else:
        response = error('The API Key is missing.')
    await pld.msg.channel.send(embed=response)
Ejemplo n.º 10
0
async def foodrecipe(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 cmd.cfg.api_key:
        if pld.args:
            search = ' '.join(pld.args)
            url = f'http://food2fork.com/api/search?key={cmd.cfg.api_key}&q={search}'
            async with aiohttp.ClientSession() as session:
                async with session.get(url) as data:
                    search_data = await data.read()
                    search_data = json.loads(search_data)
            count = search_data['count']
            if count == 0:
                response = not_found('No results.')
            else:
                info = search_data['recipes'][0]
                title = info['title']
                source = info['publisher']
                source_url = info['source_url']
                image_url = info['image_url']
                publisher_url = info['publisher_url']
                response = discord.Embed(color=0xee5b2f)
                response.set_author(name=source, url=publisher_url, icon_url='https://i.imgur.com/RH8LNdQ.png')
                response.add_field(name=title, value='[Recipe Here](' + source_url + ')')
                response.set_thumbnail(url=image_url)
        else:
            response = error('Nothing inputted.')
    else:
        response = error('The API Key is missing.')
    await pld.msg.channel.send(embed=response)
Ejemplo n.º 11
0
async def shootfoot(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
    """
    lang = ' '.join(pld.args).lower() if pld.args else None
    if lang:
        joke_doc = await cmd.db[cmd.db.db_nam
                                ].ShootFootData.find_one({'lang_low': lang})
        if not joke_doc:
            joke_docs = await get_all_sf(cmd.db)
            for joke_doc_item in joke_docs:
                alts = joke_doc_item.get('alts') or []
                if lang in alts:
                    joke_doc = joke_doc_item
                    break
    else:
        all_docs = await get_all_sf(cmd.db)
        joke_doc = secrets.choice(all_docs)
    if joke_doc:
        joke = secrets.choice(joke_doc.get('methods'))
        foot_lang = joke_doc.get('lang')
        response = discord.Embed(
            color=0xbf6952,
            title=f'🔫 How to shoot yourself in the foot with {foot_lang}...'
        )
        response.description = joke
    else:
        response = not_found(f'I don\'t know how to do it in {lang}.')
    await pld.msg.channel.send(embed=response)
Ejemplo n.º 12
0
async def roleid(_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
    """
    embed = True
    if pld.args:
        lookup = ' '.join(pld.args)
        if pld.args[-1].lower() == '--text':
            embed = False
            lookup = ' '.join(pld.args[:-1])
        role = discord.utils.find(lambda x: x.name.lower() == lookup.lower(), pld.msg.guild.roles)
        if role:
            if embed:
                response = discord.Embed(color=0x3B88C3)
                response.add_field(name=f'ℹ {role.name}', value=f'`{role.id}`')
            else:
                response = role.id
        else:
            embed = True
            response = not_found(f'{lookup} not found.')
    else:
        response = error('Nothing inputted.')
    if embed:
        await pld.msg.channel.send(embed=response)
    else:
        await pld.msg.channel.send(response)
Ejemplo n.º 13
0
async def addselfrole(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.guild_permissions.manage_roles:
        if pld.args:
            lookup = ' '.join(pld.args)
            target_role = discord.utils.find(lambda x: x.name.lower() == lookup.lower(), pld.msg.guild.roles)
            if target_role:
                role_below = bool(target_role.position < pld.msg.guild.me.top_role.position)
                if role_below:
                    selfroles = pld.settings.get('self_roles', [])
                    if target_role.id in selfroles:
                        response = error('This role is already self assignable.')
                    else:
                        selfroles.append(target_role.id)
                        await cmd.db.set_guild_settings(pld.msg.guild.id, 'self_roles', selfroles)
                        response = ok(f'{target_role.name} added.')
                else:
                    response = error('This role is above my highest role.')
            else:
                response = not_found(f'I can\'t find {lookup} on this server.')
        else:
            response = error('Nothing inputted.')
    else:
        response = denied('Access Denied. Manage Roles needed.')
    await pld.msg.channel.send(embed=response)
Ejemplo n.º 14
0
async def logmodule(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.guild_permissions.manage_guild:
        if pld.args:
            module_name = pld.args[0].lower()
            if module_name in cmd.bot.modules.categories:
                logged_modules = pld.settings.get('logged_modules') or []
                if module_name in logged_modules:
                    result = 'disabled'
                    logged_modules.remove(module_name)
                else:
                    result = 'enabled'
                    logged_modules.append(module_name)
                await cmd.db.set_guild_settings(pld.msg.guild.id,
                                                'logged_modules',
                                                logged_modules)
                response = ok(f'{module_name.upper()} logging {result}.')
            else:
                response = not_found('Module not found.')
        else:
            response = error('No module given.')
    else:
        response = denied('Access Denied. Manage Server needed.')
    await pld.msg.channel.send(embed=response)
async def gftacticaldoll(_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 not tdoll_page_index:
        await fill_tdoll_data()
    if pld.args:
        tdoll_search = ' '.join(pld.args)
        tdoll_url = tdoll_page_index.get(tdoll_search.lower())
        if tdoll_url:
            tdoll_data = await get_tdoll_data(tdoll_url)
            response = discord.Embed(
                color=tdoll_colors.get(tdoll_data.get('rarity')))
            response.set_image(url=tdoll_data.get('image'))
            response.set_author(
                name=f'Girls Frontline: {tdoll_data.get("name")}',
                icon_url=gf_icon,
                url=tdoll_url)
            response.add_field(name='Weapon Information',
                               value=get_weapon_info_block(tdoll_data),
                               inline=False)
            response.add_field(name='Weapon Statistics',
                               value=get_weapon_satats_block(tdoll_data),
                               inline=False)
        else:
            response = not_found('Nothing found.')
    else:
        response = error('Nothing inputted.')
    await pld.msg.channel.send(embed=response)
Ejemplo n.º 16
0
async def dictionary(_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.args:
        query = '_'.join(pld.args).lower()
        lexico_url = f'https://www.lexico.com/en/definition/{query}'
        async with aiohttp.ClientSession() as session:
            async with session.get(lexico_url) as data_response:
                data = await data_response.text()
                data = scrape_lexico(data)
        if data:
            response = discord.Embed(color=0x50b46c)
            response.set_author(name=f'Lexico Dictionary: {data.get("word")}', icon_url=lexico_icon, url=lexico_url)
            for gramb in data.get('grambs'):
                gramb_lines = []
                for trg in gramb.get('trgs'):
                    gramb_lines.append(f'**{trg.get("index")}.** {trg.get("context")}')
                    for sub in trg.get("subsenses"):
                        gramb_lines.append(f'-> **{trg.get("index")}.{sub.get("index")}.** {sub.get("context")}')
                gramb_text = '\n'.join(gramb_lines[:10])
                if gramb_text:
                    response.add_field(name=gramb.get("type"), value=gramb_text, inline=False)
            if data.get('audio'):
                response.description = f'{data.get("word")} Pronunciation Audio: [Here]({data.get("audio")})'
        else:
            response = not_found('No results.')
    else:
        response = error('Nothing inputted.')
    await pld.msg.channel.send(embed=response)
Ejemplo n.º 17
0
async def warmachinename(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 len(pld.args) >= 2:
        lookup = pld.args[0]
        new_name = ' '.join(pld.args[1:])
        machines = await SigmaMachine.get_machines(cmd.db, pld.msg.author)
        machine: SigmaMachine = find_machine(lookup, machines)
        if machine:
            sumarum = await cmd.db.get_resource(pld.msg.author.id, 'sumarum')
            if sumarum.current >= price:
                machine.name = new_name
                await machine.update()
                response = ok(f'Machine {machine.id} renamed.')
            else:
                response = error('Not enough sumarum.')
        else:
            response = not_found('No warmachine found.')
    else:
        response = error('Invalid number of arguments.')
    await pld.msg.channel.send(embed=response)
Ejemplo n.º 18
0
async def boundinvites(_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.guild_permissions.create_instant_invite:
        bound_invites = pld.settings.get('bound_invites')
        if bound_invites:
            output_lines = []
            output_role_data = []
            for key in bound_invites:
                role_id = bound_invites.get(key)
                target_role = pld.msg.guild.get_role(role_id)
                if target_role:
                    role_name = target_role.name
                else:
                    role_name = '{Role Missing}'
                output_role_data.append([key, role_name])
            output_role_data = sorted(output_role_data, key=lambda x: x[1])
            for key, role_name in output_role_data:
                out_line = f'`{key}`: {role_name}'
                output_lines.append(out_line)
            response = discord.Embed(color=0xF9F9F9, title='⛓ List of Bound Invites')
            response.description = '\n'.join(output_lines)
        else:
            response = not_found('No invites have been bound.')
    else:
        response = denied('Access Denied. Create Instant Invites needed.')
    await pld.msg.channel.send(embed=response)
Ejemplo n.º 19
0
async def help(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.args:
        cmd_name = ''.join(pld.args).lower()
        if cmd_name in cmd.bot.modules.alts:
            cmd_name = cmd.bot.modules.alts[cmd_name]
        if cmd_name in cmd.bot.modules.commands:
            pfx = cmd.db.get_prefix(pld.settings)
            command = cmd.bot.modules.commands[cmd_name]
            usage = command.usage.replace('{pfx}', pfx).replace('{cmd}', command.name)
            title = f'📄 [{command.category.upper()}] {command.name.upper()} Usage and Information'
            response = discord.Embed(color=0x1B6F5F, title=title)
            response.add_field(name='Usage Example', value=f'`{usage}`', inline=False)
            response.add_field(name='Command Description', value=f'```\n{command.desc}\n```', inline=False)
            if command.alts:
                response.add_field(name='Command Aliases', value=f'```\n{", ".join(command.alts)}\n```')
        else:
            response = not_found('Command not found.')
    else:
        response = discord.Embed(color=0x1B6F5F)
        response.set_author(name=sigma_title, icon_url=user_avatar(cmd.bot.user), url=cmd.bot.cfg.pref.website)
        invite_url = f'https://discordapp.com/oauth2/authorize?client_id={cmd.bot.user.id}&scope=bot&permissions=8'
        support_text = f'**Add Me**: [Link]({invite_url})'
        support_text += f' | **Commands**: [Link]({cmd.bot.cfg.pref.website}/commands)'
        support_text += f' | **Support**: [Link]({support_url})'
        support_text += f'\nWanna help? **Patreon**: [Link]({patreon_url}) | **PayPal**: [Link]({paypal_url})'
        response.add_field(name='Help', value=support_text)
        response.set_thumbnail(url=user_avatar(cmd.bot.user))
        response.set_footer(text='© by Lucia\'s Cipher. Released under the GPLv3 license.', icon_url=lucia_image)
    await pld.msg.channel.send(embed=response)
Ejemplo n.º 20
0
async def liststatuses(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
    """
    status_data = await cmd.db[cmd.db.db_nam].StatusFiles.find({}
                                                               ).to_list(None)
    if status_data:
        status_list = [[s['id'], s['text']] for s in status_data]
        status_list = sorted(status_list, key=lambda x: x[1])
        total_status = len(status_list)
        page = pld.args[0] if pld.args else 1
        status_list, page = PaginatorCore.paginate(status_list, page)
        status_block = boop(status_list, ['ID', 'Text'])
        response = discord.Embed(
            color=await get_image_colors(user_avatar(cmd.bot.user)))
        response.set_author(
            name=f'{cmd.bot.user.name}\'s Status Rotation Items',
            icon_url=user_avatar(cmd.bot.user))
        info = f'Showing {len(status_list)} items out of {total_status} on page {page}.'
        response.add_field(name='Info', value=f'```py\n{info}\n```')
        response.add_field(name="List",
                           value=f'```\n{status_block}\n```',
                           inline=False)
    else:
        response = not_found('No statuses found.')
    await pld.msg.channel.send(embed=response)
Ejemplo n.º 21
0
async def shadowpollinvisible(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.args:
        poll_id = pld.args[0].lower()
        poll_file = await cmd.db[cmd.db.db_nam].ShadowPolls.find_one({'id': poll_id})
        if poll_file:
            author = poll_file['origin']['author']
            if author == pld.msg.author.id:
                visible = poll_file['settings']['visible']
                if visible:
                    poll_file['settings'].update({'visible': False})
                    await cmd.db[cmd.db.db_nam].ShadowPolls.update_one({'id': poll_id}, {'$set': poll_file})
                    response = discord.Embed(color=0x161616, title=f'🕶 Poll {poll_file["id"]} is now invisible.')
                else:
                    response = error(f'Poll {poll_file["id"]} is already invisible.')
            else:
                response = denied('You didn\'t make this poll.')
        else:
            response = not_found('Poll not found.')
    else:
        response = error('Missing poll ID.')
    await pld.msg.channel.send(embed=response)
Ejemplo n.º 22
0
async def httpstatus(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
    """
    lookup = pld.args[0] if pld.args else None
    if lookup:
        status_data = await cmd.db[cmd.db.db_nam].HTTPStatusData.find_one({'code': lookup})
        if status_data:
            status_id = status_data.get('code')
            status_message = status_data.get('message')
            status_description = status_data.get('description')
            response = discord.Embed(color=0x3B88C3)
            response.add_field(name=f'🌐 {status_id}: {status_message}', value=f'{status_description}.')
            bonus = {'cat': 'https://http.cat/images', 'dog': 'https://httpstatusdogs.com/img'}
            bonus_arg = pld.args[-1].lower()
            if bonus_arg in bonus.keys():
                bonus_img = f'{bonus.get(bonus_arg)}/{lookup}.jpg'
                response.set_image(url=bonus_img)
        else:
            response = not_found('Response code not found.')
    else:
        response = error('Nothing inputted.')
    await pld.msg.channel.send(embed=response)
Ejemplo n.º 23
0
async def wolframalpha(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
    """
    init_message = None
    if cmd.cfg.app_id:
        if not is_ongoing('mathgame', pld.msg.channel.id):
            if pld.args:
                query = make_safe_query(pld.args)
                url = f'{api_url}{query}&appid={cmd.cfg.app_id}'
                init_response = discord.Embed(color=0xff7e00)
                init_response.set_author(name='Processing request...', icon_url=wolfram_icon)
                init_message = await pld.msg.channel.send(embed=init_response)
                results = await get_results(url)
                if results:
                    if len(results) <= 2000:
                        response = discord.Embed(color=0xff7e00, description=f'```\n{results}\n```')
                        response.set_author(name='Wolfram Alpha', icon_url=wolfram_icon, url=wolfram_url + query)
                        response.set_footer(text='View the full results by clicking the embed title.')
                    else:
                        response = error('Results too long to display.')
                        response.description = f'You can view them directly [here]({wolfram_url + query}).'
                else:
                    response = not_found('No results.')
            else:
                response = error('Nothing inputted.')
        else:
            response = error('Wolfram can\'t be used during an ongoing math game.')
    else:
        response = error('The API Key is missing.')
    await send_response(pld.msg, init_message, response)
async def removeinactivewarning(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 == pld.msg.guild.owner:
        if pld.msg.mentions:
            if len(pld.args) == 2:
                target = pld.msg.mentions[0]
                warn_id = pld.args[1].lower()
                lookup = {
                    'guild': pld.msg.guild.id,
                    'target.id': target.id,
                    'warning.id': warn_id,
                    'warning.active': False
                }
                warn_data = await cmd.db[cmd.db.db_nam
                                         ].Warnings.find_one(lookup)
                if warn_data:
                    warn_iden = warn_data.get('warning').get('id')
                    await cmd.db[cmd.db.db_nam].Warnings.delete_one(lookup)
                    response = ok(f'Warning {warn_iden} deleted.')
                else:
                    response = not_found('Inactive warning not found.')
            else:
                response = error('Both user tag and warning ID are needed.')
        else:
            response = error('No user targeted.')
    else:
        response = denied('Access Denied. Server Owner needed.')
    await pld.msg.channel.send(embed=response)
Ejemplo n.º 25
0
async def shadowpolllist(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.args:
        if pld.args[0].startswith('c'):
            lookup = {'origin.channel': pld.msg.channel.id, 'settings.active': True}
        elif pld.args[0].startswith('s'):
            lookup = {'origin.server': pld.msg.guild.id, 'settings.active': True}
        else:
            lookup = {'origin.author': pld.msg.author.id}
    else:
        lookup = {'origin.author': pld.msg.author.id}
    poll_files = await cmd.db[cmd.db.db_nam].ShadowPolls.find(lookup).to_list(None)
    if poll_files:
        response = discord.Embed(color=0xF9F9F9, title='📊 Shadow Poll List')
        list_lines = []
        for poll_file in poll_files:
            list_line = f'`{poll_file["id"]}` - {poll_file["poll"]["question"]}'
            if not poll_file['settings']['active']:
                list_line += ' [!]'
            list_lines.append(list_line)
        poll_list = '\n'.join(list_lines)
        response.description = poll_list
    else:
        response = not_found('There are no polls.')
    await pld.msg.channel.send(embed=response)
Ejemplo n.º 26
0
async def listraffles(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
    """
    lookup = {'author': pld.msg.author.id, 'active': True}
    raffle_docs = await cmd.db[cmd.db.db_nam
                               ].Raffles.find(lookup).to_list(None)
    if raffle_docs:
        raffle_lines = []
        for raf_doc in raffle_docs:
            raffle_channel = await cmd.bot.get_channel(raf_doc.get('channel'))
            if raffle_channel:
                location = f'in **#{raffle_channel.name}** on **{raffle_channel.guild.name}**.'
            else:
                location = 'in an unknown location.'
            hum_time = arrow.get(raf_doc.get('end')).humanize()
            raffle_line = f'`{raf_doc.get("id")}` ends {hum_time} {location}.'
            raffle_lines.append(raffle_line)
        outlist = '\n'.join(raffle_lines)
        response = discord.Embed(color=pld.msg.author.color)
        response.set_author(name=f'{pld.msg.author.name}\'s Raffles',
                            icon_url=user_avatar(pld.msg.author))
        response.description = outlist
    else:
        response = not_found('You have no pending raffles.')
    await pld.msg.channel.send(embed=response)
Ejemplo n.º 27
0
async def antonyms(_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.args:
        query = '+'.join(pld.args).lower()
        site_url = f'http://www.rhymezone.com/r/rhyme.cgi?Word={query}&typeofrhyme=ant'
        api_url = f'https://api.datamuse.com/words?rel_ant={query}&max=11'
        async with aiohttp.ClientSession() as session:
            async with session.get(api_url) as data_response:
                data = await data_response.read()
                try:
                    data = json.loads(data)
                except json.JSONDecodeError:
                    data = {}
        data = [r for r in data if 'score' in r]
        if data:
            data = [f'- {item.get("word")}' for item in data]
            response = discord.Embed(color=0xFBB429,
                                     description='\n'.join(data[:10]))
            response.set_author(name=f'Antonyms for {query.replace("+", " ")}',
                                url=site_url,
                                icon_url=icon)
            if len(data) > 10:
                response.set_footer(
                    text='Follow the link in the title to see more.')
        else:
            response = not_found('No results.')
    else:
        response = error('Nothing inputted.')
    await pld.msg.channel.send(embed=response)
Ejemplo n.º 28
0
async def editline(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 len(pld.args) >= 3:
        edit_line = ' '.join(pld.args[2:])
        list_coll = cmd.db[cmd.db.db_nam].CustomLists
        lookup_data = {'server_id': pld.msg.guild.id, 'list_id': pld.args[0].lower()}
        list_file = await list_coll.find_one(lookup_data)
        if list_file:
            if user_auth(pld.msg, list_file):
                line = pld.args[1]
                if line.isdigit():
                    try:
                        line_num = max(1, int(line))
                        list_file.get('contents', [])[line_num - 1] = edit_line
                        await list_coll.update_one(lookup_data, {'$set': list_file})
                        response = discord.Embed(color=0xF9F9F9, title=f'📝 Line {line_num} was edited.')
                    except IndexError:
                        response = not_found('Line not found.')
                else:
                    response = error('Invalid line number.')
            else:
                mode = 'private' if list_file.get('mode') == 'private' else 'locked'
                response = discord.Embed(color=0xFFAC33, title=f'🔏 This list is {mode}.')
        else:
            response = error('Missing or invalid list ID.')
    else:
        response = error('Not enough arguments.')
    await pld.msg.channel.send(embed=response)
Ejemplo n.º 29
0
async def generateitem(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
    """
    item_core = await get_item_core(cmd.db)
    if pld.args:
        if pld.msg.mentions:
            if len(pld.args) >= 2:
                target = pld.msg.mentions[0]
                lookup = ' '.join(pld.args[1:])
                item = item_core.get_item_by_name(lookup)
                if item:
                    connector = 'a'
                    if item.name[0].lower() in ['a', 'e', 'i', 'o', 'u']:
                        connector = 'an'
                    data_for_inv = item.generate_inventory_item()
                    await cmd.db.add_to_inventory(target.id, data_for_inv)
                    success_text = f'{item.icon} I have given {connector} {item.name} to {target.display_name}.'
                    response = discord.Embed(color=item.color,
                                             title=success_text)
                else:
                    response = not_found(f'{lookup} not found.')
            else:
                response = error('Not enough arguments.')
        else:
            response = error('No user targeted.')
    else:
        response = error('Nothing inputted.')
    await pld.msg.channel.send(embed=response)
Ejemplo n.º 30
0
async def roleinformation(_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.args:
        lookup = ' '.join(pld.args)
        role = discord.utils.find(lambda x: x.name.lower() == lookup.lower(),
                                  pld.msg.guild.roles)
        if role:
            creation_time = arrow.get(role.created_at).format('DD. MMMM YYYY')
            desc_text = f'Name: **{role.name}**'
            desc_text += f'\nID: **{role.id}**'
            desc_text += f'\nColor: **{str(role.color).upper()}**'
            desc_text += f'\nHoisted: **{role.hoist}**'
            desc_text += f'\nMembers: **{len(role.members)}**'
            desc_text += f'\nCreated: **{creation_time}**'
            response = discord.Embed(color=role.color)
            response.add_field(name=f'{role.name} Information',
                               value=desc_text)
        else:
            response = not_found(f'{lookup} not found.')
    else:
        response = error('Nothing inputted.')
    await pld.msg.channel.send(embed=response)