fix(InteractionResponses): properly resolve message flags (#10660)

This commit is contained in:
Danial Raza
2024-12-18 15:39:04 +01:00
committed by GitHub
parent 35ebcc7d5a
commit f1bce54a28
2 changed files with 9 additions and 9 deletions

View File

@@ -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 =

View File

@@ -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