Example #1
0
async def bot_added_list(self, menu: MenuBase, entries):
    """Menu for recentbotadd command."""
    offset = menu.current_page * self.per_page
    contents = ((f"{b.author}",
                 f'**{b}** `{humanize.precisedelta(b.joined_at)}`')
                for i, b in enumerate(entries, start=offset))
    return BaseEmbed(title="Bots added today", fields=contents)
Example #2
0
 async def format_page(self, menu: MenuBase, entries):
     key = "(\u200b|\u200b)"
     offset = menu.current_page * self.per_page
     content = "`{no}. {prefix} {key} {b.count}`" if self.count_mode else "`{no}. {b} {key} {prefix}`"
     contents = [content.format(no=i+1, b=b, key=key, prefix=pprefix(menu.ctx.bot, b.prefix)) for i, b in enumerate(entries, start=offset)]
     embed = BaseEmbed(title="All Prefixes",
                       description="\n".join(realign(contents, key)))
     return menu.generate_page(embed, self._max_pages)
Example #3
0
 async def format_page(self, menu: MenuBase, entries):
     key = "(\u200b|\u200b)"
     offset = menu.current_page * self.per_page
     content = "`{no}. {b} {key} {b.count}`"
     contents = [content.format(no=i+1, b=b, key=key) for i, b in enumerate(entries, start=offset)]
     embed = BaseEmbed(title="Bot Command Rank",
                       description="\n".join(realign(contents, key)))
     return menu.generate_page(embed, self._max_pages)
Example #4
0
async def all_bot_count(self, menu: MenuBase, entries):
    """Menu for botrank command."""
    key = "(\u200b|\u200b)"
    offset = menu.current_page * self.per_page
    content = "`{no}. {b} {key} {b.count}`"
    contents = [content.format(no=i+1, b=b, key=key) for i, b in enumerate(entries, start=offset)]
    return BaseEmbed(title="Bot Command Rank",
                     description="\n".join(realign(contents, key)))
Example #5
0
    async def format_page(self, menu: MenuBase, entries):
        offset = menu.current_page * self.per_page
        contents = ((f"{b.author}", f'**{b}** `{humanize.precisedelta(b.joined_at)}`')
                    for i, b in enumerate(entries, start=offset))

        embed = BaseEmbed(title="Bots added today")
        for n, v in contents:
            embed.add_field(name=n, value=v, inline=False)
        return menu.generate_page(embed, self._max_pages)
Example #6
0
 async def each_commands_list(self, menu: MenuBase, entries):
     offset = menu.current_page * self.per_page
     embed = BaseEmbed(title=f"All Commands")
     key = "(\u200b|\u200b)"
     contents = [
         "`{i}. {command}{k}{command_count}`".format(i=i, k=key, **b)
         for i, b in enumerate(entries, start=offset + 1)
     ]
     embed.description = "\n".join(realign(contents, key))
     return embed
Example #7
0
 async def end_message(self, message, **kwargs):
     self.ended_at = datetime.datetime.utcnow()
     display = await self.render_board()
     file = discord.File(display, filename="connect_4.png")
     embed = BaseEmbed(timestamp=self.ended_at, **kwargs)
     embed.title = self.game
     embed.description = message
     embed.set_image(url=f"attachment://{file.filename}")
     embed.set_footer(text=self.GAME_TIME.format(precisedelta(self.ended_at - self.created_at)))
     return {"embed": embed, "file": file}
Example #8
0
async def bot_pending_list(self, menu: MenuBase, entry):
    stellabot = menu.ctx.bot
    bot = menu.cached_bots.setdefault(entry["bot_id"], await stellabot.fetch_user(entry["bot_id"]))
    fields = (("Requested by", stellabot.get_user(entry["author_id"]) or "idk really"),
              ("Reason", entry["reason"]),
              ("Created at", default_date(bot.created_at)),
              ("Requested at", default_date(entry["requested_at"])),
              ("Message", f"[jump]({entry['jump_url']})"))
    embed = BaseEmbed(title=f"{bot}(`{bot.id}`)", fields=fields)
    embed.set_thumbnail(url=bot.avatar_url)
    return embed
Example #9
0
 async def botrank(self, ctx, bot: BotUsage = None):
     bots = {x.id: x for x in ctx.guild.members if x.bot}
     query = "SELECT * FROM bot_usage_count WHERE bot_id=ANY($1::BIGINT[])"
     record = await self.bot.pool_pg.fetch(query, list(bots))
     bot_data = [BotUsage(bots[r["bot_id"]], r["count"]) for r in record]
     bot_data.sort(key=lambda x: x.count, reverse=True)
     if not bot:
         menu = MenuBase(source=AllBotCount(bot_data), delete_message_after=True)
         await menu.start(ctx)
     else:
         key = "(\u200b|\u200b)"
         idx = [*map(int, bot_data)].index(bot.bot.id)
         scope_bot = bot_data[idx:min(idx + len(bot_data[idx:]), idx + 10)]
         contents = ["`{0}. {1} {2} {1.count}`".format(i + idx + 1, b, key) for i, b in enumerate(scope_bot)]
         embed = BaseEmbed(title="Bot Command Rank", description="\n".join(realign(contents, key)))
         await ctx.maybe_reply(embed=embed)