python - 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)
解决方案
我建议您使用client.get_channel而不是client.fetch_channel,因为它不是 API 调用,因此您不会受到速率限制,而且速度会更快。
您的代码中的第二个问题是您使用了self
,很好,但您没有在它之后放置client
(或者bot
,取决于您设置的内容)。
对我来说,您的代码必须是:
vchannel = self.client.get_channel(id)
await vchannel.edit(bitrate=96000)
祝你今天过得愉快!
推荐阅读
- vue.js - 我们如何在 vuejs 的 javascript 文件中定义的 vuejs 的 html 文件中调用函数而不在 html 文件中创建按钮?
- graph - 如何查找 amcharts 4 图表中的条数?
- nginx - 如何在github上自动部署flask app
- php - 查询一对一关系的正确方法?(Laravel 7)
- python - 使用 pd.merge 加入数据帧的问题
- python - 如何将文件从谷歌云加载到工作
- html - html5 或 css '智能文本流' 将句子或段落均匀分布在同样宽的行上?
- angular - 打字稿将数字/字符串数组传递给函数
- loadrunner - LR 事务日志
- python - 如何在熊猫 to_csv 中转义转义字符