discord.js
Advanced tools
Comparing version 15.0.0-dev.1729296707-3540c3176 to 15.0.0-dev.1729598710-48a9c665d
{ | ||
"$schema": "https://json.schemastore.org/package.json", | ||
"name": "discord.js", | ||
"version": "15.0.0-dev.1729296707-3540c3176", | ||
"version": "15.0.0-dev.1729598710-48a9c665d", | ||
"description": "A powerful library for interacting with the Discord API", | ||
@@ -63,6 +63,6 @@ "main": "./src/index.js", | ||
"undici": "6.19.8", | ||
"@discordjs/rest": "^2.4.0", | ||
"@discordjs/formatters": "^0.5.0", | ||
"@discordjs/ws": "^2.0.0", | ||
"@discordjs/util": "^1.1.1", | ||
"@discordjs/rest": "^2.4.0" | ||
"@discordjs/ws": "^2.0.0" | ||
}, | ||
@@ -84,4 +84,4 @@ "devDependencies": { | ||
"typescript": "~5.5.4", | ||
"@discordjs/api-extractor": "^7.38.1", | ||
"@discordjs/docgen": "^0.12.1", | ||
"@discordjs/api-extractor": "^7.38.1", | ||
"@discordjs/scripts": "^0.1.0" | ||
@@ -88,0 +88,0 @@ }, |
@@ -6,3 +6,2 @@ 'use strict'; | ||
const { DiscordjsError, ErrorCodes } = require('../../errors'); | ||
const MessageFlagsBitField = require('../../util/MessageFlagsBitField'); | ||
const InteractionCollector = require('../InteractionCollector'); | ||
@@ -27,3 +26,4 @@ const InteractionResponse = require('../InteractionResponse'); | ||
* @typedef {Object} InteractionDeferReplyOptions | ||
* @property {boolean} [ephemeral] Whether the reply should be ephemeral | ||
* @property {MessageFlagsResolvable} [flags] Flags for the reply. | ||
* <info>Only `MessageFlags.Ephemeral` can be set.</info> | ||
* @property {boolean} [fetchReply] Whether to fetch the reply | ||
@@ -42,5 +42,4 @@ */ | ||
* @property {boolean} [tts=false] Whether the message should be spoken aloud | ||
* @property {boolean} [ephemeral] Whether the reply should be ephemeral | ||
* @property {boolean} [fetchReply] Whether to fetch the reply | ||
* @property {MessageFlags} [flags] Which flags to set for the message. | ||
* @property {MessageFlagsResolvable} [flags] Which flags to set for the message. | ||
* <info>Only `MessageFlags.Ephemeral`, `MessageFlags.SuppressEmbeds`, and `MessageFlags.SuppressNotifications` | ||
@@ -67,3 +66,3 @@ * can be set.</info> | ||
* // Defer to send an ephemeral reply later | ||
* interaction.deferReply({ ephemeral: true }) | ||
* interaction.deferReply({ flags: MessageFlags.Ephemeral }) | ||
* .then(console.log) | ||
@@ -74,3 +73,3 @@ * .catch(console.error); | ||
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied); | ||
this.ephemeral = options.ephemeral ?? false; | ||
await this.client.rest.post(Routes.interactionCallback(this.id, this.token), { | ||
@@ -80,3 +79,3 @@ body: { | ||
data: { | ||
flags: options.ephemeral ? MessageFlags.Ephemeral : undefined, | ||
flags: options.flags, | ||
}, | ||
@@ -86,4 +85,5 @@ }, | ||
}); | ||
this.deferred = true; | ||
this.ephemeral = Boolean(options.flags & MessageFlags.Ephemeral); | ||
return options.fetchReply ? this.fetchReply() : new InteractionResponse(this); | ||
@@ -106,3 +106,3 @@ } | ||
* | ||
* interaction.reply({ embeds: [embed], ephemeral: true }) | ||
* interaction.reply({ embeds: [embed], flags: MessageFlags.Ephemeral }) | ||
* .then(() => console.log('Reply sent.')) | ||
@@ -120,4 +120,2 @@ * .catch(console.error); | ||
this.ephemeral = new MessageFlagsBitField(data.flags).has(MessageFlags.Ephemeral); | ||
await this.client.rest.post(Routes.interactionCallback(this.id, this.token), { | ||
@@ -131,4 +129,5 @@ body: { | ||
}); | ||
this.ephemeral = Boolean(options.flags & MessageFlags.Ephemeral); | ||
this.replied = true; | ||
return options.fetchReply ? this.fetchReply() : new InteractionResponse(this); | ||
@@ -135,0 +134,0 @@ } |
'use strict'; | ||
const { Buffer } = require('node:buffer'); | ||
const { lazy, isJSONEncodable } = require('@discordjs/util'); | ||
const { isJSONEncodable } = require('@discordjs/util'); | ||
const { DiscordSnowflake } = require('@sapphire/snowflake'); | ||
const { MessageFlags } = require('discord-api-types/v10'); | ||
const ActionRowBuilder = require('./ActionRowBuilder'); | ||
@@ -13,4 +12,2 @@ const { DiscordjsError, DiscordjsRangeError, ErrorCodes } = require('../errors'); | ||
const getBaseInteraction = lazy(() => require('./BaseInteraction')); | ||
/** | ||
@@ -93,13 +90,2 @@ * Represents a message to be sent to the API. | ||
/** | ||
* Whether or not the target is an {@link BaseInteraction} or an {@link InteractionWebhook} | ||
* @type {boolean} | ||
* @readonly | ||
*/ | ||
get isInteraction() { | ||
const BaseInteraction = getBaseInteraction(); | ||
const InteractionWebhook = require('./InteractionWebhook'); | ||
return this.target instanceof BaseInteraction || this.target instanceof InteractionWebhook; | ||
} | ||
/** | ||
* Makes the content of this message. | ||
@@ -125,3 +111,2 @@ * @returns {?string} | ||
if (this.body) return this; | ||
const isInteraction = this.isInteraction; | ||
const isWebhook = this.isWebhook; | ||
@@ -181,6 +166,2 @@ | ||
if (isInteraction && this.options.ephemeral) { | ||
flags |= MessageFlags.Ephemeral; | ||
} | ||
let allowedMentions = | ||
@@ -187,0 +168,0 @@ this.options.allowedMentions === undefined |
@@ -27,2 +27,11 @@ 'use strict'; | ||
/** | ||
* Data that can be resolved to give a message flags bit field. This can be: | ||
* * A string (see {@link MessageFlagsBitField.Flags}) | ||
* * A message flag | ||
* * An instance of {@link MessageFlagsBitField} | ||
* * An array of `MessageFlagsResolvable` | ||
* @typedef {string|number|MessageFlagsBitField|MessageFlagsResolvable[]} MessageFlagsResolvable | ||
*/ | ||
/** | ||
* Bitfield of the packed bits | ||
@@ -29,0 +38,0 @@ * @type {number} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1818755
40231