mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 00:53:31 +01:00
Add ability to kick members from VoiceChannels and remove duplicated methods (#3242)
* feat(voice): kick members from voice channels * fix(VoiceState): improve stability in checking for client user * feat(VoiceState): add setChannel for moving/kicking members * update typings * remove duplicated methods across GuildMember and VoiceState member.setDeaf => member.voice.setDeaf member.setMute => member.voice.setMute member.setVoiceChannel => member.voice.setChannel
This commit is contained in:
@@ -254,7 +254,8 @@ class GuildMember extends Base {
|
||||
* @property {Collection<Snowflake, Role>|RoleResolvable[]} [roles] The roles or role IDs to apply
|
||||
* @property {boolean} [mute] Whether or not the member should be muted
|
||||
* @property {boolean} [deaf] Whether or not the member should be deafened
|
||||
* @property {ChannelResolvable} [channel] Channel to move member to (if they are connected to voice)
|
||||
* @property {ChannelResolvable|null} [channel] Channel to move member to (if they are connected to voice), or `null`
|
||||
* if you want to kick them from voice
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -270,8 +271,10 @@ class GuildMember extends Base {
|
||||
throw new Error('GUILD_VOICE_CHANNEL_RESOLVE');
|
||||
}
|
||||
data.channel_id = data.channel.id;
|
||||
data.channel = null;
|
||||
} else if (data.channel === null) {
|
||||
data.channel_id = null;
|
||||
}
|
||||
data.channel = undefined;
|
||||
if (data.roles) data.roles = data.roles.map(role => role instanceof Role ? role.id : role);
|
||||
let endpoint = this.client.api.guilds(this.guild.id);
|
||||
if (this.user.id === this.client.user.id) {
|
||||
@@ -289,35 +292,6 @@ class GuildMember extends Base {
|
||||
return clone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutes/unmutes this member.
|
||||
* @param {boolean} mute Whether or not the member should be muted
|
||||
* @param {string} [reason] Reason for muting or unmuting
|
||||
* @returns {Promise<GuildMember>}
|
||||
*/
|
||||
setMute(mute, reason) {
|
||||
return this.edit({ mute }, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deafens/undeafens this member.
|
||||
* @param {boolean} deaf Whether or not the member should be deafened
|
||||
* @param {string} [reason] Reason for deafening or undeafening
|
||||
* @returns {Promise<GuildMember>}
|
||||
*/
|
||||
setDeaf(deaf, reason) {
|
||||
return this.edit({ deaf }, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves this member to the given channel.
|
||||
* @param {ChannelResolvable} channel The channel to move the member to
|
||||
* @returns {Promise<GuildMember>}
|
||||
*/
|
||||
setVoiceChannel(channel) {
|
||||
return this.edit({ channel });
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the nickname for this member.
|
||||
* @param {string} nick The nickname for the guild member
|
||||
|
||||
Reference in New Issue
Block a user