mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 03:53:29 +01:00
feat(InteractionResponses): support with_response query parameter (#10636)
feat(InteractionResponses): support with_response query parameter Co-authored-by: Ryan Munro <monbrey@gmail.com>
This commit is contained in:
@@ -147,6 +147,9 @@ exports.GuildScheduledEvent = require('./structures/GuildScheduledEvent').GuildS
|
|||||||
exports.GuildTemplate = require('./structures/GuildTemplate');
|
exports.GuildTemplate = require('./structures/GuildTemplate');
|
||||||
exports.Integration = require('./structures/Integration');
|
exports.Integration = require('./structures/Integration');
|
||||||
exports.IntegrationApplication = require('./structures/IntegrationApplication');
|
exports.IntegrationApplication = require('./structures/IntegrationApplication');
|
||||||
|
exports.InteractionCallback = require('./structures/InteractionCallback');
|
||||||
|
exports.InteractionCallbackResource = require('./structures/InteractionCallbackResource');
|
||||||
|
exports.InteractionCallbackResponse = require('./structures/InteractionCallbackResponse');
|
||||||
exports.BaseInteraction = require('./structures/BaseInteraction');
|
exports.BaseInteraction = require('./structures/BaseInteraction');
|
||||||
exports.InteractionCollector = require('./structures/InteractionCollector');
|
exports.InteractionCollector = require('./structures/InteractionCollector');
|
||||||
exports.InteractionResponse = require('./structures/InteractionResponse');
|
exports.InteractionResponse = require('./structures/InteractionResponse');
|
||||||
|
|||||||
74
packages/discord.js/src/structures/InteractionCallback.js
Normal file
74
packages/discord.js/src/structures/InteractionCallback.js
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an interaction callback response from Discord
|
||||||
|
*/
|
||||||
|
class InteractionCallback {
|
||||||
|
constructor(client, data) {
|
||||||
|
/**
|
||||||
|
* The client that instantiated this.
|
||||||
|
* @name InteractionCallback#client
|
||||||
|
* @type {Client}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
Object.defineProperty(this, 'client', { value: client });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The id of the original interaction response
|
||||||
|
* @type {Snowflake}
|
||||||
|
*/
|
||||||
|
this.id = data.id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of the original interaction
|
||||||
|
* @type {InteractionType}
|
||||||
|
*/
|
||||||
|
this.type = data.type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The instance id of the Activity if one was launched or joined
|
||||||
|
* @type {?string}
|
||||||
|
*/
|
||||||
|
this.activityInstanceId = data.activity_instance_id ?? null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The id of the message that was created by the interaction
|
||||||
|
* @type {?Snowflake}
|
||||||
|
*/
|
||||||
|
this.responseMessageId = data.response_message_id ?? null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the message is in a loading state
|
||||||
|
* @type {?boolean}
|
||||||
|
*/
|
||||||
|
this.responseMessageLoading = data.response_message_loading ?? null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the response message was ephemeral
|
||||||
|
* @type {?boolean}
|
||||||
|
*/
|
||||||
|
this.responseMessageEphemeral = data.response_message_ephemeral ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The timestamp the original interaction was created at
|
||||||
|
* @type {number}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
get createdTimestamp() {
|
||||||
|
return DiscordSnowflake.timestampFrom(this.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The time the original interaction was created at
|
||||||
|
* @type {Date}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
get createdAt() {
|
||||||
|
return new Date(this.createdTimestamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = InteractionCallback;
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const { lazy } = require('@discordjs/util');
|
||||||
|
|
||||||
|
const getMessage = lazy(() => require('./Message').Message);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the resource that was created by the interaction response.
|
||||||
|
*/
|
||||||
|
class InteractionCallbackResource {
|
||||||
|
constructor(client, data) {
|
||||||
|
/**
|
||||||
|
* The client that instantiated this
|
||||||
|
* @name InteractionCallbackResource#client
|
||||||
|
* @type {Client}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
Object.defineProperty(this, 'client', { value: client });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The interaction callback type
|
||||||
|
* @type {InteractionResponseType}
|
||||||
|
*/
|
||||||
|
this.type = data.type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Activity launched by an interaction
|
||||||
|
* @typedef {Object} ActivityInstance
|
||||||
|
* @property {string} id The instance id of the Activity
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the Activity launched by this interaction
|
||||||
|
* @type {?ActivityInstance}
|
||||||
|
*/
|
||||||
|
this.activityInstance = data.activity_instance ?? null;
|
||||||
|
|
||||||
|
if ('message' in data) {
|
||||||
|
/**
|
||||||
|
* The message created by the interaction
|
||||||
|
* @type {?Message}
|
||||||
|
*/
|
||||||
|
this.message =
|
||||||
|
this.client.channels.cache.get(data.message.channel_id)?.messages._add(data.message) ??
|
||||||
|
new (getMessage())(client, data.message);
|
||||||
|
} else {
|
||||||
|
this.message = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = InteractionCallbackResource;
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const InteractionCallback = require('./InteractionCallback');
|
||||||
|
const InteractionCallbackResource = require('./InteractionCallbackResource');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an interaction's response
|
||||||
|
*/
|
||||||
|
class InteractionCallbackResponse {
|
||||||
|
constructor(client, data) {
|
||||||
|
/**
|
||||||
|
* The client that instantiated this
|
||||||
|
* @name InteractionCallbackResponse#client
|
||||||
|
* @type {Client}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
Object.defineProperty(this, 'client', { value: client });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The interaction object associated with the interaction callback response
|
||||||
|
* @type {InteractionCallback}
|
||||||
|
*/
|
||||||
|
this.interaction = new InteractionCallback(client, data.interaction);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The resource that was created by the interaction response
|
||||||
|
* @type {?InteractionCallbackResource}
|
||||||
|
*/
|
||||||
|
this.resource = data.resource ? new InteractionCallbackResource(client, data.resource) : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = InteractionCallbackResponse;
|
||||||
@@ -2,15 +2,18 @@
|
|||||||
|
|
||||||
const process = require('node:process');
|
const process = require('node:process');
|
||||||
const { deprecate } = require('node:util');
|
const { deprecate } = require('node:util');
|
||||||
|
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 MessageFlagsBitField = require('../../util/MessageFlagsBitField');
|
||||||
|
const InteractionCallbackResponse = require('../InteractionCallbackResponse');
|
||||||
const InteractionCollector = require('../InteractionCollector');
|
const InteractionCollector = require('../InteractionCollector');
|
||||||
const InteractionResponse = require('../InteractionResponse');
|
const InteractionResponse = require('../InteractionResponse');
|
||||||
const MessagePayload = require('../MessagePayload');
|
const MessagePayload = require('../MessagePayload');
|
||||||
|
|
||||||
let deprecationEmittedForEphemeralOption = false;
|
let deprecationEmittedForEphemeralOption = false;
|
||||||
|
let deprecationEmittedForFetchReplyOption = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} ModalComponentData
|
* @typedef {Object} ModalComponentData
|
||||||
@@ -31,13 +34,17 @@ class InteractionResponses {
|
|||||||
* <warn>This option is deprecated. Use `flags` instead.</warn>
|
* <warn>This option is deprecated. Use `flags` instead.</warn>
|
||||||
* @property {MessageFlagsResolvable} [flags] Flags for the reply.
|
* @property {MessageFlagsResolvable} [flags] Flags for the reply.
|
||||||
* <info>Only `MessageFlags.Ephemeral` can be set.</info>
|
* <info>Only `MessageFlags.Ephemeral` can be set.</info>
|
||||||
|
* @property {boolean} [withResponse] Whether to return an {@link InteractionCallbackResponse} as the response
|
||||||
* @property {boolean} [fetchReply] Whether to fetch the reply
|
* @property {boolean} [fetchReply] Whether to fetch the reply
|
||||||
|
* <warn>This option is deprecated. Use `withResponse` or fetch the response instead.</warn>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options for deferring and updating the reply to a {@link MessageComponentInteraction}.
|
* Options for deferring and updating the reply to a {@link MessageComponentInteraction}.
|
||||||
* @typedef {Object} InteractionDeferUpdateOptions
|
* @typedef {Object} InteractionDeferUpdateOptions
|
||||||
|
* @property {boolean} [withResponse] Whether to return an {@link InteractionCallbackResponse} as the response
|
||||||
* @property {boolean} [fetchReply] Whether to fetch the reply
|
* @property {boolean} [fetchReply] Whether to fetch the reply
|
||||||
|
* <warn>This option is deprecated. Use `withResponse` or fetch the response instead.</warn>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,7 +53,9 @@ class InteractionResponses {
|
|||||||
* @property {boolean} [ephemeral] Whether the reply should be ephemeral.
|
* @property {boolean} [ephemeral] Whether the reply should be ephemeral.
|
||||||
* <warn>This option is deprecated. Use `flags` instead.</warn>
|
* <warn>This option is deprecated. Use `flags` instead.</warn>
|
||||||
* @property {boolean} [tts=false] Whether the message should be spoken aloud
|
* @property {boolean} [tts=false] Whether the message should be spoken aloud
|
||||||
|
* @property {boolean} [withResponse] Whether to return an {@link InteractionCallbackResponse} as the response
|
||||||
* @property {boolean} [fetchReply] Whether to fetch the reply
|
* @property {boolean} [fetchReply] Whether to fetch the reply
|
||||||
|
* <warn>This option is deprecated. Use `withResponse` or fetch the response instead.</warn>
|
||||||
* @property {MessageFlagsResolvable} [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`
|
* <info>Only `MessageFlags.Ephemeral`, `MessageFlags.SuppressEmbeds`, and `MessageFlags.SuppressNotifications`
|
||||||
* can be set.</info>
|
* can be set.</info>
|
||||||
@@ -55,13 +64,21 @@ class InteractionResponses {
|
|||||||
/**
|
/**
|
||||||
* Options for updating the message received from a {@link MessageComponentInteraction}.
|
* Options for updating the message received from a {@link MessageComponentInteraction}.
|
||||||
* @typedef {MessageEditOptions} InteractionUpdateOptions
|
* @typedef {MessageEditOptions} InteractionUpdateOptions
|
||||||
|
* @property {boolean} [withResponse] Whether to return an {@link InteractionCallbackResponse} as the response
|
||||||
* @property {boolean} [fetchReply] Whether to fetch the reply
|
* @property {boolean} [fetchReply] Whether to fetch the reply
|
||||||
|
* <warn>This option is deprecated. Use `withResponse` or fetch the response instead.</warn>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options for showing a modal in response to a {@link BaseInteraction}
|
||||||
|
* @typedef {Object} ShowModalOptions
|
||||||
|
* @property {boolean} [withResponse] Whether to return an {@link InteractionCallbackResponse} as the response
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defers the reply to this interaction.
|
* Defers the reply to this interaction.
|
||||||
* @param {InteractionDeferReplyOptions} [options] Options for deferring the reply to this interaction
|
* @param {InteractionDeferReplyOptions} [options] Options for deferring the reply to this interaction
|
||||||
* @returns {Promise<Message|InteractionResponse>}
|
* @returns {Promise<InteractionCallbackResponse|Message|InteractionResponse>}
|
||||||
* @example
|
* @example
|
||||||
* // Defer the reply to this interaction
|
* // Defer the reply to this interaction
|
||||||
* interaction.deferReply()
|
* interaction.deferReply()
|
||||||
@@ -86,13 +103,24 @@ class InteractionResponses {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ('fetchReply' in options) {
|
||||||
|
if (!deprecationEmittedForFetchReplyOption) {
|
||||||
|
process.emitWarning(
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
`Supplying "fetchReply" for interaction response options is deprecated. Utilize "withResponse" instead or fetch the response after using the method.`,
|
||||||
|
);
|
||||||
|
|
||||||
|
deprecationEmittedForFetchReplyOption = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const flags = new MessageFlagsBitField(options.flags);
|
const flags = new MessageFlagsBitField(options.flags);
|
||||||
|
|
||||||
if (options.ephemeral) {
|
if (options.ephemeral) {
|
||||||
flags.add(MessageFlags.Ephemeral);
|
flags.add(MessageFlags.Ephemeral);
|
||||||
}
|
}
|
||||||
|
|
||||||
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: {
|
||||||
@@ -100,23 +128,28 @@ class InteractionResponses {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
auth: false,
|
auth: false,
|
||||||
|
query: makeURLSearchParams({ with_response: options.withResponse ?? false }),
|
||||||
});
|
});
|
||||||
|
|
||||||
this.deferred = true;
|
this.deferred = true;
|
||||||
this.ephemeral = flags.has(MessageFlags.Ephemeral);
|
this.ephemeral = flags.has(MessageFlags.Ephemeral);
|
||||||
|
|
||||||
return options.fetchReply ? this.fetchReply() : new InteractionResponse(this);
|
return options.withResponse
|
||||||
|
? new InteractionCallbackResponse(this.client, response)
|
||||||
|
: options.fetchReply
|
||||||
|
? this.fetchReply()
|
||||||
|
: new InteractionResponse(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a reply to this interaction.
|
* Creates a reply to this interaction.
|
||||||
* <info>Use the `fetchReply` option to get the bot's reply message.</info>
|
* <info>Use the `withResponse` option to get the interaction callback response.</info>
|
||||||
* @param {string|MessagePayload|InteractionReplyOptions} options The options for the reply
|
* @param {string|MessagePayload|InteractionReplyOptions} options The options for the reply
|
||||||
* @returns {Promise<Message|InteractionResponse>}
|
* @returns {Promise<InteractionCallbackResponse|Message|InteractionResponse>}
|
||||||
* @example
|
* @example
|
||||||
* // Reply to the interaction and fetch the response
|
* // Reply to the interaction and fetch the response
|
||||||
* interaction.reply({ content: 'Pong!', fetchReply: true })
|
* interaction.reply({ content: 'Pong!', withResponse: true })
|
||||||
* .then((message) => console.log(`Reply sent with content ${message.content}`))
|
* .then((response) => console.log(`Reply sent with content ${response.resource.message.content}`))
|
||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
* @example
|
* @example
|
||||||
* // Create an ephemeral reply with an embed
|
* // Create an ephemeral reply with an embed
|
||||||
@@ -139,25 +172,41 @@ class InteractionResponses {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ('fetchReply' in options) {
|
||||||
|
if (!deprecationEmittedForFetchReplyOption) {
|
||||||
|
process.emitWarning(
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
`Supplying "fetchReply" for interaction response options is deprecated. Utilize "withResponse" instead or fetch the response after using the method.`,
|
||||||
|
);
|
||||||
|
|
||||||
|
deprecationEmittedForFetchReplyOption = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let messagePayload;
|
let messagePayload;
|
||||||
if (options instanceof MessagePayload) messagePayload = options;
|
if (options instanceof MessagePayload) messagePayload = options;
|
||||||
else messagePayload = MessagePayload.create(this, options);
|
else messagePayload = MessagePayload.create(this, options);
|
||||||
|
|
||||||
const { body: data, files } = await messagePayload.resolveBody().resolveFiles();
|
const { body: data, files } = await messagePayload.resolveBody().resolveFiles();
|
||||||
|
|
||||||
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.ChannelMessageWithSource,
|
type: InteractionResponseType.ChannelMessageWithSource,
|
||||||
data,
|
data,
|
||||||
},
|
},
|
||||||
files,
|
files,
|
||||||
auth: false,
|
auth: false,
|
||||||
|
query: makeURLSearchParams({ with_response: options.withResponse ?? false }),
|
||||||
});
|
});
|
||||||
|
|
||||||
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.withResponse
|
||||||
|
? new InteractionCallbackResponse(this.client, response)
|
||||||
|
: options.fetchReply
|
||||||
|
? this.fetchReply()
|
||||||
|
: new InteractionResponse(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -229,7 +278,7 @@ class InteractionResponses {
|
|||||||
/**
|
/**
|
||||||
* Defers an update to the message to which the component was attached.
|
* Defers an update to the message to which the component was attached.
|
||||||
* @param {InteractionDeferUpdateOptions} [options] Options for deferring the update to this interaction
|
* @param {InteractionDeferUpdateOptions} [options] Options for deferring the update to this interaction
|
||||||
* @returns {Promise<Message|InteractionResponse>}
|
* @returns {Promise<InteractionCallbackResponse|Message|InteractionResponse>}
|
||||||
* @example
|
* @example
|
||||||
* // Defer updating and reset the component's loading state
|
* // Defer updating and reset the component's loading state
|
||||||
* interaction.deferUpdate()
|
* interaction.deferUpdate()
|
||||||
@@ -238,21 +287,38 @@ class InteractionResponses {
|
|||||||
*/
|
*/
|
||||||
async deferUpdate(options = {}) {
|
async deferUpdate(options = {}) {
|
||||||
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
|
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
|
||||||
await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
|
|
||||||
|
if ('fetchReply' in options) {
|
||||||
|
if (!deprecationEmittedForFetchReplyOption) {
|
||||||
|
process.emitWarning(
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
`Supplying "fetchReply" for interaction response options is deprecated. Utilize "withResponse" instead or fetch the response after using the method.`,
|
||||||
|
);
|
||||||
|
|
||||||
|
deprecationEmittedForFetchReplyOption = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
|
||||||
body: {
|
body: {
|
||||||
type: InteractionResponseType.DeferredMessageUpdate,
|
type: InteractionResponseType.DeferredMessageUpdate,
|
||||||
},
|
},
|
||||||
auth: false,
|
auth: false,
|
||||||
|
query: makeURLSearchParams({ with_response: options.withResponse ?? false }),
|
||||||
});
|
});
|
||||||
this.deferred = true;
|
this.deferred = true;
|
||||||
|
|
||||||
return options.fetchReply ? this.fetchReply() : new InteractionResponse(this, this.message?.interaction?.id);
|
return options.withResponse
|
||||||
|
? new InteractionCallbackResponse(this.client, response)
|
||||||
|
: options.fetchReply
|
||||||
|
? this.fetchReply()
|
||||||
|
: new InteractionResponse(this, this.message?.interaction?.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the original message of the component on which the interaction was received on.
|
* Updates the original message of the component on which the interaction was received on.
|
||||||
* @param {string|MessagePayload|InteractionUpdateOptions} options The options for the updated message
|
* @param {string|MessagePayload|InteractionUpdateOptions} options The options for the updated message
|
||||||
* @returns {Promise<Message|void>}
|
* @returns {Promise<InteractionCallbackResponse|Message|void>}
|
||||||
* @example
|
* @example
|
||||||
* // Remove the components from the message
|
* // Remove the components from the message
|
||||||
* interaction.update({
|
* interaction.update({
|
||||||
@@ -265,40 +331,60 @@ class InteractionResponses {
|
|||||||
async update(options) {
|
async update(options) {
|
||||||
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
|
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
|
||||||
|
|
||||||
|
if ('fetchReply' in options) {
|
||||||
|
if (!deprecationEmittedForFetchReplyOption) {
|
||||||
|
process.emitWarning(
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
`Supplying "fetchReply" for interaction response options is deprecated. Utilize "withResponse" instead or fetch the response after using the method.`,
|
||||||
|
);
|
||||||
|
|
||||||
|
deprecationEmittedForFetchReplyOption = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let messagePayload;
|
let messagePayload;
|
||||||
if (options instanceof MessagePayload) messagePayload = options;
|
if (options instanceof MessagePayload) messagePayload = options;
|
||||||
else messagePayload = MessagePayload.create(this, options);
|
else messagePayload = MessagePayload.create(this, options);
|
||||||
|
|
||||||
const { body: data, files } = await messagePayload.resolveBody().resolveFiles();
|
const { body: data, files } = await messagePayload.resolveBody().resolveFiles();
|
||||||
|
|
||||||
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.UpdateMessage,
|
type: InteractionResponseType.UpdateMessage,
|
||||||
data,
|
data,
|
||||||
},
|
},
|
||||||
files,
|
files,
|
||||||
auth: false,
|
auth: false,
|
||||||
|
query: makeURLSearchParams({ with_response: options.withResponse ?? false }),
|
||||||
});
|
});
|
||||||
this.replied = true;
|
this.replied = true;
|
||||||
|
|
||||||
return options.fetchReply ? this.fetchReply() : new InteractionResponse(this, this.message.interaction?.id);
|
return options.withResponse
|
||||||
|
? new InteractionCallbackResponse(this.client, response)
|
||||||
|
: options.fetchReply
|
||||||
|
? this.fetchReply()
|
||||||
|
: new InteractionResponse(this, this.message.interaction?.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows a modal component
|
* Shows a modal component
|
||||||
* @param {ModalBuilder|ModalComponentData|APIModalInteractionResponseCallbackData} modal The modal to show
|
* @param {ModalBuilder|ModalComponentData|APIModalInteractionResponseCallbackData} modal The modal to show
|
||||||
* @returns {Promise<void>}
|
* @param {ShowModalOptions} [options={}] The options for sending this interaction response
|
||||||
|
* @returns {Promise<InteractionCallbackResponse|undefined>}
|
||||||
*/
|
*/
|
||||||
async showModal(modal) {
|
async showModal(modal, options = {}) {
|
||||||
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
|
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
|
||||||
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.Modal,
|
type: InteractionResponseType.Modal,
|
||||||
data: isJSONEncodable(modal) ? modal.toJSON() : this.client.options.jsonTransformer(modal),
|
data: isJSONEncodable(modal) ? modal.toJSON() : this.client.options.jsonTransformer(modal),
|
||||||
},
|
},
|
||||||
auth: false,
|
auth: false,
|
||||||
|
query: makeURLSearchParams({ with_response: options.withResponse ?? false }),
|
||||||
});
|
});
|
||||||
this.replied = true;
|
this.replied = true;
|
||||||
|
|
||||||
|
return options.withResponse ? new InteractionCallbackResponse(this.client, response) : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
110
packages/discord.js/typings/index.d.ts
vendored
110
packages/discord.js/typings/index.d.ts
vendored
@@ -192,6 +192,13 @@ import {
|
|||||||
SubscriptionStatus,
|
SubscriptionStatus,
|
||||||
ApplicationWebhookEventStatus,
|
ApplicationWebhookEventStatus,
|
||||||
ApplicationWebhookEventType,
|
ApplicationWebhookEventType,
|
||||||
|
GatewaySendPayload,
|
||||||
|
GatewayDispatchPayload,
|
||||||
|
RESTPostAPIInteractionCallbackWithResponseResult,
|
||||||
|
RESTAPIInteractionCallbackObject,
|
||||||
|
RESTAPIInteractionCallbackResourceObject,
|
||||||
|
InteractionResponseType,
|
||||||
|
RESTAPIInteractionCallbackActivityInstanceResource,
|
||||||
VoiceChannelEffectSendAnimationType,
|
VoiceChannelEffectSendAnimationType,
|
||||||
GatewayVoiceChannelEffectSendDispatchData,
|
GatewayVoiceChannelEffectSendDispatchData,
|
||||||
} from 'discord-api-types/v10';
|
} from 'discord-api-types/v10';
|
||||||
@@ -587,6 +594,10 @@ export abstract class CommandInteraction<Cached extends CacheType = CacheType> e
|
|||||||
public inGuild(): this is CommandInteraction<'raw' | 'cached'>;
|
public inGuild(): this is CommandInteraction<'raw' | 'cached'>;
|
||||||
public inCachedGuild(): this is CommandInteraction<'cached'>;
|
public inCachedGuild(): this is CommandInteraction<'cached'>;
|
||||||
public inRawGuild(): this is CommandInteraction<'raw'>;
|
public inRawGuild(): this is CommandInteraction<'raw'>;
|
||||||
|
public deferReply(
|
||||||
|
options: InteractionDeferReplyOptions & { withResponse: true },
|
||||||
|
): Promise<InteractionCallbackResponse>;
|
||||||
|
/** @deprecated `fetchReply` is deprecated. Use `withResponse` instead or fetch the response after using the method. */
|
||||||
public deferReply(
|
public deferReply(
|
||||||
options: InteractionDeferReplyOptions & { fetchReply: true },
|
options: InteractionDeferReplyOptions & { fetchReply: true },
|
||||||
): Promise<Message<BooleanCache<Cached>>>;
|
): Promise<Message<BooleanCache<Cached>>>;
|
||||||
@@ -597,6 +608,8 @@ export abstract class CommandInteraction<Cached extends CacheType = CacheType> e
|
|||||||
): Promise<Message<BooleanCache<Cached>>>;
|
): Promise<Message<BooleanCache<Cached>>>;
|
||||||
public fetchReply(message?: Snowflake | '@original'): Promise<Message<BooleanCache<Cached>>>;
|
public fetchReply(message?: Snowflake | '@original'): Promise<Message<BooleanCache<Cached>>>;
|
||||||
public followUp(options: string | MessagePayload | InteractionReplyOptions): Promise<Message<BooleanCache<Cached>>>;
|
public followUp(options: string | MessagePayload | InteractionReplyOptions): Promise<Message<BooleanCache<Cached>>>;
|
||||||
|
public reply(options: InteractionReplyOptions & { withResponse: true }): Promise<InteractionCallbackResponse>;
|
||||||
|
/** @deprecated `fetchReply` is deprecated. Use `withResponse` instead or fetch the response after using the method. */
|
||||||
public reply(options: InteractionReplyOptions & { fetchReply: true }): Promise<Message<BooleanCache<Cached>>>;
|
public reply(options: InteractionReplyOptions & { fetchReply: true }): Promise<Message<BooleanCache<Cached>>>;
|
||||||
public reply(
|
public reply(
|
||||||
options: string | MessagePayload | InteractionReplyOptions,
|
options: string | MessagePayload | InteractionReplyOptions,
|
||||||
@@ -606,7 +619,22 @@ export abstract class CommandInteraction<Cached extends CacheType = CacheType> e
|
|||||||
| JSONEncodable<APIModalInteractionResponseCallbackData>
|
| JSONEncodable<APIModalInteractionResponseCallbackData>
|
||||||
| ModalComponentData
|
| ModalComponentData
|
||||||
| APIModalInteractionResponseCallbackData,
|
| APIModalInteractionResponseCallbackData,
|
||||||
): Promise<void>;
|
options: ShowModalOptions & { withResponse: true },
|
||||||
|
): Promise<InteractionCallbackResponse>;
|
||||||
|
public showModal(
|
||||||
|
modal:
|
||||||
|
| JSONEncodable<APIModalInteractionResponseCallbackData>
|
||||||
|
| ModalComponentData
|
||||||
|
| APIModalInteractionResponseCallbackData,
|
||||||
|
options?: ShowModalOptions & { withResponse: true },
|
||||||
|
): Promise<InteractionCallbackResponse>;
|
||||||
|
public showModal(
|
||||||
|
modal:
|
||||||
|
| JSONEncodable<APIModalInteractionResponseCallbackData>
|
||||||
|
| ModalComponentData
|
||||||
|
| APIModalInteractionResponseCallbackData,
|
||||||
|
options?: ShowModalOptions,
|
||||||
|
): Promise<undefined>;
|
||||||
/** @deprecated Sending a premium-style button is the new Discord behaviour. */
|
/** @deprecated Sending a premium-style button is the new Discord behaviour. */
|
||||||
public sendPremiumRequired(): Promise<void>;
|
public sendPremiumRequired(): Promise<void>;
|
||||||
public awaitModalSubmit(
|
public awaitModalSubmit(
|
||||||
@@ -2008,6 +2036,33 @@ export class BaseInteraction<Cached extends CacheType = CacheType> extends Base
|
|||||||
public isRepliable(): this is RepliableInteraction<Cached>;
|
public isRepliable(): this is RepliableInteraction<Cached>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class InteractionCallback {
|
||||||
|
private constructor(client: Client<true>, data: RESTAPIInteractionCallbackObject);
|
||||||
|
public activityInstanceId: string | null;
|
||||||
|
public readonly client: Client<true>;
|
||||||
|
public get createdAt(): Date;
|
||||||
|
public get createdTimestamp(): number;
|
||||||
|
public id: Snowflake;
|
||||||
|
public responseMessageEphemeral: boolean | null;
|
||||||
|
public responseMessageId: Snowflake | null;
|
||||||
|
public responseMessageLoading: boolean | null;
|
||||||
|
public type: InteractionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class InteractionCallbackResponse {
|
||||||
|
private constructor(client: Client<true>, data: RESTPostAPIInteractionCallbackWithResponseResult);
|
||||||
|
public readonly client: Client<true>;
|
||||||
|
public interaction: InteractionCallback;
|
||||||
|
public resource: InteractionCallbackResource | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class InteractionCallbackResource {
|
||||||
|
private constructor(client: Client<true>, data: RESTAPIInteractionCallbackResourceObject);
|
||||||
|
public activityInstance: RESTAPIInteractionCallbackActivityInstanceResource | null;
|
||||||
|
public message: Message | null;
|
||||||
|
public type: InteractionResponseType;
|
||||||
|
}
|
||||||
|
|
||||||
export class InteractionCollector<Interaction extends CollectedInteraction> extends Collector<
|
export class InteractionCollector<Interaction extends CollectedInteraction> extends Collector<
|
||||||
Snowflake,
|
Snowflake,
|
||||||
Interaction,
|
Interaction,
|
||||||
@@ -2337,10 +2392,18 @@ export class MessageComponentInteraction<Cached extends CacheType = CacheType> e
|
|||||||
public inGuild(): this is MessageComponentInteraction<'raw' | 'cached'>;
|
public inGuild(): this is MessageComponentInteraction<'raw' | 'cached'>;
|
||||||
public inCachedGuild(): this is MessageComponentInteraction<'cached'>;
|
public inCachedGuild(): this is MessageComponentInteraction<'cached'>;
|
||||||
public inRawGuild(): this is MessageComponentInteraction<'raw'>;
|
public inRawGuild(): this is MessageComponentInteraction<'raw'>;
|
||||||
|
public deferReply(
|
||||||
|
options: InteractionDeferReplyOptions & { withResponse: true },
|
||||||
|
): Promise<InteractionCallbackResponse>;
|
||||||
|
/** @deprecated `fetchReply` is deprecated. Use `withResponse` instead or fetch the response after using the method. */
|
||||||
public deferReply(
|
public deferReply(
|
||||||
options: InteractionDeferReplyOptions & { fetchReply: true },
|
options: InteractionDeferReplyOptions & { fetchReply: true },
|
||||||
): Promise<Message<BooleanCache<Cached>>>;
|
): Promise<Message<BooleanCache<Cached>>>;
|
||||||
public deferReply(options?: InteractionDeferReplyOptions): Promise<InteractionResponse<BooleanCache<Cached>>>;
|
public deferReply(options?: InteractionDeferReplyOptions): Promise<InteractionResponse<BooleanCache<Cached>>>;
|
||||||
|
public deferUpdate(
|
||||||
|
options: InteractionDeferUpdateOptions & { withResponse: true },
|
||||||
|
): Promise<InteractionCallbackResponse>;
|
||||||
|
/** @deprecated `fetchReply` is deprecated. Use `withResponse` instead or fetch the response after using the method. */
|
||||||
public deferUpdate(
|
public deferUpdate(
|
||||||
options: InteractionDeferUpdateOptions & { fetchReply: true },
|
options: InteractionDeferUpdateOptions & { fetchReply: true },
|
||||||
): Promise<Message<BooleanCache<Cached>>>;
|
): Promise<Message<BooleanCache<Cached>>>;
|
||||||
@@ -2351,10 +2414,14 @@ export class MessageComponentInteraction<Cached extends CacheType = CacheType> e
|
|||||||
): Promise<Message<BooleanCache<Cached>>>;
|
): Promise<Message<BooleanCache<Cached>>>;
|
||||||
public fetchReply(message?: Snowflake | '@original'): Promise<Message<BooleanCache<Cached>>>;
|
public fetchReply(message?: Snowflake | '@original'): Promise<Message<BooleanCache<Cached>>>;
|
||||||
public followUp(options: string | MessagePayload | InteractionReplyOptions): Promise<Message<BooleanCache<Cached>>>;
|
public followUp(options: string | MessagePayload | InteractionReplyOptions): Promise<Message<BooleanCache<Cached>>>;
|
||||||
|
public reply(options: InteractionReplyOptions & { withResponse: true }): Promise<InteractionCallbackResponse>;
|
||||||
|
/** @deprecated `fetchReply` is deprecated. Use `withResponse` instead or fetch the response after using the method. */
|
||||||
public reply(options: InteractionReplyOptions & { fetchReply: true }): Promise<Message<BooleanCache<Cached>>>;
|
public reply(options: InteractionReplyOptions & { fetchReply: true }): Promise<Message<BooleanCache<Cached>>>;
|
||||||
public reply(
|
public reply(
|
||||||
options: string | MessagePayload | InteractionReplyOptions,
|
options: string | MessagePayload | InteractionReplyOptions,
|
||||||
): Promise<InteractionResponse<BooleanCache<Cached>>>;
|
): Promise<InteractionResponse<BooleanCache<Cached>>>;
|
||||||
|
public update(options: InteractionUpdateOptions & { withResponse: true }): Promise<InteractionCallbackResponse>;
|
||||||
|
/** @deprecated `fetchReply` is deprecated. Use `withResponse` instead or fetch the response after using the method. */
|
||||||
public update(options: InteractionUpdateOptions & { fetchReply: true }): Promise<Message<BooleanCache<Cached>>>;
|
public update(options: InteractionUpdateOptions & { fetchReply: true }): Promise<Message<BooleanCache<Cached>>>;
|
||||||
public update(
|
public update(
|
||||||
options: string | MessagePayload | InteractionUpdateOptions,
|
options: string | MessagePayload | InteractionUpdateOptions,
|
||||||
@@ -2364,7 +2431,22 @@ export class MessageComponentInteraction<Cached extends CacheType = CacheType> e
|
|||||||
| JSONEncodable<APIModalInteractionResponseCallbackData>
|
| JSONEncodable<APIModalInteractionResponseCallbackData>
|
||||||
| ModalComponentData
|
| ModalComponentData
|
||||||
| APIModalInteractionResponseCallbackData,
|
| APIModalInteractionResponseCallbackData,
|
||||||
): Promise<void>;
|
options: ShowModalOptions & { withResponse: true },
|
||||||
|
): Promise<InteractionCallbackResponse>;
|
||||||
|
public showModal(
|
||||||
|
modal:
|
||||||
|
| JSONEncodable<APIModalInteractionResponseCallbackData>
|
||||||
|
| ModalComponentData
|
||||||
|
| APIModalInteractionResponseCallbackData,
|
||||||
|
options?: ShowModalOptions,
|
||||||
|
): Promise<undefined>;
|
||||||
|
public showModal(
|
||||||
|
modal:
|
||||||
|
| JSONEncodable<APIModalInteractionResponseCallbackData>
|
||||||
|
| ModalComponentData
|
||||||
|
| APIModalInteractionResponseCallbackData,
|
||||||
|
options?: ShowModalOptions,
|
||||||
|
): Promise<undefined>;
|
||||||
/** @deprecated Sending a premium-style button is the new Discord behaviour. */
|
/** @deprecated Sending a premium-style button is the new Discord behaviour. */
|
||||||
public sendPremiumRequired(): Promise<void>;
|
public sendPremiumRequired(): Promise<void>;
|
||||||
public awaitModalSubmit(
|
public awaitModalSubmit(
|
||||||
@@ -2538,6 +2620,8 @@ export interface ModalMessageModalSubmitInteraction<Cached extends CacheType = C
|
|||||||
extends ModalSubmitInteraction<Cached> {
|
extends ModalSubmitInteraction<Cached> {
|
||||||
message: Message<BooleanCache<Cached>>;
|
message: Message<BooleanCache<Cached>>;
|
||||||
channelId: Snowflake;
|
channelId: Snowflake;
|
||||||
|
update(options: InteractionUpdateOptions & { withResponse: true }): Promise<InteractionCallbackResponse>;
|
||||||
|
/** @deprecated `fetchReply` is deprecated. Use `withResponse` instead or fetch the response after using the method. */
|
||||||
update(options: InteractionUpdateOptions & { fetchReply: true }): Promise<Message>;
|
update(options: InteractionUpdateOptions & { fetchReply: true }): Promise<Message>;
|
||||||
update(
|
update(
|
||||||
options: string | MessagePayload | InteractionUpdateOptions,
|
options: string | MessagePayload | InteractionUpdateOptions,
|
||||||
@@ -2558,6 +2642,8 @@ export class ModalSubmitInteraction<Cached extends CacheType = CacheType> extend
|
|||||||
public message: Message<BooleanCache<Cached>> | null;
|
public message: Message<BooleanCache<Cached>> | null;
|
||||||
public replied: boolean;
|
public replied: boolean;
|
||||||
public readonly webhook: InteractionWebhook;
|
public readonly webhook: InteractionWebhook;
|
||||||
|
public reply(options: InteractionReplyOptions & { withResponse: true }): Promise<InteractionCallbackResponse>;
|
||||||
|
/** @deprecated `fetchReply` is deprecated. Use `withResponse` instead or fetch the response after using the method. */
|
||||||
public reply(options: InteractionReplyOptions & { fetchReply: true }): Promise<Message<BooleanCache<Cached>>>;
|
public reply(options: InteractionReplyOptions & { fetchReply: true }): Promise<Message<BooleanCache<Cached>>>;
|
||||||
public reply(
|
public reply(
|
||||||
options: string | MessagePayload | InteractionReplyOptions,
|
options: string | MessagePayload | InteractionReplyOptions,
|
||||||
@@ -2566,12 +2652,20 @@ export class ModalSubmitInteraction<Cached extends CacheType = CacheType> extend
|
|||||||
public editReply(
|
public editReply(
|
||||||
options: string | MessagePayload | InteractionEditReplyOptions,
|
options: string | MessagePayload | InteractionEditReplyOptions,
|
||||||
): Promise<Message<BooleanCache<Cached>>>;
|
): Promise<Message<BooleanCache<Cached>>>;
|
||||||
|
public deferReply(
|
||||||
|
options: InteractionDeferReplyOptions & { withResponse: true },
|
||||||
|
): Promise<InteractionCallbackResponse>;
|
||||||
|
/** @deprecated `fetchReply` is deprecated. Use `withResponse` instead or fetch the response after using the method. */
|
||||||
public deferReply(
|
public deferReply(
|
||||||
options: InteractionDeferReplyOptions & { fetchReply: true },
|
options: InteractionDeferReplyOptions & { fetchReply: true },
|
||||||
): Promise<Message<BooleanCache<Cached>>>;
|
): Promise<Message<BooleanCache<Cached>>>;
|
||||||
public deferReply(options?: InteractionDeferReplyOptions): Promise<InteractionResponse<BooleanCache<Cached>>>;
|
public deferReply(options?: InteractionDeferReplyOptions): Promise<InteractionResponse<BooleanCache<Cached>>>;
|
||||||
public fetchReply(message?: Snowflake | '@original'): Promise<Message<BooleanCache<Cached>>>;
|
public fetchReply(message?: Snowflake | '@original'): Promise<Message<BooleanCache<Cached>>>;
|
||||||
public followUp(options: string | MessagePayload | InteractionReplyOptions): Promise<Message<BooleanCache<Cached>>>;
|
public followUp(options: string | MessagePayload | InteractionReplyOptions): Promise<Message<BooleanCache<Cached>>>;
|
||||||
|
public deferUpdate(
|
||||||
|
options: InteractionDeferUpdateOptions & { withResponse: true },
|
||||||
|
): Promise<InteractionCallbackResponse>;
|
||||||
|
/** @deprecated `fetchReply` is deprecated. Use `withResponse` instead or fetch the response after using the method. */
|
||||||
public deferUpdate(
|
public deferUpdate(
|
||||||
options: InteractionDeferUpdateOptions & { fetchReply: true },
|
options: InteractionDeferUpdateOptions & { fetchReply: true },
|
||||||
): Promise<Message<BooleanCache<Cached>>>;
|
): Promise<Message<BooleanCache<Cached>>>;
|
||||||
@@ -6442,10 +6536,14 @@ export interface InteractionDeferReplyOptions {
|
|||||||
Extract<MessageFlagsString, 'Ephemeral' | 'SuppressEmbeds' | 'SuppressNotifications'>,
|
Extract<MessageFlagsString, 'Ephemeral' | 'SuppressEmbeds' | 'SuppressNotifications'>,
|
||||||
MessageFlags.Ephemeral | MessageFlags.SuppressEmbeds | MessageFlags.SuppressNotifications
|
MessageFlags.Ephemeral | MessageFlags.SuppressEmbeds | MessageFlags.SuppressNotifications
|
||||||
>;
|
>;
|
||||||
|
withResponse?: boolean;
|
||||||
|
/** @deprecated Use {@link InteractionDeferReplyOptions.withResponse} instead. */
|
||||||
fetchReply?: boolean;
|
fetchReply?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface InteractionDeferUpdateOptions {
|
export interface InteractionDeferUpdateOptions {
|
||||||
|
withResponse?: boolean;
|
||||||
|
/** @deprecated Use {@link InteractionDeferUpdateOptions.withResponse} instead. */
|
||||||
fetchReply?: boolean;
|
fetchReply?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6453,6 +6551,8 @@ export interface InteractionReplyOptions extends BaseMessageOptionsWithPoll {
|
|||||||
/** @deprecated Use {@link InteractionReplyOptions.flags} instead. */
|
/** @deprecated Use {@link InteractionReplyOptions.flags} instead. */
|
||||||
ephemeral?: boolean;
|
ephemeral?: boolean;
|
||||||
tts?: boolean;
|
tts?: boolean;
|
||||||
|
withResponse?: boolean;
|
||||||
|
/** @deprecated Use {@link InteractionReplyOptions.withResponse} instead. */
|
||||||
fetchReply?: boolean;
|
fetchReply?: boolean;
|
||||||
flags?: BitFieldResolvable<
|
flags?: BitFieldResolvable<
|
||||||
Extract<MessageFlagsString, 'Ephemeral' | 'SuppressEmbeds' | 'SuppressNotifications'>,
|
Extract<MessageFlagsString, 'Ephemeral' | 'SuppressEmbeds' | 'SuppressNotifications'>,
|
||||||
@@ -6461,6 +6561,8 @@ export interface InteractionReplyOptions extends BaseMessageOptionsWithPoll {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface InteractionUpdateOptions extends MessageEditOptions {
|
export interface InteractionUpdateOptions extends MessageEditOptions {
|
||||||
|
withResponse?: boolean;
|
||||||
|
/** @deprecated Use {@link InteractionUpdateOptions.withResponse} instead. */
|
||||||
fetchReply?: boolean;
|
fetchReply?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6972,6 +7074,10 @@ export interface ShardingManagerOptions {
|
|||||||
execArgv?: readonly string[];
|
execArgv?: readonly string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ShowModalOptions {
|
||||||
|
withResponse?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export { Snowflake };
|
export { Snowflake };
|
||||||
|
|
||||||
export type StageInstanceResolvable = StageInstance | Snowflake;
|
export type StageInstanceResolvable = StageInstance | Snowflake;
|
||||||
|
|||||||
@@ -213,6 +213,7 @@ import {
|
|||||||
SendableChannels,
|
SendableChannels,
|
||||||
PollData,
|
PollData,
|
||||||
UserManager,
|
UserManager,
|
||||||
|
InteractionCallbackResponse,
|
||||||
} from '.';
|
} from '.';
|
||||||
import {
|
import {
|
||||||
expectAssignable,
|
expectAssignable,
|
||||||
@@ -445,6 +446,7 @@ client.on('messageCreate', async message => {
|
|||||||
const component = await message.awaitMessageComponent({ componentType: ComponentType.Button });
|
const component = await message.awaitMessageComponent({ componentType: ComponentType.Button });
|
||||||
expectType<ButtonInteraction<'cached'>>(component);
|
expectType<ButtonInteraction<'cached'>>(component);
|
||||||
expectType<Message<true>>(await component.reply({ fetchReply: true }));
|
expectType<Message<true>>(await component.reply({ fetchReply: true }));
|
||||||
|
expectType<InteractionCallbackResponse>(await component.reply({ withResponse: true }));
|
||||||
|
|
||||||
const buttonCollector = message.createMessageComponentCollector({ componentType: ComponentType.Button });
|
const buttonCollector = message.createMessageComponentCollector({ componentType: ComponentType.Button });
|
||||||
expectType<InteractionCollector<ButtonInteraction<'cached'>>>(buttonCollector);
|
expectType<InteractionCollector<ButtonInteraction<'cached'>>>(buttonCollector);
|
||||||
@@ -1812,10 +1814,14 @@ client.on('interactionCreate', async interaction => {
|
|||||||
expectType<Guild>(interaction.guild);
|
expectType<Guild>(interaction.guild);
|
||||||
expectType<Promise<Message<true>>>(interaction.reply({ content: 'a', fetchReply: true }));
|
expectType<Promise<Message<true>>>(interaction.reply({ content: 'a', fetchReply: true }));
|
||||||
expectType<Promise<Message<true>>>(interaction.deferReply({ fetchReply: true }));
|
expectType<Promise<Message<true>>>(interaction.deferReply({ fetchReply: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.reply({ content: 'a', withResponse: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.deferReply({ withResponse: true }));
|
||||||
expectType<Promise<Message<true>>>(interaction.editReply({ content: 'a' }));
|
expectType<Promise<Message<true>>>(interaction.editReply({ content: 'a' }));
|
||||||
expectType<Promise<Message<true>>>(interaction.fetchReply());
|
expectType<Promise<Message<true>>>(interaction.fetchReply());
|
||||||
expectType<Promise<Message<true>>>(interaction.update({ content: 'a', fetchReply: true }));
|
expectType<Promise<Message<true>>>(interaction.update({ content: 'a', fetchReply: true }));
|
||||||
expectType<Promise<Message<true>>>(interaction.deferUpdate({ fetchReply: true }));
|
expectType<Promise<Message<true>>>(interaction.deferUpdate({ fetchReply: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.update({ content: 'a', withResponse: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.deferUpdate({ withResponse: true }));
|
||||||
expectType<Promise<Message<true>>>(interaction.followUp({ content: 'a' }));
|
expectType<Promise<Message<true>>>(interaction.followUp({ content: 'a' }));
|
||||||
} else if (interaction.inRawGuild()) {
|
} else if (interaction.inRawGuild()) {
|
||||||
expectAssignable<MessageComponentInteraction>(interaction);
|
expectAssignable<MessageComponentInteraction>(interaction);
|
||||||
@@ -1824,10 +1830,14 @@ client.on('interactionCreate', async interaction => {
|
|||||||
expectType<null>(interaction.guild);
|
expectType<null>(interaction.guild);
|
||||||
expectType<Promise<Message<false>>>(interaction.reply({ content: 'a', fetchReply: true }));
|
expectType<Promise<Message<false>>>(interaction.reply({ content: 'a', fetchReply: true }));
|
||||||
expectType<Promise<Message<false>>>(interaction.deferReply({ fetchReply: true }));
|
expectType<Promise<Message<false>>>(interaction.deferReply({ fetchReply: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.reply({ content: 'a', withResponse: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.deferReply({ withResponse: true }));
|
||||||
expectType<Promise<Message<false>>>(interaction.editReply({ content: 'a' }));
|
expectType<Promise<Message<false>>>(interaction.editReply({ content: 'a' }));
|
||||||
expectType<Promise<Message<false>>>(interaction.fetchReply());
|
expectType<Promise<Message<false>>>(interaction.fetchReply());
|
||||||
expectType<Promise<Message<false>>>(interaction.update({ content: 'a', fetchReply: true }));
|
expectType<Promise<Message<false>>>(interaction.update({ content: 'a', fetchReply: true }));
|
||||||
expectType<Promise<Message<false>>>(interaction.deferUpdate({ fetchReply: true }));
|
expectType<Promise<Message<false>>>(interaction.deferUpdate({ fetchReply: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.update({ content: 'a', withResponse: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.deferUpdate({ withResponse: true }));
|
||||||
expectType<Promise<Message<false>>>(interaction.followUp({ content: 'a' }));
|
expectType<Promise<Message<false>>>(interaction.followUp({ content: 'a' }));
|
||||||
} else if (interaction.inGuild()) {
|
} else if (interaction.inGuild()) {
|
||||||
expectAssignable<MessageComponentInteraction>(interaction);
|
expectAssignable<MessageComponentInteraction>(interaction);
|
||||||
@@ -1836,10 +1846,14 @@ client.on('interactionCreate', async interaction => {
|
|||||||
expectType<Guild | null>(interaction.guild);
|
expectType<Guild | null>(interaction.guild);
|
||||||
expectType<Promise<Message>>(interaction.reply({ content: 'a', fetchReply: true }));
|
expectType<Promise<Message>>(interaction.reply({ content: 'a', fetchReply: true }));
|
||||||
expectType<Promise<Message>>(interaction.deferReply({ fetchReply: true }));
|
expectType<Promise<Message>>(interaction.deferReply({ fetchReply: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.reply({ content: 'a', withResponse: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.deferReply({ withResponse: true }));
|
||||||
expectType<Promise<Message>>(interaction.editReply({ content: 'a' }));
|
expectType<Promise<Message>>(interaction.editReply({ content: 'a' }));
|
||||||
expectType<Promise<Message>>(interaction.fetchReply());
|
expectType<Promise<Message>>(interaction.fetchReply());
|
||||||
expectType<Promise<Message>>(interaction.update({ content: 'a', fetchReply: true }));
|
expectType<Promise<Message>>(interaction.update({ content: 'a', fetchReply: true }));
|
||||||
expectType<Promise<Message>>(interaction.deferUpdate({ fetchReply: true }));
|
expectType<Promise<Message>>(interaction.deferUpdate({ fetchReply: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.update({ content: 'a', withResponse: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.deferUpdate({ withResponse: true }));
|
||||||
expectType<Promise<Message>>(interaction.followUp({ content: 'a' }));
|
expectType<Promise<Message>>(interaction.followUp({ content: 'a' }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1875,6 +1889,8 @@ client.on('interactionCreate', async interaction => {
|
|||||||
expectAssignable<CommandInteraction<'cached'>>(interaction);
|
expectAssignable<CommandInteraction<'cached'>>(interaction);
|
||||||
expectType<Promise<Message<true>>>(interaction.reply({ content: 'a', fetchReply: true }));
|
expectType<Promise<Message<true>>>(interaction.reply({ content: 'a', fetchReply: true }));
|
||||||
expectType<Promise<Message<true>>>(interaction.deferReply({ fetchReply: true }));
|
expectType<Promise<Message<true>>>(interaction.deferReply({ fetchReply: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.reply({ content: 'a', withResponse: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.deferReply({ withResponse: true }));
|
||||||
expectType<Promise<Message<true>>>(interaction.editReply({ content: 'a' }));
|
expectType<Promise<Message<true>>>(interaction.editReply({ content: 'a' }));
|
||||||
expectType<Promise<Message<true>>>(interaction.fetchReply());
|
expectType<Promise<Message<true>>>(interaction.fetchReply());
|
||||||
expectType<Promise<Message<true>>>(interaction.followUp({ content: 'a' }));
|
expectType<Promise<Message<true>>>(interaction.followUp({ content: 'a' }));
|
||||||
@@ -1883,6 +1899,8 @@ client.on('interactionCreate', async interaction => {
|
|||||||
expectType<null>(interaction.guild);
|
expectType<null>(interaction.guild);
|
||||||
expectType<Promise<Message<false>>>(interaction.reply({ content: 'a', fetchReply: true }));
|
expectType<Promise<Message<false>>>(interaction.reply({ content: 'a', fetchReply: true }));
|
||||||
expectType<Promise<Message<false>>>(interaction.deferReply({ fetchReply: true }));
|
expectType<Promise<Message<false>>>(interaction.deferReply({ fetchReply: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.reply({ content: 'a', withResponse: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.deferReply({ withResponse: true }));
|
||||||
expectType<Promise<Message<false>>>(interaction.editReply({ content: 'a' }));
|
expectType<Promise<Message<false>>>(interaction.editReply({ content: 'a' }));
|
||||||
expectType<Promise<Message<false>>>(interaction.fetchReply());
|
expectType<Promise<Message<false>>>(interaction.fetchReply());
|
||||||
expectType<Promise<Message<false>>>(interaction.followUp({ content: 'a' }));
|
expectType<Promise<Message<false>>>(interaction.followUp({ content: 'a' }));
|
||||||
@@ -1891,6 +1909,8 @@ client.on('interactionCreate', async interaction => {
|
|||||||
expectType<Guild | null>(interaction.guild);
|
expectType<Guild | null>(interaction.guild);
|
||||||
expectType<Promise<Message>>(interaction.reply({ content: 'a', fetchReply: true }));
|
expectType<Promise<Message>>(interaction.reply({ content: 'a', fetchReply: true }));
|
||||||
expectType<Promise<Message>>(interaction.deferReply({ fetchReply: true }));
|
expectType<Promise<Message>>(interaction.deferReply({ fetchReply: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.reply({ content: 'a', withResponse: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.deferReply({ withResponse: true }));
|
||||||
expectType<Promise<Message>>(interaction.editReply({ content: 'a' }));
|
expectType<Promise<Message>>(interaction.editReply({ content: 'a' }));
|
||||||
expectType<Promise<Message>>(interaction.fetchReply());
|
expectType<Promise<Message>>(interaction.fetchReply());
|
||||||
expectType<Promise<Message>>(interaction.followUp({ content: 'a' }));
|
expectType<Promise<Message>>(interaction.followUp({ content: 'a' }));
|
||||||
@@ -1945,18 +1965,21 @@ client.on('interactionCreate', async interaction => {
|
|||||||
expectType<Message<true>>(interaction.message);
|
expectType<Message<true>>(interaction.message);
|
||||||
expectType<Guild>(interaction.guild);
|
expectType<Guild>(interaction.guild);
|
||||||
expectType<Promise<Message<true>>>(interaction.reply({ fetchReply: true }));
|
expectType<Promise<Message<true>>>(interaction.reply({ fetchReply: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.reply({ withResponse: true }));
|
||||||
} else if (interaction.inRawGuild()) {
|
} else if (interaction.inRawGuild()) {
|
||||||
expectAssignable<ButtonInteraction>(interaction);
|
expectAssignable<ButtonInteraction>(interaction);
|
||||||
expectType<APIButtonComponent>(interaction.component);
|
expectType<APIButtonComponent>(interaction.component);
|
||||||
expectType<Message<false>>(interaction.message);
|
expectType<Message<false>>(interaction.message);
|
||||||
expectType<null>(interaction.guild);
|
expectType<null>(interaction.guild);
|
||||||
expectType<Promise<Message<false>>>(interaction.reply({ fetchReply: true }));
|
expectType<Promise<Message<false>>>(interaction.reply({ fetchReply: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.reply({ withResponse: true }));
|
||||||
} else if (interaction.inGuild()) {
|
} else if (interaction.inGuild()) {
|
||||||
expectAssignable<ButtonInteraction>(interaction);
|
expectAssignable<ButtonInteraction>(interaction);
|
||||||
expectType<ButtonComponent | APIButtonComponent>(interaction.component);
|
expectType<ButtonComponent | APIButtonComponent>(interaction.component);
|
||||||
expectType<Message>(interaction.message);
|
expectType<Message>(interaction.message);
|
||||||
expectAssignable<Guild | null>(interaction.guild);
|
expectAssignable<Guild | null>(interaction.guild);
|
||||||
expectType<Promise<Message>>(interaction.reply({ fetchReply: true }));
|
expectType<Promise<Message>>(interaction.reply({ fetchReply: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.reply({ withResponse: true }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1973,18 +1996,21 @@ client.on('interactionCreate', async interaction => {
|
|||||||
expectType<Message<true>>(interaction.message);
|
expectType<Message<true>>(interaction.message);
|
||||||
expectType<Guild>(interaction.guild);
|
expectType<Guild>(interaction.guild);
|
||||||
expectType<Promise<Message<true>>>(interaction.reply({ fetchReply: true }));
|
expectType<Promise<Message<true>>>(interaction.reply({ fetchReply: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.reply({ withResponse: true }));
|
||||||
} else if (interaction.inRawGuild()) {
|
} else if (interaction.inRawGuild()) {
|
||||||
expectAssignable<StringSelectMenuInteraction>(interaction);
|
expectAssignable<StringSelectMenuInteraction>(interaction);
|
||||||
expectType<APIStringSelectComponent>(interaction.component);
|
expectType<APIStringSelectComponent>(interaction.component);
|
||||||
expectType<Message<false>>(interaction.message);
|
expectType<Message<false>>(interaction.message);
|
||||||
expectType<null>(interaction.guild);
|
expectType<null>(interaction.guild);
|
||||||
expectType<Promise<Message<false>>>(interaction.reply({ fetchReply: true }));
|
expectType<Promise<Message<false>>>(interaction.reply({ fetchReply: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.reply({ withResponse: true }));
|
||||||
} else if (interaction.inGuild()) {
|
} else if (interaction.inGuild()) {
|
||||||
expectAssignable<StringSelectMenuInteraction>(interaction);
|
expectAssignable<StringSelectMenuInteraction>(interaction);
|
||||||
expectType<SelectMenuComponent | APIStringSelectComponent>(interaction.component);
|
expectType<SelectMenuComponent | APIStringSelectComponent>(interaction.component);
|
||||||
expectType<Message>(interaction.message);
|
expectType<Message>(interaction.message);
|
||||||
expectType<Guild | null>(interaction.guild);
|
expectType<Guild | null>(interaction.guild);
|
||||||
expectType<Promise<Message>>(interaction.reply({ fetchReply: true }));
|
expectType<Promise<Message>>(interaction.reply({ fetchReply: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.reply({ withResponse: true }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1997,6 +2023,7 @@ client.on('interactionCreate', async interaction => {
|
|||||||
expectNotAssignable<Interaction<'cached'>>(interaction);
|
expectNotAssignable<Interaction<'cached'>>(interaction);
|
||||||
expectAssignable<ChatInputCommandInteraction>(interaction);
|
expectAssignable<ChatInputCommandInteraction>(interaction);
|
||||||
expectType<Promise<Message<false>>>(interaction.reply({ fetchReply: true }));
|
expectType<Promise<Message<false>>>(interaction.reply({ fetchReply: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.reply({ withResponse: true }));
|
||||||
expectType<APIInteractionDataResolvedGuildMember | null>(interaction.options.getMember('test'));
|
expectType<APIInteractionDataResolvedGuildMember | null>(interaction.options.getMember('test'));
|
||||||
|
|
||||||
expectType<APIInteractionDataResolvedChannel>(interaction.options.getChannel('test', true));
|
expectType<APIInteractionDataResolvedChannel>(interaction.options.getChannel('test', true));
|
||||||
@@ -2011,6 +2038,7 @@ client.on('interactionCreate', async interaction => {
|
|||||||
expectType<GuildMember | null>(interaction.options.getMember('test'));
|
expectType<GuildMember | null>(interaction.options.getMember('test'));
|
||||||
expectAssignable<ChatInputCommandInteraction>(interaction);
|
expectAssignable<ChatInputCommandInteraction>(interaction);
|
||||||
expectType<Promise<Message<true>>>(interaction.reply({ fetchReply: true }));
|
expectType<Promise<Message<true>>>(interaction.reply({ fetchReply: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.reply({ withResponse: true }));
|
||||||
|
|
||||||
expectType<GuildBasedChannel>(interaction.options.getChannel('test', true));
|
expectType<GuildBasedChannel>(interaction.options.getChannel('test', true));
|
||||||
expectType<Role>(interaction.options.getRole('test', true));
|
expectType<Role>(interaction.options.getRole('test', true));
|
||||||
@@ -2035,6 +2063,7 @@ client.on('interactionCreate', async interaction => {
|
|||||||
} else {
|
} else {
|
||||||
expectType<ChatInputCommandInteraction>(interaction);
|
expectType<ChatInputCommandInteraction>(interaction);
|
||||||
expectType<Promise<Message>>(interaction.reply({ fetchReply: true }));
|
expectType<Promise<Message>>(interaction.reply({ fetchReply: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.reply({ withResponse: true }));
|
||||||
expectType<APIInteractionDataResolvedGuildMember | GuildMember | null>(interaction.options.getMember('test'));
|
expectType<APIInteractionDataResolvedGuildMember | GuildMember | null>(interaction.options.getMember('test'));
|
||||||
|
|
||||||
expectType<GuildBasedChannel | APIInteractionDataResolvedChannel>(interaction.options.getChannel('test', true));
|
expectType<GuildBasedChannel | APIInteractionDataResolvedChannel>(interaction.options.getChannel('test', true));
|
||||||
@@ -2090,27 +2119,36 @@ client.on('interactionCreate', async interaction => {
|
|||||||
expectType<Guild>(interaction.guild);
|
expectType<Guild>(interaction.guild);
|
||||||
expectType<Promise<Message<true>>>(interaction.reply({ content: 'a', fetchReply: true }));
|
expectType<Promise<Message<true>>>(interaction.reply({ content: 'a', fetchReply: true }));
|
||||||
expectType<Promise<Message<true>>>(interaction.deferReply({ fetchReply: true }));
|
expectType<Promise<Message<true>>>(interaction.deferReply({ fetchReply: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.reply({ content: 'a', withResponse: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.deferReply({ withResponse: true }));
|
||||||
expectType<Promise<Message<true>>>(interaction.editReply({ content: 'a' }));
|
expectType<Promise<Message<true>>>(interaction.editReply({ content: 'a' }));
|
||||||
expectType<Promise<Message<true>>>(interaction.fetchReply());
|
expectType<Promise<Message<true>>>(interaction.fetchReply());
|
||||||
expectType<Promise<Message<true>>>(interaction.deferUpdate({ fetchReply: true }));
|
expectType<Promise<Message<true>>>(interaction.deferUpdate({ fetchReply: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.deferUpdate({ withResponse: true }));
|
||||||
expectType<Promise<Message<true>>>(interaction.followUp({ content: 'a' }));
|
expectType<Promise<Message<true>>>(interaction.followUp({ content: 'a' }));
|
||||||
} else if (interaction.inRawGuild()) {
|
} else if (interaction.inRawGuild()) {
|
||||||
expectAssignable<ModalSubmitInteraction>(interaction);
|
expectAssignable<ModalSubmitInteraction>(interaction);
|
||||||
expectType<null>(interaction.guild);
|
expectType<null>(interaction.guild);
|
||||||
expectType<Promise<Message<false>>>(interaction.reply({ content: 'a', fetchReply: true }));
|
expectType<Promise<Message<false>>>(interaction.reply({ content: 'a', fetchReply: true }));
|
||||||
expectType<Promise<Message<false>>>(interaction.deferReply({ fetchReply: true }));
|
expectType<Promise<Message<false>>>(interaction.deferReply({ fetchReply: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.reply({ content: 'a', withResponse: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.deferReply({ withResponse: true }));
|
||||||
expectType<Promise<Message<false>>>(interaction.editReply({ content: 'a' }));
|
expectType<Promise<Message<false>>>(interaction.editReply({ content: 'a' }));
|
||||||
expectType<Promise<Message<false>>>(interaction.fetchReply());
|
expectType<Promise<Message<false>>>(interaction.fetchReply());
|
||||||
expectType<Promise<Message<false>>>(interaction.deferUpdate({ fetchReply: true }));
|
expectType<Promise<Message<false>>>(interaction.deferUpdate({ fetchReply: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.deferUpdate({ withResponse: true }));
|
||||||
expectType<Promise<Message<false>>>(interaction.followUp({ content: 'a' }));
|
expectType<Promise<Message<false>>>(interaction.followUp({ content: 'a' }));
|
||||||
} else if (interaction.inGuild()) {
|
} else if (interaction.inGuild()) {
|
||||||
expectAssignable<ModalSubmitInteraction>(interaction);
|
expectAssignable<ModalSubmitInteraction>(interaction);
|
||||||
expectType<Guild | null>(interaction.guild);
|
expectType<Guild | null>(interaction.guild);
|
||||||
expectType<Promise<Message>>(interaction.reply({ content: 'a', fetchReply: true }));
|
expectType<Promise<Message>>(interaction.reply({ content: 'a', fetchReply: true }));
|
||||||
expectType<Promise<Message>>(interaction.deferReply({ fetchReply: true }));
|
expectType<Promise<Message>>(interaction.deferReply({ fetchReply: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.reply({ content: 'a', withResponse: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.deferReply({ withResponse: true }));
|
||||||
expectType<Promise<Message>>(interaction.editReply({ content: 'a' }));
|
expectType<Promise<Message>>(interaction.editReply({ content: 'a' }));
|
||||||
expectType<Promise<Message>>(interaction.fetchReply());
|
expectType<Promise<Message>>(interaction.fetchReply());
|
||||||
expectType<Promise<Message>>(interaction.deferUpdate({ fetchReply: true }));
|
expectType<Promise<Message>>(interaction.deferUpdate({ fetchReply: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.deferUpdate({ withResponse: true }));
|
||||||
expectType<Promise<Message>>(interaction.followUp({ content: 'a' }));
|
expectType<Promise<Message>>(interaction.followUp({ content: 'a' }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user