discord.js - 如何检测到用户从一个语音通道更改为另一个语音通道?
问题描述
例如,我想检测某人何时从“Talk I”变为“Talk II”。但它应该可以在同时不断开服务器的情况下工作,然后加入“Talk II”!有没有办法做到这一点??
解决方案
每次用户更新他们的语音状态时,客户端都会发出一个voiceStateUpdate
事件。
要检测用户是否更改了他们的语音通道,您可以执行以下操作:
client.on('voiceStateUpdate', (oldMember, newMember) => {
let oldChannel = oldMember.voiceChannel, // the previous channel, if there was one
newChannel = newMember.voiceChannel; // the current channel, if there is one
if (oldChannel != newChannel) { // if the channel has changed
// do your stuff...
}
});
推荐阅读
- javascript - 如何使这个递归函数异步?
- python - Matplotlib 3d 条形图绘制*一些*条不按顺序
- azure-sql-managed-instance - 我在 SQL 服务器中遇到错误我正在使用托管实例我只从哪个数据库获取信息,我还需要从哪个应用程序知道
- reactjs - “devtool:'source-map'”上的 Webpack 配置错误
- azure - 二头肌/ARM 使用端点链接创建存储帐户到现有 DNS 区域并创建 A 记录
- c++ - 等待其他协程中的计时器(Asio)
- string - 将数据框列转换为列表中的字符串
- python - How to pivot and groupby PANDAS
- python - Groupby pandas,但对多列执行计算
- format - 在列中搜索单元格中的文本,如果值不在列中,则格式化单元格