转换为参数"name"的"int"失败



对此有解决方案吗?

async def cosmetic(ctx, name : int):
response = requests.get("https://fortnite-api.com/v2/cosmetics/br")
embed=discord.Embed(
title=f"{name}", color=0x9c3030
)
embed.add_field(f'Rarity: {BrCosmeticRarity}')
await ctx.send(embed=embed)

您通过显式地将name转换为int

async def cosmetic(ctx, name : int):

name不应该是int类型,因为它可能是一个字符串。要解决您的问题,请在函数声明中为name设置正确的类型


async def cosmetic(ctx, name : str):

async def cosmetic(ctx, name : str):
response = requests.get("https://fortnite-api.com/v2/cosmetics/br")
embed=discord.Embed(
title=f"{name}", color=0x9c3030
)
embed.add_field(f'Rarity: {BrCosmeticRarity}')
await ctx.send(embed=embed)

最新更新