【问题标题】:how get user id from specific voice channel for move in another channel如何从特定语音频道获取用户 ID 以便在另一个频道中移动
【发布时间】:2019-12-12 02:27:51
【问题描述】:

我制作了一个用于创建语音频道的机器人,不是使用命令,而是加入特定的语音频道。

实际上我被困在将我的用户移动到新的语音频道中,有人可以帮助我吗?

if (idVoiceChannel === "607195759314910090") { 
        newMember.guild.createChannel('new-general', { type: 'voice' }).then(nM => { nM.setParent(category.id); nM.edit({userLimit: 4}); });
        console.log(newUserChannel)
        //when channel is created move the user into this
    } else if(idVoiceChannel === "607245896250755073") {

    }

【问题讨论】:

    标签: move discord.js channel voice


    【解决方案1】:

    有一种方法可以将成员移动到频道。 在你的情况下:

    newMember.setVoiceChannel(nM)
    

    如果你让你的函数异步,它看起来更干净,

    if (idVoiceChannel === "607195759314910090") { 
            const nM = await newMember.guild.createChannel('new-general', { type: 'voice' })
            nM.setParent(category.id)
            nM.edit({userLimit: 4})
            newMember.setVoiceChannel(nM)
        } else if(idVoiceChannel === "607245896250755073") {
    
        }
    

    【讨论】:

    • 让你的父函数async, function async [name] { ... } 而不是function [name] { ... }
    • 我尝试了很多时间将异步包含到我的函数中,但我做不到。这是我的完整文件(对不起)pastebin.com/g3KVKaNG
    • bot.on('voiceStateUpdate', async (oldMember, newMember)
    • 确保捕获被拒绝的承诺。
    猜你喜欢
    • 2019-11-24
    • 2021-04-18
    • 1970-01-01
    • 1970-01-01
    • 2022-07-06
    • 2014-10-12
    • 2016-06-19
    • 2020-08-12
    • 2019-04-24
    相关资源
    最近更新 更多