类型错误:__init__() 缺少 1 个必需的位置参数:“字段”(discord.py,嵌入)

时间:2021-03-09 14:16:17

标签: python discord.py ctx

当我启动我的 Discord Bot 时,它给了我错误:

    Ignoring exception in on_command_error
Traceback (most recent call last):
  File "C:\Users\jaron\Documents\PBot_rewrite\bot-env\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\jaron\Documents\PyBot_rewrite\bot.py", line 81, in stats
    embed = discord.Embed(title=f'{bot.user.name} Stats', description='\uFEFF', color=ctx.author.colour, timestamp=ctx.message.created_at)
TypeError: __init__() missing 1 required positional argument: 'field'

如果我运行这个代码片段:

    @bot.command()
async def stats(ctx):
    """
    A useful command that displays bot statistics.
    """
    pythonVersion = platform.python_version()
    dpyVersion = discord.__version__
    serverCount = len(bot.guilds)
    memberCount = len(set(bot.get_all_members()))

    embed = discord.Embed(title=f'{bot.user.name} Stats', description='\uFEFF', color=ctx.author.colour,
                          timestamp=ctx.message.created_at)

    embed.add_field(name='Bot Version:', value=bot.version)
    embed.add_field(name='<:python:818814561456095233> Python Version:', value=pythonVersion)
    embed.add_field(name='<:discordpy:818474661410766899> discord.py Version:', value=dpyVersion)
    embed.add_field(name='Total Guilds:', value=serverCount)
    embed.add_field(name='Total Members:', value=memberCount)
    embed.add_field(name='Bot Developer:', value='<@751092600890458203>')

    embed.set_author(name=bot.user.name, icon_url=bot.user.avatar_url)

    await ctx.send(embed=embed)

如果您需要更多信息,请询问:)

注意安全, 普吉玛

1 个答案:

答案 0 :(得分:0)

field 似乎不是 discord.py 源代码中任何地方的参数名称,更不用说是类的 __init__ 方法的参数了。我认为您的问题是,无论您从哪里获得 discord.Embed,都不是真正的、未经修改的 discord.py 库。