【发布时间】:2021-03-09 14:16:17
【问题描述】:
当我启动我的 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'
如果我运行此代码 sn-p:
@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)
如果您需要更多信息,请询问:)
保持安全, 普基马
【问题讨论】:
-
您是否尝试过输入手册
values来检查您的定义是否有问题? -
Dominik 是什么意思?如何? (我是 discord.py 的新手 :()
-
例如将
value=pythonVersion替换为"Test"以检查您的代码是否有问题。我也会考虑将夹子分解成embed.title = ...、embed.description = ...等。 -
现在是
embed.add_field(name='Bot Version:', value=bot.version) TypeError: add_field() missing 1 required positional argument: 'self' -
试试
self.bot.version。如果你已经在这方面苦苦挣扎,你应该先看看docs 或一些教程。
标签: python discord.py ctx