首页 > 解决方案 > How would I change a voice channel's bitrate using discord.py?

问题描述

I have a voice channel that I would like to change the bitrate of, but I can't find any ways of doing it in the docs. How would I do it?

Edit: I've figured it out, you have to fetch the channel from id and change it from there.

vchannel = await self.fetch_channel(id)
await vchannel.edit(bitrate=96000)

标签: pythondiscord.py

解决方案


我建议您使用client.get_channel而不是client.fetch_channel,因为它不是 API 调用,因此您不会受到速率限制,而且速度会更快。

您的代码中的第二个问题是您使用了self,很好,但您没有在它之后放置client(或者bot,取决于您设置的内容)。

对我来说,您的代码必须是:

vchannel = self.client.get_channel(id)
await vchannel.edit(bitrate=96000)

祝你今天过得愉快!


推荐阅读