繁体   English   中英

当我有用户ID时,如何设置用户的语音通道?

[英]How do I set a user's voice channel when I have the user's id?

当用户对我的嵌入内容做出反应时,我正试图移动用户。

当我使用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 移动用户?

GuildMember上似乎存在语音(至少从 discord.js 12 开始),因此您需要执行以下操作:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM