mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 11:03:30 +01:00
fix(InteractionResponses): check if ephemeral message flag is used (#10021)
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
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');
|
||||||
@@ -100,7 +101,6 @@ class InteractionResponses {
|
|||||||
*/
|
*/
|
||||||
async reply(options) {
|
async reply(options) {
|
||||||
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
|
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
|
||||||
this.ephemeral = options.ephemeral ?? false;
|
|
||||||
|
|
||||||
let messagePayload;
|
let messagePayload;
|
||||||
if (options instanceof MessagePayload) messagePayload = options;
|
if (options instanceof MessagePayload) messagePayload = options;
|
||||||
@@ -108,6 +108,8 @@ class InteractionResponses {
|
|||||||
|
|
||||||
const { body: data, files } = await messagePayload.resolveBody().resolveFiles();
|
const { body: data, files } = await messagePayload.resolveBody().resolveFiles();
|
||||||
|
|
||||||
|
this.ephemeral = new MessageFlagsBitField(data.flags).has(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.ChannelMessageWithSource,
|
type: InteractionResponseType.ChannelMessageWithSource,
|
||||||
|
|||||||
Reference in New Issue
Block a user