在嵌入时使用for循环时出现空值字段错误

时间:2020-05-01 13:53:06

标签: discord.py

因此,我正在尝试为我的帮助菜单执行以下操作:

import discord
from discord.ext import commands


class Test(commands.Cog):
    """Fun commands"""
    def __init__(self, client):
        self.client = client

    @commands.command()
    async def test(self, ctx):
        embed = discord.Embed()
        for name, cog in self.client.cogs.items():
            cmds = cog.get_commands()
            cmdString = ''
            for command in cmds:
                cmdString += "```{}``` ".format(command.name)
                print(f'Cog Name: {name}, command: {command.name}')
            embed.add_field(name=name, value=cmdString)
        await ctx.send(embed=embed)


def setup(client):
    client.add_cog(Test(client))


但是每当我尝试执行命令时,我都会得到一个空字段错误,提示该值不应为空。

0 个答案:

没有答案