mirror of
https://github.com/discordjs/discord-api-types.git
synced 2026-05-30 07:20:10 +00:00
chore: Get up to date *again* (#156)
Co-authored-by: monbrey <rsm999@uowmail.edu.au>
* Added `DiscordCertifiedModerator` flag to UserFlags
* Updated types for Message Components
* Added `disabled` to APISelectMenuCompponent
* Cleaned up Buttons types, making them stricter based on the `style` you provide
BREAKING CHANGE: `APISelectOption` has been renamed to `APISelectMenuOption`
BREAKING CHANGE: APISelectMenuOption#default is now properly marked as optional
* Updated OAuth2 Application types
BREAKING CHANGE: `APIApplication#owner` is now marked as optional, per the docs
* Correct APIAuditLogChangeKeyNick's key
BREAKING CHANGE: This renames APIAuditLogChangeKeyNick's key from `mute` to `nick`
* Add `application_id` to APIMessage
* Correct type of `id` and `user_id` in APIThreadMember
BREAKING CHANGE: The type of `id` and `user_id` in APIThreadMember are now marked as optional; read the TSDoc for when it's actually optional
* Correctly version API route in RouteBases
BREAKING CHANGE: This changes the `RouteBases.api` to be versioned based on the API version you're importing. **Make sure to update your code to handle that**
* Added new guild features
ref: 4d36e533cf
* Cleaned up interaction types
BREAKING CHANGE: While this shouldn't be necessary, this is a warning that types for interactions HAVE changed and you may need to update your code. For the most part, the types *should* be the same, more accurate and strictly typed. You will also see that every type of interaction has a Guild/DM counterpart exported (ex: APIApplicationCommandGuildInteraction vs APIApplicationCommandInteraction, where the former has all the guild properties, while the latter has all properties that depend on context marked as optional).
* Add TSD testing support in CI
This is mostly useful for testing unions of types
* Add message property to MessageComponent interactions
This commit is contained in:
22
.github/workflows/cicd.yml
vendored
22
.github/workflows/cicd.yml
vendored
@@ -61,3 +61,25 @@ jobs:
|
||||
git add --all .
|
||||
git commit -m "build: deno build for ${GITHUB_SHA}" || true
|
||||
git push || true
|
||||
|
||||
tsd:
|
||||
name: TSD checks
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
needs: testing
|
||||
if: needs.testing.result == 'success'
|
||||
|
||||
steps:
|
||||
- name: Checkout Project
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Use Node.js v16
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 16
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Run TSD
|
||||
run: npm run test:types
|
||||
|
||||
@@ -314,9 +314,7 @@ export type GatewayApplicationCommandModifyDispatch = DataPayload<
|
||||
* https://discord.com/developers/docs/topics/gateway#application-command-update
|
||||
* https://discord.com/developers/docs/topics/gateway#application-command-delete
|
||||
*/
|
||||
export interface GatewayApplicationCommandModifyDispatchData extends APIApplicationCommand {
|
||||
guild_id?: string;
|
||||
}
|
||||
export type GatewayApplicationCommandModifyDispatchData = APIApplicationCommand;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/topics/gateway#application-command-create
|
||||
|
||||
@@ -324,9 +324,7 @@ export type GatewayApplicationCommandModifyDispatch = DataPayload<
|
||||
* https://discord.com/developers/docs/topics/gateway#application-command-update
|
||||
* https://discord.com/developers/docs/topics/gateway#application-command-delete
|
||||
*/
|
||||
export interface GatewayApplicationCommandModifyDispatchData extends APIApplicationCommand {
|
||||
guild_id?: string;
|
||||
}
|
||||
export type GatewayApplicationCommandModifyDispatchData = APIApplicationCommand;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/topics/gateway#application-command-create
|
||||
|
||||
101
deno/payloads/v8/_interactions/base.ts
Normal file
101
deno/payloads/v8/_interactions/base.ts
Normal file
@@ -0,0 +1,101 @@
|
||||
import { Permissions, Snowflake } from '../../../globals.ts';
|
||||
import { InteractionType } from '../../v8.ts';
|
||||
import { APIMessage } from '../channel.ts';
|
||||
import { APIGuildMember } from '../guild.ts';
|
||||
import { APIUser } from '../user.ts';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#message-interaction-object-message-interaction-structure
|
||||
*/
|
||||
export interface APIMessageInteraction {
|
||||
/**
|
||||
* ID of the interaction
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* The type of interaction
|
||||
*/
|
||||
type: InteractionType;
|
||||
/**
|
||||
* The name of the ApplicationCommand
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* The user who invoked the interaction
|
||||
*/
|
||||
user: APIUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#guild-member-object
|
||||
*/
|
||||
export interface APIInteractionGuildMember extends APIGuildMember {
|
||||
permissions: Permissions;
|
||||
user: APIUser;
|
||||
}
|
||||
|
||||
// INTERACTIONS RECEIVED
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-object
|
||||
*/
|
||||
export interface APIBaseInteraction<Type extends InteractionType, Data extends unknown> {
|
||||
/**
|
||||
* ID of the interaction
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* ID of the application this interaction is for
|
||||
*/
|
||||
application_id: Snowflake;
|
||||
/**
|
||||
* The type of interaction
|
||||
*/
|
||||
type: Type;
|
||||
/**
|
||||
* The command data payload
|
||||
*/
|
||||
data?: Data;
|
||||
/**
|
||||
* The guild it was sent from
|
||||
*/
|
||||
guild_id?: Snowflake;
|
||||
/**
|
||||
* The channel it was sent from
|
||||
*/
|
||||
channel_id?: Snowflake;
|
||||
/**
|
||||
* Guild member data for the invoking user, including permissions
|
||||
*
|
||||
* **This is only sent when an interaction is invoked in a guild**
|
||||
*/
|
||||
member?: APIInteractionGuildMember;
|
||||
/**
|
||||
* User object for the invoking user, if invoked in a DM
|
||||
*/
|
||||
user?: APIUser;
|
||||
/**
|
||||
* A continuation token for responding to the interaction
|
||||
*/
|
||||
token: string;
|
||||
/**
|
||||
* Read-only property, always `1`
|
||||
*/
|
||||
version: 1;
|
||||
/**
|
||||
* For components, the message they were attached to
|
||||
*/
|
||||
message?: APIMessage;
|
||||
}
|
||||
|
||||
export type APIDMInteractionWrapper<Original extends APIBaseInteraction<InteractionType, unknown>> = Omit<
|
||||
Original,
|
||||
'member' | 'guild_id'
|
||||
> &
|
||||
Required<Pick<Original, 'user'>>;
|
||||
|
||||
export type APIGuildInteractionWrapper<Original extends APIBaseInteraction<InteractionType, unknown>> = Omit<
|
||||
Original,
|
||||
'user'
|
||||
> &
|
||||
Required<Pick<Original, 'member' | 'guild_id'>>;
|
||||
38
deno/payloads/v8/_interactions/messageComponents.ts
Normal file
38
deno/payloads/v8/_interactions/messageComponents.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { ComponentType } from '../channel.ts';
|
||||
import { APIBaseInteraction, InteractionType } from '../interactions.ts';
|
||||
import { APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base.ts';
|
||||
|
||||
export type APIMessageComponentInteraction = APIBaseInteraction<
|
||||
InteractionType.MessageComponent,
|
||||
APIMessageComponentInteractionData
|
||||
> &
|
||||
Required<
|
||||
Pick<
|
||||
APIBaseInteraction<InteractionType.MessageComponent, APIMessageComponentInteractionData>,
|
||||
'channel_id' | 'data' | 'message'
|
||||
>
|
||||
>;
|
||||
|
||||
export type APIMessageComponentInteractionData = APIMessageButtonInteractionData | APIMessageSelectMenuInteractionData;
|
||||
|
||||
export interface APIMessageComponentBaseInteractionData<CType extends ComponentType> {
|
||||
/**
|
||||
* The `custom_id` of the component
|
||||
*/
|
||||
custom_id: string;
|
||||
/**
|
||||
* The type of the component
|
||||
*/
|
||||
component_type: CType;
|
||||
}
|
||||
|
||||
export type APIMessageButtonInteractionData = APIMessageComponentBaseInteractionData<ComponentType.Button>;
|
||||
|
||||
export interface APIMessageSelectMenuInteractionData
|
||||
extends APIMessageComponentBaseInteractionData<ComponentType.SelectMenu> {
|
||||
values: string[];
|
||||
}
|
||||
|
||||
export type APIMessageComponentDMInteraction = APIDMInteractionWrapper<APIMessageComponentInteraction>;
|
||||
|
||||
export type APIMessageComponentGuildInteraction = APIGuildInteractionWrapper<APIMessageComponentInteraction>;
|
||||
78
deno/payloads/v8/_interactions/responses.ts
Normal file
78
deno/payloads/v8/_interactions/responses.ts
Normal file
@@ -0,0 +1,78 @@
|
||||
import { MessageFlags } from '../mod.ts';
|
||||
import { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v8.ts';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-object-interaction-request-type
|
||||
*/
|
||||
export enum InteractionType {
|
||||
Ping = 1,
|
||||
ApplicationCommand,
|
||||
MessageComponent,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object
|
||||
*/
|
||||
export type APIInteractionResponse =
|
||||
| APIInteractionResponsePong
|
||||
| APIInteractionResponseChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredMessageUpdate
|
||||
| APIInteractionResponseUpdateMessage;
|
||||
|
||||
export interface APIInteractionResponsePong {
|
||||
type: InteractionResponseType.Pong;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseChannelMessageWithSource {
|
||||
type: InteractionResponseType.ChannelMessageWithSource;
|
||||
data: APIInteractionResponseCallbackData;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseDeferredChannelMessageWithSource {
|
||||
type: InteractionResponseType.DeferredChannelMessageWithSource;
|
||||
data?: Pick<APIInteractionResponseCallbackData, 'flags'>;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseDeferredMessageUpdate {
|
||||
type: InteractionResponseType.DeferredMessageUpdate;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseUpdateMessage {
|
||||
type: InteractionResponseType.UpdateMessage;
|
||||
data?: APIInteractionResponseCallbackData;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object-interaction-callback-type
|
||||
*/
|
||||
export enum InteractionResponseType {
|
||||
/**
|
||||
* ACK a `Ping`
|
||||
*/
|
||||
Pong = 1,
|
||||
/**
|
||||
* Respond to an interaction with a message
|
||||
*/
|
||||
ChannelMessageWithSource = 4,
|
||||
/**
|
||||
* ACK an interaction and edit to a response later, the user sees a loading state
|
||||
*/
|
||||
DeferredChannelMessageWithSource,
|
||||
/**
|
||||
* ACK a button interaction and update it to a loading state
|
||||
*/
|
||||
DeferredMessageUpdate,
|
||||
/**
|
||||
* ACK a button interaction and edit the message to which the button was attached
|
||||
*/
|
||||
UpdateMessage,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object-interaction-application-command-callback-data-structure
|
||||
*/
|
||||
export type APIInteractionResponseCallbackData = Omit<
|
||||
RESTPostAPIWebhookWithTokenJSONBody,
|
||||
'username' | 'avatar_url'
|
||||
> & { flags?: MessageFlags };
|
||||
273
deno/payloads/v8/_interactions/slashCommands.ts
Normal file
273
deno/payloads/v8/_interactions/slashCommands.ts
Normal file
@@ -0,0 +1,273 @@
|
||||
import { APIRole, APIUser } from '../mod.ts';
|
||||
import { Permissions, Snowflake } from '../../../globals.ts';
|
||||
import { APIPartialChannel } from '../channel.ts';
|
||||
import { APIGuildMember } from '../guild.ts';
|
||||
import { APIBaseInteraction, APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base.ts';
|
||||
import { InteractionType } from './responses.ts';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#application-command-object
|
||||
*/
|
||||
export interface APIApplicationCommand {
|
||||
/**
|
||||
* Unique id of the command
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* Unique id of the parent application
|
||||
*/
|
||||
application_id: Snowflake;
|
||||
/**
|
||||
* Guild id of the command, if not global
|
||||
*/
|
||||
guild_id?: Snowflake;
|
||||
/**
|
||||
* 1-32 character name matching `^[\w-]{1,32}$`
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* 1-100 character description
|
||||
*/
|
||||
description: string;
|
||||
/**
|
||||
* The parameters for the command
|
||||
*/
|
||||
options?: APIApplicationCommandOption[];
|
||||
/**
|
||||
* Whether the command is enabled by default when the app is added to a guild
|
||||
*
|
||||
* If missing, this property should be assumed as `true`
|
||||
*/
|
||||
default_permission?: boolean;
|
||||
}
|
||||
|
||||
interface APIApplicationCommandOptionBase {
|
||||
type:
|
||||
| ApplicationCommandOptionType.Boolean
|
||||
| ApplicationCommandOptionType.User
|
||||
| ApplicationCommandOptionType.Channel
|
||||
| ApplicationCommandOptionType.Role
|
||||
| ApplicationCommandOptionType.Mentionable;
|
||||
name: string;
|
||||
description: string;
|
||||
default?: boolean;
|
||||
required?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-structure
|
||||
*/
|
||||
export type APIApplicationCommandOption =
|
||||
| APIApplicationCommandArgumentOptions
|
||||
| APIApplicationCommandSubCommandOptions
|
||||
| APIApplicationCommandOptionBase;
|
||||
|
||||
/**
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
*
|
||||
* If the option is a `SUB_COMMAND` or `SUB_COMMAND_GROUP` type, this nested options will be the parameters
|
||||
*/
|
||||
export interface APIApplicationCommandSubCommandOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
|
||||
type: ApplicationCommandOptionType.SubCommand | ApplicationCommandOptionType.SubCommandGroup;
|
||||
options?: APIApplicationCommandOption[];
|
||||
}
|
||||
|
||||
/**
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
*
|
||||
* In contrast to `APIApplicationCommandSubCommandOptions`, these types cannot have an `options` array,
|
||||
* but they can have a `choices` one
|
||||
*/
|
||||
export interface APIApplicationCommandArgumentOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
|
||||
type: ApplicationCommandOptionType.String | ApplicationCommandOptionType.Integer;
|
||||
choices?: APIApplicationCommandOptionChoice[];
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-type
|
||||
*/
|
||||
export enum ApplicationCommandOptionType {
|
||||
SubCommand = 1,
|
||||
SubCommandGroup,
|
||||
String,
|
||||
Integer,
|
||||
Boolean,
|
||||
User,
|
||||
Channel,
|
||||
Role,
|
||||
Mentionable,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-choice-structure
|
||||
*/
|
||||
export interface APIApplicationCommandOptionChoice {
|
||||
name: string;
|
||||
value: string | number;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-object-interaction-structure
|
||||
*/
|
||||
export interface APIApplicationCommandInteractionData {
|
||||
id: Snowflake;
|
||||
name: string;
|
||||
options?: APIApplicationCommandInteractionDataOption[];
|
||||
resolved?: {
|
||||
users?: Record<Snowflake, APIUser>;
|
||||
roles?: Record<Snowflake, APIRole>;
|
||||
members?: Record<Snowflake, APIInteractionDataResolvedGuildMember>;
|
||||
channels?: Record<Snowflake, APIInteractionDataResolvedChannel>;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/channel#channel-object
|
||||
*/
|
||||
export interface APIInteractionDataResolvedChannel extends Required<APIPartialChannel> {
|
||||
permissions: Permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#guild-member-object
|
||||
*/
|
||||
export interface APIInteractionDataResolvedGuildMember extends Omit<APIGuildMember, 'user' | 'deaf' | 'mute'> {
|
||||
permissions: Permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-object-application-command-interaction-data-option-structure
|
||||
*/
|
||||
export type APIApplicationCommandInteractionDataOption =
|
||||
| ApplicationCommandInteractionDataOptionSubCommand
|
||||
| ApplicationCommandInteractionDataOptionSubCommandGroup
|
||||
| APIApplicationCommandInteractionDataOptionWithValues;
|
||||
|
||||
export interface ApplicationCommandInteractionDataOptionSubCommand {
|
||||
name: string;
|
||||
type: ApplicationCommandOptionType.SubCommand;
|
||||
options: APIApplicationCommandInteractionDataOptionWithValues[];
|
||||
}
|
||||
|
||||
export interface ApplicationCommandInteractionDataOptionSubCommandGroup {
|
||||
name: string;
|
||||
type: ApplicationCommandOptionType.SubCommandGroup;
|
||||
options: ApplicationCommandInteractionDataOptionSubCommand[];
|
||||
}
|
||||
|
||||
export type APIApplicationCommandInteractionDataOptionWithValues =
|
||||
| ApplicationCommandInteractionDataOptionString
|
||||
| ApplicationCommandInteractionDataOptionRole
|
||||
| ApplicationCommandInteractionDataOptionChannel
|
||||
| ApplicationCommandInteractionDataOptionUser
|
||||
| ApplicationCommandInteractionDataOptionMentionable
|
||||
| ApplicationCommandInteractionDataOptionInteger
|
||||
| ApplicationCommandInteractionDataOptionBoolean;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionString = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.String,
|
||||
string
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionRole = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Role,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionChannel = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Channel,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionUser = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.User,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionMentionable = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Mentionable,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionInteger = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Integer,
|
||||
number
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionBoolean = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Boolean,
|
||||
boolean
|
||||
>;
|
||||
|
||||
interface InteractionDataOptionBase<T extends ApplicationCommandOptionType, D = unknown> {
|
||||
name: string;
|
||||
type: T;
|
||||
value: D;
|
||||
}
|
||||
|
||||
// PERMISSIONS
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#application-command-permissions-object-guild-application-command-permissions-structure
|
||||
*/
|
||||
export interface APIGuildApplicationCommandPermissions {
|
||||
/**
|
||||
* The id of the command
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* The id of the application the command belongs to
|
||||
*/
|
||||
application_id: Snowflake;
|
||||
/**
|
||||
* The id of the guild
|
||||
*/
|
||||
guild_id: Snowflake;
|
||||
/**
|
||||
* The permissions for the command in the guild
|
||||
*/
|
||||
permissions: APIApplicationCommandPermission[];
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#application-command-permissions-object-application-command-permissions-structure
|
||||
*/
|
||||
export interface APIApplicationCommandPermission {
|
||||
/**
|
||||
* The id of the role or user
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* Role or user
|
||||
*/
|
||||
type: ApplicationCommandPermissionType;
|
||||
/**
|
||||
* `true` to allow, `false`, to disallow
|
||||
*/
|
||||
permission: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissiontype
|
||||
*/
|
||||
export enum ApplicationCommandPermissionType {
|
||||
Role = 1,
|
||||
User,
|
||||
}
|
||||
|
||||
// INTERACTIONS
|
||||
|
||||
export type APIApplicationCommandInteraction = APIBaseInteraction<
|
||||
InteractionType.ApplicationCommand,
|
||||
APIApplicationCommandInteractionData
|
||||
> &
|
||||
Required<
|
||||
Pick<
|
||||
APIBaseInteraction<InteractionType.ApplicationCommand, APIApplicationCommandInteractionData>,
|
||||
'channel_id' | 'data'
|
||||
>
|
||||
>;
|
||||
|
||||
export type APIApplicationCommandDMInteraction = APIDMInteractionWrapper<APIApplicationCommandInteraction>;
|
||||
|
||||
export type APIApplicationCommandGuildInteraction = APIGuildInteractionWrapper<APIApplicationCommandInteraction>;
|
||||
@@ -544,7 +544,7 @@ export type APIAuditLogChangeKeyMute = AuditLogChangeData<'mute', boolean>;
|
||||
/**
|
||||
* Returned when a user's nick is changed
|
||||
*/
|
||||
export type APIAuditLogChangeKeyNick = AuditLogChangeData<'mute', boolean>;
|
||||
export type APIAuditLogChangeKeyNick = AuditLogChangeData<'nick', boolean>;
|
||||
|
||||
/**
|
||||
* Returned when a user's avatar_hash is changed
|
||||
|
||||
@@ -306,7 +306,11 @@ export interface APIMessage {
|
||||
*/
|
||||
application?: Partial<APIApplication>;
|
||||
/**
|
||||
* Reference data sent with crossposted messages and replies
|
||||
* If the message is a response to an Interaction, this is the id of the interaction's application
|
||||
*/
|
||||
application_id?: Snowflake;
|
||||
/**
|
||||
* Reference data sent with crossposted messages, replies, pins, and thread starter messages
|
||||
*
|
||||
* See https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure
|
||||
*/
|
||||
@@ -899,13 +903,13 @@ export interface APIAllowedMentions {
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components
|
||||
* https://discord.com/developers/docs/interactions/message-components#component-object
|
||||
*/
|
||||
export interface APIBaseComponent {
|
||||
export interface APIBaseMessageComponent<T extends ComponentType> {
|
||||
/**
|
||||
* The type of the component
|
||||
*/
|
||||
type: ComponentType;
|
||||
type: T;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -913,7 +917,7 @@ export interface APIBaseComponent {
|
||||
*/
|
||||
export enum ComponentType {
|
||||
/**
|
||||
* ActionRow component
|
||||
* Action Row component
|
||||
*/
|
||||
ActionRow = 1,
|
||||
/**
|
||||
@@ -927,13 +931,9 @@ export enum ComponentType {
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#component-object
|
||||
* https://discord.com/developers/docs/interactions/message-components#action-rows
|
||||
*/
|
||||
export interface APIActionRowComponent extends APIBaseComponent {
|
||||
/**
|
||||
* The type of the component
|
||||
*/
|
||||
type: ComponentType.ActionRow;
|
||||
export interface APIActionRowComponent extends APIBaseMessageComponent<ComponentType.ActionRow> {
|
||||
/**
|
||||
* The components in the ActionRow
|
||||
*/
|
||||
@@ -941,73 +941,97 @@ export interface APIActionRowComponent extends APIBaseComponent {
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#buttons-button-object
|
||||
* https://discord.com/developers/docs/interactions/message-components#buttons
|
||||
*/
|
||||
export interface APIButtonComponent extends APIBaseComponent {
|
||||
/**
|
||||
* The type of the component
|
||||
*/
|
||||
type: ComponentType.Button;
|
||||
interface APIButtonComponentBase<Style extends ButtonStyle> extends APIBaseMessageComponent<ComponentType.Button> {
|
||||
/**
|
||||
* The label to be displayed on the button
|
||||
*/
|
||||
label?: string;
|
||||
/**
|
||||
* The custom_id to be sent in the interaction when clicked
|
||||
*/
|
||||
custom_id?: string;
|
||||
/**
|
||||
* The style of the button
|
||||
*/
|
||||
style: ButtonStyle;
|
||||
style: Style;
|
||||
/**
|
||||
* The emoji to display to the left of the text
|
||||
*/
|
||||
emoji?: APIPartialEmoji;
|
||||
/**
|
||||
* The URL to direct users to when clicked for Link buttons
|
||||
*/
|
||||
url?: string;
|
||||
/**
|
||||
* The status of the button
|
||||
*/
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#component-object
|
||||
*/
|
||||
export interface APISelectMenuComponent {
|
||||
/**
|
||||
* The type of the component
|
||||
*/
|
||||
type: ComponentType.SelectMenu;
|
||||
export interface APIButtonComponentWithCustomID
|
||||
extends APIButtonComponentBase<
|
||||
ButtonStyle.Primary | ButtonStyle.Secondary | ButtonStyle.Success | ButtonStyle.Danger
|
||||
> {
|
||||
/**
|
||||
* The custom_id to be sent in the interaction when clicked
|
||||
*/
|
||||
custom_id: string;
|
||||
}
|
||||
|
||||
export interface APIButtonComponentWithURL extends APIButtonComponentBase<ButtonStyle.Link> {
|
||||
/**
|
||||
* Custom placeholder text if nothing is selected
|
||||
* The URL to direct users to when clicked for Link buttons
|
||||
*/
|
||||
placeholder?: string;
|
||||
/**
|
||||
* The minimum number of items that must be chosen
|
||||
*/
|
||||
min_values?: number;
|
||||
/**
|
||||
* The maximum number of items that can be chosen
|
||||
*/
|
||||
max_values?: number;
|
||||
/**
|
||||
* Choices to display in the select menu
|
||||
*/
|
||||
options: APISelectOption[];
|
||||
url: string;
|
||||
}
|
||||
|
||||
export type APIButtonComponent = APIButtonComponentWithCustomID | APIButtonComponentWithURL;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#button-object-button-styles
|
||||
*/
|
||||
export enum ButtonStyle {
|
||||
Primary = 1,
|
||||
Secondary,
|
||||
Success,
|
||||
Danger,
|
||||
Link,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#component-object
|
||||
* https://discord.com/developers/docs/interactions/message-components#select-menus
|
||||
*/
|
||||
export interface APISelectOption {
|
||||
export interface APISelectMenuComponent extends APIBaseMessageComponent<ComponentType.SelectMenu> {
|
||||
/**
|
||||
* A developer-defined identifier for the select menu, max 100 characters
|
||||
*/
|
||||
custom_id: string;
|
||||
/**
|
||||
* The choices in the select, max 25
|
||||
*/
|
||||
options: APISelectMenuOption[];
|
||||
/**
|
||||
* Custom placeholder text if nothing is selected, max 100 characters
|
||||
*/
|
||||
placeholder?: string;
|
||||
/**
|
||||
* The minimum number of items that must be chosen; min 0, max 25
|
||||
*
|
||||
* @default 1
|
||||
*/
|
||||
min_values?: number;
|
||||
/**
|
||||
* The maximum number of items that can be chosen; max 25
|
||||
*
|
||||
* @default 1
|
||||
*/
|
||||
max_values?: number;
|
||||
/**
|
||||
* Disable the select
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-option-structure
|
||||
*/
|
||||
export interface APISelectMenuOption {
|
||||
/**
|
||||
* The user-facing name of the option (max 25 chars)
|
||||
*/
|
||||
@@ -1027,18 +1051,10 @@ export interface APISelectOption {
|
||||
/**
|
||||
* Whether this option should be already-selected by default
|
||||
*/
|
||||
default: boolean;
|
||||
default?: boolean;
|
||||
}
|
||||
|
||||
export type APIMessageComponent = APIActionRowComponent | APIButtonComponent | APISelectMenuComponent;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#buttons-button-styles
|
||||
* https://discord.com/developers/docs/interactions/message-components#message-components
|
||||
*/
|
||||
export enum ButtonStyle {
|
||||
Primary = 1,
|
||||
Secondary,
|
||||
Success,
|
||||
Danger,
|
||||
Link,
|
||||
}
|
||||
export type APIMessageComponent = APIActionRowComponent | APIButtonComponent | APISelectMenuComponent;
|
||||
|
||||
@@ -481,6 +481,30 @@ export enum GuildFeature {
|
||||
* Guild can be previewed before joining via Membership Screening or the directory
|
||||
*/
|
||||
PreviewEnabled = 'PREVIEW_ENABLED',
|
||||
/**
|
||||
* Guild has enabled ticketed events
|
||||
*/
|
||||
TicketedEventsEnabled = 'TICKETED_EVENTS_ENABLED',
|
||||
/**
|
||||
* Guild has enabled monetization
|
||||
*/
|
||||
MonetizationEnabled = 'MONETIZATION_ENABLED',
|
||||
/**
|
||||
* Guild has increased custom sticker slots
|
||||
*/
|
||||
MoreStickers = 'MORE_STICKERS',
|
||||
/**
|
||||
* Guild has access to the three day archive time for threads
|
||||
*/
|
||||
ThreeDayThreadArchive = 'THREE_DAY_THREAD_ARCHIVE',
|
||||
/**
|
||||
* Guild has access to the seven day archive time for threads
|
||||
*/
|
||||
SevenDayThreadArchive = 'SEVEN_DAY_THREAD_ARCHIVE',
|
||||
/**
|
||||
* Guild has access to create private threads
|
||||
*/
|
||||
PrivateThreads = 'PRIVATE_THREADS',
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,470 +1,21 @@
|
||||
import type { Permissions, Snowflake } from '../../globals.ts';
|
||||
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../rest/v8/mod.ts';
|
||||
import { APIMessage, ComponentType } from './channel.ts';
|
||||
import type { APIGuildMember, APIPartialChannel, APIRole, APIUser, MessageFlags } from './mod.ts';
|
||||
import {
|
||||
APIMessageComponentDMInteraction,
|
||||
APIMessageComponentGuildInteraction,
|
||||
APIMessageComponentInteraction,
|
||||
} from './_interactions/messageComponents.ts';
|
||||
import {
|
||||
APIApplicationCommandDMInteraction,
|
||||
APIApplicationCommandGuildInteraction,
|
||||
APIApplicationCommandInteraction,
|
||||
} from './_interactions/slashCommands.ts';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommand
|
||||
*/
|
||||
export interface APIApplicationCommand {
|
||||
/**
|
||||
* Unique id of the command
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* Unique id of the parent application
|
||||
*/
|
||||
application_id: Snowflake;
|
||||
/**
|
||||
* 1-32 character name matching `^[\w-]{1,32}$`
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* 1-100 character description
|
||||
*/
|
||||
description: string;
|
||||
/**
|
||||
* The parameters for the command
|
||||
*/
|
||||
options?: APIApplicationCommandOption[];
|
||||
/**
|
||||
* Whether the command is enabled by default when the app is added to a guild
|
||||
*
|
||||
* If missing, this property should be assumed as `true`
|
||||
*/
|
||||
default_permission?: boolean;
|
||||
}
|
||||
export * from './_interactions/base.ts';
|
||||
export * from './_interactions/messageComponents.ts';
|
||||
export * from './_interactions/responses.ts';
|
||||
export * from './_interactions/slashCommands.ts';
|
||||
|
||||
interface APIApplicationCommandOptionBase {
|
||||
type:
|
||||
| ApplicationCommandOptionType.Boolean
|
||||
| ApplicationCommandOptionType.User
|
||||
| ApplicationCommandOptionType.Channel
|
||||
| ApplicationCommandOptionType.Role
|
||||
| ApplicationCommandOptionType.Mentionable;
|
||||
name: string;
|
||||
description: string;
|
||||
default?: boolean;
|
||||
required?: boolean;
|
||||
}
|
||||
export type APIInteraction = APIApplicationCommandInteraction | APIMessageComponentInteraction;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoption
|
||||
*/
|
||||
export type APIApplicationCommandOption =
|
||||
| APIApplicationCommandArgumentOptions
|
||||
| APIApplicationCommandSubCommandOptions
|
||||
| APIApplicationCommandOptionBase;
|
||||
export type APIDMInteraction = APIApplicationCommandDMInteraction | APIMessageComponentDMInteraction;
|
||||
|
||||
/**
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
*
|
||||
* If the option is a `SUB_COMMAND` or `SUB_COMMAND_GROUP` type, this nested options will be the parameters
|
||||
*/
|
||||
export interface APIApplicationCommandSubCommandOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
|
||||
type: ApplicationCommandOptionType.SubCommand | ApplicationCommandOptionType.SubCommandGroup;
|
||||
options?: APIApplicationCommandOption[];
|
||||
}
|
||||
|
||||
/**
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
*
|
||||
* In contrast to `APIApplicationCommandSubCommandOptions`, these types cannot have an `options` array,
|
||||
* but they can have a `choices` one
|
||||
*/
|
||||
export interface APIApplicationCommandArgumentOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
|
||||
type: ApplicationCommandOptionType.String | ApplicationCommandOptionType.Integer;
|
||||
choices?: APIApplicationCommandOptionChoice[];
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptiontype
|
||||
*/
|
||||
export enum ApplicationCommandOptionType {
|
||||
SubCommand = 1,
|
||||
SubCommandGroup,
|
||||
String,
|
||||
Integer,
|
||||
Boolean,
|
||||
User,
|
||||
Channel,
|
||||
Role,
|
||||
Mentionable,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptionchoice
|
||||
*/
|
||||
export interface APIApplicationCommandOptionChoice {
|
||||
name: string;
|
||||
value: string | number;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction
|
||||
*/
|
||||
export interface APIBaseInteraction {
|
||||
/**
|
||||
* ID of the interaction
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* ID of the application this interaction is for
|
||||
*/
|
||||
application_id: Snowflake;
|
||||
/**
|
||||
* The type of interaction
|
||||
*/
|
||||
type: InteractionType;
|
||||
/**
|
||||
* The command data payload
|
||||
*/
|
||||
data?: APIApplicationCommandInteractionData | APIMessageComponentInteractionData;
|
||||
/**
|
||||
* The channel it was sent from
|
||||
*/
|
||||
channel_id?: Snowflake;
|
||||
/**
|
||||
* A continuation token for responding to the interaction
|
||||
*/
|
||||
token: string;
|
||||
/**
|
||||
* Read-only property, always `1`
|
||||
*/
|
||||
version: 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#guild-member-object
|
||||
*/
|
||||
export interface APIInteractionGuildMember extends APIGuildMember {
|
||||
permissions: Permissions;
|
||||
user: APIUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction
|
||||
*/
|
||||
export interface APIGuildInteraction extends APIBaseInteraction {
|
||||
/**
|
||||
* The guild it was sent from
|
||||
*
|
||||
* In the case of an `APIDMInteraction`, this will not be present
|
||||
*/
|
||||
guild_id: Snowflake;
|
||||
/**
|
||||
* Guild member data for the invoking user, including permissions
|
||||
*/
|
||||
member: APIInteractionGuildMember;
|
||||
channel_id: Snowflake;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction
|
||||
*/
|
||||
export interface APIDMInteraction extends APIBaseInteraction {
|
||||
/**
|
||||
* User object for the invoking user, if invoked in a DM
|
||||
*/
|
||||
user: APIUser;
|
||||
channel_id: Snowflake;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#buttons-button-interaction
|
||||
*/
|
||||
export interface APIMessageComponentInteraction extends APIBaseInteraction {
|
||||
/**
|
||||
* Message object to which the button was attached
|
||||
*/
|
||||
message: APIMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction
|
||||
*/
|
||||
export type APIInteraction = APIGuildInteraction | APIDMInteraction | APIMessageComponentInteraction;
|
||||
|
||||
/**
|
||||
* Like APIGuildInteraction, only with the `data` property always present
|
||||
*
|
||||
* @see APIGuildInteraction
|
||||
*/
|
||||
export type APIApplicationCommandGuildInteraction = Required<APIGuildInteraction>;
|
||||
|
||||
/**
|
||||
* Like APIDMInteraction, only with the `data` property always present
|
||||
*
|
||||
* @see APIDMInteraction
|
||||
*/
|
||||
export type APIApplicationCommandDMInteraction = Required<APIDMInteraction>;
|
||||
|
||||
/**
|
||||
* Like APIInteraction, only with the `data` property always present
|
||||
*
|
||||
* @see APIInteraction
|
||||
*/
|
||||
export type APIApplicationCommandInteraction =
|
||||
| APIApplicationCommandGuildInteraction
|
||||
| APIApplicationCommandDMInteraction;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-interactiontype
|
||||
*/
|
||||
export enum InteractionType {
|
||||
Ping = 1,
|
||||
ApplicationCommand,
|
||||
MessageComponent,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#guildapplicationcommandpermissions
|
||||
*/
|
||||
export interface APIGuildApplicationCommandPermissions {
|
||||
/**
|
||||
* The id of the command
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* The id of the application the command belongs to
|
||||
*/
|
||||
application_id: Snowflake;
|
||||
/**
|
||||
* The id of the guild
|
||||
*/
|
||||
guild_id: Snowflake;
|
||||
/**
|
||||
* The permissions for the command in the guild
|
||||
*/
|
||||
permissions: APIApplicationCommandPermission[];
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissions
|
||||
*/
|
||||
export interface APIApplicationCommandPermission {
|
||||
/**
|
||||
* The id of the role or user
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* Role or user
|
||||
*/
|
||||
type: ApplicationCommandPermissionType;
|
||||
/**
|
||||
* `true` to allow, `false`, to disallow
|
||||
*/
|
||||
permission: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissiontype
|
||||
*/
|
||||
export enum ApplicationCommandPermissionType {
|
||||
Role = 1,
|
||||
User,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/channel#channel-object
|
||||
*/
|
||||
export interface APIInteractionDataResolvedChannel extends Required<APIPartialChannel> {
|
||||
permissions: Permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#guild-member-object
|
||||
*/
|
||||
export interface APIInteractionDataResolvedGuildMember extends Omit<APIGuildMember, 'user' | 'deaf' | 'mute'> {
|
||||
permissions: Permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondata
|
||||
*/
|
||||
export interface APIApplicationCommandInteractionData {
|
||||
id: Snowflake;
|
||||
name: string;
|
||||
options?: APIApplicationCommandInteractionDataOption[];
|
||||
resolved?: {
|
||||
users?: Record<string, APIUser>;
|
||||
roles?: Record<string, APIRole>;
|
||||
members?: Record<string, APIInteractionDataResolvedGuildMember>;
|
||||
channels?: Record<string, APIInteractionDataResolvedChannel>;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondataoption
|
||||
*/
|
||||
export type APIApplicationCommandInteractionDataOption =
|
||||
| ApplicationCommandInteractionDataOptionSubCommand
|
||||
| ApplicationCommandInteractionDataOptionSubCommandGroup
|
||||
| APIApplicationCommandInteractionDataOptionWithValues;
|
||||
|
||||
export interface ApplicationCommandInteractionDataOptionSubCommand {
|
||||
name: string;
|
||||
type: ApplicationCommandOptionType.SubCommand;
|
||||
options: APIApplicationCommandInteractionDataOptionWithValues[];
|
||||
}
|
||||
|
||||
export interface ApplicationCommandInteractionDataOptionSubCommandGroup {
|
||||
name: string;
|
||||
type: ApplicationCommandOptionType.SubCommandGroup;
|
||||
options: ApplicationCommandInteractionDataOptionSubCommand[];
|
||||
}
|
||||
|
||||
export type APIApplicationCommandInteractionDataOptionWithValues =
|
||||
| ApplicationCommandInteractionDataOptionString
|
||||
| ApplicationCommandInteractionDataOptionRole
|
||||
| ApplicationCommandInteractionDataOptionChannel
|
||||
| ApplicationCommandInteractionDataOptionUser
|
||||
| ApplicationCommandInteractionDataOptionMentionable
|
||||
| ApplicationCommandInteractionDataOptionInteger
|
||||
| ApplicationCommandInteractionDataOptionBoolean;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionString = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.String,
|
||||
string
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionRole = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Role,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionChannel = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Channel,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionUser = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.User,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionMentionable = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Mentionable,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionInteger = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Integer,
|
||||
number
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionBoolean = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Boolean,
|
||||
boolean
|
||||
>;
|
||||
|
||||
export interface APIMessageButtonInteractionData {
|
||||
custom_id: string;
|
||||
component_type: ComponentType.Button;
|
||||
}
|
||||
|
||||
export interface APIMessageSelectMenuInteractionData {
|
||||
custom_id: string;
|
||||
component_type: ComponentType.SelectMenu;
|
||||
values: string[];
|
||||
}
|
||||
|
||||
export type APIMessageComponentInteractionData = APIMessageButtonInteractionData | APIMessageSelectMenuInteractionData;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response
|
||||
*/
|
||||
export type APIInteractionResponse =
|
||||
| APIInteractionResponsePong
|
||||
| APIInteractionResponseChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredMessageUpdate
|
||||
| APIInteractionResponseUpdateMessage;
|
||||
|
||||
export interface APIInteractionResponsePong {
|
||||
type: InteractionResponseType.Pong;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseChannelMessageWithSource {
|
||||
type: InteractionResponseType.ChannelMessageWithSource;
|
||||
data: APIInteractionApplicationCommandCallbackData;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseDeferredChannelMessageWithSource {
|
||||
type: InteractionResponseType.DeferredChannelMessageWithSource;
|
||||
data?: Pick<APIInteractionApplicationCommandCallbackData, 'flags'>;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseDeferredMessageUpdate {
|
||||
type: InteractionResponseType.DeferredMessageUpdate;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseUpdateMessage {
|
||||
type: InteractionResponseType.UpdateMessage;
|
||||
data?: APIInteractionApplicationCommandCallbackData;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionresponsetype
|
||||
*/
|
||||
export enum InteractionResponseType {
|
||||
/**
|
||||
* ACK a `Ping`
|
||||
*/
|
||||
Pong = 1,
|
||||
/**
|
||||
* Respond to an interaction with a message
|
||||
*/
|
||||
ChannelMessageWithSource = 4,
|
||||
/**
|
||||
* ACK an interaction and edit to a response later, the user sees a loading state
|
||||
*/
|
||||
DeferredChannelMessageWithSource,
|
||||
/**
|
||||
* ACK a button interaction and update it to a loading state
|
||||
*/
|
||||
DeferredMessageUpdate,
|
||||
/**
|
||||
* ACK a button interaction and edit the message to which the button was attached
|
||||
*/
|
||||
UpdateMessage,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionapplicationcommandcallbackdata
|
||||
*/
|
||||
export type APIInteractionApplicationCommandCallbackData = Omit<
|
||||
RESTPostAPIWebhookWithTokenJSONBody,
|
||||
'username' | 'avatar_url'
|
||||
> & { flags?: MessageFlags };
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#messageinteraction
|
||||
*/
|
||||
export interface APIMessageInteraction {
|
||||
/**
|
||||
* ID of the interaction
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* The type of interaction
|
||||
*/
|
||||
type: InteractionType;
|
||||
/**
|
||||
* The name of the ApplicationCommand
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* The user who invoked the interaction
|
||||
*/
|
||||
user: APIUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
interface InteractionDataOptionBase<T extends ApplicationCommandOptionType, D = unknown> {
|
||||
name: string;
|
||||
type: T;
|
||||
value: D;
|
||||
}
|
||||
export type APIGuildInteraction = APIApplicationCommandGuildInteraction | APIMessageComponentGuildInteraction;
|
||||
|
||||
@@ -51,7 +51,7 @@ export interface APIApplication {
|
||||
*
|
||||
* See https://discord.com/developers/docs/resources/user#user-object
|
||||
*/
|
||||
owner: APIUser;
|
||||
owner?: APIUser;
|
||||
/**
|
||||
* If this application is a game sold on Discord, this field will be the summary field for the store page
|
||||
* of its primary sku
|
||||
@@ -153,11 +153,11 @@ export enum OAuth2Scopes {
|
||||
*/
|
||||
MessagesRead = 'messages.read',
|
||||
/**
|
||||
* For local rpc server access, this allows you to control a user's local Discord client - whitelist only
|
||||
* For local rpc server access, this allows you to control a user's local Discord client - requires Discord approval
|
||||
*/
|
||||
RPC = 'rpc',
|
||||
/**
|
||||
* For local rpc server api access, this allows you to receive notifications pushed out to the user - whitelist only
|
||||
* For local rpc server api access, this allows you to receive notifications pushed out to the user - requires Discord approval
|
||||
*/
|
||||
RPCNotificationsRead = 'rpc.notifications.read',
|
||||
/**
|
||||
@@ -165,7 +165,7 @@ export enum OAuth2Scopes {
|
||||
*/
|
||||
WebhookIncoming = 'webhook.incoming',
|
||||
/**
|
||||
* Allows your app to upload/update builds for a user's applications - whitelist only
|
||||
* Allows your app to upload/update builds for a user's applications - requires Discord approval
|
||||
*/
|
||||
ApplicationsBuildsUpload = 'applications.builds.upload',
|
||||
/**
|
||||
@@ -181,27 +181,27 @@ export enum OAuth2Scopes {
|
||||
*/
|
||||
ApplicationsEntitlements = 'applications.entitlements',
|
||||
/**
|
||||
* Allows your app to know a user's friends and implicit relationships - whitelist only
|
||||
* Allows your app to know a user's friends and implicit relationships - requires Discord approval
|
||||
*/
|
||||
RelationshipsRead = 'relationships.read',
|
||||
/**
|
||||
* Allows your app to fetch data from a user's "Now Playing/Recently Played" list - whitelist only
|
||||
* Allows your app to fetch data from a user's "Now Playing/Recently Played" list - requires Discord approval
|
||||
*/
|
||||
ActivitiesRead = 'activities.read',
|
||||
/**
|
||||
* Allows your app to update a user's activity - whitelist only (NOT REQUIRED FOR GAMESDK ACTIVITY MANAGER)
|
||||
* Allows your app to update a user's activity - requires Discord approval (NOT REQUIRED FOR GAMESDK ACTIVITY MANAGER)
|
||||
*
|
||||
* See https://discord.com/developers/docs/game-sdk/activities
|
||||
*/
|
||||
ActivitiesWrite = 'activities.write',
|
||||
/**
|
||||
* Allows your app to create Slash Commands in the authorized guild
|
||||
* Allows your app to use Slash Commands in a guild
|
||||
*
|
||||
* See https://discord.com/developers/docs/interactions/slash-commands
|
||||
*/
|
||||
ApplicationsCommands = 'applications.commands',
|
||||
/**
|
||||
* Allows your app to update Slash Commands via this bearer token
|
||||
* Allows your app to update its Slash Commands via this bearer token - client credentials grant only
|
||||
*
|
||||
* See https://discord.com/developers/docs/interactions/slash-commands
|
||||
*/
|
||||
|
||||
@@ -88,6 +88,7 @@ export enum UserFlags {
|
||||
BugHunterLevel2 = 1 << 14,
|
||||
VerifiedBot = 1 << 16,
|
||||
EarlyVerifiedBotDeveloper = 1 << 17,
|
||||
DiscordCertifiedModerator = 1 << 18,
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
101
deno/payloads/v9/_interactions/base.ts
Normal file
101
deno/payloads/v9/_interactions/base.ts
Normal file
@@ -0,0 +1,101 @@
|
||||
import { Permissions, Snowflake } from '../../../globals.ts';
|
||||
import { InteractionType } from '../../v9.ts';
|
||||
import { APIMessage } from '../channel.ts';
|
||||
import { APIGuildMember } from '../guild.ts';
|
||||
import { APIUser } from '../user.ts';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#message-interaction-object-message-interaction-structure
|
||||
*/
|
||||
export interface APIMessageInteraction {
|
||||
/**
|
||||
* ID of the interaction
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* The type of interaction
|
||||
*/
|
||||
type: InteractionType;
|
||||
/**
|
||||
* The name of the ApplicationCommand
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* The user who invoked the interaction
|
||||
*/
|
||||
user: APIUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#guild-member-object
|
||||
*/
|
||||
export interface APIInteractionGuildMember extends APIGuildMember {
|
||||
permissions: Permissions;
|
||||
user: APIUser;
|
||||
}
|
||||
|
||||
// INTERACTIONS RECEIVED
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-object
|
||||
*/
|
||||
export interface APIBaseInteraction<Type extends InteractionType, Data extends unknown> {
|
||||
/**
|
||||
* ID of the interaction
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* ID of the application this interaction is for
|
||||
*/
|
||||
application_id: Snowflake;
|
||||
/**
|
||||
* The type of interaction
|
||||
*/
|
||||
type: Type;
|
||||
/**
|
||||
* The command data payload
|
||||
*/
|
||||
data?: Data;
|
||||
/**
|
||||
* The guild it was sent from
|
||||
*/
|
||||
guild_id?: Snowflake;
|
||||
/**
|
||||
* The channel it was sent from
|
||||
*/
|
||||
channel_id?: Snowflake;
|
||||
/**
|
||||
* Guild member data for the invoking user, including permissions
|
||||
*
|
||||
* **This is only sent when an interaction is invoked in a guild**
|
||||
*/
|
||||
member?: APIInteractionGuildMember;
|
||||
/**
|
||||
* User object for the invoking user, if invoked in a DM
|
||||
*/
|
||||
user?: APIUser;
|
||||
/**
|
||||
* A continuation token for responding to the interaction
|
||||
*/
|
||||
token: string;
|
||||
/**
|
||||
* Read-only property, always `1`
|
||||
*/
|
||||
version: 1;
|
||||
/**
|
||||
* For components, the message they were attached to
|
||||
*/
|
||||
message?: APIMessage;
|
||||
}
|
||||
|
||||
export type APIDMInteractionWrapper<Original extends APIBaseInteraction<InteractionType, unknown>> = Omit<
|
||||
Original,
|
||||
'member' | 'guild_id'
|
||||
> &
|
||||
Required<Pick<Original, 'user'>>;
|
||||
|
||||
export type APIGuildInteractionWrapper<Original extends APIBaseInteraction<InteractionType, unknown>> = Omit<
|
||||
Original,
|
||||
'user'
|
||||
> &
|
||||
Required<Pick<Original, 'member' | 'guild_id'>>;
|
||||
38
deno/payloads/v9/_interactions/messageComponents.ts
Normal file
38
deno/payloads/v9/_interactions/messageComponents.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { ComponentType } from '../channel.ts';
|
||||
import { APIBaseInteraction, InteractionType } from '../interactions.ts';
|
||||
import { APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base.ts';
|
||||
|
||||
export type APIMessageComponentInteraction = APIBaseInteraction<
|
||||
InteractionType.MessageComponent,
|
||||
APIMessageComponentInteractionData
|
||||
> &
|
||||
Required<
|
||||
Pick<
|
||||
APIBaseInteraction<InteractionType.MessageComponent, APIMessageComponentInteractionData>,
|
||||
'channel_id' | 'data' | 'message'
|
||||
>
|
||||
>;
|
||||
|
||||
export type APIMessageComponentInteractionData = APIMessageButtonInteractionData | APIMessageSelectMenuInteractionData;
|
||||
|
||||
export interface APIMessageComponentBaseInteractionData<CType extends ComponentType> {
|
||||
/**
|
||||
* The `custom_id` of the component
|
||||
*/
|
||||
custom_id: string;
|
||||
/**
|
||||
* The type of the component
|
||||
*/
|
||||
component_type: CType;
|
||||
}
|
||||
|
||||
export type APIMessageButtonInteractionData = APIMessageComponentBaseInteractionData<ComponentType.Button>;
|
||||
|
||||
export interface APIMessageSelectMenuInteractionData
|
||||
extends APIMessageComponentBaseInteractionData<ComponentType.SelectMenu> {
|
||||
values: string[];
|
||||
}
|
||||
|
||||
export type APIMessageComponentDMInteraction = APIDMInteractionWrapper<APIMessageComponentInteraction>;
|
||||
|
||||
export type APIMessageComponentGuildInteraction = APIGuildInteractionWrapper<APIMessageComponentInteraction>;
|
||||
78
deno/payloads/v9/_interactions/responses.ts
Normal file
78
deno/payloads/v9/_interactions/responses.ts
Normal file
@@ -0,0 +1,78 @@
|
||||
import { MessageFlags } from '../mod.ts';
|
||||
import { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v9.ts';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-object-interaction-request-type
|
||||
*/
|
||||
export enum InteractionType {
|
||||
Ping = 1,
|
||||
ApplicationCommand,
|
||||
MessageComponent,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object
|
||||
*/
|
||||
export type APIInteractionResponse =
|
||||
| APIInteractionResponsePong
|
||||
| APIInteractionResponseChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredMessageUpdate
|
||||
| APIInteractionResponseUpdateMessage;
|
||||
|
||||
export interface APIInteractionResponsePong {
|
||||
type: InteractionResponseType.Pong;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseChannelMessageWithSource {
|
||||
type: InteractionResponseType.ChannelMessageWithSource;
|
||||
data: APIInteractionResponseCallbackData;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseDeferredChannelMessageWithSource {
|
||||
type: InteractionResponseType.DeferredChannelMessageWithSource;
|
||||
data?: Pick<APIInteractionResponseCallbackData, 'flags'>;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseDeferredMessageUpdate {
|
||||
type: InteractionResponseType.DeferredMessageUpdate;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseUpdateMessage {
|
||||
type: InteractionResponseType.UpdateMessage;
|
||||
data?: APIInteractionResponseCallbackData;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object-interaction-callback-type
|
||||
*/
|
||||
export enum InteractionResponseType {
|
||||
/**
|
||||
* ACK a `Ping`
|
||||
*/
|
||||
Pong = 1,
|
||||
/**
|
||||
* Respond to an interaction with a message
|
||||
*/
|
||||
ChannelMessageWithSource = 4,
|
||||
/**
|
||||
* ACK an interaction and edit to a response later, the user sees a loading state
|
||||
*/
|
||||
DeferredChannelMessageWithSource,
|
||||
/**
|
||||
* ACK a button interaction and update it to a loading state
|
||||
*/
|
||||
DeferredMessageUpdate,
|
||||
/**
|
||||
* ACK a button interaction and edit the message to which the button was attached
|
||||
*/
|
||||
UpdateMessage,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object-interaction-application-command-callback-data-structure
|
||||
*/
|
||||
export type APIInteractionResponseCallbackData = Omit<
|
||||
RESTPostAPIWebhookWithTokenJSONBody,
|
||||
'username' | 'avatar_url'
|
||||
> & { flags?: MessageFlags };
|
||||
273
deno/payloads/v9/_interactions/slashCommands.ts
Normal file
273
deno/payloads/v9/_interactions/slashCommands.ts
Normal file
@@ -0,0 +1,273 @@
|
||||
import { APIRole, APIUser } from '../mod.ts';
|
||||
import { Permissions, Snowflake } from '../../../globals.ts';
|
||||
import { APIPartialChannel } from '../channel.ts';
|
||||
import { APIGuildMember } from '../guild.ts';
|
||||
import { APIBaseInteraction, APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base.ts';
|
||||
import { InteractionType } from './responses.ts';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#application-command-object
|
||||
*/
|
||||
export interface APIApplicationCommand {
|
||||
/**
|
||||
* Unique id of the command
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* Unique id of the parent application
|
||||
*/
|
||||
application_id: Snowflake;
|
||||
/**
|
||||
* Guild id of the command, if not global
|
||||
*/
|
||||
guild_id?: Snowflake;
|
||||
/**
|
||||
* 1-32 character name matching `^[\w-]{1,32}$`
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* 1-100 character description
|
||||
*/
|
||||
description: string;
|
||||
/**
|
||||
* The parameters for the command
|
||||
*/
|
||||
options?: APIApplicationCommandOption[];
|
||||
/**
|
||||
* Whether the command is enabled by default when the app is added to a guild
|
||||
*
|
||||
* If missing, this property should be assumed as `true`
|
||||
*/
|
||||
default_permission?: boolean;
|
||||
}
|
||||
|
||||
interface APIApplicationCommandOptionBase {
|
||||
type:
|
||||
| ApplicationCommandOptionType.Boolean
|
||||
| ApplicationCommandOptionType.User
|
||||
| ApplicationCommandOptionType.Channel
|
||||
| ApplicationCommandOptionType.Role
|
||||
| ApplicationCommandOptionType.Mentionable;
|
||||
name: string;
|
||||
description: string;
|
||||
default?: boolean;
|
||||
required?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-structure
|
||||
*/
|
||||
export type APIApplicationCommandOption =
|
||||
| APIApplicationCommandArgumentOptions
|
||||
| APIApplicationCommandSubCommandOptions
|
||||
| APIApplicationCommandOptionBase;
|
||||
|
||||
/**
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
*
|
||||
* If the option is a `SUB_COMMAND` or `SUB_COMMAND_GROUP` type, this nested options will be the parameters
|
||||
*/
|
||||
export interface APIApplicationCommandSubCommandOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
|
||||
type: ApplicationCommandOptionType.SubCommand | ApplicationCommandOptionType.SubCommandGroup;
|
||||
options?: APIApplicationCommandOption[];
|
||||
}
|
||||
|
||||
/**
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
*
|
||||
* In contrast to `APIApplicationCommandSubCommandOptions`, these types cannot have an `options` array,
|
||||
* but they can have a `choices` one
|
||||
*/
|
||||
export interface APIApplicationCommandArgumentOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
|
||||
type: ApplicationCommandOptionType.String | ApplicationCommandOptionType.Integer;
|
||||
choices?: APIApplicationCommandOptionChoice[];
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-type
|
||||
*/
|
||||
export enum ApplicationCommandOptionType {
|
||||
SubCommand = 1,
|
||||
SubCommandGroup,
|
||||
String,
|
||||
Integer,
|
||||
Boolean,
|
||||
User,
|
||||
Channel,
|
||||
Role,
|
||||
Mentionable,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-choice-structure
|
||||
*/
|
||||
export interface APIApplicationCommandOptionChoice {
|
||||
name: string;
|
||||
value: string | number;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-object-interaction-structure
|
||||
*/
|
||||
export interface APIApplicationCommandInteractionData {
|
||||
id: Snowflake;
|
||||
name: string;
|
||||
options?: APIApplicationCommandInteractionDataOption[];
|
||||
resolved?: {
|
||||
users?: Record<Snowflake, APIUser>;
|
||||
roles?: Record<Snowflake, APIRole>;
|
||||
members?: Record<Snowflake, APIInteractionDataResolvedGuildMember>;
|
||||
channels?: Record<Snowflake, APIInteractionDataResolvedChannel>;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/channel#channel-object
|
||||
*/
|
||||
export interface APIInteractionDataResolvedChannel extends Required<APIPartialChannel> {
|
||||
permissions: Permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#guild-member-object
|
||||
*/
|
||||
export interface APIInteractionDataResolvedGuildMember extends Omit<APIGuildMember, 'user' | 'deaf' | 'mute'> {
|
||||
permissions: Permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-object-application-command-interaction-data-option-structure
|
||||
*/
|
||||
export type APIApplicationCommandInteractionDataOption =
|
||||
| ApplicationCommandInteractionDataOptionSubCommand
|
||||
| ApplicationCommandInteractionDataOptionSubCommandGroup
|
||||
| APIApplicationCommandInteractionDataOptionWithValues;
|
||||
|
||||
export interface ApplicationCommandInteractionDataOptionSubCommand {
|
||||
name: string;
|
||||
type: ApplicationCommandOptionType.SubCommand;
|
||||
options: APIApplicationCommandInteractionDataOptionWithValues[];
|
||||
}
|
||||
|
||||
export interface ApplicationCommandInteractionDataOptionSubCommandGroup {
|
||||
name: string;
|
||||
type: ApplicationCommandOptionType.SubCommandGroup;
|
||||
options: ApplicationCommandInteractionDataOptionSubCommand[];
|
||||
}
|
||||
|
||||
export type APIApplicationCommandInteractionDataOptionWithValues =
|
||||
| ApplicationCommandInteractionDataOptionString
|
||||
| ApplicationCommandInteractionDataOptionRole
|
||||
| ApplicationCommandInteractionDataOptionChannel
|
||||
| ApplicationCommandInteractionDataOptionUser
|
||||
| ApplicationCommandInteractionDataOptionMentionable
|
||||
| ApplicationCommandInteractionDataOptionInteger
|
||||
| ApplicationCommandInteractionDataOptionBoolean;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionString = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.String,
|
||||
string
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionRole = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Role,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionChannel = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Channel,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionUser = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.User,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionMentionable = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Mentionable,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionInteger = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Integer,
|
||||
number
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionBoolean = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Boolean,
|
||||
boolean
|
||||
>;
|
||||
|
||||
interface InteractionDataOptionBase<T extends ApplicationCommandOptionType, D = unknown> {
|
||||
name: string;
|
||||
type: T;
|
||||
value: D;
|
||||
}
|
||||
|
||||
// PERMISSIONS
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#application-command-permissions-object-guild-application-command-permissions-structure
|
||||
*/
|
||||
export interface APIGuildApplicationCommandPermissions {
|
||||
/**
|
||||
* The id of the command
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* The id of the application the command belongs to
|
||||
*/
|
||||
application_id: Snowflake;
|
||||
/**
|
||||
* The id of the guild
|
||||
*/
|
||||
guild_id: Snowflake;
|
||||
/**
|
||||
* The permissions for the command in the guild
|
||||
*/
|
||||
permissions: APIApplicationCommandPermission[];
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#application-command-permissions-object-application-command-permissions-structure
|
||||
*/
|
||||
export interface APIApplicationCommandPermission {
|
||||
/**
|
||||
* The id of the role or user
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* Role or user
|
||||
*/
|
||||
type: ApplicationCommandPermissionType;
|
||||
/**
|
||||
* `true` to allow, `false`, to disallow
|
||||
*/
|
||||
permission: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissiontype
|
||||
*/
|
||||
export enum ApplicationCommandPermissionType {
|
||||
Role = 1,
|
||||
User,
|
||||
}
|
||||
|
||||
// INTERACTIONS
|
||||
|
||||
export type APIApplicationCommandInteraction = APIBaseInteraction<
|
||||
InteractionType.ApplicationCommand,
|
||||
APIApplicationCommandInteractionData
|
||||
> &
|
||||
Required<
|
||||
Pick<
|
||||
APIBaseInteraction<InteractionType.ApplicationCommand, APIApplicationCommandInteractionData>,
|
||||
'channel_id' | 'data'
|
||||
>
|
||||
>;
|
||||
|
||||
export type APIApplicationCommandDMInteraction = APIDMInteractionWrapper<APIApplicationCommandInteraction>;
|
||||
|
||||
export type APIApplicationCommandGuildInteraction = APIGuildInteractionWrapper<APIApplicationCommandInteraction>;
|
||||
@@ -544,7 +544,7 @@ export type APIAuditLogChangeKeyMute = AuditLogChangeData<'mute', boolean>;
|
||||
/**
|
||||
* Returned when a user's nick is changed
|
||||
*/
|
||||
export type APIAuditLogChangeKeyNick = AuditLogChangeData<'mute', boolean>;
|
||||
export type APIAuditLogChangeKeyNick = AuditLogChangeData<'nick', boolean>;
|
||||
|
||||
/**
|
||||
* Returned when a user's avatar_hash is changed
|
||||
|
||||
@@ -341,6 +341,10 @@ export interface APIMessage {
|
||||
* See https://discord.com/developers/docs/resources/channel#message-object-message-application-structure
|
||||
*/
|
||||
application?: Partial<APIApplication>;
|
||||
/**
|
||||
* If the message is a response to an Interaction, this is the id of the interaction's application
|
||||
*/
|
||||
application_id?: Snowflake;
|
||||
/**
|
||||
* Reference data sent with crossposted messages, replies, pins, and thread starter messages
|
||||
*
|
||||
@@ -596,7 +600,7 @@ export interface APIThreadMetadata {
|
||||
*/
|
||||
archive_timestamp: string;
|
||||
/**
|
||||
* When a thread is locked, only users with MANAGE_THREADS can unarchive it
|
||||
* Whether the thread is locked; when a thread is locked, only users with `MANAGE_THREADS` can unarchive it
|
||||
*/
|
||||
locked?: boolean;
|
||||
}
|
||||
@@ -614,12 +618,16 @@ export enum ThreadAutoArchiveDuration {
|
||||
export interface APIThreadMember {
|
||||
/**
|
||||
* The id of the thread
|
||||
*
|
||||
* **This field is omitted on the member sent within each thread in the `GUILD_CREATE` event**
|
||||
*/
|
||||
id: Snowflake;
|
||||
id?: Snowflake;
|
||||
/**
|
||||
* The id of the member
|
||||
*
|
||||
* **This field is omitted on the member sent within each thread in the `GUILD_CREATE` event**
|
||||
*/
|
||||
user_id: Snowflake;
|
||||
user_id?: Snowflake;
|
||||
/**
|
||||
* An ISO8601 timestamp for when the member last joined
|
||||
*/
|
||||
@@ -1015,13 +1023,13 @@ export interface APIAllowedMentions {
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components
|
||||
* https://discord.com/developers/docs/interactions/message-components#component-object
|
||||
*/
|
||||
export interface APIBaseComponent {
|
||||
export interface APIBaseMessageComponent<T extends ComponentType> {
|
||||
/**
|
||||
* The type of the component
|
||||
*/
|
||||
type: ComponentType;
|
||||
type: T;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1029,7 +1037,7 @@ export interface APIBaseComponent {
|
||||
*/
|
||||
export enum ComponentType {
|
||||
/**
|
||||
* ActionRow component
|
||||
* Action Row component
|
||||
*/
|
||||
ActionRow = 1,
|
||||
/**
|
||||
@@ -1043,13 +1051,9 @@ export enum ComponentType {
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#component-object
|
||||
* https://discord.com/developers/docs/interactions/message-components#action-rows
|
||||
*/
|
||||
export interface APIActionRowComponent extends APIBaseComponent {
|
||||
/**
|
||||
* The type of the component
|
||||
*/
|
||||
type: ComponentType.ActionRow;
|
||||
export interface APIActionRowComponent extends APIBaseMessageComponent<ComponentType.ActionRow> {
|
||||
/**
|
||||
* The components in the ActionRow
|
||||
*/
|
||||
@@ -1057,73 +1061,97 @@ export interface APIActionRowComponent extends APIBaseComponent {
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#buttons-button-object
|
||||
* https://discord.com/developers/docs/interactions/message-components#buttons
|
||||
*/
|
||||
export interface APIButtonComponent extends APIBaseComponent {
|
||||
/**
|
||||
* The type of the component
|
||||
*/
|
||||
type: ComponentType.Button;
|
||||
interface APIButtonComponentBase<Style extends ButtonStyle> extends APIBaseMessageComponent<ComponentType.Button> {
|
||||
/**
|
||||
* The label to be displayed on the button
|
||||
*/
|
||||
label?: string;
|
||||
/**
|
||||
* The custom_id to be sent in the interaction when clicked
|
||||
*/
|
||||
custom_id?: string;
|
||||
/**
|
||||
* The style of the button
|
||||
*/
|
||||
style: ButtonStyle;
|
||||
style: Style;
|
||||
/**
|
||||
* The emoji to display to the left of the text
|
||||
*/
|
||||
emoji?: APIPartialEmoji;
|
||||
/**
|
||||
* The URL to direct users to when clicked for Link buttons
|
||||
*/
|
||||
url?: string;
|
||||
/**
|
||||
* The status of the button
|
||||
*/
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#component-object
|
||||
*/
|
||||
export interface APISelectMenuComponent {
|
||||
/**
|
||||
* The type of the component
|
||||
*/
|
||||
type: ComponentType.SelectMenu;
|
||||
export interface APIButtonComponentWithCustomID
|
||||
extends APIButtonComponentBase<
|
||||
ButtonStyle.Primary | ButtonStyle.Secondary | ButtonStyle.Success | ButtonStyle.Danger
|
||||
> {
|
||||
/**
|
||||
* The custom_id to be sent in the interaction when clicked
|
||||
*/
|
||||
custom_id: string;
|
||||
}
|
||||
|
||||
export interface APIButtonComponentWithURL extends APIButtonComponentBase<ButtonStyle.Link> {
|
||||
/**
|
||||
* Custom placeholder text if nothing is selected
|
||||
* The URL to direct users to when clicked for Link buttons
|
||||
*/
|
||||
placeholder?: string;
|
||||
/**
|
||||
* The minimum number of items that must be chosen
|
||||
*/
|
||||
min_values?: number;
|
||||
/**
|
||||
* The maximum number of items that can be chosen
|
||||
*/
|
||||
max_values?: number;
|
||||
/**
|
||||
* Choices to display in the select menu
|
||||
*/
|
||||
options: APISelectOption[];
|
||||
url: string;
|
||||
}
|
||||
|
||||
export type APIButtonComponent = APIButtonComponentWithCustomID | APIButtonComponentWithURL;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#button-object-button-styles
|
||||
*/
|
||||
export enum ButtonStyle {
|
||||
Primary = 1,
|
||||
Secondary,
|
||||
Success,
|
||||
Danger,
|
||||
Link,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#component-object
|
||||
* https://discord.com/developers/docs/interactions/message-components#select-menus
|
||||
*/
|
||||
export interface APISelectOption {
|
||||
export interface APISelectMenuComponent extends APIBaseMessageComponent<ComponentType.SelectMenu> {
|
||||
/**
|
||||
* A developer-defined identifier for the select menu, max 100 characters
|
||||
*/
|
||||
custom_id: string;
|
||||
/**
|
||||
* The choices in the select, max 25
|
||||
*/
|
||||
options: APISelectMenuOption[];
|
||||
/**
|
||||
* Custom placeholder text if nothing is selected, max 100 characters
|
||||
*/
|
||||
placeholder?: string;
|
||||
/**
|
||||
* The minimum number of items that must be chosen; min 0, max 25
|
||||
*
|
||||
* @default 1
|
||||
*/
|
||||
min_values?: number;
|
||||
/**
|
||||
* The maximum number of items that can be chosen; max 25
|
||||
*
|
||||
* @default 1
|
||||
*/
|
||||
max_values?: number;
|
||||
/**
|
||||
* Disable the select
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-option-structure
|
||||
*/
|
||||
export interface APISelectMenuOption {
|
||||
/**
|
||||
* The user-facing name of the option (max 25 chars)
|
||||
*/
|
||||
@@ -1143,18 +1171,10 @@ export interface APISelectOption {
|
||||
/**
|
||||
* Whether this option should be already-selected by default
|
||||
*/
|
||||
default: boolean;
|
||||
default?: boolean;
|
||||
}
|
||||
|
||||
export type APIMessageComponent = APIActionRowComponent | APIButtonComponent | APISelectMenuComponent;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#buttons-button-styles
|
||||
* https://discord.com/developers/docs/interactions/message-components#message-components
|
||||
*/
|
||||
export enum ButtonStyle {
|
||||
Primary = 1,
|
||||
Secondary,
|
||||
Success,
|
||||
Danger,
|
||||
Link,
|
||||
}
|
||||
export type APIMessageComponent = APIActionRowComponent | APIButtonComponent | APISelectMenuComponent;
|
||||
|
||||
@@ -489,6 +489,30 @@ export enum GuildFeature {
|
||||
* Guild can be previewed before joining via Membership Screening or the directory
|
||||
*/
|
||||
PreviewEnabled = 'PREVIEW_ENABLED',
|
||||
/**
|
||||
* Guild has enabled ticketed events
|
||||
*/
|
||||
TicketedEventsEnabled = 'TICKETED_EVENTS_ENABLED',
|
||||
/**
|
||||
* Guild has enabled monetization
|
||||
*/
|
||||
MonetizationEnabled = 'MONETIZATION_ENABLED',
|
||||
/**
|
||||
* Guild has increased custom sticker slots
|
||||
*/
|
||||
MoreStickers = 'MORE_STICKERS',
|
||||
/**
|
||||
* Guild has access to the three day archive time for threads
|
||||
*/
|
||||
ThreeDayThreadArchive = 'THREE_DAY_THREAD_ARCHIVE',
|
||||
/**
|
||||
* Guild has access to the seven day archive time for threads
|
||||
*/
|
||||
SevenDayThreadArchive = 'SEVEN_DAY_THREAD_ARCHIVE',
|
||||
/**
|
||||
* Guild has access to create private threads
|
||||
*/
|
||||
PrivateThreads = 'PRIVATE_THREADS',
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,470 +1,21 @@
|
||||
import type { Permissions, Snowflake } from '../../globals.ts';
|
||||
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../rest/v9/mod.ts';
|
||||
import { APIMessage, ComponentType } from './channel.ts';
|
||||
import type { APIGuildMember, APIPartialChannel, APIRole, APIUser, MessageFlags } from './mod.ts';
|
||||
import {
|
||||
APIMessageComponentDMInteraction,
|
||||
APIMessageComponentGuildInteraction,
|
||||
APIMessageComponentInteraction,
|
||||
} from './_interactions/messageComponents.ts';
|
||||
import {
|
||||
APIApplicationCommandDMInteraction,
|
||||
APIApplicationCommandGuildInteraction,
|
||||
APIApplicationCommandInteraction,
|
||||
} from './_interactions/slashCommands.ts';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommand
|
||||
*/
|
||||
export interface APIApplicationCommand {
|
||||
/**
|
||||
* Unique id of the command
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* Unique id of the parent application
|
||||
*/
|
||||
application_id: Snowflake;
|
||||
/**
|
||||
* 1-32 character name matching `^[\w-]{1,32}$`
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* 1-100 character description
|
||||
*/
|
||||
description: string;
|
||||
/**
|
||||
* The parameters for the command
|
||||
*/
|
||||
options?: APIApplicationCommandOption[];
|
||||
/**
|
||||
* Whether the command is enabled by default when the app is added to a guild
|
||||
*
|
||||
* If missing, this property should be assumed as `true`
|
||||
*/
|
||||
default_permission?: boolean;
|
||||
}
|
||||
export * from './_interactions/base.ts';
|
||||
export * from './_interactions/messageComponents.ts';
|
||||
export * from './_interactions/responses.ts';
|
||||
export * from './_interactions/slashCommands.ts';
|
||||
|
||||
interface APIApplicationCommandOptionBase {
|
||||
type:
|
||||
| ApplicationCommandOptionType.Boolean
|
||||
| ApplicationCommandOptionType.User
|
||||
| ApplicationCommandOptionType.Channel
|
||||
| ApplicationCommandOptionType.Role
|
||||
| ApplicationCommandOptionType.Mentionable;
|
||||
name: string;
|
||||
description: string;
|
||||
default?: boolean;
|
||||
required?: boolean;
|
||||
}
|
||||
export type APIInteraction = APIApplicationCommandInteraction | APIMessageComponentInteraction;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoption
|
||||
*/
|
||||
export type APIApplicationCommandOption =
|
||||
| APIApplicationCommandArgumentOptions
|
||||
| APIApplicationCommandSubCommandOptions
|
||||
| APIApplicationCommandOptionBase;
|
||||
export type APIDMInteraction = APIApplicationCommandDMInteraction | APIMessageComponentDMInteraction;
|
||||
|
||||
/**
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
*
|
||||
* If the option is a `SUB_COMMAND` or `SUB_COMMAND_GROUP` type, this nested options will be the parameters
|
||||
*/
|
||||
export interface APIApplicationCommandSubCommandOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
|
||||
type: ApplicationCommandOptionType.SubCommand | ApplicationCommandOptionType.SubCommandGroup;
|
||||
options?: APIApplicationCommandOption[];
|
||||
}
|
||||
|
||||
/**
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
*
|
||||
* In contrast to `APIApplicationCommandSubCommandOptions`, these types cannot have an `options` array,
|
||||
* but they can have a `choices` one
|
||||
*/
|
||||
export interface APIApplicationCommandArgumentOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
|
||||
type: ApplicationCommandOptionType.String | ApplicationCommandOptionType.Integer;
|
||||
choices?: APIApplicationCommandOptionChoice[];
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptiontype
|
||||
*/
|
||||
export enum ApplicationCommandOptionType {
|
||||
SubCommand = 1,
|
||||
SubCommandGroup,
|
||||
String,
|
||||
Integer,
|
||||
Boolean,
|
||||
User,
|
||||
Channel,
|
||||
Role,
|
||||
Mentionable,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptionchoice
|
||||
*/
|
||||
export interface APIApplicationCommandOptionChoice {
|
||||
name: string;
|
||||
value: string | number;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction
|
||||
*/
|
||||
export interface APIBaseInteraction {
|
||||
/**
|
||||
* ID of the interaction
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* ID of the application this interaction is for
|
||||
*/
|
||||
application_id: Snowflake;
|
||||
/**
|
||||
* The type of interaction
|
||||
*/
|
||||
type: InteractionType;
|
||||
/**
|
||||
* The command data payload
|
||||
*/
|
||||
data?: APIApplicationCommandInteractionData | APIMessageComponentInteractionData;
|
||||
/**
|
||||
* The channel it was sent from
|
||||
*/
|
||||
channel_id?: Snowflake;
|
||||
/**
|
||||
* A continuation token for responding to the interaction
|
||||
*/
|
||||
token: string;
|
||||
/**
|
||||
* Read-only property, always `1`
|
||||
*/
|
||||
version: 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#guild-member-object
|
||||
*/
|
||||
export interface APIInteractionGuildMember extends APIGuildMember {
|
||||
permissions: Permissions;
|
||||
user: APIUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction
|
||||
*/
|
||||
export interface APIGuildInteraction extends APIBaseInteraction {
|
||||
/**
|
||||
* The guild it was sent from
|
||||
*
|
||||
* In the case of an `APIDMInteraction`, this will not be present
|
||||
*/
|
||||
guild_id: Snowflake;
|
||||
/**
|
||||
* Guild member data for the invoking user, including permissions
|
||||
*/
|
||||
member: APIInteractionGuildMember;
|
||||
channel_id: Snowflake;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction
|
||||
*/
|
||||
export interface APIDMInteraction extends APIBaseInteraction {
|
||||
/**
|
||||
* User object for the invoking user, if invoked in a DM
|
||||
*/
|
||||
user: APIUser;
|
||||
channel_id: Snowflake;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#buttons-button-interaction
|
||||
*/
|
||||
export interface APIMessageComponentInteraction extends APIBaseInteraction {
|
||||
/**
|
||||
* Message object to which the button was attached
|
||||
*/
|
||||
message: APIMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction
|
||||
*/
|
||||
export type APIInteraction = APIGuildInteraction | APIDMInteraction | APIMessageComponentInteraction;
|
||||
|
||||
/**
|
||||
* Like APIGuildInteraction, only with the `data` property always present
|
||||
*
|
||||
* @see APIGuildInteraction
|
||||
*/
|
||||
export type APIApplicationCommandGuildInteraction = Required<APIGuildInteraction>;
|
||||
|
||||
/**
|
||||
* Like APIDMInteraction, only with the `data` property always present
|
||||
*
|
||||
* @see APIDMInteraction
|
||||
*/
|
||||
export type APIApplicationCommandDMInteraction = Required<APIDMInteraction>;
|
||||
|
||||
/**
|
||||
* Like APIInteraction, only with the `data` property always present
|
||||
*
|
||||
* @see APIInteraction
|
||||
*/
|
||||
export type APIApplicationCommandInteraction =
|
||||
| APIApplicationCommandGuildInteraction
|
||||
| APIApplicationCommandDMInteraction;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-interactiontype
|
||||
*/
|
||||
export enum InteractionType {
|
||||
Ping = 1,
|
||||
ApplicationCommand,
|
||||
MessageComponent,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#guildapplicationcommandpermissions
|
||||
*/
|
||||
export interface APIGuildApplicationCommandPermissions {
|
||||
/**
|
||||
* The id of the command
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* The id of the application the command belongs to
|
||||
*/
|
||||
application_id: Snowflake;
|
||||
/**
|
||||
* The id of the guild
|
||||
*/
|
||||
guild_id: Snowflake;
|
||||
/**
|
||||
* The permissions for the command in the guild
|
||||
*/
|
||||
permissions: APIApplicationCommandPermission[];
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissions
|
||||
*/
|
||||
export interface APIApplicationCommandPermission {
|
||||
/**
|
||||
* The id of the role or user
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* Role or user
|
||||
*/
|
||||
type: ApplicationCommandPermissionType;
|
||||
/**
|
||||
* `true` to allow, `false`, to disallow
|
||||
*/
|
||||
permission: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissiontype
|
||||
*/
|
||||
export enum ApplicationCommandPermissionType {
|
||||
Role = 1,
|
||||
User,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/channel#channel-object
|
||||
*/
|
||||
export interface APIInteractionDataResolvedChannel extends Required<APIPartialChannel> {
|
||||
permissions: Permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#guild-member-object
|
||||
*/
|
||||
export interface APIInteractionDataResolvedGuildMember extends Omit<APIGuildMember, 'user' | 'deaf' | 'mute'> {
|
||||
permissions: Permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondata
|
||||
*/
|
||||
export interface APIApplicationCommandInteractionData {
|
||||
id: Snowflake;
|
||||
name: string;
|
||||
options?: APIApplicationCommandInteractionDataOption[];
|
||||
resolved?: {
|
||||
users?: Record<string, APIUser>;
|
||||
roles?: Record<string, APIRole>;
|
||||
members?: Record<string, APIInteractionDataResolvedGuildMember>;
|
||||
channels?: Record<string, APIInteractionDataResolvedChannel>;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondataoption
|
||||
*/
|
||||
export type APIApplicationCommandInteractionDataOption =
|
||||
| ApplicationCommandInteractionDataOptionSubCommand
|
||||
| ApplicationCommandInteractionDataOptionSubCommandGroup
|
||||
| APIApplicationCommandInteractionDataOptionWithValues;
|
||||
|
||||
export interface ApplicationCommandInteractionDataOptionSubCommand {
|
||||
name: string;
|
||||
type: ApplicationCommandOptionType.SubCommand;
|
||||
options: APIApplicationCommandInteractionDataOptionWithValues[];
|
||||
}
|
||||
|
||||
export interface ApplicationCommandInteractionDataOptionSubCommandGroup {
|
||||
name: string;
|
||||
type: ApplicationCommandOptionType.SubCommandGroup;
|
||||
options: ApplicationCommandInteractionDataOptionSubCommand[];
|
||||
}
|
||||
|
||||
export type APIApplicationCommandInteractionDataOptionWithValues =
|
||||
| ApplicationCommandInteractionDataOptionString
|
||||
| ApplicationCommandInteractionDataOptionRole
|
||||
| ApplicationCommandInteractionDataOptionChannel
|
||||
| ApplicationCommandInteractionDataOptionUser
|
||||
| ApplicationCommandInteractionDataOptionMentionable
|
||||
| ApplicationCommandInteractionDataOptionInteger
|
||||
| ApplicationCommandInteractionDataOptionBoolean;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionString = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.String,
|
||||
string
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionRole = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Role,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionChannel = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Channel,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionUser = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.User,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionMentionable = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Mentionable,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionInteger = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Integer,
|
||||
number
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionBoolean = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Boolean,
|
||||
boolean
|
||||
>;
|
||||
|
||||
export interface APIMessageButtonInteractionData {
|
||||
custom_id: string;
|
||||
component_type: ComponentType.Button;
|
||||
}
|
||||
|
||||
export interface APIMessageSelectMenuInteractionData {
|
||||
custom_id: string;
|
||||
component_type: ComponentType.SelectMenu;
|
||||
values: string[];
|
||||
}
|
||||
|
||||
export type APIMessageComponentInteractionData = APIMessageButtonInteractionData | APIMessageSelectMenuInteractionData;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response
|
||||
*/
|
||||
export type APIInteractionResponse =
|
||||
| APIInteractionResponsePong
|
||||
| APIInteractionResponseChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredMessageUpdate
|
||||
| APIInteractionResponseUpdateMessage;
|
||||
|
||||
export interface APIInteractionResponsePong {
|
||||
type: InteractionResponseType.Pong;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseChannelMessageWithSource {
|
||||
type: InteractionResponseType.ChannelMessageWithSource;
|
||||
data: APIInteractionApplicationCommandCallbackData;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseDeferredChannelMessageWithSource {
|
||||
type: InteractionResponseType.DeferredChannelMessageWithSource;
|
||||
data?: Pick<APIInteractionApplicationCommandCallbackData, 'flags'>;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseDeferredMessageUpdate {
|
||||
type: InteractionResponseType.DeferredMessageUpdate;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseUpdateMessage {
|
||||
type: InteractionResponseType.UpdateMessage;
|
||||
data?: APIInteractionApplicationCommandCallbackData;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionresponsetype
|
||||
*/
|
||||
export enum InteractionResponseType {
|
||||
/**
|
||||
* ACK a `Ping`
|
||||
*/
|
||||
Pong = 1,
|
||||
/**
|
||||
* Respond to an interaction with a message
|
||||
*/
|
||||
ChannelMessageWithSource = 4,
|
||||
/**
|
||||
* ACK an interaction and edit to a response later, the user sees a loading state
|
||||
*/
|
||||
DeferredChannelMessageWithSource,
|
||||
/**
|
||||
* ACK a button interaction and update it to a loading state
|
||||
*/
|
||||
DeferredMessageUpdate,
|
||||
/**
|
||||
* ACK a button interaction and edit the message to which the button was attached
|
||||
*/
|
||||
UpdateMessage,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionapplicationcommandcallbackdata
|
||||
*/
|
||||
export type APIInteractionApplicationCommandCallbackData = Omit<
|
||||
RESTPostAPIWebhookWithTokenJSONBody,
|
||||
'username' | 'avatar_url'
|
||||
> & { flags?: MessageFlags };
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#messageinteraction
|
||||
*/
|
||||
export interface APIMessageInteraction {
|
||||
/**
|
||||
* ID of the interaction
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* The type of interaction
|
||||
*/
|
||||
type: InteractionType;
|
||||
/**
|
||||
* The name of the ApplicationCommand
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* The user who invoked the interaction
|
||||
*/
|
||||
user: APIUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
interface InteractionDataOptionBase<T extends ApplicationCommandOptionType, D = unknown> {
|
||||
name: string;
|
||||
type: T;
|
||||
value: D;
|
||||
}
|
||||
export type APIGuildInteraction = APIApplicationCommandGuildInteraction | APIMessageComponentGuildInteraction;
|
||||
|
||||
@@ -51,7 +51,7 @@ export interface APIApplication {
|
||||
*
|
||||
* See https://discord.com/developers/docs/resources/user#user-object
|
||||
*/
|
||||
owner: APIUser;
|
||||
owner?: APIUser;
|
||||
/**
|
||||
* If this application is a game sold on Discord, this field will be the summary field for the store page
|
||||
* of its primary sku
|
||||
@@ -153,11 +153,11 @@ export enum OAuth2Scopes {
|
||||
*/
|
||||
MessagesRead = 'messages.read',
|
||||
/**
|
||||
* For local rpc server access, this allows you to control a user's local Discord client - whitelist only
|
||||
* For local rpc server access, this allows you to control a user's local Discord client - requires Discord approval
|
||||
*/
|
||||
RPC = 'rpc',
|
||||
/**
|
||||
* For local rpc server api access, this allows you to receive notifications pushed out to the user - whitelist only
|
||||
* For local rpc server api access, this allows you to receive notifications pushed out to the user - requires Discord approval
|
||||
*/
|
||||
RPCNotificationsRead = 'rpc.notifications.read',
|
||||
/**
|
||||
@@ -165,7 +165,7 @@ export enum OAuth2Scopes {
|
||||
*/
|
||||
WebhookIncoming = 'webhook.incoming',
|
||||
/**
|
||||
* Allows your app to upload/update builds for a user's applications - whitelist only
|
||||
* Allows your app to upload/update builds for a user's applications - requires Discord approval
|
||||
*/
|
||||
ApplicationsBuildsUpload = 'applications.builds.upload',
|
||||
/**
|
||||
@@ -181,27 +181,27 @@ export enum OAuth2Scopes {
|
||||
*/
|
||||
ApplicationsEntitlements = 'applications.entitlements',
|
||||
/**
|
||||
* Allows your app to know a user's friends and implicit relationships - whitelist only
|
||||
* Allows your app to know a user's friends and implicit relationships - requires Discord approval
|
||||
*/
|
||||
RelationshipsRead = 'relationships.read',
|
||||
/**
|
||||
* Allows your app to fetch data from a user's "Now Playing/Recently Played" list - whitelist only
|
||||
* Allows your app to fetch data from a user's "Now Playing/Recently Played" list - requires Discord approval
|
||||
*/
|
||||
ActivitiesRead = 'activities.read',
|
||||
/**
|
||||
* Allows your app to update a user's activity - whitelist only (NOT REQUIRED FOR GAMESDK ACTIVITY MANAGER)
|
||||
* Allows your app to update a user's activity - requires Discord approval (NOT REQUIRED FOR GAMESDK ACTIVITY MANAGER)
|
||||
*
|
||||
* See https://discord.com/developers/docs/game-sdk/activities
|
||||
*/
|
||||
ActivitiesWrite = 'activities.write',
|
||||
/**
|
||||
* Allows your app to create Slash Commands in the authorized guild
|
||||
* Allows your app to use Slash Commands in a guild
|
||||
*
|
||||
* See https://discord.com/developers/docs/interactions/slash-commands
|
||||
*/
|
||||
ApplicationsCommands = 'applications.commands',
|
||||
/**
|
||||
* Allows your app to update Slash Commands via this bearer token
|
||||
* Allows your app to update its Slash Commands via this bearer token - client credentials grant only
|
||||
*
|
||||
* See https://discord.com/developers/docs/interactions/slash-commands
|
||||
*/
|
||||
|
||||
@@ -88,6 +88,7 @@ export enum UserFlags {
|
||||
BugHunterLevel2 = 1 << 14,
|
||||
VerifiedBot = 1 << 16,
|
||||
EarlyVerifiedBotDeveloper = 1 << 17,
|
||||
DiscordCertifiedModerator = 1 << 18,
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -717,7 +717,7 @@ export const Routes = {
|
||||
};
|
||||
|
||||
export const RouteBases = {
|
||||
api: 'https://discord.com/api',
|
||||
api: `https://discord.com/api/v${APIVersion}`,
|
||||
cdn: 'https://cdn.discordapp.com',
|
||||
invite: 'https://discord.gg',
|
||||
template: 'https://discord.new',
|
||||
|
||||
@@ -775,7 +775,7 @@ export const Routes = {
|
||||
};
|
||||
|
||||
export const RouteBases = {
|
||||
api: 'https://discord.com/api',
|
||||
api: `https://discord.com/api/v${APIVersion}`,
|
||||
cdn: 'https://cdn.discordapp.com',
|
||||
invite: 'https://discord.gg',
|
||||
template: 'https://discord.new',
|
||||
|
||||
@@ -2,33 +2,55 @@ import {
|
||||
APIApplicationCommandDMInteraction,
|
||||
APIApplicationCommandGuildInteraction,
|
||||
APIApplicationCommandInteraction,
|
||||
APIButtonComponent,
|
||||
APIButtonComponentWithCustomID,
|
||||
APIButtonComponentWithURL,
|
||||
APIDMInteraction,
|
||||
APIGuildInteraction,
|
||||
APIInteraction,
|
||||
APIMessageComponentDMInteraction,
|
||||
APIMessageComponentGuildInteraction,
|
||||
APIMessageComponentInteraction,
|
||||
ButtonStyle,
|
||||
} from '../payloads/v8/mod.ts';
|
||||
|
||||
// Interactions
|
||||
|
||||
/**
|
||||
* A type-guard check for guild interactions.
|
||||
* @param interaction The interaction to check against the
|
||||
* @returns A boolean that indicates if the interaction was received from a guild
|
||||
* A type-guard check for DM interactions
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the interaction was received in a DM channel
|
||||
*/
|
||||
export function isDMInteraction(interaction: APIInteraction): interaction is APIDMInteraction {
|
||||
return Reflect.has(interaction, 'user');
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for guild interactions
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the interaction was received in a guild
|
||||
*/
|
||||
export function isGuildInteraction(interaction: APIInteraction): interaction is APIGuildInteraction {
|
||||
return Reflect.has(interaction, 'guild_id');
|
||||
}
|
||||
|
||||
// ApplicationCommandInteractions
|
||||
|
||||
/**
|
||||
* A type-guard check for DM interactions.
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the interaction was received from a direct message
|
||||
* A type-guard check for DM application command interactions
|
||||
* @param interaction The application command interaction to check against
|
||||
* @returns A boolean that indicates if the application command interaction was received in a DM channel
|
||||
*/
|
||||
export function isDMInteraction(interaction: APIInteraction): interaction is APIDMInteraction {
|
||||
return !isGuildInteraction(interaction);
|
||||
export function isApplicationCommandDMInteraction(
|
||||
interaction: APIApplicationCommandInteraction,
|
||||
): interaction is APIApplicationCommandDMInteraction {
|
||||
return isDMInteraction(interaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for guild application command interactions.
|
||||
* A type-guard check for guild application command interactions
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the command interaction was received from a guild
|
||||
* @returns A boolean that indicates if the application command interaction was received in a guild
|
||||
*/
|
||||
export function isApplicationCommandGuildInteraction(
|
||||
interaction: APIApplicationCommandInteraction,
|
||||
@@ -36,13 +58,46 @@ export function isApplicationCommandGuildInteraction(
|
||||
return isGuildInteraction(interaction);
|
||||
}
|
||||
|
||||
// MessageComponentInteractions
|
||||
|
||||
/**
|
||||
* A type-guard check for direct message application command interactions.
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the command interaction was received from a direct message
|
||||
* A type-guard check for DM message component interactions
|
||||
* @param interaction The message component interaction to check against
|
||||
* @returns A boolean that indicates if the message component interaction was received in a DM channel
|
||||
*/
|
||||
export function isApplicationCommandDMInteraction(
|
||||
interaction: APIApplicationCommandInteraction,
|
||||
): interaction is APIApplicationCommandDMInteraction {
|
||||
return !isGuildInteraction(interaction);
|
||||
export function isMessageComponentDMInteraction(
|
||||
interaction: APIMessageComponentInteraction,
|
||||
): interaction is APIMessageComponentDMInteraction {
|
||||
return isDMInteraction(interaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for guild message component interactions
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the message component interaction was received in a guild
|
||||
*/
|
||||
export function isMessageComponentGuildInteraction(
|
||||
interaction: APIMessageComponentInteraction,
|
||||
): interaction is APIMessageComponentGuildInteraction {
|
||||
return isGuildInteraction(interaction);
|
||||
}
|
||||
|
||||
// Buttons
|
||||
|
||||
/**
|
||||
* A type-guard check for buttons that have a `url` attached to them.
|
||||
* @param component The button to check against
|
||||
* @returns A boolean that indicates if the button has a `url` attached to it
|
||||
*/
|
||||
export function isLinkButton(component: APIButtonComponent): component is APIButtonComponentWithURL {
|
||||
return component.style === ButtonStyle.Link;
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for buttons that have a `custom_id` attached to them.
|
||||
* @param button The button to check against
|
||||
* @returns A boolean that indicates if the button has a `custom_id` attached to it
|
||||
*/
|
||||
export function isStyledButton(component: APIButtonComponent): component is APIButtonComponentWithCustomID {
|
||||
return component.style !== ButtonStyle.Link;
|
||||
}
|
||||
|
||||
@@ -2,33 +2,55 @@ import {
|
||||
APIApplicationCommandDMInteraction,
|
||||
APIApplicationCommandGuildInteraction,
|
||||
APIApplicationCommandInteraction,
|
||||
APIButtonComponent,
|
||||
APIButtonComponentWithCustomID,
|
||||
APIButtonComponentWithURL,
|
||||
APIDMInteraction,
|
||||
APIGuildInteraction,
|
||||
APIInteraction,
|
||||
APIMessageComponentDMInteraction,
|
||||
APIMessageComponentGuildInteraction,
|
||||
APIMessageComponentInteraction,
|
||||
ButtonStyle,
|
||||
} from '../payloads/v9/mod.ts';
|
||||
|
||||
// Interactions
|
||||
|
||||
/**
|
||||
* A type-guard check for guild interactions.
|
||||
* @param interaction The interaction to check against the
|
||||
* @returns A boolean that indicates if the interaction was received from a guild
|
||||
* A type-guard check for DM interactions
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the interaction was received in a DM channel
|
||||
*/
|
||||
export function isDMInteraction(interaction: APIInteraction): interaction is APIDMInteraction {
|
||||
return Reflect.has(interaction, 'user');
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for guild interactions
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the interaction was received in a guild
|
||||
*/
|
||||
export function isGuildInteraction(interaction: APIInteraction): interaction is APIGuildInteraction {
|
||||
return Reflect.has(interaction, 'guild_id');
|
||||
}
|
||||
|
||||
// ApplicationCommandInteractions
|
||||
|
||||
/**
|
||||
* A type-guard check for DM interactions.
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the interaction was received from a direct message
|
||||
* A type-guard check for DM application command interactions
|
||||
* @param interaction The application command interaction to check against
|
||||
* @returns A boolean that indicates if the application command interaction was received in a DM channel
|
||||
*/
|
||||
export function isDMInteraction(interaction: APIInteraction): interaction is APIDMInteraction {
|
||||
return !isGuildInteraction(interaction);
|
||||
export function isApplicationCommandDMInteraction(
|
||||
interaction: APIApplicationCommandInteraction,
|
||||
): interaction is APIApplicationCommandDMInteraction {
|
||||
return isDMInteraction(interaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for guild application command interactions.
|
||||
* A type-guard check for guild application command interactions
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the command interaction was received from a guild
|
||||
* @returns A boolean that indicates if the application command interaction was received in a guild
|
||||
*/
|
||||
export function isApplicationCommandGuildInteraction(
|
||||
interaction: APIApplicationCommandInteraction,
|
||||
@@ -36,13 +58,46 @@ export function isApplicationCommandGuildInteraction(
|
||||
return isGuildInteraction(interaction);
|
||||
}
|
||||
|
||||
// MessageComponentInteractions
|
||||
|
||||
/**
|
||||
* A type-guard check for direct message application command interactions.
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the command interaction was received from a direct message
|
||||
* A type-guard check for DM message component interactions
|
||||
* @param interaction The message component interaction to check against
|
||||
* @returns A boolean that indicates if the message component interaction was received in a DM channel
|
||||
*/
|
||||
export function isApplicationCommandDMInteraction(
|
||||
interaction: APIApplicationCommandInteraction,
|
||||
): interaction is APIApplicationCommandDMInteraction {
|
||||
return !isGuildInteraction(interaction);
|
||||
export function isMessageComponentDMInteraction(
|
||||
interaction: APIMessageComponentInteraction,
|
||||
): interaction is APIMessageComponentDMInteraction {
|
||||
return isDMInteraction(interaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for guild message component interactions
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the message component interaction was received in a guild
|
||||
*/
|
||||
export function isMessageComponentGuildInteraction(
|
||||
interaction: APIMessageComponentInteraction,
|
||||
): interaction is APIMessageComponentGuildInteraction {
|
||||
return isGuildInteraction(interaction);
|
||||
}
|
||||
|
||||
// Buttons
|
||||
|
||||
/**
|
||||
* A type-guard check for buttons that have a `url` attached to them.
|
||||
* @param component The button to check against
|
||||
* @returns A boolean that indicates if the button has a `url` attached to it
|
||||
*/
|
||||
export function isLinkButton(component: APIButtonComponent): component is APIButtonComponentWithURL {
|
||||
return component.style === ButtonStyle.Link;
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for buttons that have a `custom_id` attached to them.
|
||||
* @param button The button to check against
|
||||
* @returns A boolean that indicates if the button has a `custom_id` attached to it
|
||||
*/
|
||||
export function isStyledButton(component: APIButtonComponent): component is APIButtonComponentWithCustomID {
|
||||
return component.style !== ButtonStyle.Link;
|
||||
}
|
||||
|
||||
@@ -314,9 +314,7 @@ export type GatewayApplicationCommandModifyDispatch = DataPayload<
|
||||
* https://discord.com/developers/docs/topics/gateway#application-command-update
|
||||
* https://discord.com/developers/docs/topics/gateway#application-command-delete
|
||||
*/
|
||||
export interface GatewayApplicationCommandModifyDispatchData extends APIApplicationCommand {
|
||||
guild_id?: string;
|
||||
}
|
||||
export type GatewayApplicationCommandModifyDispatchData = APIApplicationCommand;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/topics/gateway#application-command-create
|
||||
|
||||
@@ -324,9 +324,7 @@ export type GatewayApplicationCommandModifyDispatch = DataPayload<
|
||||
* https://discord.com/developers/docs/topics/gateway#application-command-update
|
||||
* https://discord.com/developers/docs/topics/gateway#application-command-delete
|
||||
*/
|
||||
export interface GatewayApplicationCommandModifyDispatchData extends APIApplicationCommand {
|
||||
guild_id?: string;
|
||||
}
|
||||
export type GatewayApplicationCommandModifyDispatchData = APIApplicationCommand;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/topics/gateway#application-command-create
|
||||
|
||||
8778
package-lock.json
generated
8778
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
35
package.json
35
package.json
@@ -91,6 +91,9 @@
|
||||
"prepare": "is-ci || husky install",
|
||||
"prepublishOnly": "run-s clean test:lint build:node",
|
||||
"test:lint": "eslint --ext mjs,ts {gateway,payloads,rest,rpc,voice,utils}/**/*.ts {globals,v*}.ts",
|
||||
"pretest:types": "tsc",
|
||||
"test:types": "tsd",
|
||||
"posttest:types": "npm run clean:node",
|
||||
"version": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md"
|
||||
},
|
||||
"keywords": [
|
||||
@@ -109,28 +112,29 @@
|
||||
"node": ">=12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.14.3",
|
||||
"@babel/eslint-parser": "^7.14.4",
|
||||
"@babel/plugin-syntax-top-level-await": "^7.12.13",
|
||||
"@babel/core": "^7.14.6",
|
||||
"@babel/eslint-parser": "^7.14.7",
|
||||
"@babel/plugin-syntax-top-level-await": "^7.14.5",
|
||||
"@commitlint/cli": "^12.1.4",
|
||||
"@commitlint/config-angular": "^12.1.4",
|
||||
"@types/node": "^15.6.1",
|
||||
"@typescript-eslint/eslint-plugin": "^4.26.0",
|
||||
"@typescript-eslint/parser": "^4.26.0",
|
||||
"@types/node": "^16.3.3",
|
||||
"@typescript-eslint/eslint-plugin": "^4.28.3",
|
||||
"@typescript-eslint/parser": "^4.28.3",
|
||||
"conventional-changelog-cli": "^2.1.1",
|
||||
"eslint": "^7.27.0",
|
||||
"eslint": "^7.30.0",
|
||||
"eslint-config-marine": "^9.0.6",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-prettier": "^3.4.0",
|
||||
"gen-esm-wrapper": "^1.1.1",
|
||||
"husky": "^6.0.0",
|
||||
"gen-esm-wrapper": "^1.1.2",
|
||||
"husky": "^7.0.1",
|
||||
"is-ci": "^3.0.0",
|
||||
"lint-staged": "^11.0.0",
|
||||
"lint-staged": "^11.0.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.3.0",
|
||||
"pretty-quick": "^3.1.0",
|
||||
"prettier": "^2.3.2",
|
||||
"pretty-quick": "^3.1.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.3.2"
|
||||
"tsd": "^0.17.0",
|
||||
"typescript": "^4.3.5"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -161,7 +165,7 @@
|
||||
]
|
||||
},
|
||||
"lint-staged": {
|
||||
"{gateway,payloads,rest,rpc,voice,shortcuts,utils}/**/*.{mjs,js,ts}": "eslint --fix --ext mjs,js,ts",
|
||||
"{gateway,payloads,rest,rpc,voice,utils}/**/*.{mjs,js,ts}": "eslint --fix --ext mjs,js,ts",
|
||||
"{globals,v*}.ts": "eslint --fix --ext mjs,js,ts"
|
||||
},
|
||||
"commitlint": {
|
||||
@@ -201,5 +205,8 @@
|
||||
"commit": true,
|
||||
"tag": true
|
||||
}
|
||||
},
|
||||
"tsd": {
|
||||
"directory": "tests"
|
||||
}
|
||||
}
|
||||
|
||||
101
payloads/v8/_interactions/base.ts
Normal file
101
payloads/v8/_interactions/base.ts
Normal file
@@ -0,0 +1,101 @@
|
||||
import { Permissions, Snowflake } from '../../../globals';
|
||||
import { InteractionType } from '../../v8';
|
||||
import { APIMessage } from '../channel';
|
||||
import { APIGuildMember } from '../guild';
|
||||
import { APIUser } from '../user';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#message-interaction-object-message-interaction-structure
|
||||
*/
|
||||
export interface APIMessageInteraction {
|
||||
/**
|
||||
* ID of the interaction
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* The type of interaction
|
||||
*/
|
||||
type: InteractionType;
|
||||
/**
|
||||
* The name of the ApplicationCommand
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* The user who invoked the interaction
|
||||
*/
|
||||
user: APIUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#guild-member-object
|
||||
*/
|
||||
export interface APIInteractionGuildMember extends APIGuildMember {
|
||||
permissions: Permissions;
|
||||
user: APIUser;
|
||||
}
|
||||
|
||||
// INTERACTIONS RECEIVED
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-object
|
||||
*/
|
||||
export interface APIBaseInteraction<Type extends InteractionType, Data extends unknown> {
|
||||
/**
|
||||
* ID of the interaction
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* ID of the application this interaction is for
|
||||
*/
|
||||
application_id: Snowflake;
|
||||
/**
|
||||
* The type of interaction
|
||||
*/
|
||||
type: Type;
|
||||
/**
|
||||
* The command data payload
|
||||
*/
|
||||
data?: Data;
|
||||
/**
|
||||
* The guild it was sent from
|
||||
*/
|
||||
guild_id?: Snowflake;
|
||||
/**
|
||||
* The channel it was sent from
|
||||
*/
|
||||
channel_id?: Snowflake;
|
||||
/**
|
||||
* Guild member data for the invoking user, including permissions
|
||||
*
|
||||
* **This is only sent when an interaction is invoked in a guild**
|
||||
*/
|
||||
member?: APIInteractionGuildMember;
|
||||
/**
|
||||
* User object for the invoking user, if invoked in a DM
|
||||
*/
|
||||
user?: APIUser;
|
||||
/**
|
||||
* A continuation token for responding to the interaction
|
||||
*/
|
||||
token: string;
|
||||
/**
|
||||
* Read-only property, always `1`
|
||||
*/
|
||||
version: 1;
|
||||
/**
|
||||
* For components, the message they were attached to
|
||||
*/
|
||||
message?: APIMessage;
|
||||
}
|
||||
|
||||
export type APIDMInteractionWrapper<Original extends APIBaseInteraction<InteractionType, unknown>> = Omit<
|
||||
Original,
|
||||
'member' | 'guild_id'
|
||||
> &
|
||||
Required<Pick<Original, 'user'>>;
|
||||
|
||||
export type APIGuildInteractionWrapper<Original extends APIBaseInteraction<InteractionType, unknown>> = Omit<
|
||||
Original,
|
||||
'user'
|
||||
> &
|
||||
Required<Pick<Original, 'member' | 'guild_id'>>;
|
||||
38
payloads/v8/_interactions/messageComponents.ts
Normal file
38
payloads/v8/_interactions/messageComponents.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { ComponentType } from '../channel';
|
||||
import { APIBaseInteraction, InteractionType } from '../interactions';
|
||||
import { APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base';
|
||||
|
||||
export type APIMessageComponentInteraction = APIBaseInteraction<
|
||||
InteractionType.MessageComponent,
|
||||
APIMessageComponentInteractionData
|
||||
> &
|
||||
Required<
|
||||
Pick<
|
||||
APIBaseInteraction<InteractionType.MessageComponent, APIMessageComponentInteractionData>,
|
||||
'channel_id' | 'data' | 'message'
|
||||
>
|
||||
>;
|
||||
|
||||
export type APIMessageComponentInteractionData = APIMessageButtonInteractionData | APIMessageSelectMenuInteractionData;
|
||||
|
||||
export interface APIMessageComponentBaseInteractionData<CType extends ComponentType> {
|
||||
/**
|
||||
* The `custom_id` of the component
|
||||
*/
|
||||
custom_id: string;
|
||||
/**
|
||||
* The type of the component
|
||||
*/
|
||||
component_type: CType;
|
||||
}
|
||||
|
||||
export type APIMessageButtonInteractionData = APIMessageComponentBaseInteractionData<ComponentType.Button>;
|
||||
|
||||
export interface APIMessageSelectMenuInteractionData
|
||||
extends APIMessageComponentBaseInteractionData<ComponentType.SelectMenu> {
|
||||
values: string[];
|
||||
}
|
||||
|
||||
export type APIMessageComponentDMInteraction = APIDMInteractionWrapper<APIMessageComponentInteraction>;
|
||||
|
||||
export type APIMessageComponentGuildInteraction = APIGuildInteractionWrapper<APIMessageComponentInteraction>;
|
||||
78
payloads/v8/_interactions/responses.ts
Normal file
78
payloads/v8/_interactions/responses.ts
Normal file
@@ -0,0 +1,78 @@
|
||||
import { MessageFlags } from '../index';
|
||||
import { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v8';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-object-interaction-request-type
|
||||
*/
|
||||
export const enum InteractionType {
|
||||
Ping = 1,
|
||||
ApplicationCommand,
|
||||
MessageComponent,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object
|
||||
*/
|
||||
export type APIInteractionResponse =
|
||||
| APIInteractionResponsePong
|
||||
| APIInteractionResponseChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredMessageUpdate
|
||||
| APIInteractionResponseUpdateMessage;
|
||||
|
||||
export interface APIInteractionResponsePong {
|
||||
type: InteractionResponseType.Pong;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseChannelMessageWithSource {
|
||||
type: InteractionResponseType.ChannelMessageWithSource;
|
||||
data: APIInteractionResponseCallbackData;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseDeferredChannelMessageWithSource {
|
||||
type: InteractionResponseType.DeferredChannelMessageWithSource;
|
||||
data?: Pick<APIInteractionResponseCallbackData, 'flags'>;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseDeferredMessageUpdate {
|
||||
type: InteractionResponseType.DeferredMessageUpdate;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseUpdateMessage {
|
||||
type: InteractionResponseType.UpdateMessage;
|
||||
data?: APIInteractionResponseCallbackData;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object-interaction-callback-type
|
||||
*/
|
||||
export const enum InteractionResponseType {
|
||||
/**
|
||||
* ACK a `Ping`
|
||||
*/
|
||||
Pong = 1,
|
||||
/**
|
||||
* Respond to an interaction with a message
|
||||
*/
|
||||
ChannelMessageWithSource = 4,
|
||||
/**
|
||||
* ACK an interaction and edit to a response later, the user sees a loading state
|
||||
*/
|
||||
DeferredChannelMessageWithSource,
|
||||
/**
|
||||
* ACK a button interaction and update it to a loading state
|
||||
*/
|
||||
DeferredMessageUpdate,
|
||||
/**
|
||||
* ACK a button interaction and edit the message to which the button was attached
|
||||
*/
|
||||
UpdateMessage,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object-interaction-application-command-callback-data-structure
|
||||
*/
|
||||
export type APIInteractionResponseCallbackData = Omit<
|
||||
RESTPostAPIWebhookWithTokenJSONBody,
|
||||
'username' | 'avatar_url'
|
||||
> & { flags?: MessageFlags };
|
||||
273
payloads/v8/_interactions/slashCommands.ts
Normal file
273
payloads/v8/_interactions/slashCommands.ts
Normal file
@@ -0,0 +1,273 @@
|
||||
import { APIRole, APIUser } from '../index';
|
||||
import { Permissions, Snowflake } from '../../../globals';
|
||||
import { APIPartialChannel } from '../channel';
|
||||
import { APIGuildMember } from '../guild';
|
||||
import { APIBaseInteraction, APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base';
|
||||
import { InteractionType } from './responses';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#application-command-object
|
||||
*/
|
||||
export interface APIApplicationCommand {
|
||||
/**
|
||||
* Unique id of the command
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* Unique id of the parent application
|
||||
*/
|
||||
application_id: Snowflake;
|
||||
/**
|
||||
* Guild id of the command, if not global
|
||||
*/
|
||||
guild_id?: Snowflake;
|
||||
/**
|
||||
* 1-32 character name matching `^[\w-]{1,32}$`
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* 1-100 character description
|
||||
*/
|
||||
description: string;
|
||||
/**
|
||||
* The parameters for the command
|
||||
*/
|
||||
options?: APIApplicationCommandOption[];
|
||||
/**
|
||||
* Whether the command is enabled by default when the app is added to a guild
|
||||
*
|
||||
* If missing, this property should be assumed as `true`
|
||||
*/
|
||||
default_permission?: boolean;
|
||||
}
|
||||
|
||||
interface APIApplicationCommandOptionBase {
|
||||
type:
|
||||
| ApplicationCommandOptionType.Boolean
|
||||
| ApplicationCommandOptionType.User
|
||||
| ApplicationCommandOptionType.Channel
|
||||
| ApplicationCommandOptionType.Role
|
||||
| ApplicationCommandOptionType.Mentionable;
|
||||
name: string;
|
||||
description: string;
|
||||
default?: boolean;
|
||||
required?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-structure
|
||||
*/
|
||||
export type APIApplicationCommandOption =
|
||||
| APIApplicationCommandArgumentOptions
|
||||
| APIApplicationCommandSubCommandOptions
|
||||
| APIApplicationCommandOptionBase;
|
||||
|
||||
/**
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
*
|
||||
* If the option is a `SUB_COMMAND` or `SUB_COMMAND_GROUP` type, this nested options will be the parameters
|
||||
*/
|
||||
export interface APIApplicationCommandSubCommandOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
|
||||
type: ApplicationCommandOptionType.SubCommand | ApplicationCommandOptionType.SubCommandGroup;
|
||||
options?: APIApplicationCommandOption[];
|
||||
}
|
||||
|
||||
/**
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
*
|
||||
* In contrast to `APIApplicationCommandSubCommandOptions`, these types cannot have an `options` array,
|
||||
* but they can have a `choices` one
|
||||
*/
|
||||
export interface APIApplicationCommandArgumentOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
|
||||
type: ApplicationCommandOptionType.String | ApplicationCommandOptionType.Integer;
|
||||
choices?: APIApplicationCommandOptionChoice[];
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-type
|
||||
*/
|
||||
export const enum ApplicationCommandOptionType {
|
||||
SubCommand = 1,
|
||||
SubCommandGroup,
|
||||
String,
|
||||
Integer,
|
||||
Boolean,
|
||||
User,
|
||||
Channel,
|
||||
Role,
|
||||
Mentionable,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-choice-structure
|
||||
*/
|
||||
export interface APIApplicationCommandOptionChoice {
|
||||
name: string;
|
||||
value: string | number;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-object-interaction-structure
|
||||
*/
|
||||
export interface APIApplicationCommandInteractionData {
|
||||
id: Snowflake;
|
||||
name: string;
|
||||
options?: APIApplicationCommandInteractionDataOption[];
|
||||
resolved?: {
|
||||
users?: Record<Snowflake, APIUser>;
|
||||
roles?: Record<Snowflake, APIRole>;
|
||||
members?: Record<Snowflake, APIInteractionDataResolvedGuildMember>;
|
||||
channels?: Record<Snowflake, APIInteractionDataResolvedChannel>;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/channel#channel-object
|
||||
*/
|
||||
export interface APIInteractionDataResolvedChannel extends Required<APIPartialChannel> {
|
||||
permissions: Permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#guild-member-object
|
||||
*/
|
||||
export interface APIInteractionDataResolvedGuildMember extends Omit<APIGuildMember, 'user' | 'deaf' | 'mute'> {
|
||||
permissions: Permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-object-application-command-interaction-data-option-structure
|
||||
*/
|
||||
export type APIApplicationCommandInteractionDataOption =
|
||||
| ApplicationCommandInteractionDataOptionSubCommand
|
||||
| ApplicationCommandInteractionDataOptionSubCommandGroup
|
||||
| APIApplicationCommandInteractionDataOptionWithValues;
|
||||
|
||||
export interface ApplicationCommandInteractionDataOptionSubCommand {
|
||||
name: string;
|
||||
type: ApplicationCommandOptionType.SubCommand;
|
||||
options: APIApplicationCommandInteractionDataOptionWithValues[];
|
||||
}
|
||||
|
||||
export interface ApplicationCommandInteractionDataOptionSubCommandGroup {
|
||||
name: string;
|
||||
type: ApplicationCommandOptionType.SubCommandGroup;
|
||||
options: ApplicationCommandInteractionDataOptionSubCommand[];
|
||||
}
|
||||
|
||||
export type APIApplicationCommandInteractionDataOptionWithValues =
|
||||
| ApplicationCommandInteractionDataOptionString
|
||||
| ApplicationCommandInteractionDataOptionRole
|
||||
| ApplicationCommandInteractionDataOptionChannel
|
||||
| ApplicationCommandInteractionDataOptionUser
|
||||
| ApplicationCommandInteractionDataOptionMentionable
|
||||
| ApplicationCommandInteractionDataOptionInteger
|
||||
| ApplicationCommandInteractionDataOptionBoolean;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionString = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.String,
|
||||
string
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionRole = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Role,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionChannel = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Channel,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionUser = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.User,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionMentionable = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Mentionable,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionInteger = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Integer,
|
||||
number
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionBoolean = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Boolean,
|
||||
boolean
|
||||
>;
|
||||
|
||||
interface InteractionDataOptionBase<T extends ApplicationCommandOptionType, D = unknown> {
|
||||
name: string;
|
||||
type: T;
|
||||
value: D;
|
||||
}
|
||||
|
||||
// PERMISSIONS
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#application-command-permissions-object-guild-application-command-permissions-structure
|
||||
*/
|
||||
export interface APIGuildApplicationCommandPermissions {
|
||||
/**
|
||||
* The id of the command
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* The id of the application the command belongs to
|
||||
*/
|
||||
application_id: Snowflake;
|
||||
/**
|
||||
* The id of the guild
|
||||
*/
|
||||
guild_id: Snowflake;
|
||||
/**
|
||||
* The permissions for the command in the guild
|
||||
*/
|
||||
permissions: APIApplicationCommandPermission[];
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#application-command-permissions-object-application-command-permissions-structure
|
||||
*/
|
||||
export interface APIApplicationCommandPermission {
|
||||
/**
|
||||
* The id of the role or user
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* Role or user
|
||||
*/
|
||||
type: ApplicationCommandPermissionType;
|
||||
/**
|
||||
* `true` to allow, `false`, to disallow
|
||||
*/
|
||||
permission: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissiontype
|
||||
*/
|
||||
export const enum ApplicationCommandPermissionType {
|
||||
Role = 1,
|
||||
User,
|
||||
}
|
||||
|
||||
// INTERACTIONS
|
||||
|
||||
export type APIApplicationCommandInteraction = APIBaseInteraction<
|
||||
InteractionType.ApplicationCommand,
|
||||
APIApplicationCommandInteractionData
|
||||
> &
|
||||
Required<
|
||||
Pick<
|
||||
APIBaseInteraction<InteractionType.ApplicationCommand, APIApplicationCommandInteractionData>,
|
||||
'channel_id' | 'data'
|
||||
>
|
||||
>;
|
||||
|
||||
export type APIApplicationCommandDMInteraction = APIDMInteractionWrapper<APIApplicationCommandInteraction>;
|
||||
|
||||
export type APIApplicationCommandGuildInteraction = APIGuildInteractionWrapper<APIApplicationCommandInteraction>;
|
||||
@@ -544,7 +544,7 @@ export type APIAuditLogChangeKeyMute = AuditLogChangeData<'mute', boolean>;
|
||||
/**
|
||||
* Returned when a user's nick is changed
|
||||
*/
|
||||
export type APIAuditLogChangeKeyNick = AuditLogChangeData<'mute', boolean>;
|
||||
export type APIAuditLogChangeKeyNick = AuditLogChangeData<'nick', boolean>;
|
||||
|
||||
/**
|
||||
* Returned when a user's avatar_hash is changed
|
||||
|
||||
@@ -306,7 +306,11 @@ export interface APIMessage {
|
||||
*/
|
||||
application?: Partial<APIApplication>;
|
||||
/**
|
||||
* Reference data sent with crossposted messages and replies
|
||||
* If the message is a response to an Interaction, this is the id of the interaction's application
|
||||
*/
|
||||
application_id?: Snowflake;
|
||||
/**
|
||||
* Reference data sent with crossposted messages, replies, pins, and thread starter messages
|
||||
*
|
||||
* See https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure
|
||||
*/
|
||||
@@ -899,13 +903,13 @@ export interface APIAllowedMentions {
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components
|
||||
* https://discord.com/developers/docs/interactions/message-components#component-object
|
||||
*/
|
||||
export interface APIBaseComponent {
|
||||
export interface APIBaseMessageComponent<T extends ComponentType> {
|
||||
/**
|
||||
* The type of the component
|
||||
*/
|
||||
type: ComponentType;
|
||||
type: T;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -913,7 +917,7 @@ export interface APIBaseComponent {
|
||||
*/
|
||||
export const enum ComponentType {
|
||||
/**
|
||||
* ActionRow component
|
||||
* Action Row component
|
||||
*/
|
||||
ActionRow = 1,
|
||||
/**
|
||||
@@ -927,13 +931,9 @@ export const enum ComponentType {
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#component-object
|
||||
* https://discord.com/developers/docs/interactions/message-components#action-rows
|
||||
*/
|
||||
export interface APIActionRowComponent extends APIBaseComponent {
|
||||
/**
|
||||
* The type of the component
|
||||
*/
|
||||
type: ComponentType.ActionRow;
|
||||
export interface APIActionRowComponent extends APIBaseMessageComponent<ComponentType.ActionRow> {
|
||||
/**
|
||||
* The components in the ActionRow
|
||||
*/
|
||||
@@ -941,73 +941,97 @@ export interface APIActionRowComponent extends APIBaseComponent {
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#buttons-button-object
|
||||
* https://discord.com/developers/docs/interactions/message-components#buttons
|
||||
*/
|
||||
export interface APIButtonComponent extends APIBaseComponent {
|
||||
/**
|
||||
* The type of the component
|
||||
*/
|
||||
type: ComponentType.Button;
|
||||
interface APIButtonComponentBase<Style extends ButtonStyle> extends APIBaseMessageComponent<ComponentType.Button> {
|
||||
/**
|
||||
* The label to be displayed on the button
|
||||
*/
|
||||
label?: string;
|
||||
/**
|
||||
* The custom_id to be sent in the interaction when clicked
|
||||
*/
|
||||
custom_id?: string;
|
||||
/**
|
||||
* The style of the button
|
||||
*/
|
||||
style: ButtonStyle;
|
||||
style: Style;
|
||||
/**
|
||||
* The emoji to display to the left of the text
|
||||
*/
|
||||
emoji?: APIPartialEmoji;
|
||||
/**
|
||||
* The URL to direct users to when clicked for Link buttons
|
||||
*/
|
||||
url?: string;
|
||||
/**
|
||||
* The status of the button
|
||||
*/
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#component-object
|
||||
*/
|
||||
export interface APISelectMenuComponent {
|
||||
/**
|
||||
* The type of the component
|
||||
*/
|
||||
type: ComponentType.SelectMenu;
|
||||
export interface APIButtonComponentWithCustomID
|
||||
extends APIButtonComponentBase<
|
||||
ButtonStyle.Primary | ButtonStyle.Secondary | ButtonStyle.Success | ButtonStyle.Danger
|
||||
> {
|
||||
/**
|
||||
* The custom_id to be sent in the interaction when clicked
|
||||
*/
|
||||
custom_id: string;
|
||||
}
|
||||
|
||||
export interface APIButtonComponentWithURL extends APIButtonComponentBase<ButtonStyle.Link> {
|
||||
/**
|
||||
* Custom placeholder text if nothing is selected
|
||||
* The URL to direct users to when clicked for Link buttons
|
||||
*/
|
||||
placeholder?: string;
|
||||
/**
|
||||
* The minimum number of items that must be chosen
|
||||
*/
|
||||
min_values?: number;
|
||||
/**
|
||||
* The maximum number of items that can be chosen
|
||||
*/
|
||||
max_values?: number;
|
||||
/**
|
||||
* Choices to display in the select menu
|
||||
*/
|
||||
options: APISelectOption[];
|
||||
url: string;
|
||||
}
|
||||
|
||||
export type APIButtonComponent = APIButtonComponentWithCustomID | APIButtonComponentWithURL;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#button-object-button-styles
|
||||
*/
|
||||
export const enum ButtonStyle {
|
||||
Primary = 1,
|
||||
Secondary,
|
||||
Success,
|
||||
Danger,
|
||||
Link,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#component-object
|
||||
* https://discord.com/developers/docs/interactions/message-components#select-menus
|
||||
*/
|
||||
export interface APISelectOption {
|
||||
export interface APISelectMenuComponent extends APIBaseMessageComponent<ComponentType.SelectMenu> {
|
||||
/**
|
||||
* A developer-defined identifier for the select menu, max 100 characters
|
||||
*/
|
||||
custom_id: string;
|
||||
/**
|
||||
* The choices in the select, max 25
|
||||
*/
|
||||
options: APISelectMenuOption[];
|
||||
/**
|
||||
* Custom placeholder text if nothing is selected, max 100 characters
|
||||
*/
|
||||
placeholder?: string;
|
||||
/**
|
||||
* The minimum number of items that must be chosen; min 0, max 25
|
||||
*
|
||||
* @default 1
|
||||
*/
|
||||
min_values?: number;
|
||||
/**
|
||||
* The maximum number of items that can be chosen; max 25
|
||||
*
|
||||
* @default 1
|
||||
*/
|
||||
max_values?: number;
|
||||
/**
|
||||
* Disable the select
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-option-structure
|
||||
*/
|
||||
export interface APISelectMenuOption {
|
||||
/**
|
||||
* The user-facing name of the option (max 25 chars)
|
||||
*/
|
||||
@@ -1027,18 +1051,10 @@ export interface APISelectOption {
|
||||
/**
|
||||
* Whether this option should be already-selected by default
|
||||
*/
|
||||
default: boolean;
|
||||
default?: boolean;
|
||||
}
|
||||
|
||||
export type APIMessageComponent = APIActionRowComponent | APIButtonComponent | APISelectMenuComponent;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#buttons-button-styles
|
||||
* https://discord.com/developers/docs/interactions/message-components#message-components
|
||||
*/
|
||||
export const enum ButtonStyle {
|
||||
Primary = 1,
|
||||
Secondary,
|
||||
Success,
|
||||
Danger,
|
||||
Link,
|
||||
}
|
||||
export type APIMessageComponent = APIActionRowComponent | APIButtonComponent | APISelectMenuComponent;
|
||||
|
||||
@@ -481,6 +481,30 @@ export const enum GuildFeature {
|
||||
* Guild can be previewed before joining via Membership Screening or the directory
|
||||
*/
|
||||
PreviewEnabled = 'PREVIEW_ENABLED',
|
||||
/**
|
||||
* Guild has enabled ticketed events
|
||||
*/
|
||||
TicketedEventsEnabled = 'TICKETED_EVENTS_ENABLED',
|
||||
/**
|
||||
* Guild has enabled monetization
|
||||
*/
|
||||
MonetizationEnabled = 'MONETIZATION_ENABLED',
|
||||
/**
|
||||
* Guild has increased custom sticker slots
|
||||
*/
|
||||
MoreStickers = 'MORE_STICKERS',
|
||||
/**
|
||||
* Guild has access to the three day archive time for threads
|
||||
*/
|
||||
ThreeDayThreadArchive = 'THREE_DAY_THREAD_ARCHIVE',
|
||||
/**
|
||||
* Guild has access to the seven day archive time for threads
|
||||
*/
|
||||
SevenDayThreadArchive = 'SEVEN_DAY_THREAD_ARCHIVE',
|
||||
/**
|
||||
* Guild has access to create private threads
|
||||
*/
|
||||
PrivateThreads = 'PRIVATE_THREADS',
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,470 +1,21 @@
|
||||
import type { Permissions, Snowflake } from '../../globals';
|
||||
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../rest/v8/index';
|
||||
import { APIMessage, ComponentType } from './channel';
|
||||
import type { APIGuildMember, APIPartialChannel, APIRole, APIUser, MessageFlags } from './index';
|
||||
import {
|
||||
APIMessageComponentDMInteraction,
|
||||
APIMessageComponentGuildInteraction,
|
||||
APIMessageComponentInteraction,
|
||||
} from './_interactions/messageComponents';
|
||||
import {
|
||||
APIApplicationCommandDMInteraction,
|
||||
APIApplicationCommandGuildInteraction,
|
||||
APIApplicationCommandInteraction,
|
||||
} from './_interactions/slashCommands';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommand
|
||||
*/
|
||||
export interface APIApplicationCommand {
|
||||
/**
|
||||
* Unique id of the command
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* Unique id of the parent application
|
||||
*/
|
||||
application_id: Snowflake;
|
||||
/**
|
||||
* 1-32 character name matching `^[\w-]{1,32}$`
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* 1-100 character description
|
||||
*/
|
||||
description: string;
|
||||
/**
|
||||
* The parameters for the command
|
||||
*/
|
||||
options?: APIApplicationCommandOption[];
|
||||
/**
|
||||
* Whether the command is enabled by default when the app is added to a guild
|
||||
*
|
||||
* If missing, this property should be assumed as `true`
|
||||
*/
|
||||
default_permission?: boolean;
|
||||
}
|
||||
export * from './_interactions/base';
|
||||
export * from './_interactions/messageComponents';
|
||||
export * from './_interactions/responses';
|
||||
export * from './_interactions/slashCommands';
|
||||
|
||||
interface APIApplicationCommandOptionBase {
|
||||
type:
|
||||
| ApplicationCommandOptionType.Boolean
|
||||
| ApplicationCommandOptionType.User
|
||||
| ApplicationCommandOptionType.Channel
|
||||
| ApplicationCommandOptionType.Role
|
||||
| ApplicationCommandOptionType.Mentionable;
|
||||
name: string;
|
||||
description: string;
|
||||
default?: boolean;
|
||||
required?: boolean;
|
||||
}
|
||||
export type APIInteraction = APIApplicationCommandInteraction | APIMessageComponentInteraction;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoption
|
||||
*/
|
||||
export type APIApplicationCommandOption =
|
||||
| APIApplicationCommandArgumentOptions
|
||||
| APIApplicationCommandSubCommandOptions
|
||||
| APIApplicationCommandOptionBase;
|
||||
export type APIDMInteraction = APIApplicationCommandDMInteraction | APIMessageComponentDMInteraction;
|
||||
|
||||
/**
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
*
|
||||
* If the option is a `SUB_COMMAND` or `SUB_COMMAND_GROUP` type, this nested options will be the parameters
|
||||
*/
|
||||
export interface APIApplicationCommandSubCommandOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
|
||||
type: ApplicationCommandOptionType.SubCommand | ApplicationCommandOptionType.SubCommandGroup;
|
||||
options?: APIApplicationCommandOption[];
|
||||
}
|
||||
|
||||
/**
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
*
|
||||
* In contrast to `APIApplicationCommandSubCommandOptions`, these types cannot have an `options` array,
|
||||
* but they can have a `choices` one
|
||||
*/
|
||||
export interface APIApplicationCommandArgumentOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
|
||||
type: ApplicationCommandOptionType.String | ApplicationCommandOptionType.Integer;
|
||||
choices?: APIApplicationCommandOptionChoice[];
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptiontype
|
||||
*/
|
||||
export const enum ApplicationCommandOptionType {
|
||||
SubCommand = 1,
|
||||
SubCommandGroup,
|
||||
String,
|
||||
Integer,
|
||||
Boolean,
|
||||
User,
|
||||
Channel,
|
||||
Role,
|
||||
Mentionable,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptionchoice
|
||||
*/
|
||||
export interface APIApplicationCommandOptionChoice {
|
||||
name: string;
|
||||
value: string | number;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction
|
||||
*/
|
||||
export interface APIBaseInteraction {
|
||||
/**
|
||||
* ID of the interaction
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* ID of the application this interaction is for
|
||||
*/
|
||||
application_id: Snowflake;
|
||||
/**
|
||||
* The type of interaction
|
||||
*/
|
||||
type: InteractionType;
|
||||
/**
|
||||
* The command data payload
|
||||
*/
|
||||
data?: APIApplicationCommandInteractionData | APIMessageComponentInteractionData;
|
||||
/**
|
||||
* The channel it was sent from
|
||||
*/
|
||||
channel_id?: Snowflake;
|
||||
/**
|
||||
* A continuation token for responding to the interaction
|
||||
*/
|
||||
token: string;
|
||||
/**
|
||||
* Read-only property, always `1`
|
||||
*/
|
||||
version: 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#guild-member-object
|
||||
*/
|
||||
export interface APIInteractionGuildMember extends APIGuildMember {
|
||||
permissions: Permissions;
|
||||
user: APIUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction
|
||||
*/
|
||||
export interface APIGuildInteraction extends APIBaseInteraction {
|
||||
/**
|
||||
* The guild it was sent from
|
||||
*
|
||||
* In the case of an `APIDMInteraction`, this will not be present
|
||||
*/
|
||||
guild_id: Snowflake;
|
||||
/**
|
||||
* Guild member data for the invoking user, including permissions
|
||||
*/
|
||||
member: APIInteractionGuildMember;
|
||||
channel_id: Snowflake;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction
|
||||
*/
|
||||
export interface APIDMInteraction extends APIBaseInteraction {
|
||||
/**
|
||||
* User object for the invoking user, if invoked in a DM
|
||||
*/
|
||||
user: APIUser;
|
||||
channel_id: Snowflake;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#buttons-button-interaction
|
||||
*/
|
||||
export interface APIMessageComponentInteraction extends APIBaseInteraction {
|
||||
/**
|
||||
* Message object to which the button was attached
|
||||
*/
|
||||
message: APIMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction
|
||||
*/
|
||||
export type APIInteraction = APIGuildInteraction | APIDMInteraction | APIMessageComponentInteraction;
|
||||
|
||||
/**
|
||||
* Like APIGuildInteraction, only with the `data` property always present
|
||||
*
|
||||
* @see APIGuildInteraction
|
||||
*/
|
||||
export type APIApplicationCommandGuildInteraction = Required<APIGuildInteraction>;
|
||||
|
||||
/**
|
||||
* Like APIDMInteraction, only with the `data` property always present
|
||||
*
|
||||
* @see APIDMInteraction
|
||||
*/
|
||||
export type APIApplicationCommandDMInteraction = Required<APIDMInteraction>;
|
||||
|
||||
/**
|
||||
* Like APIInteraction, only with the `data` property always present
|
||||
*
|
||||
* @see APIInteraction
|
||||
*/
|
||||
export type APIApplicationCommandInteraction =
|
||||
| APIApplicationCommandGuildInteraction
|
||||
| APIApplicationCommandDMInteraction;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-interactiontype
|
||||
*/
|
||||
export const enum InteractionType {
|
||||
Ping = 1,
|
||||
ApplicationCommand,
|
||||
MessageComponent,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#guildapplicationcommandpermissions
|
||||
*/
|
||||
export interface APIGuildApplicationCommandPermissions {
|
||||
/**
|
||||
* The id of the command
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* The id of the application the command belongs to
|
||||
*/
|
||||
application_id: Snowflake;
|
||||
/**
|
||||
* The id of the guild
|
||||
*/
|
||||
guild_id: Snowflake;
|
||||
/**
|
||||
* The permissions for the command in the guild
|
||||
*/
|
||||
permissions: APIApplicationCommandPermission[];
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissions
|
||||
*/
|
||||
export interface APIApplicationCommandPermission {
|
||||
/**
|
||||
* The id of the role or user
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* Role or user
|
||||
*/
|
||||
type: ApplicationCommandPermissionType;
|
||||
/**
|
||||
* `true` to allow, `false`, to disallow
|
||||
*/
|
||||
permission: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissiontype
|
||||
*/
|
||||
export const enum ApplicationCommandPermissionType {
|
||||
Role = 1,
|
||||
User,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/channel#channel-object
|
||||
*/
|
||||
export interface APIInteractionDataResolvedChannel extends Required<APIPartialChannel> {
|
||||
permissions: Permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#guild-member-object
|
||||
*/
|
||||
export interface APIInteractionDataResolvedGuildMember extends Omit<APIGuildMember, 'user' | 'deaf' | 'mute'> {
|
||||
permissions: Permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondata
|
||||
*/
|
||||
export interface APIApplicationCommandInteractionData {
|
||||
id: Snowflake;
|
||||
name: string;
|
||||
options?: APIApplicationCommandInteractionDataOption[];
|
||||
resolved?: {
|
||||
users?: Record<string, APIUser>;
|
||||
roles?: Record<string, APIRole>;
|
||||
members?: Record<string, APIInteractionDataResolvedGuildMember>;
|
||||
channels?: Record<string, APIInteractionDataResolvedChannel>;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondataoption
|
||||
*/
|
||||
export type APIApplicationCommandInteractionDataOption =
|
||||
| ApplicationCommandInteractionDataOptionSubCommand
|
||||
| ApplicationCommandInteractionDataOptionSubCommandGroup
|
||||
| APIApplicationCommandInteractionDataOptionWithValues;
|
||||
|
||||
export interface ApplicationCommandInteractionDataOptionSubCommand {
|
||||
name: string;
|
||||
type: ApplicationCommandOptionType.SubCommand;
|
||||
options: APIApplicationCommandInteractionDataOptionWithValues[];
|
||||
}
|
||||
|
||||
export interface ApplicationCommandInteractionDataOptionSubCommandGroup {
|
||||
name: string;
|
||||
type: ApplicationCommandOptionType.SubCommandGroup;
|
||||
options: ApplicationCommandInteractionDataOptionSubCommand[];
|
||||
}
|
||||
|
||||
export type APIApplicationCommandInteractionDataOptionWithValues =
|
||||
| ApplicationCommandInteractionDataOptionString
|
||||
| ApplicationCommandInteractionDataOptionRole
|
||||
| ApplicationCommandInteractionDataOptionChannel
|
||||
| ApplicationCommandInteractionDataOptionUser
|
||||
| ApplicationCommandInteractionDataOptionMentionable
|
||||
| ApplicationCommandInteractionDataOptionInteger
|
||||
| ApplicationCommandInteractionDataOptionBoolean;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionString = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.String,
|
||||
string
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionRole = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Role,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionChannel = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Channel,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionUser = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.User,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionMentionable = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Mentionable,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionInteger = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Integer,
|
||||
number
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionBoolean = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Boolean,
|
||||
boolean
|
||||
>;
|
||||
|
||||
export interface APIMessageButtonInteractionData {
|
||||
custom_id: string;
|
||||
component_type: ComponentType.Button;
|
||||
}
|
||||
|
||||
export interface APIMessageSelectMenuInteractionData {
|
||||
custom_id: string;
|
||||
component_type: ComponentType.SelectMenu;
|
||||
values: string[];
|
||||
}
|
||||
|
||||
export type APIMessageComponentInteractionData = APIMessageButtonInteractionData | APIMessageSelectMenuInteractionData;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response
|
||||
*/
|
||||
export type APIInteractionResponse =
|
||||
| APIInteractionResponsePong
|
||||
| APIInteractionResponseChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredMessageUpdate
|
||||
| APIInteractionResponseUpdateMessage;
|
||||
|
||||
export interface APIInteractionResponsePong {
|
||||
type: InteractionResponseType.Pong;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseChannelMessageWithSource {
|
||||
type: InteractionResponseType.ChannelMessageWithSource;
|
||||
data: APIInteractionApplicationCommandCallbackData;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseDeferredChannelMessageWithSource {
|
||||
type: InteractionResponseType.DeferredChannelMessageWithSource;
|
||||
data?: Pick<APIInteractionApplicationCommandCallbackData, 'flags'>;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseDeferredMessageUpdate {
|
||||
type: InteractionResponseType.DeferredMessageUpdate;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseUpdateMessage {
|
||||
type: InteractionResponseType.UpdateMessage;
|
||||
data?: APIInteractionApplicationCommandCallbackData;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionresponsetype
|
||||
*/
|
||||
export const enum InteractionResponseType {
|
||||
/**
|
||||
* ACK a `Ping`
|
||||
*/
|
||||
Pong = 1,
|
||||
/**
|
||||
* Respond to an interaction with a message
|
||||
*/
|
||||
ChannelMessageWithSource = 4,
|
||||
/**
|
||||
* ACK an interaction and edit to a response later, the user sees a loading state
|
||||
*/
|
||||
DeferredChannelMessageWithSource,
|
||||
/**
|
||||
* ACK a button interaction and update it to a loading state
|
||||
*/
|
||||
DeferredMessageUpdate,
|
||||
/**
|
||||
* ACK a button interaction and edit the message to which the button was attached
|
||||
*/
|
||||
UpdateMessage,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionapplicationcommandcallbackdata
|
||||
*/
|
||||
export type APIInteractionApplicationCommandCallbackData = Omit<
|
||||
RESTPostAPIWebhookWithTokenJSONBody,
|
||||
'username' | 'avatar_url'
|
||||
> & { flags?: MessageFlags };
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#messageinteraction
|
||||
*/
|
||||
export interface APIMessageInteraction {
|
||||
/**
|
||||
* ID of the interaction
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* The type of interaction
|
||||
*/
|
||||
type: InteractionType;
|
||||
/**
|
||||
* The name of the ApplicationCommand
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* The user who invoked the interaction
|
||||
*/
|
||||
user: APIUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
interface InteractionDataOptionBase<T extends ApplicationCommandOptionType, D = unknown> {
|
||||
name: string;
|
||||
type: T;
|
||||
value: D;
|
||||
}
|
||||
export type APIGuildInteraction = APIApplicationCommandGuildInteraction | APIMessageComponentGuildInteraction;
|
||||
|
||||
@@ -51,7 +51,7 @@ export interface APIApplication {
|
||||
*
|
||||
* See https://discord.com/developers/docs/resources/user#user-object
|
||||
*/
|
||||
owner: APIUser;
|
||||
owner?: APIUser;
|
||||
/**
|
||||
* If this application is a game sold on Discord, this field will be the summary field for the store page
|
||||
* of its primary sku
|
||||
@@ -153,11 +153,11 @@ export const enum OAuth2Scopes {
|
||||
*/
|
||||
MessagesRead = 'messages.read',
|
||||
/**
|
||||
* For local rpc server access, this allows you to control a user's local Discord client - whitelist only
|
||||
* For local rpc server access, this allows you to control a user's local Discord client - requires Discord approval
|
||||
*/
|
||||
RPC = 'rpc',
|
||||
/**
|
||||
* For local rpc server api access, this allows you to receive notifications pushed out to the user - whitelist only
|
||||
* For local rpc server api access, this allows you to receive notifications pushed out to the user - requires Discord approval
|
||||
*/
|
||||
RPCNotificationsRead = 'rpc.notifications.read',
|
||||
/**
|
||||
@@ -165,7 +165,7 @@ export const enum OAuth2Scopes {
|
||||
*/
|
||||
WebhookIncoming = 'webhook.incoming',
|
||||
/**
|
||||
* Allows your app to upload/update builds for a user's applications - whitelist only
|
||||
* Allows your app to upload/update builds for a user's applications - requires Discord approval
|
||||
*/
|
||||
ApplicationsBuildsUpload = 'applications.builds.upload',
|
||||
/**
|
||||
@@ -181,27 +181,27 @@ export const enum OAuth2Scopes {
|
||||
*/
|
||||
ApplicationsEntitlements = 'applications.entitlements',
|
||||
/**
|
||||
* Allows your app to know a user's friends and implicit relationships - whitelist only
|
||||
* Allows your app to know a user's friends and implicit relationships - requires Discord approval
|
||||
*/
|
||||
RelationshipsRead = 'relationships.read',
|
||||
/**
|
||||
* Allows your app to fetch data from a user's "Now Playing/Recently Played" list - whitelist only
|
||||
* Allows your app to fetch data from a user's "Now Playing/Recently Played" list - requires Discord approval
|
||||
*/
|
||||
ActivitiesRead = 'activities.read',
|
||||
/**
|
||||
* Allows your app to update a user's activity - whitelist only (NOT REQUIRED FOR GAMESDK ACTIVITY MANAGER)
|
||||
* Allows your app to update a user's activity - requires Discord approval (NOT REQUIRED FOR GAMESDK ACTIVITY MANAGER)
|
||||
*
|
||||
* See https://discord.com/developers/docs/game-sdk/activities
|
||||
*/
|
||||
ActivitiesWrite = 'activities.write',
|
||||
/**
|
||||
* Allows your app to create Slash Commands in the authorized guild
|
||||
* Allows your app to use Slash Commands in a guild
|
||||
*
|
||||
* See https://discord.com/developers/docs/interactions/slash-commands
|
||||
*/
|
||||
ApplicationsCommands = 'applications.commands',
|
||||
/**
|
||||
* Allows your app to update Slash Commands via this bearer token
|
||||
* Allows your app to update its Slash Commands via this bearer token - client credentials grant only
|
||||
*
|
||||
* See https://discord.com/developers/docs/interactions/slash-commands
|
||||
*/
|
||||
|
||||
@@ -88,6 +88,7 @@ export const enum UserFlags {
|
||||
BugHunterLevel2 = 1 << 14,
|
||||
VerifiedBot = 1 << 16,
|
||||
EarlyVerifiedBotDeveloper = 1 << 17,
|
||||
DiscordCertifiedModerator = 1 << 18,
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
101
payloads/v9/_interactions/base.ts
Normal file
101
payloads/v9/_interactions/base.ts
Normal file
@@ -0,0 +1,101 @@
|
||||
import { Permissions, Snowflake } from '../../../globals';
|
||||
import { InteractionType } from '../../v9';
|
||||
import { APIMessage } from '../channel';
|
||||
import { APIGuildMember } from '../guild';
|
||||
import { APIUser } from '../user';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#message-interaction-object-message-interaction-structure
|
||||
*/
|
||||
export interface APIMessageInteraction {
|
||||
/**
|
||||
* ID of the interaction
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* The type of interaction
|
||||
*/
|
||||
type: InteractionType;
|
||||
/**
|
||||
* The name of the ApplicationCommand
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* The user who invoked the interaction
|
||||
*/
|
||||
user: APIUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#guild-member-object
|
||||
*/
|
||||
export interface APIInteractionGuildMember extends APIGuildMember {
|
||||
permissions: Permissions;
|
||||
user: APIUser;
|
||||
}
|
||||
|
||||
// INTERACTIONS RECEIVED
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-object
|
||||
*/
|
||||
export interface APIBaseInteraction<Type extends InteractionType, Data extends unknown> {
|
||||
/**
|
||||
* ID of the interaction
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* ID of the application this interaction is for
|
||||
*/
|
||||
application_id: Snowflake;
|
||||
/**
|
||||
* The type of interaction
|
||||
*/
|
||||
type: Type;
|
||||
/**
|
||||
* The command data payload
|
||||
*/
|
||||
data?: Data;
|
||||
/**
|
||||
* The guild it was sent from
|
||||
*/
|
||||
guild_id?: Snowflake;
|
||||
/**
|
||||
* The channel it was sent from
|
||||
*/
|
||||
channel_id?: Snowflake;
|
||||
/**
|
||||
* Guild member data for the invoking user, including permissions
|
||||
*
|
||||
* **This is only sent when an interaction is invoked in a guild**
|
||||
*/
|
||||
member?: APIInteractionGuildMember;
|
||||
/**
|
||||
* User object for the invoking user, if invoked in a DM
|
||||
*/
|
||||
user?: APIUser;
|
||||
/**
|
||||
* A continuation token for responding to the interaction
|
||||
*/
|
||||
token: string;
|
||||
/**
|
||||
* Read-only property, always `1`
|
||||
*/
|
||||
version: 1;
|
||||
/**
|
||||
* For components, the message they were attached to
|
||||
*/
|
||||
message?: APIMessage;
|
||||
}
|
||||
|
||||
export type APIDMInteractionWrapper<Original extends APIBaseInteraction<InteractionType, unknown>> = Omit<
|
||||
Original,
|
||||
'member' | 'guild_id'
|
||||
> &
|
||||
Required<Pick<Original, 'user'>>;
|
||||
|
||||
export type APIGuildInteractionWrapper<Original extends APIBaseInteraction<InteractionType, unknown>> = Omit<
|
||||
Original,
|
||||
'user'
|
||||
> &
|
||||
Required<Pick<Original, 'member' | 'guild_id'>>;
|
||||
38
payloads/v9/_interactions/messageComponents.ts
Normal file
38
payloads/v9/_interactions/messageComponents.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { ComponentType } from '../channel';
|
||||
import { APIBaseInteraction, InteractionType } from '../interactions';
|
||||
import { APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base';
|
||||
|
||||
export type APIMessageComponentInteraction = APIBaseInteraction<
|
||||
InteractionType.MessageComponent,
|
||||
APIMessageComponentInteractionData
|
||||
> &
|
||||
Required<
|
||||
Pick<
|
||||
APIBaseInteraction<InteractionType.MessageComponent, APIMessageComponentInteractionData>,
|
||||
'channel_id' | 'data' | 'message'
|
||||
>
|
||||
>;
|
||||
|
||||
export type APIMessageComponentInteractionData = APIMessageButtonInteractionData | APIMessageSelectMenuInteractionData;
|
||||
|
||||
export interface APIMessageComponentBaseInteractionData<CType extends ComponentType> {
|
||||
/**
|
||||
* The `custom_id` of the component
|
||||
*/
|
||||
custom_id: string;
|
||||
/**
|
||||
* The type of the component
|
||||
*/
|
||||
component_type: CType;
|
||||
}
|
||||
|
||||
export type APIMessageButtonInteractionData = APIMessageComponentBaseInteractionData<ComponentType.Button>;
|
||||
|
||||
export interface APIMessageSelectMenuInteractionData
|
||||
extends APIMessageComponentBaseInteractionData<ComponentType.SelectMenu> {
|
||||
values: string[];
|
||||
}
|
||||
|
||||
export type APIMessageComponentDMInteraction = APIDMInteractionWrapper<APIMessageComponentInteraction>;
|
||||
|
||||
export type APIMessageComponentGuildInteraction = APIGuildInteractionWrapper<APIMessageComponentInteraction>;
|
||||
78
payloads/v9/_interactions/responses.ts
Normal file
78
payloads/v9/_interactions/responses.ts
Normal file
@@ -0,0 +1,78 @@
|
||||
import { MessageFlags } from '../index';
|
||||
import { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v9';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-object-interaction-request-type
|
||||
*/
|
||||
export const enum InteractionType {
|
||||
Ping = 1,
|
||||
ApplicationCommand,
|
||||
MessageComponent,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object
|
||||
*/
|
||||
export type APIInteractionResponse =
|
||||
| APIInteractionResponsePong
|
||||
| APIInteractionResponseChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredMessageUpdate
|
||||
| APIInteractionResponseUpdateMessage;
|
||||
|
||||
export interface APIInteractionResponsePong {
|
||||
type: InteractionResponseType.Pong;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseChannelMessageWithSource {
|
||||
type: InteractionResponseType.ChannelMessageWithSource;
|
||||
data: APIInteractionResponseCallbackData;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseDeferredChannelMessageWithSource {
|
||||
type: InteractionResponseType.DeferredChannelMessageWithSource;
|
||||
data?: Pick<APIInteractionResponseCallbackData, 'flags'>;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseDeferredMessageUpdate {
|
||||
type: InteractionResponseType.DeferredMessageUpdate;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseUpdateMessage {
|
||||
type: InteractionResponseType.UpdateMessage;
|
||||
data?: APIInteractionResponseCallbackData;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object-interaction-callback-type
|
||||
*/
|
||||
export const enum InteractionResponseType {
|
||||
/**
|
||||
* ACK a `Ping`
|
||||
*/
|
||||
Pong = 1,
|
||||
/**
|
||||
* Respond to an interaction with a message
|
||||
*/
|
||||
ChannelMessageWithSource = 4,
|
||||
/**
|
||||
* ACK an interaction and edit to a response later, the user sees a loading state
|
||||
*/
|
||||
DeferredChannelMessageWithSource,
|
||||
/**
|
||||
* ACK a button interaction and update it to a loading state
|
||||
*/
|
||||
DeferredMessageUpdate,
|
||||
/**
|
||||
* ACK a button interaction and edit the message to which the button was attached
|
||||
*/
|
||||
UpdateMessage,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object-interaction-application-command-callback-data-structure
|
||||
*/
|
||||
export type APIInteractionResponseCallbackData = Omit<
|
||||
RESTPostAPIWebhookWithTokenJSONBody,
|
||||
'username' | 'avatar_url'
|
||||
> & { flags?: MessageFlags };
|
||||
273
payloads/v9/_interactions/slashCommands.ts
Normal file
273
payloads/v9/_interactions/slashCommands.ts
Normal file
@@ -0,0 +1,273 @@
|
||||
import { APIRole, APIUser } from '../index';
|
||||
import { Permissions, Snowflake } from '../../../globals';
|
||||
import { APIPartialChannel } from '../channel';
|
||||
import { APIGuildMember } from '../guild';
|
||||
import { APIBaseInteraction, APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base';
|
||||
import { InteractionType } from './responses';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#application-command-object
|
||||
*/
|
||||
export interface APIApplicationCommand {
|
||||
/**
|
||||
* Unique id of the command
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* Unique id of the parent application
|
||||
*/
|
||||
application_id: Snowflake;
|
||||
/**
|
||||
* Guild id of the command, if not global
|
||||
*/
|
||||
guild_id?: Snowflake;
|
||||
/**
|
||||
* 1-32 character name matching `^[\w-]{1,32}$`
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* 1-100 character description
|
||||
*/
|
||||
description: string;
|
||||
/**
|
||||
* The parameters for the command
|
||||
*/
|
||||
options?: APIApplicationCommandOption[];
|
||||
/**
|
||||
* Whether the command is enabled by default when the app is added to a guild
|
||||
*
|
||||
* If missing, this property should be assumed as `true`
|
||||
*/
|
||||
default_permission?: boolean;
|
||||
}
|
||||
|
||||
interface APIApplicationCommandOptionBase {
|
||||
type:
|
||||
| ApplicationCommandOptionType.Boolean
|
||||
| ApplicationCommandOptionType.User
|
||||
| ApplicationCommandOptionType.Channel
|
||||
| ApplicationCommandOptionType.Role
|
||||
| ApplicationCommandOptionType.Mentionable;
|
||||
name: string;
|
||||
description: string;
|
||||
default?: boolean;
|
||||
required?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-structure
|
||||
*/
|
||||
export type APIApplicationCommandOption =
|
||||
| APIApplicationCommandArgumentOptions
|
||||
| APIApplicationCommandSubCommandOptions
|
||||
| APIApplicationCommandOptionBase;
|
||||
|
||||
/**
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
*
|
||||
* If the option is a `SUB_COMMAND` or `SUB_COMMAND_GROUP` type, this nested options will be the parameters
|
||||
*/
|
||||
export interface APIApplicationCommandSubCommandOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
|
||||
type: ApplicationCommandOptionType.SubCommand | ApplicationCommandOptionType.SubCommandGroup;
|
||||
options?: APIApplicationCommandOption[];
|
||||
}
|
||||
|
||||
/**
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
*
|
||||
* In contrast to `APIApplicationCommandSubCommandOptions`, these types cannot have an `options` array,
|
||||
* but they can have a `choices` one
|
||||
*/
|
||||
export interface APIApplicationCommandArgumentOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
|
||||
type: ApplicationCommandOptionType.String | ApplicationCommandOptionType.Integer;
|
||||
choices?: APIApplicationCommandOptionChoice[];
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-type
|
||||
*/
|
||||
export const enum ApplicationCommandOptionType {
|
||||
SubCommand = 1,
|
||||
SubCommandGroup,
|
||||
String,
|
||||
Integer,
|
||||
Boolean,
|
||||
User,
|
||||
Channel,
|
||||
Role,
|
||||
Mentionable,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-choice-structure
|
||||
*/
|
||||
export interface APIApplicationCommandOptionChoice {
|
||||
name: string;
|
||||
value: string | number;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-object-interaction-structure
|
||||
*/
|
||||
export interface APIApplicationCommandInteractionData {
|
||||
id: Snowflake;
|
||||
name: string;
|
||||
options?: APIApplicationCommandInteractionDataOption[];
|
||||
resolved?: {
|
||||
users?: Record<Snowflake, APIUser>;
|
||||
roles?: Record<Snowflake, APIRole>;
|
||||
members?: Record<Snowflake, APIInteractionDataResolvedGuildMember>;
|
||||
channels?: Record<Snowflake, APIInteractionDataResolvedChannel>;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/channel#channel-object
|
||||
*/
|
||||
export interface APIInteractionDataResolvedChannel extends Required<APIPartialChannel> {
|
||||
permissions: Permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#guild-member-object
|
||||
*/
|
||||
export interface APIInteractionDataResolvedGuildMember extends Omit<APIGuildMember, 'user' | 'deaf' | 'mute'> {
|
||||
permissions: Permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-object-application-command-interaction-data-option-structure
|
||||
*/
|
||||
export type APIApplicationCommandInteractionDataOption =
|
||||
| ApplicationCommandInteractionDataOptionSubCommand
|
||||
| ApplicationCommandInteractionDataOptionSubCommandGroup
|
||||
| APIApplicationCommandInteractionDataOptionWithValues;
|
||||
|
||||
export interface ApplicationCommandInteractionDataOptionSubCommand {
|
||||
name: string;
|
||||
type: ApplicationCommandOptionType.SubCommand;
|
||||
options: APIApplicationCommandInteractionDataOptionWithValues[];
|
||||
}
|
||||
|
||||
export interface ApplicationCommandInteractionDataOptionSubCommandGroup {
|
||||
name: string;
|
||||
type: ApplicationCommandOptionType.SubCommandGroup;
|
||||
options: ApplicationCommandInteractionDataOptionSubCommand[];
|
||||
}
|
||||
|
||||
export type APIApplicationCommandInteractionDataOptionWithValues =
|
||||
| ApplicationCommandInteractionDataOptionString
|
||||
| ApplicationCommandInteractionDataOptionRole
|
||||
| ApplicationCommandInteractionDataOptionChannel
|
||||
| ApplicationCommandInteractionDataOptionUser
|
||||
| ApplicationCommandInteractionDataOptionMentionable
|
||||
| ApplicationCommandInteractionDataOptionInteger
|
||||
| ApplicationCommandInteractionDataOptionBoolean;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionString = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.String,
|
||||
string
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionRole = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Role,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionChannel = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Channel,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionUser = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.User,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionMentionable = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Mentionable,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionInteger = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Integer,
|
||||
number
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionBoolean = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Boolean,
|
||||
boolean
|
||||
>;
|
||||
|
||||
interface InteractionDataOptionBase<T extends ApplicationCommandOptionType, D = unknown> {
|
||||
name: string;
|
||||
type: T;
|
||||
value: D;
|
||||
}
|
||||
|
||||
// PERMISSIONS
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#application-command-permissions-object-guild-application-command-permissions-structure
|
||||
*/
|
||||
export interface APIGuildApplicationCommandPermissions {
|
||||
/**
|
||||
* The id of the command
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* The id of the application the command belongs to
|
||||
*/
|
||||
application_id: Snowflake;
|
||||
/**
|
||||
* The id of the guild
|
||||
*/
|
||||
guild_id: Snowflake;
|
||||
/**
|
||||
* The permissions for the command in the guild
|
||||
*/
|
||||
permissions: APIApplicationCommandPermission[];
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#application-command-permissions-object-application-command-permissions-structure
|
||||
*/
|
||||
export interface APIApplicationCommandPermission {
|
||||
/**
|
||||
* The id of the role or user
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* Role or user
|
||||
*/
|
||||
type: ApplicationCommandPermissionType;
|
||||
/**
|
||||
* `true` to allow, `false`, to disallow
|
||||
*/
|
||||
permission: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissiontype
|
||||
*/
|
||||
export const enum ApplicationCommandPermissionType {
|
||||
Role = 1,
|
||||
User,
|
||||
}
|
||||
|
||||
// INTERACTIONS
|
||||
|
||||
export type APIApplicationCommandInteraction = APIBaseInteraction<
|
||||
InteractionType.ApplicationCommand,
|
||||
APIApplicationCommandInteractionData
|
||||
> &
|
||||
Required<
|
||||
Pick<
|
||||
APIBaseInteraction<InteractionType.ApplicationCommand, APIApplicationCommandInteractionData>,
|
||||
'channel_id' | 'data'
|
||||
>
|
||||
>;
|
||||
|
||||
export type APIApplicationCommandDMInteraction = APIDMInteractionWrapper<APIApplicationCommandInteraction>;
|
||||
|
||||
export type APIApplicationCommandGuildInteraction = APIGuildInteractionWrapper<APIApplicationCommandInteraction>;
|
||||
@@ -544,7 +544,7 @@ export type APIAuditLogChangeKeyMute = AuditLogChangeData<'mute', boolean>;
|
||||
/**
|
||||
* Returned when a user's nick is changed
|
||||
*/
|
||||
export type APIAuditLogChangeKeyNick = AuditLogChangeData<'mute', boolean>;
|
||||
export type APIAuditLogChangeKeyNick = AuditLogChangeData<'nick', boolean>;
|
||||
|
||||
/**
|
||||
* Returned when a user's avatar_hash is changed
|
||||
|
||||
@@ -341,6 +341,10 @@ export interface APIMessage {
|
||||
* See https://discord.com/developers/docs/resources/channel#message-object-message-application-structure
|
||||
*/
|
||||
application?: Partial<APIApplication>;
|
||||
/**
|
||||
* If the message is a response to an Interaction, this is the id of the interaction's application
|
||||
*/
|
||||
application_id?: Snowflake;
|
||||
/**
|
||||
* Reference data sent with crossposted messages, replies, pins, and thread starter messages
|
||||
*
|
||||
@@ -596,7 +600,7 @@ export interface APIThreadMetadata {
|
||||
*/
|
||||
archive_timestamp: string;
|
||||
/**
|
||||
* When a thread is locked, only users with MANAGE_THREADS can unarchive it
|
||||
* Whether the thread is locked; when a thread is locked, only users with `MANAGE_THREADS` can unarchive it
|
||||
*/
|
||||
locked?: boolean;
|
||||
}
|
||||
@@ -614,12 +618,16 @@ export const enum ThreadAutoArchiveDuration {
|
||||
export interface APIThreadMember {
|
||||
/**
|
||||
* The id of the thread
|
||||
*
|
||||
* **This field is omitted on the member sent within each thread in the `GUILD_CREATE` event**
|
||||
*/
|
||||
id: Snowflake;
|
||||
id?: Snowflake;
|
||||
/**
|
||||
* The id of the member
|
||||
*
|
||||
* **This field is omitted on the member sent within each thread in the `GUILD_CREATE` event**
|
||||
*/
|
||||
user_id: Snowflake;
|
||||
user_id?: Snowflake;
|
||||
/**
|
||||
* An ISO8601 timestamp for when the member last joined
|
||||
*/
|
||||
@@ -1015,13 +1023,13 @@ export interface APIAllowedMentions {
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components
|
||||
* https://discord.com/developers/docs/interactions/message-components#component-object
|
||||
*/
|
||||
export interface APIBaseComponent {
|
||||
export interface APIBaseMessageComponent<T extends ComponentType> {
|
||||
/**
|
||||
* The type of the component
|
||||
*/
|
||||
type: ComponentType;
|
||||
type: T;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1029,7 +1037,7 @@ export interface APIBaseComponent {
|
||||
*/
|
||||
export const enum ComponentType {
|
||||
/**
|
||||
* ActionRow component
|
||||
* Action Row component
|
||||
*/
|
||||
ActionRow = 1,
|
||||
/**
|
||||
@@ -1043,13 +1051,9 @@ export const enum ComponentType {
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#component-object
|
||||
* https://discord.com/developers/docs/interactions/message-components#action-rows
|
||||
*/
|
||||
export interface APIActionRowComponent extends APIBaseComponent {
|
||||
/**
|
||||
* The type of the component
|
||||
*/
|
||||
type: ComponentType.ActionRow;
|
||||
export interface APIActionRowComponent extends APIBaseMessageComponent<ComponentType.ActionRow> {
|
||||
/**
|
||||
* The components in the ActionRow
|
||||
*/
|
||||
@@ -1057,73 +1061,97 @@ export interface APIActionRowComponent extends APIBaseComponent {
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#buttons-button-object
|
||||
* https://discord.com/developers/docs/interactions/message-components#buttons
|
||||
*/
|
||||
export interface APIButtonComponent extends APIBaseComponent {
|
||||
/**
|
||||
* The type of the component
|
||||
*/
|
||||
type: ComponentType.Button;
|
||||
interface APIButtonComponentBase<Style extends ButtonStyle> extends APIBaseMessageComponent<ComponentType.Button> {
|
||||
/**
|
||||
* The label to be displayed on the button
|
||||
*/
|
||||
label?: string;
|
||||
/**
|
||||
* The custom_id to be sent in the interaction when clicked
|
||||
*/
|
||||
custom_id?: string;
|
||||
/**
|
||||
* The style of the button
|
||||
*/
|
||||
style: ButtonStyle;
|
||||
style: Style;
|
||||
/**
|
||||
* The emoji to display to the left of the text
|
||||
*/
|
||||
emoji?: APIPartialEmoji;
|
||||
/**
|
||||
* The URL to direct users to when clicked for Link buttons
|
||||
*/
|
||||
url?: string;
|
||||
/**
|
||||
* The status of the button
|
||||
*/
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#component-object
|
||||
*/
|
||||
export interface APISelectMenuComponent {
|
||||
/**
|
||||
* The type of the component
|
||||
*/
|
||||
type: ComponentType.SelectMenu;
|
||||
export interface APIButtonComponentWithCustomID
|
||||
extends APIButtonComponentBase<
|
||||
ButtonStyle.Primary | ButtonStyle.Secondary | ButtonStyle.Success | ButtonStyle.Danger
|
||||
> {
|
||||
/**
|
||||
* The custom_id to be sent in the interaction when clicked
|
||||
*/
|
||||
custom_id: string;
|
||||
}
|
||||
|
||||
export interface APIButtonComponentWithURL extends APIButtonComponentBase<ButtonStyle.Link> {
|
||||
/**
|
||||
* Custom placeholder text if nothing is selected
|
||||
* The URL to direct users to when clicked for Link buttons
|
||||
*/
|
||||
placeholder?: string;
|
||||
/**
|
||||
* The minimum number of items that must be chosen
|
||||
*/
|
||||
min_values?: number;
|
||||
/**
|
||||
* The maximum number of items that can be chosen
|
||||
*/
|
||||
max_values?: number;
|
||||
/**
|
||||
* Choices to display in the select menu
|
||||
*/
|
||||
options: APISelectOption[];
|
||||
url: string;
|
||||
}
|
||||
|
||||
export type APIButtonComponent = APIButtonComponentWithCustomID | APIButtonComponentWithURL;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#button-object-button-styles
|
||||
*/
|
||||
export const enum ButtonStyle {
|
||||
Primary = 1,
|
||||
Secondary,
|
||||
Success,
|
||||
Danger,
|
||||
Link,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#component-object
|
||||
* https://discord.com/developers/docs/interactions/message-components#select-menus
|
||||
*/
|
||||
export interface APISelectOption {
|
||||
export interface APISelectMenuComponent extends APIBaseMessageComponent<ComponentType.SelectMenu> {
|
||||
/**
|
||||
* A developer-defined identifier for the select menu, max 100 characters
|
||||
*/
|
||||
custom_id: string;
|
||||
/**
|
||||
* The choices in the select, max 25
|
||||
*/
|
||||
options: APISelectMenuOption[];
|
||||
/**
|
||||
* Custom placeholder text if nothing is selected, max 100 characters
|
||||
*/
|
||||
placeholder?: string;
|
||||
/**
|
||||
* The minimum number of items that must be chosen; min 0, max 25
|
||||
*
|
||||
* @default 1
|
||||
*/
|
||||
min_values?: number;
|
||||
/**
|
||||
* The maximum number of items that can be chosen; max 25
|
||||
*
|
||||
* @default 1
|
||||
*/
|
||||
max_values?: number;
|
||||
/**
|
||||
* Disable the select
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-option-structure
|
||||
*/
|
||||
export interface APISelectMenuOption {
|
||||
/**
|
||||
* The user-facing name of the option (max 25 chars)
|
||||
*/
|
||||
@@ -1143,18 +1171,10 @@ export interface APISelectOption {
|
||||
/**
|
||||
* Whether this option should be already-selected by default
|
||||
*/
|
||||
default: boolean;
|
||||
default?: boolean;
|
||||
}
|
||||
|
||||
export type APIMessageComponent = APIActionRowComponent | APIButtonComponent | APISelectMenuComponent;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#buttons-button-styles
|
||||
* https://discord.com/developers/docs/interactions/message-components#message-components
|
||||
*/
|
||||
export const enum ButtonStyle {
|
||||
Primary = 1,
|
||||
Secondary,
|
||||
Success,
|
||||
Danger,
|
||||
Link,
|
||||
}
|
||||
export type APIMessageComponent = APIActionRowComponent | APIButtonComponent | APISelectMenuComponent;
|
||||
|
||||
@@ -489,6 +489,30 @@ export const enum GuildFeature {
|
||||
* Guild can be previewed before joining via Membership Screening or the directory
|
||||
*/
|
||||
PreviewEnabled = 'PREVIEW_ENABLED',
|
||||
/**
|
||||
* Guild has enabled ticketed events
|
||||
*/
|
||||
TicketedEventsEnabled = 'TICKETED_EVENTS_ENABLED',
|
||||
/**
|
||||
* Guild has enabled monetization
|
||||
*/
|
||||
MonetizationEnabled = 'MONETIZATION_ENABLED',
|
||||
/**
|
||||
* Guild has increased custom sticker slots
|
||||
*/
|
||||
MoreStickers = 'MORE_STICKERS',
|
||||
/**
|
||||
* Guild has access to the three day archive time for threads
|
||||
*/
|
||||
ThreeDayThreadArchive = 'THREE_DAY_THREAD_ARCHIVE',
|
||||
/**
|
||||
* Guild has access to the seven day archive time for threads
|
||||
*/
|
||||
SevenDayThreadArchive = 'SEVEN_DAY_THREAD_ARCHIVE',
|
||||
/**
|
||||
* Guild has access to create private threads
|
||||
*/
|
||||
PrivateThreads = 'PRIVATE_THREADS',
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,470 +1,21 @@
|
||||
import type { Permissions, Snowflake } from '../../globals';
|
||||
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../rest/v9/index';
|
||||
import { APIMessage, ComponentType } from './channel';
|
||||
import type { APIGuildMember, APIPartialChannel, APIRole, APIUser, MessageFlags } from './index';
|
||||
import {
|
||||
APIMessageComponentDMInteraction,
|
||||
APIMessageComponentGuildInteraction,
|
||||
APIMessageComponentInteraction,
|
||||
} from './_interactions/messageComponents';
|
||||
import {
|
||||
APIApplicationCommandDMInteraction,
|
||||
APIApplicationCommandGuildInteraction,
|
||||
APIApplicationCommandInteraction,
|
||||
} from './_interactions/slashCommands';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommand
|
||||
*/
|
||||
export interface APIApplicationCommand {
|
||||
/**
|
||||
* Unique id of the command
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* Unique id of the parent application
|
||||
*/
|
||||
application_id: Snowflake;
|
||||
/**
|
||||
* 1-32 character name matching `^[\w-]{1,32}$`
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* 1-100 character description
|
||||
*/
|
||||
description: string;
|
||||
/**
|
||||
* The parameters for the command
|
||||
*/
|
||||
options?: APIApplicationCommandOption[];
|
||||
/**
|
||||
* Whether the command is enabled by default when the app is added to a guild
|
||||
*
|
||||
* If missing, this property should be assumed as `true`
|
||||
*/
|
||||
default_permission?: boolean;
|
||||
}
|
||||
export * from './_interactions/base';
|
||||
export * from './_interactions/messageComponents';
|
||||
export * from './_interactions/responses';
|
||||
export * from './_interactions/slashCommands';
|
||||
|
||||
interface APIApplicationCommandOptionBase {
|
||||
type:
|
||||
| ApplicationCommandOptionType.Boolean
|
||||
| ApplicationCommandOptionType.User
|
||||
| ApplicationCommandOptionType.Channel
|
||||
| ApplicationCommandOptionType.Role
|
||||
| ApplicationCommandOptionType.Mentionable;
|
||||
name: string;
|
||||
description: string;
|
||||
default?: boolean;
|
||||
required?: boolean;
|
||||
}
|
||||
export type APIInteraction = APIApplicationCommandInteraction | APIMessageComponentInteraction;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoption
|
||||
*/
|
||||
export type APIApplicationCommandOption =
|
||||
| APIApplicationCommandArgumentOptions
|
||||
| APIApplicationCommandSubCommandOptions
|
||||
| APIApplicationCommandOptionBase;
|
||||
export type APIDMInteraction = APIApplicationCommandDMInteraction | APIMessageComponentDMInteraction;
|
||||
|
||||
/**
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
*
|
||||
* If the option is a `SUB_COMMAND` or `SUB_COMMAND_GROUP` type, this nested options will be the parameters
|
||||
*/
|
||||
export interface APIApplicationCommandSubCommandOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
|
||||
type: ApplicationCommandOptionType.SubCommand | ApplicationCommandOptionType.SubCommandGroup;
|
||||
options?: APIApplicationCommandOption[];
|
||||
}
|
||||
|
||||
/**
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
*
|
||||
* In contrast to `APIApplicationCommandSubCommandOptions`, these types cannot have an `options` array,
|
||||
* but they can have a `choices` one
|
||||
*/
|
||||
export interface APIApplicationCommandArgumentOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
|
||||
type: ApplicationCommandOptionType.String | ApplicationCommandOptionType.Integer;
|
||||
choices?: APIApplicationCommandOptionChoice[];
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptiontype
|
||||
*/
|
||||
export const enum ApplicationCommandOptionType {
|
||||
SubCommand = 1,
|
||||
SubCommandGroup,
|
||||
String,
|
||||
Integer,
|
||||
Boolean,
|
||||
User,
|
||||
Channel,
|
||||
Role,
|
||||
Mentionable,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptionchoice
|
||||
*/
|
||||
export interface APIApplicationCommandOptionChoice {
|
||||
name: string;
|
||||
value: string | number;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction
|
||||
*/
|
||||
export interface APIBaseInteraction {
|
||||
/**
|
||||
* ID of the interaction
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* ID of the application this interaction is for
|
||||
*/
|
||||
application_id: Snowflake;
|
||||
/**
|
||||
* The type of interaction
|
||||
*/
|
||||
type: InteractionType;
|
||||
/**
|
||||
* The command data payload
|
||||
*/
|
||||
data?: APIApplicationCommandInteractionData | APIMessageComponentInteractionData;
|
||||
/**
|
||||
* The channel it was sent from
|
||||
*/
|
||||
channel_id?: Snowflake;
|
||||
/**
|
||||
* A continuation token for responding to the interaction
|
||||
*/
|
||||
token: string;
|
||||
/**
|
||||
* Read-only property, always `1`
|
||||
*/
|
||||
version: 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#guild-member-object
|
||||
*/
|
||||
export interface APIInteractionGuildMember extends APIGuildMember {
|
||||
permissions: Permissions;
|
||||
user: APIUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction
|
||||
*/
|
||||
export interface APIGuildInteraction extends APIBaseInteraction {
|
||||
/**
|
||||
* The guild it was sent from
|
||||
*
|
||||
* In the case of an `APIDMInteraction`, this will not be present
|
||||
*/
|
||||
guild_id: Snowflake;
|
||||
/**
|
||||
* Guild member data for the invoking user, including permissions
|
||||
*/
|
||||
member: APIInteractionGuildMember;
|
||||
channel_id: Snowflake;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction
|
||||
*/
|
||||
export interface APIDMInteraction extends APIBaseInteraction {
|
||||
/**
|
||||
* User object for the invoking user, if invoked in a DM
|
||||
*/
|
||||
user: APIUser;
|
||||
channel_id: Snowflake;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#buttons-button-interaction
|
||||
*/
|
||||
export interface APIMessageComponentInteraction extends APIBaseInteraction {
|
||||
/**
|
||||
* Message object to which the button was attached
|
||||
*/
|
||||
message: APIMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction
|
||||
*/
|
||||
export type APIInteraction = APIGuildInteraction | APIDMInteraction | APIMessageComponentInteraction;
|
||||
|
||||
/**
|
||||
* Like APIGuildInteraction, only with the `data` property always present
|
||||
*
|
||||
* @see APIGuildInteraction
|
||||
*/
|
||||
export type APIApplicationCommandGuildInteraction = Required<APIGuildInteraction>;
|
||||
|
||||
/**
|
||||
* Like APIDMInteraction, only with the `data` property always present
|
||||
*
|
||||
* @see APIDMInteraction
|
||||
*/
|
||||
export type APIApplicationCommandDMInteraction = Required<APIDMInteraction>;
|
||||
|
||||
/**
|
||||
* Like APIInteraction, only with the `data` property always present
|
||||
*
|
||||
* @see APIInteraction
|
||||
*/
|
||||
export type APIApplicationCommandInteraction =
|
||||
| APIApplicationCommandGuildInteraction
|
||||
| APIApplicationCommandDMInteraction;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-interactiontype
|
||||
*/
|
||||
export const enum InteractionType {
|
||||
Ping = 1,
|
||||
ApplicationCommand,
|
||||
MessageComponent,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#guildapplicationcommandpermissions
|
||||
*/
|
||||
export interface APIGuildApplicationCommandPermissions {
|
||||
/**
|
||||
* The id of the command
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* The id of the application the command belongs to
|
||||
*/
|
||||
application_id: Snowflake;
|
||||
/**
|
||||
* The id of the guild
|
||||
*/
|
||||
guild_id: Snowflake;
|
||||
/**
|
||||
* The permissions for the command in the guild
|
||||
*/
|
||||
permissions: APIApplicationCommandPermission[];
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissions
|
||||
*/
|
||||
export interface APIApplicationCommandPermission {
|
||||
/**
|
||||
* The id of the role or user
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* Role or user
|
||||
*/
|
||||
type: ApplicationCommandPermissionType;
|
||||
/**
|
||||
* `true` to allow, `false`, to disallow
|
||||
*/
|
||||
permission: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissiontype
|
||||
*/
|
||||
export const enum ApplicationCommandPermissionType {
|
||||
Role = 1,
|
||||
User,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/channel#channel-object
|
||||
*/
|
||||
export interface APIInteractionDataResolvedChannel extends Required<APIPartialChannel> {
|
||||
permissions: Permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#guild-member-object
|
||||
*/
|
||||
export interface APIInteractionDataResolvedGuildMember extends Omit<APIGuildMember, 'user' | 'deaf' | 'mute'> {
|
||||
permissions: Permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondata
|
||||
*/
|
||||
export interface APIApplicationCommandInteractionData {
|
||||
id: Snowflake;
|
||||
name: string;
|
||||
options?: APIApplicationCommandInteractionDataOption[];
|
||||
resolved?: {
|
||||
users?: Record<string, APIUser>;
|
||||
roles?: Record<string, APIRole>;
|
||||
members?: Record<string, APIInteractionDataResolvedGuildMember>;
|
||||
channels?: Record<string, APIInteractionDataResolvedChannel>;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondataoption
|
||||
*/
|
||||
export type APIApplicationCommandInteractionDataOption =
|
||||
| ApplicationCommandInteractionDataOptionSubCommand
|
||||
| ApplicationCommandInteractionDataOptionSubCommandGroup
|
||||
| APIApplicationCommandInteractionDataOptionWithValues;
|
||||
|
||||
export interface ApplicationCommandInteractionDataOptionSubCommand {
|
||||
name: string;
|
||||
type: ApplicationCommandOptionType.SubCommand;
|
||||
options: APIApplicationCommandInteractionDataOptionWithValues[];
|
||||
}
|
||||
|
||||
export interface ApplicationCommandInteractionDataOptionSubCommandGroup {
|
||||
name: string;
|
||||
type: ApplicationCommandOptionType.SubCommandGroup;
|
||||
options: ApplicationCommandInteractionDataOptionSubCommand[];
|
||||
}
|
||||
|
||||
export type APIApplicationCommandInteractionDataOptionWithValues =
|
||||
| ApplicationCommandInteractionDataOptionString
|
||||
| ApplicationCommandInteractionDataOptionRole
|
||||
| ApplicationCommandInteractionDataOptionChannel
|
||||
| ApplicationCommandInteractionDataOptionUser
|
||||
| ApplicationCommandInteractionDataOptionMentionable
|
||||
| ApplicationCommandInteractionDataOptionInteger
|
||||
| ApplicationCommandInteractionDataOptionBoolean;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionString = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.String,
|
||||
string
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionRole = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Role,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionChannel = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Channel,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionUser = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.User,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionMentionable = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Mentionable,
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionInteger = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Integer,
|
||||
number
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionBoolean = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Boolean,
|
||||
boolean
|
||||
>;
|
||||
|
||||
export interface APIMessageButtonInteractionData {
|
||||
custom_id: string;
|
||||
component_type: ComponentType.Button;
|
||||
}
|
||||
|
||||
export interface APIMessageSelectMenuInteractionData {
|
||||
custom_id: string;
|
||||
component_type: ComponentType.SelectMenu;
|
||||
values: string[];
|
||||
}
|
||||
|
||||
export type APIMessageComponentInteractionData = APIMessageButtonInteractionData | APIMessageSelectMenuInteractionData;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response
|
||||
*/
|
||||
export type APIInteractionResponse =
|
||||
| APIInteractionResponsePong
|
||||
| APIInteractionResponseChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredMessageUpdate
|
||||
| APIInteractionResponseUpdateMessage;
|
||||
|
||||
export interface APIInteractionResponsePong {
|
||||
type: InteractionResponseType.Pong;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseChannelMessageWithSource {
|
||||
type: InteractionResponseType.ChannelMessageWithSource;
|
||||
data: APIInteractionApplicationCommandCallbackData;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseDeferredChannelMessageWithSource {
|
||||
type: InteractionResponseType.DeferredChannelMessageWithSource;
|
||||
data?: Pick<APIInteractionApplicationCommandCallbackData, 'flags'>;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseDeferredMessageUpdate {
|
||||
type: InteractionResponseType.DeferredMessageUpdate;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseUpdateMessage {
|
||||
type: InteractionResponseType.UpdateMessage;
|
||||
data?: APIInteractionApplicationCommandCallbackData;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionresponsetype
|
||||
*/
|
||||
export const enum InteractionResponseType {
|
||||
/**
|
||||
* ACK a `Ping`
|
||||
*/
|
||||
Pong = 1,
|
||||
/**
|
||||
* Respond to an interaction with a message
|
||||
*/
|
||||
ChannelMessageWithSource = 4,
|
||||
/**
|
||||
* ACK an interaction and edit to a response later, the user sees a loading state
|
||||
*/
|
||||
DeferredChannelMessageWithSource,
|
||||
/**
|
||||
* ACK a button interaction and update it to a loading state
|
||||
*/
|
||||
DeferredMessageUpdate,
|
||||
/**
|
||||
* ACK a button interaction and edit the message to which the button was attached
|
||||
*/
|
||||
UpdateMessage,
|
||||
}
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionapplicationcommandcallbackdata
|
||||
*/
|
||||
export type APIInteractionApplicationCommandCallbackData = Omit<
|
||||
RESTPostAPIWebhookWithTokenJSONBody,
|
||||
'username' | 'avatar_url'
|
||||
> & { flags?: MessageFlags };
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/slash-commands#messageinteraction
|
||||
*/
|
||||
export interface APIMessageInteraction {
|
||||
/**
|
||||
* ID of the interaction
|
||||
*/
|
||||
id: Snowflake;
|
||||
/**
|
||||
* The type of interaction
|
||||
*/
|
||||
type: InteractionType;
|
||||
/**
|
||||
* The name of the ApplicationCommand
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* The user who invoked the interaction
|
||||
*/
|
||||
user: APIUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
interface InteractionDataOptionBase<T extends ApplicationCommandOptionType, D = unknown> {
|
||||
name: string;
|
||||
type: T;
|
||||
value: D;
|
||||
}
|
||||
export type APIGuildInteraction = APIApplicationCommandGuildInteraction | APIMessageComponentGuildInteraction;
|
||||
|
||||
@@ -51,7 +51,7 @@ export interface APIApplication {
|
||||
*
|
||||
* See https://discord.com/developers/docs/resources/user#user-object
|
||||
*/
|
||||
owner: APIUser;
|
||||
owner?: APIUser;
|
||||
/**
|
||||
* If this application is a game sold on Discord, this field will be the summary field for the store page
|
||||
* of its primary sku
|
||||
@@ -153,11 +153,11 @@ export const enum OAuth2Scopes {
|
||||
*/
|
||||
MessagesRead = 'messages.read',
|
||||
/**
|
||||
* For local rpc server access, this allows you to control a user's local Discord client - whitelist only
|
||||
* For local rpc server access, this allows you to control a user's local Discord client - requires Discord approval
|
||||
*/
|
||||
RPC = 'rpc',
|
||||
/**
|
||||
* For local rpc server api access, this allows you to receive notifications pushed out to the user - whitelist only
|
||||
* For local rpc server api access, this allows you to receive notifications pushed out to the user - requires Discord approval
|
||||
*/
|
||||
RPCNotificationsRead = 'rpc.notifications.read',
|
||||
/**
|
||||
@@ -165,7 +165,7 @@ export const enum OAuth2Scopes {
|
||||
*/
|
||||
WebhookIncoming = 'webhook.incoming',
|
||||
/**
|
||||
* Allows your app to upload/update builds for a user's applications - whitelist only
|
||||
* Allows your app to upload/update builds for a user's applications - requires Discord approval
|
||||
*/
|
||||
ApplicationsBuildsUpload = 'applications.builds.upload',
|
||||
/**
|
||||
@@ -181,27 +181,27 @@ export const enum OAuth2Scopes {
|
||||
*/
|
||||
ApplicationsEntitlements = 'applications.entitlements',
|
||||
/**
|
||||
* Allows your app to know a user's friends and implicit relationships - whitelist only
|
||||
* Allows your app to know a user's friends and implicit relationships - requires Discord approval
|
||||
*/
|
||||
RelationshipsRead = 'relationships.read',
|
||||
/**
|
||||
* Allows your app to fetch data from a user's "Now Playing/Recently Played" list - whitelist only
|
||||
* Allows your app to fetch data from a user's "Now Playing/Recently Played" list - requires Discord approval
|
||||
*/
|
||||
ActivitiesRead = 'activities.read',
|
||||
/**
|
||||
* Allows your app to update a user's activity - whitelist only (NOT REQUIRED FOR GAMESDK ACTIVITY MANAGER)
|
||||
* Allows your app to update a user's activity - requires Discord approval (NOT REQUIRED FOR GAMESDK ACTIVITY MANAGER)
|
||||
*
|
||||
* See https://discord.com/developers/docs/game-sdk/activities
|
||||
*/
|
||||
ActivitiesWrite = 'activities.write',
|
||||
/**
|
||||
* Allows your app to create Slash Commands in the authorized guild
|
||||
* Allows your app to use Slash Commands in a guild
|
||||
*
|
||||
* See https://discord.com/developers/docs/interactions/slash-commands
|
||||
*/
|
||||
ApplicationsCommands = 'applications.commands',
|
||||
/**
|
||||
* Allows your app to update Slash Commands via this bearer token
|
||||
* Allows your app to update its Slash Commands via this bearer token - client credentials grant only
|
||||
*
|
||||
* See https://discord.com/developers/docs/interactions/slash-commands
|
||||
*/
|
||||
|
||||
@@ -88,6 +88,7 @@ export const enum UserFlags {
|
||||
BugHunterLevel2 = 1 << 14,
|
||||
VerifiedBot = 1 << 16,
|
||||
EarlyVerifiedBotDeveloper = 1 << 17,
|
||||
DiscordCertifiedModerator = 1 << 18,
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -717,7 +717,7 @@ export const Routes = {
|
||||
};
|
||||
|
||||
export const RouteBases = {
|
||||
api: 'https://discord.com/api',
|
||||
api: `https://discord.com/api/v${APIVersion}`,
|
||||
cdn: 'https://cdn.discordapp.com',
|
||||
invite: 'https://discord.gg',
|
||||
template: 'https://discord.new',
|
||||
|
||||
@@ -775,7 +775,7 @@ export const Routes = {
|
||||
};
|
||||
|
||||
export const RouteBases = {
|
||||
api: 'https://discord.com/api',
|
||||
api: `https://discord.com/api/v${APIVersion}`,
|
||||
cdn: 'https://cdn.discordapp.com',
|
||||
invite: 'https://discord.gg',
|
||||
template: 'https://discord.new',
|
||||
|
||||
46
tests/v9/interactions.test-d.ts
Normal file
46
tests/v9/interactions.test-d.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { expectType } from 'tsd';
|
||||
import {
|
||||
APIApplicationCommandInteraction,
|
||||
APIApplicationCommandInteractionData,
|
||||
APIDMInteraction,
|
||||
APIGuildInteraction,
|
||||
APIInteraction,
|
||||
APIInteractionGuildMember,
|
||||
APIMessageButtonInteractionData,
|
||||
APIMessageComponentInteraction,
|
||||
APIMessageSelectMenuInteractionData,
|
||||
APIUser,
|
||||
ComponentType,
|
||||
InteractionType,
|
||||
} from '../../v9';
|
||||
|
||||
declare const interaction: APIInteraction;
|
||||
|
||||
if (interaction.type === InteractionType.ApplicationCommand) {
|
||||
expectType<APIApplicationCommandInteraction>(interaction);
|
||||
|
||||
const { data } = interaction;
|
||||
expectType<APIApplicationCommandInteractionData>(data);
|
||||
}
|
||||
|
||||
if (interaction.type === InteractionType.MessageComponent) {
|
||||
expectType<APIMessageComponentInteraction>(interaction);
|
||||
|
||||
const { data } = interaction;
|
||||
if (data.component_type === ComponentType.Button) {
|
||||
expectType<APIMessageButtonInteractionData>(data);
|
||||
}
|
||||
|
||||
if (data.component_type === ComponentType.SelectMenu) {
|
||||
expectType<APIMessageSelectMenuInteractionData>(data);
|
||||
expectType<string[]>(data.values);
|
||||
}
|
||||
}
|
||||
|
||||
declare const dmInteraction: APIDMInteraction;
|
||||
|
||||
expectType<APIUser>(dmInteraction.user);
|
||||
|
||||
declare const guildInteraction: APIGuildInteraction;
|
||||
|
||||
expectType<APIInteractionGuildMember>(guildInteraction.member);
|
||||
@@ -16,6 +16,7 @@
|
||||
"utils/**/*.ts",
|
||||
"voice/**/*.ts",
|
||||
"scripts",
|
||||
"deno"
|
||||
"deno",
|
||||
"tests/**/*.ts"
|
||||
]
|
||||
}
|
||||
|
||||
89
utils/v8.ts
89
utils/v8.ts
@@ -2,33 +2,55 @@ import {
|
||||
APIApplicationCommandDMInteraction,
|
||||
APIApplicationCommandGuildInteraction,
|
||||
APIApplicationCommandInteraction,
|
||||
APIButtonComponent,
|
||||
APIButtonComponentWithCustomID,
|
||||
APIButtonComponentWithURL,
|
||||
APIDMInteraction,
|
||||
APIGuildInteraction,
|
||||
APIInteraction,
|
||||
APIMessageComponentDMInteraction,
|
||||
APIMessageComponentGuildInteraction,
|
||||
APIMessageComponentInteraction,
|
||||
ButtonStyle,
|
||||
} from '../payloads/v8/index';
|
||||
|
||||
// Interactions
|
||||
|
||||
/**
|
||||
* A type-guard check for guild interactions.
|
||||
* @param interaction The interaction to check against the
|
||||
* @returns A boolean that indicates if the interaction was received from a guild
|
||||
* A type-guard check for DM interactions
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the interaction was received in a DM channel
|
||||
*/
|
||||
export function isDMInteraction(interaction: APIInteraction): interaction is APIDMInteraction {
|
||||
return Reflect.has(interaction, 'user');
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for guild interactions
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the interaction was received in a guild
|
||||
*/
|
||||
export function isGuildInteraction(interaction: APIInteraction): interaction is APIGuildInteraction {
|
||||
return Reflect.has(interaction, 'guild_id');
|
||||
}
|
||||
|
||||
// ApplicationCommandInteractions
|
||||
|
||||
/**
|
||||
* A type-guard check for DM interactions.
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the interaction was received from a direct message
|
||||
* A type-guard check for DM application command interactions
|
||||
* @param interaction The application command interaction to check against
|
||||
* @returns A boolean that indicates if the application command interaction was received in a DM channel
|
||||
*/
|
||||
export function isDMInteraction(interaction: APIInteraction): interaction is APIDMInteraction {
|
||||
return !isGuildInteraction(interaction);
|
||||
export function isApplicationCommandDMInteraction(
|
||||
interaction: APIApplicationCommandInteraction,
|
||||
): interaction is APIApplicationCommandDMInteraction {
|
||||
return isDMInteraction(interaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for guild application command interactions.
|
||||
* A type-guard check for guild application command interactions
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the command interaction was received from a guild
|
||||
* @returns A boolean that indicates if the application command interaction was received in a guild
|
||||
*/
|
||||
export function isApplicationCommandGuildInteraction(
|
||||
interaction: APIApplicationCommandInteraction,
|
||||
@@ -36,13 +58,46 @@ export function isApplicationCommandGuildInteraction(
|
||||
return isGuildInteraction(interaction);
|
||||
}
|
||||
|
||||
// MessageComponentInteractions
|
||||
|
||||
/**
|
||||
* A type-guard check for direct message application command interactions.
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the command interaction was received from a direct message
|
||||
* A type-guard check for DM message component interactions
|
||||
* @param interaction The message component interaction to check against
|
||||
* @returns A boolean that indicates if the message component interaction was received in a DM channel
|
||||
*/
|
||||
export function isApplicationCommandDMInteraction(
|
||||
interaction: APIApplicationCommandInteraction,
|
||||
): interaction is APIApplicationCommandDMInteraction {
|
||||
return !isGuildInteraction(interaction);
|
||||
export function isMessageComponentDMInteraction(
|
||||
interaction: APIMessageComponentInteraction,
|
||||
): interaction is APIMessageComponentDMInteraction {
|
||||
return isDMInteraction(interaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for guild message component interactions
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the message component interaction was received in a guild
|
||||
*/
|
||||
export function isMessageComponentGuildInteraction(
|
||||
interaction: APIMessageComponentInteraction,
|
||||
): interaction is APIMessageComponentGuildInteraction {
|
||||
return isGuildInteraction(interaction);
|
||||
}
|
||||
|
||||
// Buttons
|
||||
|
||||
/**
|
||||
* A type-guard check for buttons that have a `url` attached to them.
|
||||
* @param component The button to check against
|
||||
* @returns A boolean that indicates if the button has a `url` attached to it
|
||||
*/
|
||||
export function isLinkButton(component: APIButtonComponent): component is APIButtonComponentWithURL {
|
||||
return component.style === ButtonStyle.Link;
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for buttons that have a `custom_id` attached to them.
|
||||
* @param button The button to check against
|
||||
* @returns A boolean that indicates if the button has a `custom_id` attached to it
|
||||
*/
|
||||
export function isStyledButton(component: APIButtonComponent): component is APIButtonComponentWithCustomID {
|
||||
return component.style !== ButtonStyle.Link;
|
||||
}
|
||||
|
||||
89
utils/v9.ts
89
utils/v9.ts
@@ -2,33 +2,55 @@ import {
|
||||
APIApplicationCommandDMInteraction,
|
||||
APIApplicationCommandGuildInteraction,
|
||||
APIApplicationCommandInteraction,
|
||||
APIButtonComponent,
|
||||
APIButtonComponentWithCustomID,
|
||||
APIButtonComponentWithURL,
|
||||
APIDMInteraction,
|
||||
APIGuildInteraction,
|
||||
APIInteraction,
|
||||
APIMessageComponentDMInteraction,
|
||||
APIMessageComponentGuildInteraction,
|
||||
APIMessageComponentInteraction,
|
||||
ButtonStyle,
|
||||
} from '../payloads/v9/index';
|
||||
|
||||
// Interactions
|
||||
|
||||
/**
|
||||
* A type-guard check for guild interactions.
|
||||
* @param interaction The interaction to check against the
|
||||
* @returns A boolean that indicates if the interaction was received from a guild
|
||||
* A type-guard check for DM interactions
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the interaction was received in a DM channel
|
||||
*/
|
||||
export function isDMInteraction(interaction: APIInteraction): interaction is APIDMInteraction {
|
||||
return Reflect.has(interaction, 'user');
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for guild interactions
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the interaction was received in a guild
|
||||
*/
|
||||
export function isGuildInteraction(interaction: APIInteraction): interaction is APIGuildInteraction {
|
||||
return Reflect.has(interaction, 'guild_id');
|
||||
}
|
||||
|
||||
// ApplicationCommandInteractions
|
||||
|
||||
/**
|
||||
* A type-guard check for DM interactions.
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the interaction was received from a direct message
|
||||
* A type-guard check for DM application command interactions
|
||||
* @param interaction The application command interaction to check against
|
||||
* @returns A boolean that indicates if the application command interaction was received in a DM channel
|
||||
*/
|
||||
export function isDMInteraction(interaction: APIInteraction): interaction is APIDMInteraction {
|
||||
return !isGuildInteraction(interaction);
|
||||
export function isApplicationCommandDMInteraction(
|
||||
interaction: APIApplicationCommandInteraction,
|
||||
): interaction is APIApplicationCommandDMInteraction {
|
||||
return isDMInteraction(interaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for guild application command interactions.
|
||||
* A type-guard check for guild application command interactions
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the command interaction was received from a guild
|
||||
* @returns A boolean that indicates if the application command interaction was received in a guild
|
||||
*/
|
||||
export function isApplicationCommandGuildInteraction(
|
||||
interaction: APIApplicationCommandInteraction,
|
||||
@@ -36,13 +58,46 @@ export function isApplicationCommandGuildInteraction(
|
||||
return isGuildInteraction(interaction);
|
||||
}
|
||||
|
||||
// MessageComponentInteractions
|
||||
|
||||
/**
|
||||
* A type-guard check for direct message application command interactions.
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the command interaction was received from a direct message
|
||||
* A type-guard check for DM message component interactions
|
||||
* @param interaction The message component interaction to check against
|
||||
* @returns A boolean that indicates if the message component interaction was received in a DM channel
|
||||
*/
|
||||
export function isApplicationCommandDMInteraction(
|
||||
interaction: APIApplicationCommandInteraction,
|
||||
): interaction is APIApplicationCommandDMInteraction {
|
||||
return !isGuildInteraction(interaction);
|
||||
export function isMessageComponentDMInteraction(
|
||||
interaction: APIMessageComponentInteraction,
|
||||
): interaction is APIMessageComponentDMInteraction {
|
||||
return isDMInteraction(interaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for guild message component interactions
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the message component interaction was received in a guild
|
||||
*/
|
||||
export function isMessageComponentGuildInteraction(
|
||||
interaction: APIMessageComponentInteraction,
|
||||
): interaction is APIMessageComponentGuildInteraction {
|
||||
return isGuildInteraction(interaction);
|
||||
}
|
||||
|
||||
// Buttons
|
||||
|
||||
/**
|
||||
* A type-guard check for buttons that have a `url` attached to them.
|
||||
* @param component The button to check against
|
||||
* @returns A boolean that indicates if the button has a `url` attached to it
|
||||
*/
|
||||
export function isLinkButton(component: APIButtonComponent): component is APIButtonComponentWithURL {
|
||||
return component.style === ButtonStyle.Link;
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for buttons that have a `custom_id` attached to them.
|
||||
* @param button The button to check against
|
||||
* @returns A boolean that indicates if the button has a `custom_id` attached to it
|
||||
*/
|
||||
export function isStyledButton(component: APIButtonComponent): component is APIButtonComponentWithCustomID {
|
||||
return component.style !== ButtonStyle.Link;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user