diff --git a/packages/discord.js/src/structures/MessagePayload.js b/packages/discord.js/src/structures/MessagePayload.js index 7dc567924..5420d250d 100644 --- a/packages/discord.js/src/structures/MessagePayload.js +++ b/packages/discord.js/src/structures/MessagePayload.js @@ -149,15 +149,12 @@ class MessagePayload { let flags; if ( - this.options.flags !== undefined || + // eslint-disable-next-line eqeqeq + this.options.flags != null || (this.isMessage && this.options.reply === undefined) || this.isMessageManager ) { - flags = - // eslint-disable-next-line eqeqeq - this.options.flags != null - ? new MessageFlagsBitField(this.options.flags).bitfield - : this.target.flags?.bitfield; + flags = new MessageFlagsBitField(this.options.flags).bitfield; } let allowedMentions = diff --git a/packages/discord.js/src/structures/interfaces/InteractionResponses.js b/packages/discord.js/src/structures/interfaces/InteractionResponses.js index 1f33486ca..899ef6474 100644 --- a/packages/discord.js/src/structures/interfaces/InteractionResponses.js +++ b/packages/discord.js/src/structures/interfaces/InteractionResponses.js @@ -4,6 +4,7 @@ const { makeURLSearchParams } = require('@discordjs/rest'); const { isJSONEncodable } = require('@discordjs/util'); const { InteractionResponseType, MessageFlags, Routes, InteractionType } = require('discord-api-types/v10'); const { DiscordjsError, ErrorCodes } = require('../../errors'); +const MessageFlagsBitField = require('../../util/MessageFlagsBitField'); const InteractionCallbackResponse = require('../InteractionCallbackResponse'); const InteractionCollector = require('../InteractionCollector'); const InteractionResponse = require('../InteractionResponse'); @@ -75,11 +76,13 @@ class InteractionResponses { async deferReply(options = {}) { if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied); + const resolvedFlags = new MessageFlagsBitField(options.flags); + const response = await this.client.rest.post(Routes.interactionCallback(this.id, this.token), { body: { type: InteractionResponseType.DeferredChannelMessageWithSource, data: { - flags: options.flags, + flags: resolvedFlags.bitfield, }, }, auth: false, @@ -87,7 +90,7 @@ class InteractionResponses { }); this.deferred = true; - this.ephemeral = Boolean(options.flags & MessageFlags.Ephemeral); + this.ephemeral = resolvedFlags.has(MessageFlags.Ephemeral); return options.withResponse ? new InteractionCallbackResponse(this.client, response) @@ -131,7 +134,7 @@ class InteractionResponses { query: makeURLSearchParams({ with_response: options.withResponse ?? false }), }); - this.ephemeral = Boolean(options.flags & MessageFlags.Ephemeral); + this.ephemeral = Boolean(data.flags & MessageFlags.Ephemeral); this.replied = true; return options.withResponse