【问题标题】:TypeError: 'str' object is not callable when trying to run a bot commandTypeError:尝试运行机器人命令时“str”对象不可调用
【发布时间】:2018-05-04 18:00:24
【问题描述】:

[续。我最近的两个帖子]

在升级 aiohttp 并使用“main”修复导入问题后,我在尝试从 Discord 机器人运行命令时遇到了另一个错误。有没有什么办法解决这一问题?

Ignoring exception in command botcheck
Traceback (most recent call last):
  File "C:\Users\Jeriel\AppData\Local\Programs\Python\Python36-32\lib\site-packa
ges\discord\ext\commands\core.py", line 50, in wrapped
    ret = yield from coro(*args, **kwargs)
  File "C:\Users\Jeriel\Desktop\JerryBot\run.py", line 15, in botcheck
    await bot.say("I am up and running! {}".format(ctx.message.author.mention())
)
TypeError: 'str' object is not callable

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

Traceback (most recent call last):
  File "C:\Users\Jeriel\AppData\Local\Programs\Python\Python36-32\lib\site-packa
ges\discord\ext\commands\bot.py", line 846, in process_commands
    yield from command.invoke(ctx)
  File "C:\Users\Jeriel\AppData\Local\Programs\Python\Python36-32\lib\site-packa
ges\discord\ext\commands\core.py", line 374, in invoke
    yield from injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\Jeriel\AppData\Local\Programs\Python\Python36-32\lib\site-packa
ges\discord\ext\commands\core.py", line 54, in wrapped
    raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: Typ
eError: 'str' object is not callable

【问题讨论】:

  • ctx.message.author.mention 是什么类型的对象?
  • 请添加一个minimal reproducible example的run.py代码
  • 有错别字的问题通常会被关闭或删除。顺便说一句

标签: python python-3.x discord.py


【解决方案1】:

刚刚意识到一个错字是问题所在。哎呀。。

【讨论】:

  • 欢迎来到 Stack Overflow,错别字应该被删除(通过点击 delete 按钮),因为没有多少人会从查找印刷错误问题中受益。
猜你喜欢
  • 2015-03-07
  • 2019-03-05
  • 1970-01-01
  • 2020-09-16
  • 2019-06-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多