From 111b3ddde9bca7f5a0df8f096991ba6ef68d4bd0 Mon Sep 17 00:00:00 2001 From: monbrey Date: Thu, 14 Nov 2024 09:58:32 +1100 Subject: [PATCH] fix: suggestions from code review --- .../src/structures/InteractionCallback.js | 20 ++++--------------- .../structures/InteractionCallbackResource.js | 1 + .../structures/InteractionCallbackResponse.js | 3 ++- .../interfaces/InteractionResponses.js | 9 +++++---- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/packages/discord.js/src/structures/InteractionCallback.js b/packages/discord.js/src/structures/InteractionCallback.js index 72d35eb6528f..e2d2cf9b3c5b 100644 --- a/packages/discord.js/src/structures/InteractionCallback.js +++ b/packages/discord.js/src/structures/InteractionCallback.js @@ -27,39 +27,27 @@ class InteractionCallback { */ this.type = data.type; - /** - * The id of the channel the original interaction was sent in - * @type {?Snowflake} - */ - this.channelId = data.channel_id ?? null; - - /** - * The id of the guild the original interaction was sent in - * @type {Snowflake} - */ - this.guildId = data.guild_id ?? null; - /** * The instance id of the Activity if one was launched or joined - * @type {string} + * @type {?string} */ this.activityInstanceId = data.activity_instance_id ?? null; /** * The id of the message that was created by the interaction - * @type {Snowflake} + * @type {?Snowflake} */ this.responseMessageId = data.response_message_id ?? null; /** * Whether the message is in a loading state - * @type {boolean} + * @type {?boolean} */ this.responseMessageLoading = data.response_message_loading ?? null; /** * Whether the response message was ephemeral - * @type {boolean} + * @type {?boolean} */ this.responseMessageEphemeral = data.response_message_ephemeral ?? null; } diff --git a/packages/discord.js/src/structures/InteractionCallbackResource.js b/packages/discord.js/src/structures/InteractionCallbackResource.js index bb0bca5756ed..ffb088d8100e 100644 --- a/packages/discord.js/src/structures/InteractionCallbackResource.js +++ b/packages/discord.js/src/structures/InteractionCallbackResource.js @@ -1,4 +1,5 @@ 'use strict'; + const { lazy } = require('@discordjs/util'); const getMessage = lazy(() => require('./Message').Message); diff --git a/packages/discord.js/src/structures/InteractionCallbackResponse.js b/packages/discord.js/src/structures/InteractionCallbackResponse.js index 7211ce6bcd1b..c114648398ae 100644 --- a/packages/discord.js/src/structures/InteractionCallbackResponse.js +++ b/packages/discord.js/src/structures/InteractionCallbackResponse.js @@ -2,6 +2,7 @@ const InteractionCallback = require('./InteractionCallback'); const InteractionCallbackResource = require('./InteractionCallbackResource'); + /** * Represents an interaction's response */ @@ -22,7 +23,7 @@ class InteractionCallbackResponse { this.interaction = new InteractionCallback(client, data.interaction); /** - * The resource that was created by the interaction response + * The resource that was created by the interaction response * @type {?InteractionCallbackResource} */ this.resource = data.resource ? new InteractionCallbackResource(client, data.resource) : null; diff --git a/packages/discord.js/src/structures/interfaces/InteractionResponses.js b/packages/discord.js/src/structures/interfaces/InteractionResponses.js index 2c974c341657..23541b16aeb9 100644 --- a/packages/discord.js/src/structures/interfaces/InteractionResponses.js +++ b/packages/discord.js/src/structures/interfaces/InteractionResponses.js @@ -98,6 +98,7 @@ class InteractionResponses { if (options.withResponse) { return new InteractionCallbackResponse(this.client, response); } + return options.fetchReply ? this.fetchReply() : new InteractionResponse(this); } @@ -237,9 +238,9 @@ class InteractionResponses { if (options.withResponse) { return new InteractionCallbackResponse(this.client, response); - } else { - return options.fetchReply ? this.fetchReply() : new InteractionResponse(this, this.message?.interaction?.id); } + + return options.fetchReply ? this.fetchReply() : new InteractionResponse(this, this.message?.interaction?.id); } /** @@ -277,9 +278,9 @@ class InteractionResponses { if (options.withResponse) { return new InteractionCallbackResponse(this.client, response); - } else { - return options.fetchReply ? this.fetchReply() : new InteractionResponse(this, this.message.interaction?.id); } + + return options.fetchReply ? this.fetchReply() : new InteractionResponse(this, this.message.interaction?.id); } /**