【问题标题】:How to fix 'create_channel BAD REQUEST(status code : 400)' in Discord.py如何修复 Discord.py 中的“create_channel BAD REQUEST(状态代码:400)”
【发布时间】:2021-04-07 14:27:25
【问题描述】:

这段代码没有问题。但是有一天,突然,一个错误开始出现。请帮我。 (我用了翻译器。)谢谢

我不知道..对不起。

@client.command(pass_context=True)
async def test(ctx):
    server = ctx.message.server
    name = "NAME"

    await client.create_channel(server, "NAME", type=discord.ChannelType.voice)

这是错误代码。

Traceback (most recent call last):
  File "/home/ydepong93/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 50, in wrapped
    ret = yield from coro(args, **kwargs)
  File "feelblue.py", line 5790, in test
    await client.create_channel(server, name, type=discord.ChannelType.text)
  File "/home/ydepong93/.local/lib/python3.6/site-packages/discord/client.py", line 2163, in create_channel
    data = yield from self.http.create_channel(server.id, name, str(type), permission_overwrites=perms)
  File "/home/ydepong93/.local/lib/python3.6/site-packages/discord/http.py", line 200, in request
    raise HTTPException(r, data)
discord.errors.HTTPException: BAD REQUEST (status code: 400)

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

Traceback (most recent call last):
  File "/home/ydepong93/.local/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 846, in process_commands
    yield from command.invoke(ctx)
  File "/home/ydepong93/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 374, in invoke
    yield from injected(ctx.args, **ctx.kwargs)
  File "/home/ydepong93/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 54, in wrapped
    raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: BAD REQUEST (status code: 400)

【问题讨论】:

  • 您使用的是什么版本的 discord.py?
  • 我使用的是 0.16.12 版本

标签: discord.py


【解决方案1】:

看看这里:https://discordpy.readthedocs.io/en/latest/api.html?highlight=create_voice#discord.Guild.create_voice_channel

你必须使用

await ctx.guild.create_voice_channel(**kwargs)

而不是您的代码。如果你在问这里之前先看看文档,下次会更好。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-12-19
    • 2019-12-24
    • 2020-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-07
    • 2021-08-06
    相关资源
    最近更新 更多