mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 19:43:29 +01:00
Fix & clean up Guild.voiceConnection and VoiceChannel.connection
This commit is contained in:
@@ -232,6 +232,16 @@ class Guild {
|
|||||||
return this.members.get(this.ownerID);
|
return this.members.get(this.ownerID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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) || null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The `#general` GuildChannel of the server.
|
* The `#general` GuildChannel of the server.
|
||||||
* @type {GuildChannel}
|
* @type {GuildChannel}
|
||||||
@@ -690,16 +700,6 @@ 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;
|
||||||
|
|||||||
@@ -34,6 +34,18 @@ class VoiceChannel extends GuildChannel {
|
|||||||
this.userLimit = data.user_limit;
|
this.userLimit = data.user_limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.guild.voiceConnection;
|
||||||
|
if (connection && connection.channel.id === this.id) return connection;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the bitrate of the channel
|
* Sets the bitrate of the channel
|
||||||
* @param {number} bitrate The new bitrate
|
* @param {number} bitrate The new bitrate
|
||||||
@@ -71,20 +83,6 @@ 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;
|
||||||
|
|||||||
Reference in New Issue
Block a user