コード例 #1
0
    def _init_embeds(self, ctx: SlashContext, guild_data: GuildData, content: dict):
        translated_commands = None
        guild_language = guild_data.configuration.language
        if guild_language not in ["en-US", "English"]:
            translated_commands = get_content("TRANSLATED_COMMANDS", guild_language)
        commands_data = self._get_commands_data()
        embeds = [self._get_main_menu(ctx, guild_data, content)]
        cog_translations = content["PLUGINS"]

        for cog_name, cog in self.bot.cogs.items():
            if self._cog_check(guild_data, cog, commands_data):
                continue

            embed = Embed(
                title=f"{cog_translations[cog_name.upper()]} | Asteroid Bot",
                description="",
                timestamp=datetime.datetime.utcnow(),
                color=DiscordColors.EMBED_COLOR,
            )
            embed.set_footer(
                text=content["REQUIRED_BY_TEXT"].format(user=ctx.author),
                icon_url=ctx.author.avatar_url,
            )
            embed.set_thumbnail(url=ctx.bot.user.avatar_url)
            embed.custom_id = cog_name
            embed = self._fill_embed_page(embed, commands_data[cog], content, translated_commands)
            embeds.append(embed)

        return embeds
コード例 #2
0
    def _get_main_menu(self, ctx: SlashContext, guild_data: GuildData, content: dict) -> Embed:
        embed = Embed(
            title="Help | Asteroid Bot",
            timestamp=datetime.datetime.utcnow(),
            color=DiscordColors.EMBED_COLOR,
        )
        embed.add_field(
            name=content["INFORMATION_TEXT"],
            value=content["INFORMATION_CONTENT_TEXT"],
            inline=False,
        )
        embed.set_thumbnail(url=ctx.bot.user.avatar_url)
        embed.set_footer(
            text=content["REQUIRED_BY_TEXT"].format(user=ctx.author),
            icon_url=ctx.author.avatar_url,
        )

        cog_translations = content["PLUGINS"]
        cogs = "".join(
            f"**» {cog_translations[cog_name.upper()]}**\n"
            for cog_name, cog in self.bot.cogs.items()
            if not self._cog_check(guild_data, cog)
        )

        embed.add_field(name=content["PLUGINS_TEXT"], value=cogs)
        return embed