Example #1
0
    def emojistats_custom(self, event, mode, sort):
        if mode not in ('server', 'global'):
            raise CommandFail(
                'invalid emoji mode, must be `server` or `global`')

        if sort not in ('least', 'most'):
            raise CommandFail('invalid emoji sort, must be `least` or `most`')

        order = 'DESC' if sort == 'most' else 'ASC'

        if mode == 'server':
            q = CUSTOM_EMOJI_STATS_SERVER_SQL.format(order,
                                                     guild=event.guild.id)
        else:
            q = CUSTOM_EMOJI_STATS_GLOBAL_SQL.format(order,
                                                     guild=event.guild.id)

        q = list(GuildEmoji.raw(q).tuples())

        tbl = MessageTable()
        tbl.set_header('Count', 'Name', 'ID')
        for emoji_id, name, count in q:
            tbl.add(count, name, emoji_id)

        event.msg.reply(tbl.compile())
Example #2
0
    def serialize_emoji(gcc):
        for i in gcc:
            emoji_raw = '''
                SELECT emoji_id
                FROM guild_emojis
                WHERE
                    emoji_id=%s AND
                    guild_id=%s;
            '''

            emoji = list(
                GuildEmoji.raw(emoji_raw, i[0], guild.guild_id).tuples())

            if emoji:
                return str(emoji[0][0])

        return '230870076126003200'