mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 12:03:31 +01:00
fix(InteractionResponses): properly resolve message flags (#10660)
This commit is contained in:
@@ -149,15 +149,12 @@ class MessagePayload {
|
|||||||
|
|
||||||
let flags;
|
let flags;
|
||||||
if (
|
if (
|
||||||
this.options.flags !== undefined ||
|
// eslint-disable-next-line eqeqeq
|
||||||
|
this.options.flags != null ||
|
||||||
(this.isMessage && this.options.reply === undefined) ||
|
(this.isMessage && this.options.reply === undefined) ||
|
||||||
this.isMessageManager
|
this.isMessageManager
|
||||||
) {
|
) {
|
||||||
flags =
|
flags = new MessageFlagsBitField(this.options.flags).bitfield;
|
||||||
// eslint-disable-next-line eqeqeq
|
|
||||||
this.options.flags != null
|
|
||||||
? new MessageFlagsBitField(this.options.flags).bitfield
|
|
||||||
: this.target.flags?.bitfield;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let allowedMentions =
|
let allowedMentions =
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ const { makeURLSearchParams } = require('@discordjs/rest');
|
|||||||
const { isJSONEncodable } = require('@discordjs/util');
|
const { isJSONEncodable } = require('@discordjs/util');
|
||||||
const { InteractionResponseType, MessageFlags, Routes, InteractionType } = require('discord-api-types/v10');
|
const { InteractionResponseType, MessageFlags, Routes, InteractionType } = require('discord-api-types/v10');
|
||||||
const { DiscordjsError, ErrorCodes } = require('../../errors');
|
const { DiscordjsError, ErrorCodes } = require('../../errors');
|
||||||
|
const MessageFlagsBitField = require('../../util/MessageFlagsBitField');
|
||||||
const InteractionCallbackResponse = require('../InteractionCallbackResponse');
|
const InteractionCallbackResponse = require('../InteractionCallbackResponse');
|
||||||
const InteractionCollector = require('../InteractionCollector');
|
const InteractionCollector = require('../InteractionCollector');
|
||||||
const InteractionResponse = require('../InteractionResponse');
|
const InteractionResponse = require('../InteractionResponse');
|
||||||
@@ -75,11 +76,13 @@ class InteractionResponses {
|
|||||||
async deferReply(options = {}) {
|
async deferReply(options = {}) {
|
||||||
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
|
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), {
|
const response = await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
|
||||||
body: {
|
body: {
|
||||||
type: InteractionResponseType.DeferredChannelMessageWithSource,
|
type: InteractionResponseType.DeferredChannelMessageWithSource,
|
||||||
data: {
|
data: {
|
||||||
flags: options.flags,
|
flags: resolvedFlags.bitfield,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
auth: false,
|
auth: false,
|
||||||
@@ -87,7 +90,7 @@ class InteractionResponses {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.deferred = true;
|
this.deferred = true;
|
||||||
this.ephemeral = Boolean(options.flags & MessageFlags.Ephemeral);
|
this.ephemeral = resolvedFlags.has(MessageFlags.Ephemeral);
|
||||||
|
|
||||||
return options.withResponse
|
return options.withResponse
|
||||||
? new InteractionCallbackResponse(this.client, response)
|
? new InteractionCallbackResponse(this.client, response)
|
||||||
@@ -131,7 +134,7 @@ class InteractionResponses {
|
|||||||
query: makeURLSearchParams({ with_response: options.withResponse ?? false }),
|
query: makeURLSearchParams({ with_response: options.withResponse ?? false }),
|
||||||
});
|
});
|
||||||
|
|
||||||
this.ephemeral = Boolean(options.flags & MessageFlags.Ephemeral);
|
this.ephemeral = Boolean(data.flags & MessageFlags.Ephemeral);
|
||||||
this.replied = true;
|
this.replied = true;
|
||||||
|
|
||||||
return options.withResponse
|
return options.withResponse
|
||||||
|
|||||||
Reference in New Issue
Block a user