From bb04e69a927d4ac3a6b61cead5cc1aa134fdae93 Mon Sep 17 00:00:00 2001 From: Jan <66554238+Vaporox@users.noreply.github.com> Date: Sat, 12 Dec 2020 14:49:32 +0100 Subject: [PATCH] cleanup(Guild): remove Guild#voice (#5091) --- src/client/actions/GuildDelete.js | 2 +- src/client/voice/VoiceConnection.js | 6 +++--- src/structures/Guild.js | 9 --------- typings/index.d.ts | 1 - 4 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/client/actions/GuildDelete.js b/src/client/actions/GuildDelete.js index 8bb630ff4..091c13f7b 100644 --- a/src/client/actions/GuildDelete.js +++ b/src/client/actions/GuildDelete.js @@ -37,7 +37,7 @@ class GuildDeleteAction extends Action { } for (const channel of guild.channels.cache.values()) this.client.channels.remove(channel.id); - if (guild.voice && guild.voice.connection) guild.voice.connection.disconnect(); + guild.me?.voice.connection?.disconnect(); // Delete guild client.guilds.cache.delete(guild.id); diff --git a/src/client/voice/VoiceConnection.js b/src/client/voice/VoiceConnection.js index bdc21d51e..06362f949 100644 --- a/src/client/voice/VoiceConnection.js +++ b/src/client/voice/VoiceConnection.js @@ -168,7 +168,7 @@ class VoiceConnection extends EventEmitter { * @type {?VoiceState} */ get voice() { - return this.channel.guild.voice; + return this.channel.guild.me?.voice ?? null; } /** @@ -182,8 +182,8 @@ class VoiceConnection extends EventEmitter { { guild_id: this.channel.guild.id, channel_id: this.channel.id, - self_mute: this.voice ? this.voice.selfMute : false, - self_deaf: this.voice ? this.voice.selfDeaf : false, + self_mute: this.voice?.selfMute ?? false, + self_deaf: this.voice?.selfDeaf ?? false, }, options, ); diff --git a/src/structures/Guild.js b/src/structures/Guild.js index c9c4fe9f9..881822871 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -628,15 +628,6 @@ class Guild extends Base { ); } - /** - * The voice state for the client user of this guild, if any - * @type {?VoiceState} - * @readonly - */ - get voice() { - return this.voiceStates.cache.get(this.client.user.id); - } - /** * Fetches this guild. * @returns {Promise} diff --git a/typings/index.d.ts b/typings/index.d.ts index f1419eace..30cd83af5 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -629,7 +629,6 @@ declare module 'discord.js' { public vanityURLUses: number | null; public verificationLevel: VerificationLevel; public readonly verified: boolean; - public readonly voice: VoiceState | null; public readonly voiceStates: VoiceStateManager; public readonly widgetChannel: TextChannel | null; public widgetChannelID: Snowflake | null;