mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
fix(InteractionResponses): properly resolve message flags (#10661)
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user