首页 > 解决方案 > 从 exc,discord.py 中引发 CommandInvokeError(exc)

问题描述

我是蟒蛇的新手!错误总结: CommandInvokeError(exc) from exc,ctx.command.invoke(ctx)

这是我的代码。

@client.command(pass_context=True)
async def serverinfo(ctx):
    embed = discord.Embed(name="{}'s info".format(ctx.message.guild.name), color=0x176cd5)
    embed.add_field(name="guild Name", value=ctx.message.guild.name, inline=True)
    embed.add_field(name="Roles", value=len(ctx.message.guild.roles), inline=True)
    embed.add_field(name="Members", value=len(ctx.message.guild.members))
    embed.add_field(name="Channels", value=len(ctx.message.guild.channels))
    embed.add_field(name="Region", value=ctx.message.guild.region)
    embed.add_field(name="Verification Level", value=ctx.message.guild.verification_level)
    embed.add_field(name="Owner", value=ctx.message.guild.owner.mention)
    embed.add_field(name="Emojis", value=len(ctx.message.guild.emojis))
    embed.set_thumbnail(url=ctx.message.guild.icon_url)
    embed.set_thumbnail(url=ctx.message.guild.icon_url)
    embed.set_author(name=ctx.message.guild.name, icon_url=ctx.message.guild.icon_url)
    embed.set_footer(text="Server ID is " + ctx.message.guild.id)
    await ctx.send(embed=embed)

错误 :-

  File "C:\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc

你能帮我解决这个问题吗?谢谢!

标签: discorddiscord.py

解决方案


我想你已经添加了embed.set_thumbnail(url=ctx.message.guild.icon_url)2 次删除一个,然后再试一次


推荐阅读