【问题标题】:How do I set a user's voice channel when I have the user's id?当我有用户ID时,如何设置用户的语音通道?
【发布时间】:2020-09-07 15:43:39
【问题描述】:

当用户对我的嵌入有西瓜表情符号做出反应时,我正试图移动他们。

当我使用user.id 时,我可以获得他们的用户ID,但它不适用于

user.id.voice.setChannel("712142435794550894");

我得到的错误是:

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'setChannel' of undefined

这是我正在使用的代码:

const check = new MessageEmbed()
  .setTitle("AFK CHECK")
  .setColor(0xFF0000)
  .setDescription("React with a `watermelon ????` PLS");

message.channel.send(check).then(sentEmbed => {
  sentEmbed.react("????");
})

bot.on('messageReactionAdd', async(reaction, user) => {
  let msg = reaction.message,
    emoji = reaction.emoji;
  const person = user.id;
  if (emoji.name == '????' && user.id != "711388151960043582") {
    message.channel.send("HI")
    user.id.voice.setChannel("712142435794550894");
  }
});

如何根据 id 移动用户?

【问题讨论】:

    标签: javascript node.js bots discord.js


    【解决方案1】:

    GuildMember 上似乎存在语音(至少从 discord.js 12 开始),因此您需要这样做:

    message.guild.member(user.id).voice.setChannel("712142435794550894");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-06
      • 1970-01-01
      • 2022-07-06
      • 2019-09-23
      • 2020-09-16
      • 2020-10-19
      • 2021-05-07
      • 2022-10-14
      相关资源
      最近更新 更多