Esempio n. 1
0
 async def set_guild_punishments(self, ctx, **flags):
     """Set the guild punishments for a server.\n\nE.g. `sgp --mute 2 --kick 4 --ban 6`"""
     new_dict = {key: value for key, value in flags.items() if value}
     set_infraction_punishments(ctx.guild.id, **new_dict)
     single, double = "'", '"'
     await ctx.send(
         "Infraction Punishments edited to:\n" + f"```json\n{str(new_dict).replace(single, double)}\n```")
Esempio n. 2
0
    async def create_filter(self, flags, ctx):
        aggregations = {}
        flatten = lambda t: [item for sublist in t for item in sublist]

        for k, v in flags.items():
            if k == 'mine' and flags[k]:
                k = 'owner_id'
                t_val = str(ctx.author.id)
                aggregations[k] = t_val
                continue
            elif k == 'page' or k == 'sort' or k in constants.FILTER_BY_NUMERICAL.keys(
            ):
                continue
            if flags[k]:
                inp = ' '.join(flatten(flags[k]))
                if ',' in inp:
                    t_val = inp.split(',')
                    t_val = tuple([x.strip() for x in t_val])
                else:
                    t_val = '%' + inp + '%'
                if k == 'subtype':
                    k = 'sub_type'
                elif k == 'supertype':
                    k = 'super_type'
                elif k == 'evolvesfrom':
                    k = 'evolves_from'
                elif k == 'set':
                    k = 'pc_set'
                elif k == 'type':
                    k = 'types'
                elif k == 'card_id':
                    k = 'pokemon_cards.id'
                elif k == 'market_id':
                    k = 'market.id'
                elif k == 'rarity':
                    k = 'pokemon_cards.rarity'
                aggregations[k] = t_val

        # numerical flags
        for flag, expr in constants.FILTER_BY_NUMERICAL.items():
            if flag in flags:
                for text in flags[flag] or []:
                    ops = await self.parse_numerical_flag(text)

                    if ops is None:
                        raise commands.BadArgument(
                            f"Couldn't parse `--{flag} {' '.join(text)}`")

                    if ops[0] == '<':
                        aggregations[expr] = f"< {int(ops[1])}"
                    elif ops[0] == '=':
                        aggregations[expr] = f"= {int(ops[1])}"
                    elif ops[0] == '>':
                        aggregations[expr] = f"> {int(ops[1])}"
        return aggregations
Esempio n. 3
0
    async def support_ticket(self, ctx: commands.Context, **flags):
        """Contact Developer by making a support ticket
        Available Tags -> `--error` `--help` `--suggestion`
        `<prefix> <message> --error` will notify developer about an error
        `<prefix> --help <message>` will notify developer of the help you need"""
        true_f = [k for k,v in flags.items() if v and k != "message"]
        if not true_f:
            return await ctx.send("Please add a type for your ticket/message| `--error` `--help` `--suggestion`\nUse command `help send` for more info")
        flags['message'] = ' '.join(flags['message'])
        flags['user_id'] = str(ctx.author.id)
        flags['flags'] = ', '.join(true_f)
    
        cursor = self.bot.db.connection.cursor()
        cursor.execute("INSERT INTO support(user_id, flags, message) VALUES (%(user_id)s, %(flags)s, %(message)s)", flags)
        cursor.close()

        embed = self.bot.Embed(color = 0x6CFF00)
        embed.title = f"Support Ticket Sent"
        embed.description = f"**Type:** {flags['flags']}\n\n**Message:** {flags['message']}"
        await ctx.send(embed = embed)
Esempio n. 4
0
    async def sort(self, ctx: commands.Context, **flags):
        """Sort user's card collection
        Available criterias: name, series, id, amount, rarity
        Example `sort --rarity --amount` `sort --id`
        Only max 2 criterias"""

        true_f = [k for k,v in flags.items() if v]
        if len(true_f) == 0:
            return await ctx.send(embed = await self.bot.embeds.get({'type': 'GENERAL', 'color': discord.Color.dark_teal(),
                                        'title': 'Sorting Help',
                                        'body': f'Can sort name, rarity, series, id, amount\nBut only 2 criteria, Example: `{ctx.prefix}sort --rarity --amount` or `{ctx.prefix}sort --amount`',
                                        'footer': random.choice(FOOTER)}))
        if len(true_f) > 2:
            return await ctx.send(embed = await self.bot.embeds.get({'type': 'GENERAL', 'color': discord.Color.dark_teal(),
                                        'title': 'Sorting Help',
                                        'body': f'Only two criteras allowed - Ex. `{ctx.prefix}sort --rarity --amount`',
                                        'footer': random.choice(FOOTER)}))

        db_sort = ','.join(true_f)
        await self.bot.db.update_user_sort(ctx.author, db_sort)
        await ctx.send(embed = await self.bot.embeds.get({'type': 'GENERAL', 'color': discord.Color.dark_teal(),
                                    'title': 'Sorting Updated',
                                    'body': f'Changed collection sorting to {db_sort}',
                                    'footer': random.choice(FOOTER)}))
Esempio n. 5
0
 async def set_guild_punishments(self, ctx, **flags):
     new_dict = {key: value for key, value in flags.items() if value}
     set_infraction_punishments(ctx.guild.id, **new_dict)
     single, double = "'", '"'
     await ctx.send(
         "Infraction Punishments edited to:\n" + f"```json\n{str(new_dict).replace(single, double)}\n```")