【问题标题】:I get a HTTP Exception 405 error when I run my py-cord program运行 py-cord 程序时出现 HTTP Exception 405 错误
【发布时间】:2022-06-25 05:10:42
【问题描述】:

我第一次尝试使用斜杠命令创建一个不和谐的机器人,但我在运行我的程序时不断收到此错误!

Ignoring exception in on_connect
Traceback (most recent call last):
  File "/home/runner/AgonizingDrabEmbeds/venv/lib/python3.8/site-packages/discord/client.py", line 352, in _run_event
    await coro(*args, **kwargs)
  File "/home/runner/AgonizingDrabEmbeds/venv/lib/python3.8/site-packages/discord/bot.py", line 793, in on_connect
    await self.register_commands()
  File "/home/runner/AgonizingDrabEmbeds/venv/lib/python3.8/site-packages/discord/bot.py", line 460, in register_commands
    await self.http.bulk_upsert_command_permissions(
  File "/home/runner/AgonizingDrabEmbeds/venv/lib/python3.8/site-packages/discord/http.py", line 338, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 405 Method Not Allowed (error code: 0): 405: Method Not Allowed

Bot is online!

这是我的代码:

import discord
import os
token = os.environ["nekto"]


client = discord.Bot(owner_id=<my_user_id>)

async def on_ready():
  print('Bot is online!')

guilds_ids = [<myGuildId>]

client.add_listener(on_ready)
client.run(token)

我们将不胜感激

【问题讨论】:

  • 这看起来像是 PyCord 的问题。如果尚未报告,您可能想在他们的 GitHub 页面上打开一个问题
  • 你有什么版本的py-cord
  • 我想我得到了 py-cord 2.0,我安装了 github 版本,但现在它工作正常

标签: python discord.py pycord


【解决方案1】:

我遇到了同样的问题。按照 cmets 的建议,我去查看了他们的 Github。

找到the ticket。如果我理解正确的话,曾经有一个问题,但很久以前就已经解决了。因此,如果您运行的是旧版本,则可以尝试更新。 对我来说,2.0.0.b1 仍然有这个问题,2.0.0rc1 已经解决了这个问题。

如果您运行的是较新版本,则可能是脏 venv 的原因。删除 venv 文件夹并重新构建。

【讨论】:

    猜你喜欢
    • 2014-11-20
    • 1970-01-01
    • 1970-01-01
    • 2021-09-05
    • 2017-09-09
    • 1970-01-01
    • 2022-08-16
    • 2021-02-04
    • 1970-01-01
    相关资源
    最近更新 更多