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

This commit is contained in:
Danial Raza
2024-12-18 16:02:35 +01:00
committed by GitHub
parent 53cbb0e36d
commit b2754d4a0e
2 changed files with 10 additions and 10 deletions

View File

@@ -165,15 +165,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;
}
if (isInteraction && this.options.ephemeral) {

View File

@@ -5,6 +5,7 @@ const { deprecate } = require('node:util');
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 InteractionCollector = require('../InteractionCollector');
const InteractionResponse = require('../InteractionResponse');
const MessagePayload = require('../MessagePayload');
@@ -85,24 +86,25 @@ class InteractionResponses {
}
}
let { flags } = options;
const flags = new MessageFlagsBitField(options.flags);
if (options.ephemeral) {
flags |= MessageFlags.Ephemeral;
flags.add(MessageFlags.Ephemeral);
}
await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
body: {
type: InteractionResponseType.DeferredChannelMessageWithSource,
data: {
flags,
flags: flags.bitfield,
},
},
auth: false,
});
this.deferred = true;
this.ephemeral = Boolean(flags & MessageFlags.Ephemeral);
this.ephemeral = flags.has(MessageFlags.Ephemeral);
return options.fetchReply ? this.fetchReply() : new InteractionResponse(this);
}
@@ -154,6 +156,7 @@ class InteractionResponses {
this.ephemeral = Boolean(data.flags & MessageFlags.Ephemeral);
this.replied = true;
return options.fetchReply ? this.fetchReply() : new InteractionResponse(this);
}