Ejemplo n.º 1
0
    async def leaderboard(self,
                          inter: disnake.ApplicationCommandInteraction,
                          start: int = 1):
        if not await self.validate_leaderboard_offset(start, inter):
            return
        embed = disnake.Embed()
        value_num = math.ceil(start / config.karma_grillbot_leaderboard_size)
        value = messages.karma_web if value_num == 1 else f"{messages.karma_web}{value_num}"
        embed.add_field(name=messages.karma_web_title, value=value)
        page_source = LeaderboardPageSource(
            bot=self.bot,
            author=inter.author,
            query=karma_r.leaderboard_query(Database_karma.karma.desc()),
            row_formatter=self._leaderboard_formatter,
            base_embed=embed,
            title='KARMA LEADERBOARD',
            emote_name='trophy',
            member_id_col_name='member_ID',
        )
        page_num = math.floor(start / page_source.per_page)
        page = page_source.get_page(page_num)
        embed = page_source.format_page(page)

        await self.check.botroom_check(inter)
        view = EmbedView(embeds=[embed], page_source=page_source)
        view.message = await inter.response.send_message(embed=embed,
                                                         view=view)
Ejemplo n.º 2
0
    async def huggers(self, ctx: commands.Context):
        """
        Get the biggest huggers.
        """
        async with ctx.typing():
            page_source = LeaderboardPageSource(
                bot=self.bot,
                author=ctx.author,
                query=self.hugs_repo.get_top_givers_query(),
                row_formatter=self._tophuggers_formatter,
                title='TOP HUGGERS',
                emote_name='peepoHugger')

            page = page_source.get_page(0)
            embed = page_source.format_page(page)

        await self.check.botroom_check(ctx.message)
        view = EmbedView(embeds=[embed], page_source=page_source)
        view.message = await ctx.send(embed=embed, view=view)
Ejemplo n.º 3
0
    async def hugboard(self, ctx: commands.Context):
        """
        Overall hugging stats.
        """
        async with ctx.typing():
            page_source = LeaderboardPageSource(
                bot=self.bot,
                author=ctx.author,
                query=self.hugs_repo.get_top_all_query(),
                row_formatter=_tophugs_formatter,
                title='HUGBOARD',
                emote_name='peepoHugger',
            )
            page = page_source.get_page(0)
            embed = page_source.format_page(page)

        await self.check.botroom_check(ctx.message)
        view = EmbedView(embeds=[embed], page_source=page_source)
        view.message = await ctx.send(embed=embed, view=view)
Ejemplo n.º 4
0
    async def ishaboard(self,
                        inter: disnake.ApplicationCommandInteraction,
                        start: int = 1):
        if not await self.validate_leaderboard_offset(start, inter):
            return

        page_source = LeaderboardPageSource(
            bot=self.bot,
            author=inter.author,
            query=karma_r.leaderboard_query(Database_karma.negative.desc()),
            row_formatter=self._negative_formatter,
            title='KARMA ISHABOARD',
            emote_name='ishagrin',
            member_id_col_name='member_ID',
        )
        page_num = math.floor(start / page_source.per_page)
        page = page_source.get_page(page_num)
        embed = page_source.format_page(page)

        await self.check.botroom_check(inter)
        view = EmbedView(embeds=[embed], page_source=page_source)
        view.message = await inter.response.send_message(embed=embed,
                                                         view=view)