mirror of
https://github.com/danbulant/discord.js
synced 2026-06-06 08:11:50 +00:00
Add Guild.voiceConnection and VoiceChannel.connection
This commit is contained in:
parent
0405b1a59f
commit
420f2ecdd4
3 changed files with 25 additions and 1 deletions
File diff suppressed because one or more lines are too long
|
|
@ -661,6 +661,16 @@ class Guild {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the client is connected to any voice channel in this guild, this will be the relevant
|
||||||
|
* VoiceConnection.
|
||||||
|
* @type {VoiceConnection}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
get voiceConnection() {
|
||||||
|
return this.client.voice.connections.get(this.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Guild;
|
module.exports = Guild;
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,20 @@ class VoiceChannel extends GuildChannel {
|
||||||
const connection = this.client.voice.connections.get(this.guild.id);
|
const connection = this.client.voice.connections.get(this.guild.id);
|
||||||
if (connection && connection.channel.id === this.id) connection.disconnect();
|
if (connection && connection.channel.id === this.id) connection.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If connected to this guild's voice channel and the client is marked as being in this voice channel,
|
||||||
|
* then this will give the relevant voice connection.
|
||||||
|
* @type {VoiceConnection}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
get connection() {
|
||||||
|
const connection = this.client.voice.connections.get(this.guild.id);
|
||||||
|
if (connection.channel.id === this.id) {
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = VoiceChannel;
|
module.exports = VoiceChannel;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue