[英]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.