Discord机器人帮助页面(齿轮)

时间:2020-09-29 08:36:52

标签: python discord.py

美好的一天。 我需要这样做,以便当用户调用第二个帮助页面时,机器人将编辑旧消息(并且最好删除call命令) 以及如何使它指示哪个齿轮将显示在哪个页面上?现在它们按创建日期显示((((

    @commands.command(
        name="help", aliases=["commands"])
    async def help(self, ctx, cog="1"):
        help_embed = discord.Embed(title="Bot commands", description=f"Use `prefix command`", color=0x979c9f)

        cogs = [c for c in self.bot.cogs.keys()]

        total_pages = math.ceil(len(cogs) / 1) 

        cog = int(cog)
        if cog > total_pages or cog < 1:
            await ctx.send(f"Error: no such page exists ({cog}). Choose page from{total_pages}")
            return

        needed_cogs = []
        for i in range(1): 
            x = i + (int(cog) - 1) * 1
            try:
                needed_cogs.append(cogs[x])
            except IndexError:
                pass

        for cog in needed_cogs:
            command_list = ""
            for command in self.bot.get_cog(cog).walk_commands():
                if command.hidden:
                    continue
                elif command.parent != None:
                    continue

                command_list += f"`{command.name}` "
                print(command_list)

            help_embed.add_field(name=cog, value=command_list, inline=False)
           
        await ctx.send(embed=help_embed)

0 个答案:

没有答案