mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat: entry-point command (#10640)
* feat: entry point command * chore: update tests * chore: suggested change * chore: suggestion Co-authored-by: Almeida <github@almeidx.dev> * chore: suggestion Co-authored-by: Almeida <github@almeidx.dev> * chore: suggestion Co-authored-by: Almeida <github@almeidx.dev> * chore: suggestion Co-authored-by: Almeida <github@almeidx.dev> * chore: suggestion Co-authored-by: Almeida <github@almeidx.dev> * chore: remove extra info closing tag --------- Co-authored-by: Almeida <github@almeidx.dev> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -9,6 +9,7 @@ const { ChatInputCommandInteraction } = require('../../structures/ChatInputComma
|
|||||||
const { MentionableSelectMenuInteraction } = require('../../structures/MentionableSelectMenuInteraction.js');
|
const { MentionableSelectMenuInteraction } = require('../../structures/MentionableSelectMenuInteraction.js');
|
||||||
const { MessageContextMenuCommandInteraction } = require('../../structures/MessageContextMenuCommandInteraction.js');
|
const { MessageContextMenuCommandInteraction } = require('../../structures/MessageContextMenuCommandInteraction.js');
|
||||||
const { ModalSubmitInteraction } = require('../../structures/ModalSubmitInteraction.js');
|
const { ModalSubmitInteraction } = require('../../structures/ModalSubmitInteraction.js');
|
||||||
|
const { PrimaryEntryPointCommandInteraction } = require('../../structures/PrimaryEntryPointCommandInteraction.js');
|
||||||
const { RoleSelectMenuInteraction } = require('../../structures/RoleSelectMenuInteraction.js');
|
const { RoleSelectMenuInteraction } = require('../../structures/RoleSelectMenuInteraction.js');
|
||||||
const { StringSelectMenuInteraction } = require('../../structures/StringSelectMenuInteraction.js');
|
const { StringSelectMenuInteraction } = require('../../structures/StringSelectMenuInteraction.js');
|
||||||
const { UserContextMenuCommandInteraction } = require('../../structures/UserContextMenuCommandInteraction.js');
|
const { UserContextMenuCommandInteraction } = require('../../structures/UserContextMenuCommandInteraction.js');
|
||||||
@@ -38,6 +39,9 @@ class InteractionCreateAction extends Action {
|
|||||||
if (channel && !channel.isTextBased()) return;
|
if (channel && !channel.isTextBased()) return;
|
||||||
InteractionClass = MessageContextMenuCommandInteraction;
|
InteractionClass = MessageContextMenuCommandInteraction;
|
||||||
break;
|
break;
|
||||||
|
case ApplicationCommandType.PrimaryEntryPoint:
|
||||||
|
InteractionClass = PrimaryEntryPointCommandInteraction;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
client.emit(
|
client.emit(
|
||||||
Events.Debug,
|
Events.Debug,
|
||||||
|
|||||||
@@ -186,6 +186,8 @@ exports.PartialGroupDMChannel = require('./structures/PartialGroupDMChannel.js')
|
|||||||
exports.PermissionOverwrites = require('./structures/PermissionOverwrites.js').PermissionOverwrites;
|
exports.PermissionOverwrites = require('./structures/PermissionOverwrites.js').PermissionOverwrites;
|
||||||
exports.Poll = require('./structures/Poll.js').Poll;
|
exports.Poll = require('./structures/Poll.js').Poll;
|
||||||
exports.PollAnswer = require('./structures/PollAnswer.js').PollAnswer;
|
exports.PollAnswer = require('./structures/PollAnswer.js').PollAnswer;
|
||||||
|
exports.PrimaryEntryPointCommandInteraction =
|
||||||
|
require('./structures/PrimaryEntryPointCommandInteraction.js').PrimaryEntryPointCommandInteraction;
|
||||||
exports.Presence = require('./structures/Presence.js').Presence;
|
exports.Presence = require('./structures/Presence.js').Presence;
|
||||||
exports.ReactionCollector = require('./structures/ReactionCollector.js').ReactionCollector;
|
exports.ReactionCollector = require('./structures/ReactionCollector.js').ReactionCollector;
|
||||||
exports.ReactionEmoji = require('./structures/ReactionEmoji.js').ReactionEmoji;
|
exports.ReactionEmoji = require('./structures/ReactionEmoji.js').ReactionEmoji;
|
||||||
|
|||||||
@@ -282,6 +282,7 @@ class ApplicationCommandManager extends CachedManager {
|
|||||||
default_member_permissions,
|
default_member_permissions,
|
||||||
integration_types: command.integrationTypes ?? command.integration_types,
|
integration_types: command.integrationTypes ?? command.integration_types,
|
||||||
contexts: command.contexts,
|
contexts: command.contexts,
|
||||||
|
handler: command.handler,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -162,6 +162,18 @@ class ApplicationCommand extends Base {
|
|||||||
this.contexts ??= null;
|
this.contexts ??= null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ('handler' in data) {
|
||||||
|
/**
|
||||||
|
* Determines whether the interaction is handled by the app's interactions handler or by Discord.
|
||||||
|
* <info>Only available for {@link ApplicationCommandType.PrimaryEntryPoint} commands on
|
||||||
|
* applications with the {@link ApplicationFlags.Embedded} flag (i.e, those that have an Activity)</info>
|
||||||
|
* @type {?EntryPointCommandHandlerType}
|
||||||
|
*/
|
||||||
|
this.handler = data.handler;
|
||||||
|
} else {
|
||||||
|
this.handler ??= null;
|
||||||
|
}
|
||||||
|
|
||||||
if ('version' in data) {
|
if ('version' in data) {
|
||||||
/**
|
/**
|
||||||
* Autoincrementing version identifier updated during substantial record changes
|
* Autoincrementing version identifier updated during substantial record changes
|
||||||
@@ -204,14 +216,19 @@ class ApplicationCommand extends Base {
|
|||||||
* @property {string} name The name of the command, must be in all lowercase if type is
|
* @property {string} name The name of the command, must be in all lowercase if type is
|
||||||
* {@link ApplicationCommandType.ChatInput}
|
* {@link ApplicationCommandType.ChatInput}
|
||||||
* @property {Object<Locale, string>} [nameLocalizations] The localizations for the command name
|
* @property {Object<Locale, string>} [nameLocalizations] The localizations for the command name
|
||||||
* @property {string} description The description of the command, if type is {@link ApplicationCommandType.ChatInput}
|
* @property {string} description The description of the command,
|
||||||
|
* if type is {@link ApplicationCommandType.ChatInput} or {@link ApplicationCommandType.PrimaryEntryPoint}
|
||||||
* @property {boolean} [nsfw] Whether the command is age-restricted
|
* @property {boolean} [nsfw] Whether the command is age-restricted
|
||||||
* @property {Object<Locale, string>} [descriptionLocalizations] The localizations for the command description,
|
* @property {Object<Locale, string>} [descriptionLocalizations] The localizations for the command description,
|
||||||
* if type is {@link ApplicationCommandType.ChatInput}
|
* if type is {@link ApplicationCommandType.ChatInput} or {@link ApplicationCommandType.PrimaryEntryPoint}
|
||||||
* @property {ApplicationCommandType} [type=ApplicationCommandType.ChatInput] The type of the command
|
* @property {ApplicationCommandType} [type=ApplicationCommandType.ChatInput] The type of the command
|
||||||
* @property {ApplicationCommandOptionData[]} [options] Options for the command
|
* @property {ApplicationCommandOptionData[]} [options] Options for the command
|
||||||
* @property {?PermissionResolvable} [defaultMemberPermissions] The bitfield used to determine the default permissions
|
* @property {?PermissionResolvable} [defaultMemberPermissions] The bitfield used to determine the default permissions
|
||||||
* a member needs in order to run the command
|
* a member needs in order to run the command
|
||||||
|
* @property {ApplicationIntegrationType[]} [integrationTypes] Installation contexts where the command is available
|
||||||
|
* @property {InteractionContextType[]} [contexts] Interaction contexts where the command can be used
|
||||||
|
* @property {EntryPointCommandHandlerType} [handler] Whether the interaction is handled by the app's
|
||||||
|
* interactions handler or by Discord.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -395,7 +412,8 @@ class ApplicationCommand extends Base {
|
|||||||
this.descriptionLocalizations ?? {},
|
this.descriptionLocalizations ?? {},
|
||||||
) ||
|
) ||
|
||||||
!isEqual(command.integrationTypes ?? command.integration_types ?? [], this.integrationTypes ?? []) ||
|
!isEqual(command.integrationTypes ?? command.integration_types ?? [], this.integrationTypes ?? []) ||
|
||||||
!isEqual(command.contexts ?? [], this.contexts ?? [])
|
!isEqual(command.contexts ?? [], this.contexts ?? []) ||
|
||||||
|
('handler' in command && command.handler !== this.handler)
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -224,6 +224,16 @@ class BaseInteraction extends Base {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether this interaction is a {@link PrimaryEntryPointCommandInteraction}
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
isPrimaryEntryPointCommand() {
|
||||||
|
return (
|
||||||
|
this.type === InteractionType.ApplicationCommand && this.commandType === ApplicationCommandType.PrimaryEntryPoint
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether this interaction is a {@link MessageComponentInteraction}
|
* Indicates whether this interaction is a {@link MessageComponentInteraction}
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
|
|||||||
@@ -152,6 +152,7 @@ class CommandInteraction extends BaseInteraction {
|
|||||||
editReply() {}
|
editReply() {}
|
||||||
deleteReply() {}
|
deleteReply() {}
|
||||||
followUp() {}
|
followUp() {}
|
||||||
|
launchActivity() {}
|
||||||
showModal() {}
|
showModal() {}
|
||||||
awaitModalSubmit() {}
|
awaitModalSubmit() {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ class MessageComponentInteraction extends BaseInteraction {
|
|||||||
followUp() {}
|
followUp() {}
|
||||||
deferUpdate() {}
|
deferUpdate() {}
|
||||||
update() {}
|
update() {}
|
||||||
|
launchActivity() {}
|
||||||
showModal() {}
|
showModal() {}
|
||||||
awaitModalSubmit() {}
|
awaitModalSubmit() {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ class ModalSubmitInteraction extends BaseInteraction {
|
|||||||
followUp() {}
|
followUp() {}
|
||||||
deferUpdate() {}
|
deferUpdate() {}
|
||||||
update() {}
|
update() {}
|
||||||
|
launchActivity() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
InteractionResponses.applyToClass(ModalSubmitInteraction, 'showModal');
|
InteractionResponses.applyToClass(ModalSubmitInteraction, 'showModal');
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const { CommandInteraction } = require('./CommandInteraction.js');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a primary entry point command interaction.
|
||||||
|
* @extends {CommandInteraction}
|
||||||
|
*/
|
||||||
|
class PrimaryEntryPointCommandInteraction extends CommandInteraction {}
|
||||||
|
|
||||||
|
exports.PrimaryEntryPointCommandInteraction = PrimaryEntryPointCommandInteraction;
|
||||||
@@ -51,6 +51,12 @@ class InteractionResponses {
|
|||||||
* @property {boolean} [withResponse] Whether to return an {@link InteractionCallbackResponse} as the response
|
* @property {boolean} [withResponse] Whether to return an {@link InteractionCallbackResponse} as the response
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options for launching activity in response to a {@link BaseInteraction}
|
||||||
|
* @typedef {Object} LaunchActivityOptions
|
||||||
|
* @property {boolean} [withResponse] Whether to return an {@link InteractionCallbackResponse} as the response
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options for showing a modal in response to a {@link BaseInteraction}
|
* Options for showing a modal in response to a {@link BaseInteraction}
|
||||||
* @typedef {Object} ShowModalOptions
|
* @typedef {Object} ShowModalOptions
|
||||||
@@ -265,6 +271,25 @@ class InteractionResponses {
|
|||||||
return options.withResponse ? new InteractionCallbackResponse(this.client, response) : undefined;
|
return options.withResponse ? new InteractionCallbackResponse(this.client, response) : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launches this application's activity, if enabled
|
||||||
|
* @param {LaunchActivityOptions} [options={}] Options for launching the activity
|
||||||
|
* @returns {Promise<InteractionCallbackResponse|undefined>}
|
||||||
|
*/
|
||||||
|
async launchActivity({ withResponse } = {}) {
|
||||||
|
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
|
||||||
|
const response = await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
|
||||||
|
query: makeURLSearchParams({ with_response: withResponse ?? false }),
|
||||||
|
body: {
|
||||||
|
type: InteractionResponseType.LaunchActivity,
|
||||||
|
},
|
||||||
|
auth: false,
|
||||||
|
});
|
||||||
|
this.replied = true;
|
||||||
|
|
||||||
|
return withResponse ? new InteractionCallbackResponse(this.client, response) : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
@@ -328,6 +353,7 @@ class InteractionResponses {
|
|||||||
'followUp',
|
'followUp',
|
||||||
'deferUpdate',
|
'deferUpdate',
|
||||||
'update',
|
'update',
|
||||||
|
'launchActivity',
|
||||||
'showModal',
|
'showModal',
|
||||||
'awaitModalSubmit',
|
'awaitModalSubmit',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -325,6 +325,11 @@
|
|||||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/EntitlementType}
|
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/EntitlementType}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @external EntryPointCommandHandlerType
|
||||||
|
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/EntryPointCommandHandlerType}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @external ForumLayoutType
|
* @external ForumLayoutType
|
||||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/ForumLayoutType}
|
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/ForumLayoutType}
|
||||||
|
|||||||
82
packages/discord.js/typings/index.d.ts
vendored
82
packages/discord.js/typings/index.d.ts
vendored
@@ -159,6 +159,7 @@ import {
|
|||||||
VoiceChannelEffectSendAnimationType,
|
VoiceChannelEffectSendAnimationType,
|
||||||
GatewayVoiceChannelEffectSendDispatchData,
|
GatewayVoiceChannelEffectSendDispatchData,
|
||||||
RESTAPIPoll,
|
RESTAPIPoll,
|
||||||
|
EntryPointCommandHandlerType,
|
||||||
} from 'discord-api-types/v10';
|
} from 'discord-api-types/v10';
|
||||||
import { ChildProcess } from 'node:child_process';
|
import { ChildProcess } from 'node:child_process';
|
||||||
import { Stream } from 'node:stream';
|
import { Stream } from 'node:stream';
|
||||||
@@ -406,6 +407,7 @@ export class ApplicationCommand<PermissionsFetchType = {}> extends Base {
|
|||||||
public get manager(): ApplicationCommandManager;
|
public get manager(): ApplicationCommandManager;
|
||||||
public id: Snowflake;
|
public id: Snowflake;
|
||||||
public integrationTypes: ApplicationIntegrationType[] | null;
|
public integrationTypes: ApplicationIntegrationType[] | null;
|
||||||
|
public handler: EntryPointCommandHandlerType | null;
|
||||||
public name: string;
|
public name: string;
|
||||||
public nameLocalizations: LocalizationMap | null;
|
public nameLocalizations: LocalizationMap | null;
|
||||||
public nameLocalized: string | null;
|
public nameLocalized: string | null;
|
||||||
@@ -508,23 +510,6 @@ export type BooleanCache<Cached extends CacheType> = Cached extends 'cached' ? t
|
|||||||
export abstract class CommandInteraction<Cached extends CacheType = CacheType> extends BaseInteraction<Cached> {
|
export abstract class CommandInteraction<Cached extends CacheType = CacheType> extends BaseInteraction<Cached> {
|
||||||
public type: InteractionType.ApplicationCommand;
|
public type: InteractionType.ApplicationCommand;
|
||||||
public get command(): ApplicationCommand | ApplicationCommand<{ guild: GuildResolvable }> | null;
|
public get command(): ApplicationCommand | ApplicationCommand<{ guild: GuildResolvable }> | null;
|
||||||
public options: Omit<
|
|
||||||
CommandInteractionOptionResolver<Cached>,
|
|
||||||
| 'getMessage'
|
|
||||||
| 'getFocused'
|
|
||||||
| 'getMentionable'
|
|
||||||
| 'getRole'
|
|
||||||
| 'getUser'
|
|
||||||
| 'getMember'
|
|
||||||
| 'getAttachment'
|
|
||||||
| 'getNumber'
|
|
||||||
| 'getInteger'
|
|
||||||
| 'getString'
|
|
||||||
| 'getChannel'
|
|
||||||
| 'getBoolean'
|
|
||||||
| 'getSubcommandGroup'
|
|
||||||
| 'getSubcommand'
|
|
||||||
>;
|
|
||||||
public channelId: Snowflake;
|
public channelId: Snowflake;
|
||||||
public commandId: Snowflake;
|
public commandId: Snowflake;
|
||||||
public commandName: string;
|
public commandName: string;
|
||||||
@@ -557,6 +542,13 @@ export abstract class CommandInteraction<Cached extends CacheType = CacheType> e
|
|||||||
public reply(
|
public reply(
|
||||||
options: string | MessagePayload | InteractionReplyOptions,
|
options: string | MessagePayload | InteractionReplyOptions,
|
||||||
): Promise<InteractionCallbackResponse<BooleanCache<Cached>> | undefined>;
|
): Promise<InteractionCallbackResponse<BooleanCache<Cached>> | undefined>;
|
||||||
|
public launchActivity(
|
||||||
|
options: LaunchActivityOptions & { withResponse: true },
|
||||||
|
): Promise<InteractionCallbackResponse<BooleanCache<Cached>>>;
|
||||||
|
public launchActivity(options?: LaunchActivityOptions & { withResponse?: false }): Promise<undefined>;
|
||||||
|
public launchActivity(
|
||||||
|
options?: LaunchActivityOptions,
|
||||||
|
): Promise<InteractionCallbackResponse<BooleanCache<Cached>> | undefined>;
|
||||||
public showModal(
|
public showModal(
|
||||||
modal:
|
modal:
|
||||||
| JSONEncodable<APIModalInteractionResponseCallbackData>
|
| JSONEncodable<APIModalInteractionResponseCallbackData>
|
||||||
@@ -1156,6 +1148,23 @@ export class CommandInteractionOptionResolver<Cached extends CacheType = CacheTy
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class ContextMenuCommandInteraction<Cached extends CacheType = CacheType> extends CommandInteraction<Cached> {
|
export class ContextMenuCommandInteraction<Cached extends CacheType = CacheType> extends CommandInteraction<Cached> {
|
||||||
|
public options: Omit<
|
||||||
|
CommandInteractionOptionResolver<Cached>,
|
||||||
|
| 'getMessage'
|
||||||
|
| 'getFocused'
|
||||||
|
| 'getMentionable'
|
||||||
|
| 'getRole'
|
||||||
|
| 'getUser'
|
||||||
|
| 'getMember'
|
||||||
|
| 'getAttachment'
|
||||||
|
| 'getNumber'
|
||||||
|
| 'getInteger'
|
||||||
|
| 'getString'
|
||||||
|
| 'getChannel'
|
||||||
|
| 'getBoolean'
|
||||||
|
| 'getSubcommandGroup'
|
||||||
|
| 'getSubcommand'
|
||||||
|
>;
|
||||||
public commandType: ApplicationCommandType.Message | ApplicationCommandType.User;
|
public commandType: ApplicationCommandType.Message | ApplicationCommandType.User;
|
||||||
public targetId: Snowflake;
|
public targetId: Snowflake;
|
||||||
public inGuild(): this is ContextMenuCommandInteraction<'raw' | 'cached'>;
|
public inGuild(): this is ContextMenuCommandInteraction<'raw' | 'cached'>;
|
||||||
@@ -1164,6 +1173,15 @@ export class ContextMenuCommandInteraction<Cached extends CacheType = CacheType>
|
|||||||
private resolveContextMenuOptions(data: APIApplicationCommandInteractionData): CommandInteractionOption<Cached>[];
|
private resolveContextMenuOptions(data: APIApplicationCommandInteractionData): CommandInteractionOption<Cached>[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class PrimaryEntryPointCommandInteraction<
|
||||||
|
Cached extends CacheType = CacheType,
|
||||||
|
> extends CommandInteraction<Cached> {
|
||||||
|
public commandType: ApplicationCommandType.PrimaryEntryPoint;
|
||||||
|
public inGuild(): this is PrimaryEntryPointCommandInteraction<'raw' | 'cached'>;
|
||||||
|
public inCachedGuild(): this is PrimaryEntryPointCommandInteraction<'cached'>;
|
||||||
|
public inRawGuild(): this is PrimaryEntryPointCommandInteraction<'raw'>;
|
||||||
|
}
|
||||||
|
|
||||||
// tslint:disable-next-line no-empty-interface
|
// tslint:disable-next-line no-empty-interface
|
||||||
export interface DMChannel
|
export interface DMChannel
|
||||||
extends Omit<
|
extends Omit<
|
||||||
@@ -1779,6 +1797,7 @@ export type Interaction<Cached extends CacheType = CacheType> =
|
|||||||
| ChatInputCommandInteraction<Cached>
|
| ChatInputCommandInteraction<Cached>
|
||||||
| MessageContextMenuCommandInteraction<Cached>
|
| MessageContextMenuCommandInteraction<Cached>
|
||||||
| UserContextMenuCommandInteraction<Cached>
|
| UserContextMenuCommandInteraction<Cached>
|
||||||
|
| PrimaryEntryPointCommandInteraction<Cached>
|
||||||
| SelectMenuInteraction<Cached>
|
| SelectMenuInteraction<Cached>
|
||||||
| ButtonInteraction<Cached>
|
| ButtonInteraction<Cached>
|
||||||
| AutocompleteInteraction<Cached>
|
| AutocompleteInteraction<Cached>
|
||||||
@@ -1828,6 +1847,7 @@ export class BaseInteraction<Cached extends CacheType = CacheType> extends Base
|
|||||||
public isChatInputCommand(): this is ChatInputCommandInteraction<Cached>;
|
public isChatInputCommand(): this is ChatInputCommandInteraction<Cached>;
|
||||||
public isCommand(): this is CommandInteraction<Cached>;
|
public isCommand(): this is CommandInteraction<Cached>;
|
||||||
public isContextMenuCommand(): this is ContextMenuCommandInteraction<Cached>;
|
public isContextMenuCommand(): this is ContextMenuCommandInteraction<Cached>;
|
||||||
|
public isPrimaryEntryPointCommand(): this is PrimaryEntryPointCommandInteraction<Cached>;
|
||||||
public isMessageComponent(): this is MessageComponentInteraction<Cached>;
|
public isMessageComponent(): this is MessageComponentInteraction<Cached>;
|
||||||
public isMessageContextMenuCommand(): this is MessageContextMenuCommandInteraction<Cached>;
|
public isMessageContextMenuCommand(): this is MessageContextMenuCommandInteraction<Cached>;
|
||||||
public isModalSubmit(): this is ModalSubmitInteraction<Cached>;
|
public isModalSubmit(): this is ModalSubmitInteraction<Cached>;
|
||||||
@@ -2199,6 +2219,13 @@ export class MessageComponentInteraction<Cached extends CacheType = CacheType> e
|
|||||||
public update(
|
public update(
|
||||||
options: string | MessagePayload | InteractionUpdateOptions,
|
options: string | MessagePayload | InteractionUpdateOptions,
|
||||||
): Promise<InteractionCallbackResponse<BooleanCache<Cached>> | undefined>;
|
): Promise<InteractionCallbackResponse<BooleanCache<Cached>> | undefined>;
|
||||||
|
public launchActivity(
|
||||||
|
options: LaunchActivityOptions & { withResponse: true },
|
||||||
|
): Promise<InteractionCallbackResponse<BooleanCache<Cached>>>;
|
||||||
|
public launchActivity(options?: LaunchActivityOptions & { withResponse?: false }): Promise<undefined>;
|
||||||
|
public launchActivity(
|
||||||
|
options?: LaunchActivityOptions,
|
||||||
|
): Promise<InteractionCallbackResponse<BooleanCache<Cached>> | undefined>;
|
||||||
public showModal(
|
public showModal(
|
||||||
modal:
|
modal:
|
||||||
| JSONEncodable<APIModalInteractionResponseCallbackData>
|
| JSONEncodable<APIModalInteractionResponseCallbackData>
|
||||||
@@ -2437,6 +2464,13 @@ export class ModalSubmitInteraction<Cached extends CacheType = CacheType> extend
|
|||||||
public deferUpdate(
|
public deferUpdate(
|
||||||
options?: InteractionDeferUpdateOptions,
|
options?: InteractionDeferUpdateOptions,
|
||||||
): Promise<InteractionCallbackResponse<BooleanCache<Cached>> | undefined>;
|
): Promise<InteractionCallbackResponse<BooleanCache<Cached>> | undefined>;
|
||||||
|
public launchActivity(
|
||||||
|
options: LaunchActivityOptions & { withResponse: true },
|
||||||
|
): Promise<InteractionCallbackResponse<BooleanCache<Cached>>>;
|
||||||
|
public launchActivity(options?: LaunchActivityOptions & { withResponse?: false }): Promise<undefined>;
|
||||||
|
public launchActivity(
|
||||||
|
options?: LaunchActivityOptions,
|
||||||
|
): Promise<InteractionCallbackResponse<BooleanCache<Cached>> | undefined>;
|
||||||
public inGuild(): this is ModalSubmitInteraction<'raw' | 'cached'>;
|
public inGuild(): this is ModalSubmitInteraction<'raw' | 'cached'>;
|
||||||
public inCachedGuild(): this is ModalSubmitInteraction<'cached'>;
|
public inCachedGuild(): this is ModalSubmitInteraction<'cached'>;
|
||||||
public inRawGuild(): this is ModalSubmitInteraction<'raw'>;
|
public inRawGuild(): this is ModalSubmitInteraction<'raw'>;
|
||||||
@@ -4576,10 +4610,18 @@ export interface ChatInputApplicationCommandData extends BaseApplicationCommandD
|
|||||||
options?: readonly ApplicationCommandOptionData[];
|
options?: readonly ApplicationCommandOptionData[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PrimaryEntryPointCommandData extends BaseApplicationCommandData {
|
||||||
|
description?: string;
|
||||||
|
descriptionLocalizations?: LocalizationMap;
|
||||||
|
type: ApplicationCommandType.PrimaryEntryPoint;
|
||||||
|
handler?: EntryPointCommandHandlerType;
|
||||||
|
}
|
||||||
|
|
||||||
export type ApplicationCommandData =
|
export type ApplicationCommandData =
|
||||||
| UserApplicationCommandData
|
| UserApplicationCommandData
|
||||||
| MessageApplicationCommandData
|
| MessageApplicationCommandData
|
||||||
| ChatInputApplicationCommandData;
|
| ChatInputApplicationCommandData
|
||||||
|
| PrimaryEntryPointCommandData;
|
||||||
|
|
||||||
export interface ApplicationCommandChannelOptionData extends BaseApplicationCommandOptionsData {
|
export interface ApplicationCommandChannelOptionData extends BaseApplicationCommandOptionsData {
|
||||||
type: CommandOptionChannelResolvableType;
|
type: CommandOptionChannelResolvableType;
|
||||||
@@ -6605,6 +6647,10 @@ export interface ShowModalOptions {
|
|||||||
withResponse?: boolean;
|
withResponse?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface LaunchActivityOptions {
|
||||||
|
withResponse?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export { Snowflake };
|
export { Snowflake };
|
||||||
|
|
||||||
export type StageInstanceResolvable = StageInstance | Snowflake;
|
export type StageInstanceResolvable = StageInstance | Snowflake;
|
||||||
|
|||||||
@@ -204,6 +204,7 @@ import {
|
|||||||
SendableChannels,
|
SendableChannels,
|
||||||
PollData,
|
PollData,
|
||||||
InteractionCallbackResponse,
|
InteractionCallbackResponse,
|
||||||
|
PrimaryEntryPointCommandInteraction,
|
||||||
GuildScheduledEventRecurrenceRuleOptions,
|
GuildScheduledEventRecurrenceRuleOptions,
|
||||||
ThreadOnlyChannel,
|
ThreadOnlyChannel,
|
||||||
PartialPoll,
|
PartialPoll,
|
||||||
@@ -1884,6 +1885,11 @@ client.on('interactionCreate', async interaction => {
|
|||||||
expectType<Promise<InteractionCallbackResponse<true>>>(interaction.deferUpdate({ withResponse: true }));
|
expectType<Promise<InteractionCallbackResponse<true>>>(interaction.deferUpdate({ withResponse: true }));
|
||||||
expectType<Promise<undefined>>(interaction.deferUpdate());
|
expectType<Promise<undefined>>(interaction.deferUpdate());
|
||||||
expectType<Promise<Message<true>>>(interaction.followUp({ content: 'a' }));
|
expectType<Promise<Message<true>>>(interaction.followUp({ content: 'a' }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse<true>>>(interaction.launchActivity({ withResponse: true }));
|
||||||
|
expectType<Promise<undefined>>(interaction.launchActivity({ withResponse: false }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse<true> | undefined>>(
|
||||||
|
interaction.launchActivity({ withResponse: booleanValue }),
|
||||||
|
);
|
||||||
} else if (interaction.inRawGuild()) {
|
} else if (interaction.inRawGuild()) {
|
||||||
expectAssignable<MessageComponentInteraction>(interaction);
|
expectAssignable<MessageComponentInteraction>(interaction);
|
||||||
expectType<APIButtonComponent | APISelectMenuComponent>(interaction.component);
|
expectType<APIButtonComponent | APISelectMenuComponent>(interaction.component);
|
||||||
@@ -1910,6 +1916,11 @@ client.on('interactionCreate', async interaction => {
|
|||||||
expectType<Promise<InteractionCallbackResponse<false>>>(interaction.deferUpdate({ withResponse: true }));
|
expectType<Promise<InteractionCallbackResponse<false>>>(interaction.deferUpdate({ withResponse: true }));
|
||||||
expectType<Promise<undefined>>(interaction.deferUpdate());
|
expectType<Promise<undefined>>(interaction.deferUpdate());
|
||||||
expectType<Promise<Message<false>>>(interaction.followUp({ content: 'a' }));
|
expectType<Promise<Message<false>>>(interaction.followUp({ content: 'a' }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse<false>>>(interaction.launchActivity({ withResponse: true }));
|
||||||
|
expectType<Promise<undefined>>(interaction.launchActivity({ withResponse: false }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse<false> | undefined>>(
|
||||||
|
interaction.launchActivity({ withResponse: booleanValue }),
|
||||||
|
);
|
||||||
} else if (interaction.inGuild()) {
|
} else if (interaction.inGuild()) {
|
||||||
expectAssignable<MessageComponentInteraction>(interaction);
|
expectAssignable<MessageComponentInteraction>(interaction);
|
||||||
expectType<MessageActionRowComponent | APIButtonComponent | APISelectMenuComponent>(interaction.component);
|
expectType<MessageActionRowComponent | APIButtonComponent | APISelectMenuComponent>(interaction.component);
|
||||||
@@ -1936,6 +1947,11 @@ client.on('interactionCreate', async interaction => {
|
|||||||
expectType<Promise<InteractionCallbackResponse>>(interaction.deferUpdate({ withResponse: true }));
|
expectType<Promise<InteractionCallbackResponse>>(interaction.deferUpdate({ withResponse: true }));
|
||||||
expectType<Promise<undefined>>(interaction.deferUpdate());
|
expectType<Promise<undefined>>(interaction.deferUpdate());
|
||||||
expectType<Promise<Message>>(interaction.followUp({ content: 'a' }));
|
expectType<Promise<Message>>(interaction.followUp({ content: 'a' }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.launchActivity({ withResponse: true }));
|
||||||
|
expectType<Promise<undefined>>(interaction.launchActivity({ withResponse: false }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse | undefined>>(
|
||||||
|
interaction.launchActivity({ withResponse: booleanValue }),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1982,6 +1998,11 @@ client.on('interactionCreate', async interaction => {
|
|||||||
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' }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse<true>>>(interaction.launchActivity({ withResponse: true }));
|
||||||
|
expectType<Promise<undefined>>(interaction.launchActivity({ withResponse: false }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse<true> | undefined>>(
|
||||||
|
interaction.launchActivity({ withResponse: booleanValue }),
|
||||||
|
);
|
||||||
} else if (interaction.inRawGuild()) {
|
} else if (interaction.inRawGuild()) {
|
||||||
expectAssignable<ContextMenuCommandInteraction>(interaction);
|
expectAssignable<ContextMenuCommandInteraction>(interaction);
|
||||||
expectType<null>(interaction.guild);
|
expectType<null>(interaction.guild);
|
||||||
@@ -1999,6 +2020,11 @@ client.on('interactionCreate', async interaction => {
|
|||||||
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' }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse<false>>>(interaction.launchActivity({ withResponse: true }));
|
||||||
|
expectType<Promise<undefined>>(interaction.launchActivity({ withResponse: false }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse<false> | undefined>>(
|
||||||
|
interaction.launchActivity({ withResponse: booleanValue }),
|
||||||
|
);
|
||||||
} else if (interaction.inGuild()) {
|
} else if (interaction.inGuild()) {
|
||||||
expectAssignable<ContextMenuCommandInteraction>(interaction);
|
expectAssignable<ContextMenuCommandInteraction>(interaction);
|
||||||
expectType<Guild | null>(interaction.guild);
|
expectType<Guild | null>(interaction.guild);
|
||||||
@@ -2016,6 +2042,11 @@ client.on('interactionCreate', async interaction => {
|
|||||||
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' }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.launchActivity({ withResponse: true }));
|
||||||
|
expectType<Promise<undefined>>(interaction.launchActivity({ withResponse: false }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse | undefined>>(
|
||||||
|
interaction.launchActivity({ withResponse: booleanValue }),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2184,6 +2215,84 @@ client.on('interactionCreate', async interaction => {
|
|||||||
interaction.options.getMessage('name');
|
interaction.options.getMessage('name');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
interaction.type === InteractionType.ApplicationCommand &&
|
||||||
|
interaction.commandType === ApplicationCommandType.PrimaryEntryPoint
|
||||||
|
) {
|
||||||
|
expectType<PrimaryEntryPointCommandInteraction>(interaction);
|
||||||
|
|
||||||
|
// @ts-expect-error No options on primary entry point commands
|
||||||
|
interaction.options;
|
||||||
|
if (interaction.inCachedGuild()) {
|
||||||
|
expectAssignable<PrimaryEntryPointCommandInteraction>(interaction);
|
||||||
|
expectAssignable<Guild>(interaction.guild);
|
||||||
|
expectAssignable<CommandInteraction<'cached'>>(interaction);
|
||||||
|
expectType<Promise<InteractionCallbackResponse<true>>>(interaction.reply({ content: 'a', withResponse: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse<true>>>(interaction.deferReply({ withResponse: true }));
|
||||||
|
expectType<Promise<undefined>>(interaction.deferReply());
|
||||||
|
expectType<Promise<undefined>>(interaction.reply({ content: 'a', withResponse: false }));
|
||||||
|
expectType<Promise<undefined>>(interaction.deferReply({ withResponse: false }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse<true> | undefined>>(
|
||||||
|
interaction.reply({ content: 'a', withResponse: booleanValue }),
|
||||||
|
);
|
||||||
|
expectType<Promise<InteractionCallbackResponse<true> | undefined>>(
|
||||||
|
interaction.deferReply({ withResponse: booleanValue }),
|
||||||
|
);
|
||||||
|
expectType<Promise<Message<true>>>(interaction.editReply({ content: 'a' }));
|
||||||
|
expectType<Promise<Message<true>>>(interaction.fetchReply());
|
||||||
|
expectType<Promise<Message<true>>>(interaction.followUp({ content: 'a' }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse<true>>>(interaction.launchActivity({ withResponse: true }));
|
||||||
|
expectType<Promise<undefined>>(interaction.launchActivity({ withResponse: false }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse<true> | undefined>>(
|
||||||
|
interaction.launchActivity({ withResponse: booleanValue }),
|
||||||
|
);
|
||||||
|
} else if (interaction.inRawGuild()) {
|
||||||
|
expectAssignable<PrimaryEntryPointCommandInteraction>(interaction);
|
||||||
|
expectType<null>(interaction.guild);
|
||||||
|
expectType<Promise<InteractionCallbackResponse<false>>>(interaction.reply({ content: 'a', withResponse: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse<false>>>(interaction.deferReply({ withResponse: true }));
|
||||||
|
expectType<Promise<undefined>>(interaction.deferReply());
|
||||||
|
expectType<Promise<undefined>>(interaction.reply({ content: 'a', withResponse: false }));
|
||||||
|
expectType<Promise<undefined>>(interaction.deferReply({ withResponse: false }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse<false> | undefined>>(
|
||||||
|
interaction.reply({ content: 'a', withResponse: booleanValue }),
|
||||||
|
);
|
||||||
|
expectType<Promise<InteractionCallbackResponse<false> | undefined>>(
|
||||||
|
interaction.deferReply({ withResponse: booleanValue }),
|
||||||
|
);
|
||||||
|
expectType<Promise<Message<false>>>(interaction.editReply({ content: 'a' }));
|
||||||
|
expectType<Promise<Message<false>>>(interaction.fetchReply());
|
||||||
|
expectType<Promise<Message<false>>>(interaction.followUp({ content: 'a' }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse<false>>>(interaction.launchActivity({ withResponse: true }));
|
||||||
|
expectType<Promise<undefined>>(interaction.launchActivity({ withResponse: false }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse<false> | undefined>>(
|
||||||
|
interaction.launchActivity({ withResponse: booleanValue }),
|
||||||
|
);
|
||||||
|
} else if (interaction.inGuild()) {
|
||||||
|
expectAssignable<PrimaryEntryPointCommandInteraction>(interaction);
|
||||||
|
expectType<Guild | null>(interaction.guild);
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.reply({ content: 'a', withResponse: true }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.deferReply({ withResponse: true }));
|
||||||
|
expectType<Promise<undefined>>(interaction.deferReply());
|
||||||
|
expectType<Promise<undefined>>(interaction.reply({ content: 'a', withResponse: false }));
|
||||||
|
expectType<Promise<undefined>>(interaction.deferReply({ withResponse: false }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse | undefined>>(
|
||||||
|
interaction.reply({ content: 'a', withResponse: booleanValue }),
|
||||||
|
);
|
||||||
|
expectType<Promise<InteractionCallbackResponse | undefined>>(
|
||||||
|
interaction.deferReply({ withResponse: booleanValue }),
|
||||||
|
);
|
||||||
|
expectType<Promise<Message>>(interaction.editReply({ content: 'a' }));
|
||||||
|
expectType<Promise<Message>>(interaction.fetchReply());
|
||||||
|
expectType<Promise<Message>>(interaction.followUp({ content: 'a' }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.launchActivity({ withResponse: true }));
|
||||||
|
expectType<Promise<undefined>>(interaction.launchActivity({ withResponse: false }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse | undefined>>(
|
||||||
|
interaction.launchActivity({ withResponse: booleanValue }),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (interaction.isRepliable()) {
|
if (interaction.isRepliable()) {
|
||||||
expectAssignable<RepliableInteraction>(interaction);
|
expectAssignable<RepliableInteraction>(interaction);
|
||||||
interaction.reply('test');
|
interaction.reply('test');
|
||||||
@@ -2212,6 +2321,7 @@ client.on('interactionCreate', async interaction => {
|
|||||||
expectType<Promise<InteractionCallbackResponse<true>>>(interaction.deferUpdate({ withResponse: true }));
|
expectType<Promise<InteractionCallbackResponse<true>>>(interaction.deferUpdate({ withResponse: true }));
|
||||||
expectType<Promise<undefined>>(interaction.deferUpdate());
|
expectType<Promise<undefined>>(interaction.deferUpdate());
|
||||||
expectType<Promise<Message<true>>>(interaction.followUp({ content: 'a' }));
|
expectType<Promise<Message<true>>>(interaction.followUp({ content: 'a' }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse<true>>>(interaction.launchActivity({ withResponse: true }));
|
||||||
} else if (interaction.inRawGuild()) {
|
} else if (interaction.inRawGuild()) {
|
||||||
expectAssignable<ModalSubmitInteraction>(interaction);
|
expectAssignable<ModalSubmitInteraction>(interaction);
|
||||||
expectType<null>(interaction.guild);
|
expectType<null>(interaction.guild);
|
||||||
@@ -2223,6 +2333,7 @@ client.on('interactionCreate', async interaction => {
|
|||||||
expectType<Promise<InteractionCallbackResponse<false>>>(interaction.deferUpdate({ withResponse: true }));
|
expectType<Promise<InteractionCallbackResponse<false>>>(interaction.deferUpdate({ withResponse: true }));
|
||||||
expectType<Promise<undefined>>(interaction.deferUpdate());
|
expectType<Promise<undefined>>(interaction.deferUpdate());
|
||||||
expectType<Promise<Message<false>>>(interaction.followUp({ content: 'a' }));
|
expectType<Promise<Message<false>>>(interaction.followUp({ content: 'a' }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse<false>>>(interaction.launchActivity({ withResponse: true }));
|
||||||
} else if (interaction.inGuild()) {
|
} else if (interaction.inGuild()) {
|
||||||
expectAssignable<ModalSubmitInteraction>(interaction);
|
expectAssignable<ModalSubmitInteraction>(interaction);
|
||||||
expectType<Guild | null>(interaction.guild);
|
expectType<Guild | null>(interaction.guild);
|
||||||
@@ -2234,6 +2345,7 @@ client.on('interactionCreate', async interaction => {
|
|||||||
expectType<Promise<InteractionCallbackResponse>>(interaction.deferUpdate({ withResponse: true }));
|
expectType<Promise<InteractionCallbackResponse>>(interaction.deferUpdate({ withResponse: true }));
|
||||||
expectType<Promise<undefined>>(interaction.deferUpdate());
|
expectType<Promise<undefined>>(interaction.deferUpdate());
|
||||||
expectType<Promise<Message>>(interaction.followUp({ content: 'a' }));
|
expectType<Promise<Message>>(interaction.followUp({ content: 'a' }));
|
||||||
|
expectType<Promise<InteractionCallbackResponse>>(interaction.launchActivity({ withResponse: true }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user