【问题标题】:Previously working discord bots stopped working after pip update以前工作的不和谐机器人在 pip 更新后停止工作
【发布时间】:2019-04-12 22:05:26
【问题描述】:

首先,很抱歉这个模糊的问题,tbf 我真的不知道如何命名这个

所以我有一些我拥有的机器人,以及另一个由其他人制造的机器人,该机器人随机停止工作,所以我更新了它,它也随之更新了依赖项 很确定它更新了与-pip有关的东西

从那以后我的机器人都不再工作了,像await client.send_message(message.channel, embed=embed) 这样简单的东西不再工作了,说:

line 30, in on_message
    await client.send_message(message.channel, embed=embed)
AttributeError: 'Bot' object has no attribute 'send_message'

以前一直有效,所以代码应该没有问题

line 170, in on_message
    await client.delete_message(message)
AttributeError: 'Bot' object has no attribute 'delete_message'

我的机器人似乎也无法分别删除消息或更改状态

 line 23, in on_ready
    await client.change_presence(game=discord.Game(name='m!help',type = 3))
TypeError: change_presence() got an unexpected keyword argument 'game'

我完全不知道应该做什么来解决我的问题,因为我没有更改代码本身的任何内容

这可能很重要,因为我在上面的代码中提到了它,但这是我为“客户”client = commands.Bot(command_prefix = "m!") 提供的代码

感谢任何帮助

【问题讨论】:

  • 您使用的是哪个版本的discord.py?试试import discord; print(discord.__version__)
  • @PatrickHaugh 为长时间的延迟道歉,这是困倦的时间。 - print(discord._version__version__ 打印“1.0.0a”
  • 您安装了较新的“重写”分支,changed the way messages are sent。您可以为 rewrite 分支重写代码,或降级回 0.16 异步版本。
  • @PatrickHaugh 我明白了,谢谢你告诉我,我很迷茫我会研究这两种选择,看看最适合我的选择
  • pip 应该默认使用 python -m pip install discord 安装异步 0.16.12 分支。如果这不起作用,那么您可以手动下载它并使用 pip 从本地硬盘驱动器安装它。 github.com/Rapptz/discord.py/tree/async

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


【解决方案1】:

问题是由我独立更新到更新的重写品牌的另一个机器人引起的,正如 PatrickHaugh 在上面的 cmets 中指出的那样

要解决这个问题,我必须先运行 pip freeze > requirements.txt 然后 pip uninstall -r requirements.txt -y 来卸载每个 pip

然后通过 runnin python3 -m pip install -U discord.py 重新安装较旧的异步版本

【讨论】:

    【解决方案2】:


    尝试将您的 client = commands.Bot(command_prefix = "m!") 更改为 client = discord.Client() 我认为它可以解决你所有的问题。

    【讨论】:

    • 遗憾的是没有解决问题,它提出了基本相同的错误:AttributeError: 'Client' object has no attribute 'send_message'
    • 这很奇怪。你忘了括号吗?你用的是 discord.py 还是 discord.py-rewrite ?
    • 我很确定我只是在使用 discord.py 而不是重写 不,我包括了括号
    猜你喜欢
    • 2021-01-17
    • 1970-01-01
    • 2018-08-24
    • 2021-01-19
    • 2021-10-20
    • 2018-05-19
    • 2021-11-08
    • 1970-01-01
    • 2016-11-03
    相关资源
    最近更新 更多