简体   繁体   English

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

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

I'm trying to move a user when they react with a watermelon emoji to my embed.当用户对我的嵌入内容做出反应时,我正试图移动用户。

I can get their user id when I use user.id , but it doesn't work with当我使用user.id时,我可以获得他们的用户 ID,但它不适用于

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

The error I'm getting is:我得到的错误是:

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

This is the code I'm using:这是我正在使用的代码:

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");
  }
});

How do I move the users based on their id?如何根据用户的 ID 移动用户?

Looks like voice exists on GuildMember (at least as of discord.js 12), so you'll need to do: GuildMember上似乎存在语音(至少从 discord.js 12 开始),因此您需要执行以下操作:

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

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

相关问题 如何通过频道 ID 获取语音的用户数? Discordjs v.13 - How do I get the user count of a voice by channel id? Discordjs v.13 为什么在用户离开语音频道时尝试编辑用户时会出现 DiscordAPIError? - Why do I get a DiscordAPIError when trying to edit a user as they leave a voice channel? 如何检查用户是否拥有特定语音通道的权限? - How can I check if a user has permissions in a specific voice channel? 如何断开用户与 discord.js 中的语音通道的连接? - How do I disconnect a user from a voice channel in discord.js? 我如何检测用户何时在语音通道中讲话 discord.JS v13 - How would I detect when a user is speaking in a voice channel discord.JS v13 如何让机器人更改语音频道的名称? (不和谐.js) - How do I make the bot to change a voice channel's name? (Discord.js) Firestore - 如何在删除他的帐户时从他自己创建的所有文档中删除用户 ID? - Firestore - how do I remove user's ID from all the documents he's created himself when deleting his account? 当用户按下 CTRL + S 时如何捕获? - How do I capture when a user presses CTRL + S? 如何检查用户是否指定了频道? - How do I check if the user specified a channel? 如何获取用户的输入并返回已定义的匹配变量的值? - How do I take a user's input and return the value of a matching variable I have defined?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM