mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 20:43:30 +01:00
fix(InteractionResponses): properly resolve message flags (#10661)
This commit is contained in:
@@ -165,15 +165,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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isInteraction && this.options.ephemeral) {
|
if (isInteraction && this.options.ephemeral) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ const { deprecate } = require('node:util');
|
|||||||
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 InteractionCollector = require('../InteractionCollector');
|
const InteractionCollector = require('../InteractionCollector');
|
||||||
const InteractionResponse = require('../InteractionResponse');
|
const InteractionResponse = require('../InteractionResponse');
|
||||||
const MessagePayload = require('../MessagePayload');
|
const MessagePayload = require('../MessagePayload');
|
||||||
@@ -85,24 +86,25 @@ class InteractionResponses {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let { flags } = options;
|
const flags = new MessageFlagsBitField(options.flags);
|
||||||
|
|
||||||
if (options.ephemeral) {
|
if (options.ephemeral) {
|
||||||
flags |= MessageFlags.Ephemeral;
|
flags.add(MessageFlags.Ephemeral);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
|
await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
|
||||||
body: {
|
body: {
|
||||||
type: InteractionResponseType.DeferredChannelMessageWithSource,
|
type: InteractionResponseType.DeferredChannelMessageWithSource,
|
||||||
data: {
|
data: {
|
||||||
flags,
|
flags: flags.bitfield,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
auth: false,
|
auth: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.deferred = true;
|
this.deferred = true;
|
||||||
this.ephemeral = Boolean(flags & MessageFlags.Ephemeral);
|
this.ephemeral = flags.has(MessageFlags.Ephemeral);
|
||||||
|
|
||||||
return options.fetchReply ? this.fetchReply() : new InteractionResponse(this);
|
return options.fetchReply ? this.fetchReply() : new InteractionResponse(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,6 +156,7 @@ class InteractionResponses {
|
|||||||
|
|
||||||
this.ephemeral = Boolean(data.flags & MessageFlags.Ephemeral);
|
this.ephemeral = Boolean(data.flags & MessageFlags.Ephemeral);
|
||||||
this.replied = true;
|
this.replied = true;
|
||||||
|
|
||||||
return options.fetchReply ? this.fetchReply() : new InteractionResponse(this);
|
return options.fetchReply ? this.fetchReply() : new InteractionResponse(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user