javascript - 我如何自动将某人移回频道?
问题描述
所以,基本上我有一些代码设置,我没有看到代码的问题。但基本上我想要它做的是,如果切换频道的成员之前的语音频道是“请勿打扰”,它会将他们移回“请勿打扰”语音频道。我做错了什么?我在控制台中收到 0 个错误。
client.on('voiceStateUpdate', async (oldState, newState) => {
let newUserChannel = newState.channel;
let oldUserChannel = oldState.channel;
if(oldUserChannel.id === "894024223088050176") {
var dndChannel = oldState.guild.channels.cache.find(ch => ch.type === "voice" && ch.name === "DO NOT DISTURB")
newState.member.voice.setChannel(dndChannel)
}
});
解决方案
仔细检查 if 条件中的 channelid 是否正确并使用
Guild.channels.fetch(channelId)
安装的Guild.channels.cache.find()
。
推荐阅读
- javascript - 子组件中的事件返回“未捕获的类型错误:无法读取未定义的属性“值”
- algorithm - 使用最少给定的矩形覆盖一条折线,同时保持她的连续性
- botframework - LUIS 意图中无法识别 Communication.ContactName 实体
- spring - 比较 JDBCTemplate 和 Hibernate 使用 Spring 进行数据访问
- unity3d - 为什么我在尝试初始化 Unit IAP 时无法解析“实例”调用?
- c# - 排序点不正确
- mysql - 通过 MySQL 命令更改并显示“客户端”的 max_allowed_packet
- c# - C# WPF DataGrid with user input and update the variables accordingly
- vuejs2 - Vuejs-在生产模式下重定向期间出错
- azure - Powershell - 检查 Azure AD 来宾是否已存在