как переместить участника на другой канал - PullRequest
0 голосов
/ 05 августа 2020

Итак, я искал, как сделать команду для перемещения кого-то на другой канал, но они используют команду с именем .setVoiceChannel, но я не могу ее найти? Я знаю, это может быть вопрос для новичков.

вот что у меня сейчас есть

const user = message.author.id;
const member = message.guild.member(user);

// what a I trying to do
member.setVoiceChannel(/* them parameters */); // not defined and I can't find it in documents

1 Ответ

1 голос
/ 05 августа 2020
// The member is the message author.
const member = message.member;
// Getting the channel.
const channel = client.channels.cache.get("Channel");

// Checking if the channel exists and if the channel is a voice channel.
if (!channel || channel.type !== "voice") return console.log("Invalid channel");
// Checking if the member is in a voice channel.
if (!member.voice.channel) return console.log("The member is not in a voice channel.");

// Moving the member.
member.voice.setChannel(channel).catch(e => console.error(`Couldn't move the user. | ${e}`));

Примечание: setVoiceChannel () - допустимый метод для GuildMember в Discord JS v11.

Он был изменен на GuildMember.voice.setChannel(ChannelResolvable) в Discord JS v12.

...