Discord setembed命令出现问题(以10为基数的int()的文本无效:';0x00ffff';)

Discord setembed命令出现问题(以10为基数的int()的文本无效:';0x00ffff';),discord,discord.py,Discord,Discord.py,因此,我尝试使用此命令,允许用户在他们想要的频道中设置嵌入,它也会获取标题、链接、页脚和正文,但当用户输入颜色时,会出现以下错误: @commands.command() async def setembed(self, ctx, title, link, footer, color, body): emb = discord.Embed(title = f"{title}", description = f"{body}", co

因此,我尝试使用此命令,允许用户在他们想要的频道中设置嵌入,它也会获取标题、链接、页脚和正文,但当用户输入颜色时,会出现以下错误:

@commands.command()
    async def setembed(self, ctx, title, link, footer, color, body):
        emb = discord.Embed(title = f"{title}", description = f"{body}", color = color)
        emb.set_footer(text=f"{footer}", icon_url = str(self.client.user.avatar_url))
        emb.set_image(url=f"{link}")
        await ctx.send(embed=emb)
你知道为什么会这样吗?我确实理解错误,但仍不确定如何修复它

这是用户输入:

Traceback (most recent call last):

  File "C:\Users\Aqua\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 467, in _actual_conversion
    return converter(argument)

ValueError: invalid literal for int() with base 10: '0x00ffff'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\Aqua\AppData\Local\Programs\Python\Python38\lib\site-packages\jishaku\cog_base.py", line 358, in jsk_debug
    await alt_ctx.command.invoke(alt_ctx)

  File "C:\Users\Aqua\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 856, in invoke
    await self.prepare(ctx)

  File "C:\Users\Aqua\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 790, in prepare
    await self._parse_arguments(ctx)

  File "C:\Users\Aqua\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 697, in _parse_arguments
    transformed = await self.transform(ctx, param)

  File "C:\Users\Aqua\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 552, in transform
    return await self.do_conversion(ctx, converter, argument, param)

  File "C:\Users\Aqua\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 505, in do_conversion
    return await self._actual_conversion(ctx, converter, argument, param)

  File "C:\Users\Aqua\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 476, in _actual_conversion
    raise BadArgument('Converting to "{}" failed for parameter "{}".'.format(name, param.name)) from exc
discord.ext.commands.errors.BadArgument: Converting to "int" failed for parameter "color".
我确实搜索了它,但是在这种情况下,该值是一个浮点值,用户试图将其直接转换为int值,因此他们通过int(float(36.0000000))对其进行了更正

36.0


在问这个问题的几分钟内,我偶然发现了一种将十六进制字符串转换为十六进制整数的方法。

我就是这样解决这个问题的

我刚才补充说:

r!setembed "This is the title" "https://nintendowire.com/wp-content/uploads/2020/09/Banner-SuperMario-3D-AllStars-Screenshot.jpg" "This is my footer" 0x00ffff  "this is the body"
然后在embed中使用颜色作为
x
,现在它可以工作了^^

x = int(f"{color}", 16)