mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 17:13: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:
@@ -85,7 +85,7 @@ class VoiceState extends Base {
|
||||
* @readonly
|
||||
*/
|
||||
get connection() {
|
||||
if (browser || this.id !== this.guild.me.id) return null;
|
||||
if (browser || this.id !== this.client.user.id) return null;
|
||||
return this.client.voice.connections.get(this.guild.id) || null;
|
||||
}
|
||||
|
||||
@@ -139,6 +139,19 @@ class VoiceState extends Base {
|
||||
return this.member ? this.member.edit({ deaf }, reason) : Promise.reject(new Error('VOICE_STATE_UNCACHED_MEMBER'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the member to a different channel, or kick them from the one they're in.
|
||||
* @param {ChannelResolvable|null} [channel] Channel to move the member to, or `null` if you want to kick them from
|
||||
* voice
|
||||
* @param {string} [reason] Reason for moving member to another channel or kicking
|
||||
* @returns {Promise<GuildMember>}
|
||||
*/
|
||||
setChannel(channel, reason) {
|
||||
return this.member ?
|
||||
this.member.edit({ channel }, reason) :
|
||||
Promise.reject(new Error('VOICE_STATE_UNCACHED_MEMBER'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Self-mutes/unmutes the bot for this voice state.
|
||||
* @param {boolean} mute Whether or not the bot should be self-muted
|
||||
|
||||
Reference in New Issue
Block a user