有没有更简单的方法通过命令进行嵌入? | discord.py重写

Is there an easier way of making an embed via command? | discord.py REWRITE

我正在设置一个新命令,我想将其嵌入到一个不错的程序中。如果每个参数都是 1 个字长,它就可以工作。但是,对于像 dark reddark magenta 这样的颜色,它将 "dark" 视为颜色,将 "magenta" 视为标题,然后将其后的所有内容视为值。

我认为我可以让它工作的唯一方法是命令让你做类似 k!embed <colour>, <title>, <value> 的事情,全部用逗号分隔,但我不知道有什么方法可以做到这一点。我试过谷歌搜索,但很可能是由于缺乏术语,什么也没找到。另外,添加更多星号似乎没有帮助......那是我最后的绝望努力。

@client.command(name='embed',
                aliases=['e'],
                pass_ctx=True)
async def embed(ctx, colour, name, *, value):

    # making paramater match dictionary
    colour = colour.lower()
    colour.replace(' ', '_') 

    # checking if colour is valid
    if colour not in colours:
        await ctx.send('Invalid colour')
        return
    else:
        colour = colours[colour]
        # sets colour
        embed = discord.Embed(
            color = colour()
            )  
    # adds other paramaters
    embed.add_field(name='{}'.format(name), value="{}".format(value), inline=False)

    # final product
    await ctx.send(embed=embed)
    print('Embed executed\n- - -')

正如我所提到的,输入 k!embed dark magenta title this is the value 之类的内容会完全丢失,我更喜欢 k!embed dark magenta, title, this is the value 之类的内容。谢谢!

编辑:对于上下文,这是 colours 词典和标题拼写错误:

colours = { "red" : discord.Color.red,
            "dark_red" : discord.Color.dark_red,
            "blue" : discord.Color.blue,
            "dark_blue" : discord.Color.dark_blue,
            "teal" : discord.Color.teal,
            "dark_teal" :discord.Color.dark_teal,
            "green" : discord.Color.green,
            "dark_green" : discord.Color.dark_green,
            "purple" : discord.Color.purple,
            "dark_purple" :discord.Color.dark_purple,
            "magenta" : discord.Color.magenta,
            "dark_magenta" : discord.Color.dark_magenta,
            "gold" :discord.Color.gold,
            "dark_gold" : discord.Color.dark_gold,
            "orange" :discord.Color.orange,
            "dark_orange" :discord.Color.dark_orange
            }

这是一个自定义转换器,它应该能够识别颜色,即使它们没有通过从未解析的参数中使用另一个词来引用:

from discord.ext.commands import Converter, ArgumentParsingError
from discord import Color, Embed

class ColorConverter(Converter):
    async def convert(self, ctx, argument):
        argument = argument.lower()
        if argument in ('dark', 'darker', 'light', 'lighter'):
            ctx.view.skip_ws()
            argument += "_" + ctx.view.get_word().lower()
        if not hasattr(Color, argument):
            ctx.view.undo()
            raise ArgumentParsingError(f"Invalid color {argument}")
        return getattr(Color, argument)()

@bot.command()
async def test(ctx, color: ColorConverter, *, text):
    await ctx.send(embed=Embed(color=color, description=text))