You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Discord机器人开发:如何更新语音频道的user_limit人数上限?

Discord语音频道修改user_limit参数实现方案

前置条件确认

  • 你已持有目标语音频道的ID
  • 机器人账号已被授予对应服务器的「管理频道」权限
  • 机器人已正常上线并完成网关连接

常用开发库实现示例

1. Node.js环境(discord.js v14+)

discord.js封装后使用驼峰格式的userLimit参数,示例代码如下:

// client为你初始化的Discord客户端实例
const targetChannelId = '替换为你的语音频道ID';
const expectLimit = 8; // 替换为你需要设置的人数上限,填0即为无上限

// 获取频道实例后执行修改
const voiceChannel = await client.channels.fetch(targetChannelId);
await voiceChannel.edit({
  userLimit: expectLimit
});

2. Python环境(Pycord/Nextcord 2.0+)

Python SDK直接使用和API一致的蛇形命名user_limit参数,示例代码如下:

# bot为你初始化的Discord机器人实例
target_channel_id = 123456789 # 替换为你的语音频道ID,注意为整数类型
expect_limit = 8 # 替换为目标人数上限,填0即为无上限

# 获取频道实例后执行修改
voice_channel = await bot.fetch_channel(target_channel_id)
await voice_channel.edit(user_limit=expect_limit)

原生API调用方式

如果直接请求Discord官方REST API,发送PATCH请求到/channels/你的频道ID接口,请求体传入{"user_limit": 目标上限}即可,请求头需携带合法的机器人鉴权Token。

注:如果设置的上限低于当前频道已有的在线人数,不会强制踢出已在频道内的用户,仅会阻止后续新用户加入。

内容的提问来源于stack exchange,提问作者user15242190

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.02 22:12:00