mirror of
https://github.com/discordjs/discord-api-types.git
synced 2026-05-22 11:20:10 +00:00
Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dad9eea547 | ||
|
|
f702988112 | ||
|
|
e822e45b3b | ||
|
|
fa740eb16c | ||
|
|
8cb629befe | ||
|
|
b0443a02ec | ||
|
|
cb92843991 | ||
|
|
d06d2d6a9a | ||
|
|
854aa3691c | ||
|
|
e5710d0e42 | ||
|
|
9a578489ad | ||
|
|
10fdeaa68d | ||
|
|
fddff2167c | ||
|
|
e8127b89f8 | ||
|
|
ab2598441a | ||
|
|
95f3e175b1 | ||
|
|
a3b1006c87 | ||
|
|
dec7717bc7 | ||
|
|
e9ee6966c3 | ||
|
|
3503a4fd38 | ||
|
|
1eba8a3a34 | ||
|
|
3e3acb5297 |
@@ -77,11 +77,6 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: npm ci --ignore-scripts
|
||||
|
||||
- name: Deprecate old versions
|
||||
run: npx npm-deprecate --name "*" --package discord-api-types --message "No longer supported. Install the latest release!" || true
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
|
||||
|
||||
- name: Publish release to npm
|
||||
run: npm publish
|
||||
env:
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -47,4 +47,4 @@ voice/**/*.d.ts
|
||||
voice/**/*.mjs
|
||||
|
||||
# macOS files
|
||||
.DS_store
|
||||
.DS_Store
|
||||
|
||||
61
CHANGELOG.md
61
CHANGELOG.md
@@ -1,3 +1,64 @@
|
||||
# [0.30.0](https://github.com/discordjs/discord-api-types/compare/0.29.0...0.30.0) (2022-03-24)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **APIGuildIntegrationType:** correct name of type ([#366](https://github.com/discordjs/discord-api-types/issues/366)) ([fa740eb](https://github.com/discordjs/discord-api-types/commit/fa740eb16c8bba9d2c9c915d2e0139e5e1211040))
|
||||
|
||||
### Features
|
||||
|
||||
- **APIApplicationCommand:** add command localization ([#370](https://github.com/discordjs/discord-api-types/issues/370)) ([f702988](https://github.com/discordjs/discord-api-types/commit/f70298811242d946cee01b112c34382f0e54cb78))
|
||||
|
||||
### Reverts
|
||||
|
||||
- fix(GatewayVoiceState): some fields are optional instead of nullable ([#367](https://github.com/discordjs/discord-api-types/issues/367)) ([e822e45](https://github.com/discordjs/discord-api-types/commit/e822e45b3b6e07eb85a45039975cb33636765f5e))
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
- **APIGuildIntegrationType:** `APIGuildInteractionType` is now correctly named `APIGuildIntegrationType`
|
||||
|
||||
# [0.29.0](https://github.com/discordjs/discord-api-types/compare/0.28.0...0.29.0) (2022-03-10)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **GatewayVoiceState:** some fields are optional instead of nullable ([#345](https://github.com/discordjs/discord-api-types/issues/345)) ([fddff21](https://github.com/discordjs/discord-api-types/commit/fddff2167c858832d6c61f3efca8d944fd356a85))
|
||||
- **RESTJSONErrorCodes:** typo in error `30046` ([#362](https://github.com/discordjs/discord-api-types/issues/362)) ([854aa36](https://github.com/discordjs/discord-api-types/commit/854aa3691c4d16a2c7fec7421cf25ea03a030e55))
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
- **APIGuildScheduledEventBase:** make `description` nullable ([#359](https://github.com/discordjs/discord-api-types/issues/359)) ([e5710d0](https://github.com/discordjs/discord-api-types/commit/e5710d0e42d4f597bc9ed5594619a5032bf59bcb))
|
||||
- make things optional and nullable where applicable ([#361](https://github.com/discordjs/discord-api-types/issues/361)) ([10fdeaa](https://github.com/discordjs/discord-api-types/commit/10fdeaa68df9b3b61b20b8d90b9587d03d95a450))
|
||||
- **RESTJSONErrorCodes:** update error `50008` key ([#338](https://github.com/discordjs/discord-api-types/issues/338)) ([9a57848](https://github.com/discordjs/discord-api-types/commit/9a578489ad05b2ba8ed8d496db19cb86fa572ef7))
|
||||
|
||||
### Features
|
||||
|
||||
- **APIInviteGuild:** add boost count ([#323](https://github.com/discordjs/discord-api-types/issues/323)) ([cb92843](https://github.com/discordjs/discord-api-types/commit/cb92843991307d59c61d017d8ab1adcd469b4512))
|
||||
- **APIStageInstance:** add `guild_scheduled_event_id` ([#350](https://github.com/discordjs/discord-api-types/issues/350)) ([d06d2d6](https://github.com/discordjs/discord-api-types/commit/d06d2d6a9a8ccc84337b2ce9c59430694ae93e8a))
|
||||
- **RESTJSONErrorCodes:** add error `10065` ([#336](https://github.com/discordjs/discord-api-types/issues/336)) ([e8127b8](https://github.com/discordjs/discord-api-types/commit/e8127b89f89c4612fab0d3702ce512e41ab75b6e))
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
- **RESTJSONErrorCodes:** `MaximumNumberOfEditsToMessagesOlderThanOneHourReached` is no longer mistyped as `MaxmimumNumberOfEditsToMessagesOlderThanOneHourReached`
|
||||
- **APIGuildScheduledEventBase:** The type for `description` can also be null, not just optional
|
||||
- **RESTJSONErrorCodes:** The error code `50008` has been renamed from `CannotSendMessagesInVoiceChannel` to `CannotSendMessagesInNonTextChannel`
|
||||
- The deprecated `asset` field for stickers is correctly marked as optional now. The `image` field for Guild Scheduled Events is now correctly typed as optional.
|
||||
- **GatewayVoiceState:** `channel_id` and `request_to_speak_timestamp` are correctly typed as optional, not nullable now.
|
||||
|
||||
# [0.28.0](https://github.com/discordjs/discord-api-types/compare/0.27.3...0.28.0) (2022-03-07)
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
- **PermissionFlagsBits:** rename `StartEmbeddedActivities` to `UseEmbeddedActivities` ([#342](https://github.com/discordjs/discord-api-types/issues/342)) ([3e3acb5](https://github.com/discordjs/discord-api-types/commit/3e3acb5297e3e546fbb7fc82acddb50170ffc1de))
|
||||
|
||||
### Features
|
||||
|
||||
- add support for TS module: NodeNext ([#356](https://github.com/discordjs/discord-api-types/issues/356)) ([e9ee696](https://github.com/discordjs/discord-api-types/commit/e9ee6966c38c82544536ece85af0c1b3bd592bfc))
|
||||
- **MessageComponentInteraction:** export specific interaction aliases ([#353](https://github.com/discordjs/discord-api-types/issues/353)) ([3503a4f](https://github.com/discordjs/discord-api-types/commit/3503a4fd384be8459a1628a6f019a1bc164c0386))
|
||||
- **Utils:** add more typeguard functions to determine the interaction types ([#355](https://github.com/discordjs/discord-api-types/issues/355)) ([dec7717](https://github.com/discordjs/discord-api-types/commit/dec7717bc76ac86c8b7d45ed4e0b506e532f7cb9))
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
- **PermissionFlagsBits:** The `StartEmbeddedActivities` permission flag has been renamed to `UseEmbeddedActivities`
|
||||
|
||||
## [0.27.3](https://github.com/discordjs/discord-api-types/compare/0.27.2...0.27.3) (2022-02-24)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
@@ -1,3 +1,64 @@
|
||||
# [0.30.0](https://github.com/discordjs/discord-api-types/compare/0.29.0...0.30.0) (2022-03-24)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **APIGuildIntegrationType:** correct name of type ([#366](https://github.com/discordjs/discord-api-types/issues/366)) ([fa740eb](https://github.com/discordjs/discord-api-types/commit/fa740eb16c8bba9d2c9c915d2e0139e5e1211040))
|
||||
|
||||
### Features
|
||||
|
||||
- **APIApplicationCommand:** add command localization ([#370](https://github.com/discordjs/discord-api-types/issues/370)) ([f702988](https://github.com/discordjs/discord-api-types/commit/f70298811242d946cee01b112c34382f0e54cb78))
|
||||
|
||||
### Reverts
|
||||
|
||||
- fix(GatewayVoiceState): some fields are optional instead of nullable ([#367](https://github.com/discordjs/discord-api-types/issues/367)) ([e822e45](https://github.com/discordjs/discord-api-types/commit/e822e45b3b6e07eb85a45039975cb33636765f5e))
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
- **APIGuildIntegrationType:** `APIGuildInteractionType` is now correctly named `APIGuildIntegrationType`
|
||||
|
||||
# [0.29.0](https://github.com/discordjs/discord-api-types/compare/0.28.0...0.29.0) (2022-03-10)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **GatewayVoiceState:** some fields are optional instead of nullable ([#345](https://github.com/discordjs/discord-api-types/issues/345)) ([fddff21](https://github.com/discordjs/discord-api-types/commit/fddff2167c858832d6c61f3efca8d944fd356a85))
|
||||
- **RESTJSONErrorCodes:** typo in error `30046` ([#362](https://github.com/discordjs/discord-api-types/issues/362)) ([854aa36](https://github.com/discordjs/discord-api-types/commit/854aa3691c4d16a2c7fec7421cf25ea03a030e55))
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
- **APIGuildScheduledEventBase:** make `description` nullable ([#359](https://github.com/discordjs/discord-api-types/issues/359)) ([e5710d0](https://github.com/discordjs/discord-api-types/commit/e5710d0e42d4f597bc9ed5594619a5032bf59bcb))
|
||||
- make things optional and nullable where applicable ([#361](https://github.com/discordjs/discord-api-types/issues/361)) ([10fdeaa](https://github.com/discordjs/discord-api-types/commit/10fdeaa68df9b3b61b20b8d90b9587d03d95a450))
|
||||
- **RESTJSONErrorCodes:** update error `50008` key ([#338](https://github.com/discordjs/discord-api-types/issues/338)) ([9a57848](https://github.com/discordjs/discord-api-types/commit/9a578489ad05b2ba8ed8d496db19cb86fa572ef7))
|
||||
|
||||
### Features
|
||||
|
||||
- **APIInviteGuild:** add boost count ([#323](https://github.com/discordjs/discord-api-types/issues/323)) ([cb92843](https://github.com/discordjs/discord-api-types/commit/cb92843991307d59c61d017d8ab1adcd469b4512))
|
||||
- **APIStageInstance:** add `guild_scheduled_event_id` ([#350](https://github.com/discordjs/discord-api-types/issues/350)) ([d06d2d6](https://github.com/discordjs/discord-api-types/commit/d06d2d6a9a8ccc84337b2ce9c59430694ae93e8a))
|
||||
- **RESTJSONErrorCodes:** add error `10065` ([#336](https://github.com/discordjs/discord-api-types/issues/336)) ([e8127b8](https://github.com/discordjs/discord-api-types/commit/e8127b89f89c4612fab0d3702ce512e41ab75b6e))
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
- **RESTJSONErrorCodes:** `MaximumNumberOfEditsToMessagesOlderThanOneHourReached` is no longer mistyped as `MaxmimumNumberOfEditsToMessagesOlderThanOneHourReached`
|
||||
- **APIGuildScheduledEventBase:** The type for `description` can also be null, not just optional
|
||||
- **RESTJSONErrorCodes:** The error code `50008` has been renamed from `CannotSendMessagesInVoiceChannel` to `CannotSendMessagesInNonTextChannel`
|
||||
- The deprecated `asset` field for stickers is correctly marked as optional now. The `image` field for Guild Scheduled Events is now correctly typed as optional.
|
||||
- **GatewayVoiceState:** `channel_id` and `request_to_speak_timestamp` are correctly typed as optional, not nullable now.
|
||||
|
||||
# [0.28.0](https://github.com/discordjs/discord-api-types/compare/0.27.3...0.28.0) (2022-03-07)
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
- **PermissionFlagsBits:** rename `StartEmbeddedActivities` to `UseEmbeddedActivities` ([#342](https://github.com/discordjs/discord-api-types/issues/342)) ([3e3acb5](https://github.com/discordjs/discord-api-types/commit/3e3acb5297e3e546fbb7fc82acddb50170ffc1de))
|
||||
|
||||
### Features
|
||||
|
||||
- add support for TS module: NodeNext ([#356](https://github.com/discordjs/discord-api-types/issues/356)) ([e9ee696](https://github.com/discordjs/discord-api-types/commit/e9ee6966c38c82544536ece85af0c1b3bd592bfc))
|
||||
- **MessageComponentInteraction:** export specific interaction aliases ([#353](https://github.com/discordjs/discord-api-types/issues/353)) ([3503a4f](https://github.com/discordjs/discord-api-types/commit/3503a4fd384be8459a1628a6f019a1bc164c0386))
|
||||
- **Utils:** add more typeguard functions to determine the interaction types ([#355](https://github.com/discordjs/discord-api-types/issues/355)) ([dec7717](https://github.com/discordjs/discord-api-types/commit/dec7717bc76ac86c8b7d45ed4e0b506e532f7cb9))
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
- **PermissionFlagsBits:** The `StartEmbeddedActivities` permission flag has been renamed to `UseEmbeddedActivities`
|
||||
|
||||
## [0.27.3](https://github.com/discordjs/discord-api-types/compare/0.27.2...0.27.3) (2022-02-24)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { LocaleString } from '../v10.ts';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags
|
||||
*
|
||||
@@ -45,7 +47,7 @@ export const PermissionFlagsBits = {
|
||||
CreatePrivateThreads: 1n << 36n,
|
||||
UseExternalStickers: 1n << 37n,
|
||||
SendMessagesInThreads: 1n << 38n,
|
||||
StartEmbeddedActivities: 1n << 39n,
|
||||
UseEmbeddedActivities: 1n << 39n,
|
||||
ModerateMembers: 1n << 40n,
|
||||
} as const;
|
||||
|
||||
@@ -54,3 +56,5 @@ export const PermissionFlagsBits = {
|
||||
* @internal
|
||||
*/
|
||||
Object.freeze(PermissionFlagsBits);
|
||||
|
||||
export type LocalizationMap = Partial<Record<LocaleString, string>>;
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import type { LocalizationMap } from '../../../../../v10.ts';
|
||||
import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared.ts';
|
||||
|
||||
export interface APIApplicationCommandOptionBase<Type extends ApplicationCommandOptionType> {
|
||||
type: Type;
|
||||
name: string;
|
||||
name_localizations?: LocalizationMap;
|
||||
description: string;
|
||||
description_localizations?: LocalizationMap;
|
||||
required?: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { LocalizationMap } from '../../../../../v10.ts';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type
|
||||
*/
|
||||
@@ -20,5 +22,6 @@ export enum ApplicationCommandOptionType {
|
||||
*/
|
||||
export interface APIApplicationCommandOptionChoice<ValueType = string | number> {
|
||||
name: string;
|
||||
name_localizations?: LocalizationMap;
|
||||
value: ValueType;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { Permissions, Snowflake } from '../../../globals.ts';
|
||||
import type { LocalizationMap } from '../../../v10.ts';
|
||||
import type { APIPartialChannel, APIThreadMetadata } from '../channel.ts';
|
||||
import type { APIGuildMember } from '../guild.ts';
|
||||
import type { APIBaseInteraction } from './base.ts';
|
||||
@@ -45,10 +46,18 @@ export interface APIApplicationCommand {
|
||||
* 1-32 character name; `CHAT_INPUT` command names must be all lowercase matching `^[\w-]{1,32}$`
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Localization dictionary for the name field. Values follow the same restrictions as name
|
||||
*/
|
||||
name_localizations?: LocalizationMap;
|
||||
/**
|
||||
* 1-100 character description for `CHAT_INPUT` commands, empty string for `USER` and `MESSAGE` commands
|
||||
*/
|
||||
description: string;
|
||||
/**
|
||||
* Localization dictionary for the description field. Values follow the same restrictions as description
|
||||
*/
|
||||
description_localizations?: LocalizationMap;
|
||||
/**
|
||||
* The parameters for the `CHAT_INPUT` command, max 25
|
||||
*/
|
||||
|
||||
@@ -13,6 +13,28 @@ export type APIMessageComponentInteraction = APIBaseInteraction<
|
||||
>
|
||||
>;
|
||||
|
||||
export type APIMessageComponentButtonInteraction = APIBaseInteraction<
|
||||
InteractionType.MessageComponent,
|
||||
APIMessageButtonInteractionData
|
||||
> &
|
||||
Required<
|
||||
Pick<
|
||||
APIBaseInteraction<InteractionType.MessageComponent, APIMessageButtonInteractionData>,
|
||||
'channel_id' | 'data' | 'message'
|
||||
>
|
||||
>;
|
||||
|
||||
export type APIMessageComponentSelectMenuInteraction = APIBaseInteraction<
|
||||
InteractionType.MessageComponent,
|
||||
APIMessageSelectMenuInteractionData
|
||||
> &
|
||||
Required<
|
||||
Pick<
|
||||
APIBaseInteraction<InteractionType.MessageComponent, APIMessageSelectMenuInteractionData>,
|
||||
'channel_id' | 'data' | 'message'
|
||||
>
|
||||
>;
|
||||
|
||||
export type APIMessageComponentInteractionData = APIMessageButtonInteractionData | APIMessageSelectMenuInteractionData;
|
||||
|
||||
export interface APIMessageComponentBaseInteractionData<CType extends ComponentType> {
|
||||
|
||||
@@ -1188,7 +1188,7 @@ export interface APIActionRowComponent<T extends APIActionRowComponentTypes>
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#buttons
|
||||
*/
|
||||
interface APIButtonComponentBase<Style extends ButtonStyle> extends APIBaseComponent<ComponentType.Button> {
|
||||
export interface APIButtonComponentBase<Style extends ButtonStyle> extends APIBaseComponent<ComponentType.Button> {
|
||||
/**
|
||||
* The label to be displayed on the button
|
||||
*/
|
||||
@@ -1273,7 +1273,7 @@ export interface APISelectMenuComponent extends APIBaseComponent<ComponentType.S
|
||||
*/
|
||||
options: APISelectMenuOption[];
|
||||
/**
|
||||
* Custom placeholder text if nothing is selected, max 100 characters
|
||||
* Custom placeholder text if nothing is selected, max 150 characters
|
||||
*/
|
||||
placeholder?: string;
|
||||
/**
|
||||
|
||||
@@ -681,7 +681,7 @@ export interface APIGuildIntegration {
|
||||
/**
|
||||
* Integration type
|
||||
*/
|
||||
type: APIGuildInteractionType;
|
||||
type: APIGuildIntegrationType;
|
||||
/**
|
||||
* Is this integration enabled
|
||||
*/
|
||||
@@ -760,7 +760,7 @@ export interface APIGuildIntegration {
|
||||
application?: APIGuildIntegrationApplication;
|
||||
}
|
||||
|
||||
export type APIGuildInteractionType = 'twitch' | 'youtube' | 'discord';
|
||||
export type APIGuildIntegrationType = 'twitch' | 'youtube' | 'discord';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors
|
||||
|
||||
@@ -26,7 +26,7 @@ interface APIGuildScheduledEventBase<Type extends GuildScheduledEventEntityType>
|
||||
/**
|
||||
* The description of the scheduled event
|
||||
*/
|
||||
description?: string;
|
||||
description?: string | null;
|
||||
/**
|
||||
* The time the scheduled event will start
|
||||
*/
|
||||
@@ -66,7 +66,7 @@ interface APIGuildScheduledEventBase<Type extends GuildScheduledEventEntityType>
|
||||
/**
|
||||
* The cover image of the scheduled event
|
||||
*/
|
||||
image: string | null;
|
||||
image?: string | null;
|
||||
}
|
||||
|
||||
export interface APIStageInstanceGuildScheduledEvent
|
||||
|
||||
@@ -4,11 +4,26 @@
|
||||
|
||||
import type { APIApplication } from './application.ts';
|
||||
import type { APIPartialChannel } from './channel.ts';
|
||||
import type { APIPartialGuild } from './guild.ts';
|
||||
import type { APIGuild } from './guild.ts';
|
||||
import type { APIGuildScheduledEvent } from './guildScheduledEvent.ts';
|
||||
import type { APIInviteStageInstance } from './stageInstance.ts';
|
||||
import type { APIUser } from './user.ts';
|
||||
|
||||
export type APIInviteGuild = Pick<
|
||||
APIGuild,
|
||||
| 'id'
|
||||
| 'name'
|
||||
| 'splash'
|
||||
| 'banner'
|
||||
| 'icon'
|
||||
| 'vanity_url_code'
|
||||
| 'description'
|
||||
| 'features'
|
||||
| 'verification_level'
|
||||
| 'nsfw_level'
|
||||
| 'premium_subscription_count'
|
||||
>;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/invite#invite-object
|
||||
*/
|
||||
@@ -22,7 +37,7 @@ export interface APIInvite {
|
||||
*
|
||||
* See https://discord.com/developers/docs/resources/guild#guild-object
|
||||
*/
|
||||
guild?: APIPartialGuild;
|
||||
guild?: APIInviteGuild;
|
||||
/**
|
||||
* The channel this invite is for
|
||||
*
|
||||
|
||||
@@ -32,6 +32,10 @@ export interface APIStageInstance {
|
||||
* @deprecated
|
||||
*/
|
||||
discoverable_disabled: boolean;
|
||||
/**
|
||||
* The id of the scheduled event for this stage instance
|
||||
*/
|
||||
guild_scheduled_event_id?: Snowflake;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,7 +33,7 @@ export interface APISticker {
|
||||
* Previously the sticker asset hash, now an empty string
|
||||
* @deprecated
|
||||
*/
|
||||
asset: '';
|
||||
asset?: '';
|
||||
/**
|
||||
* Type of sticker
|
||||
*
|
||||
|
||||
@@ -4,11 +4,26 @@
|
||||
|
||||
import type { APIApplication } from './application.ts';
|
||||
import type { APIPartialChannel } from './channel.ts';
|
||||
import type { APIPartialGuild } from './guild.ts';
|
||||
import type { APIGuild } from './guild.ts';
|
||||
import type { APIGuildScheduledEvent } from './guildScheduledEvent.ts';
|
||||
import type { APIInviteStageInstance } from './stageInstance.ts';
|
||||
import type { APIUser } from './user.ts';
|
||||
|
||||
export type APIInviteGuild = Pick<
|
||||
APIGuild,
|
||||
| 'id'
|
||||
| 'name'
|
||||
| 'splash'
|
||||
| 'banner'
|
||||
| 'icon'
|
||||
| 'vanity_url_code'
|
||||
| 'description'
|
||||
| 'features'
|
||||
| 'verification_level'
|
||||
| 'nsfw_level'
|
||||
| 'premium_subscription_count'
|
||||
>;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/invite#invite-object
|
||||
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
|
||||
@@ -23,7 +38,7 @@ export interface APIInvite {
|
||||
*
|
||||
* See https://discord.com/developers/docs/resources/guild#guild-object
|
||||
*/
|
||||
guild?: APIPartialGuild;
|
||||
guild?: APIInviteGuild;
|
||||
/**
|
||||
* The channel this invite is for
|
||||
*
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import type { LocalizationMap } from '../../../../../v9.ts';
|
||||
import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared.ts';
|
||||
|
||||
export interface APIApplicationCommandOptionBase<Type extends ApplicationCommandOptionType> {
|
||||
type: Type;
|
||||
name: string;
|
||||
name_localizations?: LocalizationMap;
|
||||
description: string;
|
||||
description_localizations?: LocalizationMap;
|
||||
required?: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { LocalizationMap } from '../../../../../v9.ts';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type
|
||||
*/
|
||||
@@ -20,5 +22,6 @@ export enum ApplicationCommandOptionType {
|
||||
*/
|
||||
export interface APIApplicationCommandOptionChoice<ValueType = string | number> {
|
||||
name: string;
|
||||
name_localizations?: LocalizationMap;
|
||||
value: ValueType;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { Permissions, Snowflake } from '../../../globals.ts';
|
||||
import type { LocalizationMap } from '../../../v9.ts';
|
||||
import type { APIPartialChannel, APIThreadMetadata } from '../channel.ts';
|
||||
import type { APIGuildMember } from '../guild.ts';
|
||||
import type { APIBaseInteraction } from './base.ts';
|
||||
@@ -45,10 +46,18 @@ export interface APIApplicationCommand {
|
||||
* 1-32 character name; `CHAT_INPUT` command names must be all lowercase matching `^[\w-]{1,32}$`
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Localization dictionary for the name field. Values follow the same restrictions as name
|
||||
*/
|
||||
name_localizations?: LocalizationMap;
|
||||
/**
|
||||
* 1-100 character description for `CHAT_INPUT` commands, empty string for `USER` and `MESSAGE` commands
|
||||
*/
|
||||
description: string;
|
||||
/**
|
||||
* Localization dictionary for the description field. Values follow the same restrictions as description
|
||||
*/
|
||||
description_localizations?: LocalizationMap;
|
||||
/**
|
||||
* The parameters for the `CHAT_INPUT` command, max 25
|
||||
*/
|
||||
|
||||
@@ -13,6 +13,28 @@ export type APIMessageComponentInteraction = APIBaseInteraction<
|
||||
>
|
||||
>;
|
||||
|
||||
export type APIMessageComponentButtonInteraction = APIBaseInteraction<
|
||||
InteractionType.MessageComponent,
|
||||
APIMessageButtonInteractionData
|
||||
> &
|
||||
Required<
|
||||
Pick<
|
||||
APIBaseInteraction<InteractionType.MessageComponent, APIMessageButtonInteractionData>,
|
||||
'channel_id' | 'data' | 'message'
|
||||
>
|
||||
>;
|
||||
|
||||
export type APIMessageComponentSelectMenuInteraction = APIBaseInteraction<
|
||||
InteractionType.MessageComponent,
|
||||
APIMessageSelectMenuInteractionData
|
||||
> &
|
||||
Required<
|
||||
Pick<
|
||||
APIBaseInteraction<InteractionType.MessageComponent, APIMessageSelectMenuInteractionData>,
|
||||
'channel_id' | 'data' | 'message'
|
||||
>
|
||||
>;
|
||||
|
||||
export type APIMessageComponentInteractionData = APIMessageButtonInteractionData | APIMessageSelectMenuInteractionData;
|
||||
|
||||
export interface APIMessageComponentBaseInteractionData<CType extends ComponentType> {
|
||||
|
||||
@@ -1188,7 +1188,7 @@ export interface APIActionRowComponent<T extends APIActionRowComponentTypes>
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#buttons
|
||||
*/
|
||||
interface APIButtonComponentBase<Style extends ButtonStyle> extends APIBaseComponent<ComponentType.Button> {
|
||||
export interface APIButtonComponentBase<Style extends ButtonStyle> extends APIBaseComponent<ComponentType.Button> {
|
||||
/**
|
||||
* The label to be displayed on the button
|
||||
*/
|
||||
@@ -1273,7 +1273,7 @@ export interface APISelectMenuComponent extends APIBaseComponent<ComponentType.S
|
||||
*/
|
||||
options: APISelectMenuOption[];
|
||||
/**
|
||||
* Custom placeholder text if nothing is selected, max 100 characters
|
||||
* Custom placeholder text if nothing is selected, max 150 characters
|
||||
*/
|
||||
placeholder?: string;
|
||||
/**
|
||||
|
||||
@@ -681,7 +681,7 @@ export interface APIGuildIntegration {
|
||||
/**
|
||||
* Integration type
|
||||
*/
|
||||
type: APIGuildInteractionType;
|
||||
type: APIGuildIntegrationType;
|
||||
/**
|
||||
* Is this integration enabled
|
||||
*/
|
||||
@@ -760,7 +760,7 @@ export interface APIGuildIntegration {
|
||||
application?: APIGuildIntegrationApplication;
|
||||
}
|
||||
|
||||
export type APIGuildInteractionType = 'twitch' | 'youtube' | 'discord';
|
||||
export type APIGuildIntegrationType = 'twitch' | 'youtube' | 'discord';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors
|
||||
|
||||
@@ -26,7 +26,7 @@ interface APIGuildScheduledEventBase<Type extends GuildScheduledEventEntityType>
|
||||
/**
|
||||
* The description of the scheduled event
|
||||
*/
|
||||
description?: string;
|
||||
description?: string | null;
|
||||
/**
|
||||
* The time the scheduled event will start
|
||||
*/
|
||||
@@ -66,7 +66,7 @@ interface APIGuildScheduledEventBase<Type extends GuildScheduledEventEntityType>
|
||||
/**
|
||||
* The cover image of the scheduled event
|
||||
*/
|
||||
image: string | null;
|
||||
image?: string | null;
|
||||
}
|
||||
|
||||
export interface APIStageInstanceGuildScheduledEvent
|
||||
|
||||
@@ -4,11 +4,26 @@
|
||||
|
||||
import type { APIApplication } from './application.ts';
|
||||
import type { APIPartialChannel } from './channel.ts';
|
||||
import type { APIPartialGuild } from './guild.ts';
|
||||
import type { APIGuild } from './guild.ts';
|
||||
import type { APIGuildScheduledEvent } from './guildScheduledEvent.ts';
|
||||
import type { APIInviteStageInstance } from './stageInstance.ts';
|
||||
import type { APIUser } from './user.ts';
|
||||
|
||||
export type APIInviteGuild = Pick<
|
||||
APIGuild,
|
||||
| 'id'
|
||||
| 'name'
|
||||
| 'splash'
|
||||
| 'banner'
|
||||
| 'icon'
|
||||
| 'vanity_url_code'
|
||||
| 'description'
|
||||
| 'features'
|
||||
| 'verification_level'
|
||||
| 'nsfw_level'
|
||||
| 'premium_subscription_count'
|
||||
>;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/invite#invite-object
|
||||
*/
|
||||
@@ -22,7 +37,7 @@ export interface APIInvite {
|
||||
*
|
||||
* See https://discord.com/developers/docs/resources/guild#guild-object
|
||||
*/
|
||||
guild?: APIPartialGuild;
|
||||
guild?: APIInviteGuild;
|
||||
/**
|
||||
* The channel this invite is for
|
||||
*
|
||||
|
||||
@@ -32,6 +32,10 @@ export interface APIStageInstance {
|
||||
* @deprecated
|
||||
*/
|
||||
discoverable_disabled: boolean;
|
||||
/**
|
||||
* The id of the scheduled event for this stage instance
|
||||
*/
|
||||
guild_scheduled_event_id?: Snowflake;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,7 +33,7 @@ export interface APISticker {
|
||||
* Previously the sticker asset hash, now an empty string
|
||||
* @deprecated
|
||||
*/
|
||||
asset: '';
|
||||
asset?: '';
|
||||
/**
|
||||
* Type of sticker
|
||||
*
|
||||
|
||||
@@ -47,7 +47,8 @@ export enum RESTJSONErrorCodes {
|
||||
UnknownInteraction = 10062,
|
||||
UnknownApplicationCommand,
|
||||
|
||||
UnknownApplicationCommandPermissions = 10066,
|
||||
UnknownVoiceState = 10065,
|
||||
UnknownApplicationCommandPermissions,
|
||||
UnknownStageInstance,
|
||||
UnknownGuildMemberVerificationForm,
|
||||
UnknownGuildWelcomeScreen,
|
||||
@@ -109,7 +110,7 @@ export enum RESTJSONErrorCodes {
|
||||
|
||||
MaximumNumberOfGuildWidgetSettingsUpdatesHasBeenReached = 30042,
|
||||
|
||||
MaxmimumNumberOfEditsToMessagesOlderThanOneHourReached = 30046,
|
||||
MaximumNumberOfEditsToMessagesOlderThanOneHourReached = 30046,
|
||||
|
||||
Unauthorized = 40001,
|
||||
VerifyYourAccount,
|
||||
@@ -133,7 +134,7 @@ export enum RESTJSONErrorCodes {
|
||||
CannotEditMessageAuthoredByAnotherUser,
|
||||
CannotSendAnEmptyMessage,
|
||||
CannotSendMessagesToThisUser,
|
||||
CannotSendMessagesInVoiceChannel,
|
||||
CannotSendMessagesInNonTextChannel,
|
||||
ChannelVerificationLevelTooHighForYouToGainAccess,
|
||||
OAuth2ApplicationDoesNotHaveBot,
|
||||
OAuth2ApplicationLimitReached,
|
||||
|
||||
@@ -95,6 +95,14 @@ export type RESTPatchAPIGuildScheduledEventJSONBody = StrictPartial<RESTPostAPIG
|
||||
* The status of the scheduled event
|
||||
*/
|
||||
status?: GuildScheduledEventStatus;
|
||||
/**
|
||||
* The entity metadata of the scheduled event
|
||||
*/
|
||||
entity_metadata?: APIGuildScheduledEventEntityMetadata | null;
|
||||
/**
|
||||
* The description of the guild event
|
||||
*/
|
||||
description?: string | null;
|
||||
}>;
|
||||
|
||||
/**
|
||||
|
||||
@@ -95,6 +95,14 @@ export type RESTPatchAPIGuildScheduledEventJSONBody = StrictPartial<RESTPostAPIG
|
||||
* The status of the scheduled event
|
||||
*/
|
||||
status?: GuildScheduledEventStatus;
|
||||
/**
|
||||
* The entity metadata of the scheduled event
|
||||
*/
|
||||
entity_metadata?: APIGuildScheduledEventEntityMetadata | null;
|
||||
/**
|
||||
* The description of the guild event
|
||||
*/
|
||||
description?: string | null;
|
||||
}>;
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,13 +5,20 @@ import {
|
||||
APIButtonComponent,
|
||||
APIButtonComponentWithCustomId,
|
||||
APIButtonComponentWithURL,
|
||||
APIChatInputApplicationCommandInteraction,
|
||||
APIContextMenuInteraction,
|
||||
APIDMInteraction,
|
||||
APIGuildInteraction,
|
||||
APIInteraction,
|
||||
APIMessageComponentButtonInteraction,
|
||||
APIMessageComponentDMInteraction,
|
||||
APIMessageComponentGuildInteraction,
|
||||
APIMessageComponentInteraction,
|
||||
APIMessageComponentSelectMenuInteraction,
|
||||
ApplicationCommandType,
|
||||
ButtonStyle,
|
||||
ComponentType,
|
||||
InteractionType,
|
||||
} from '../payloads/v10/mod.ts';
|
||||
|
||||
// Interactions
|
||||
@@ -101,3 +108,64 @@ export function isLinkButton(component: APIButtonComponent): component is APIBut
|
||||
export function isInteractionButton(component: APIButtonComponent): component is APIButtonComponentWithCustomId {
|
||||
return component.style !== ButtonStyle.Link;
|
||||
}
|
||||
|
||||
// Message Components
|
||||
|
||||
/**
|
||||
* A type-guard check for message component interactions
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the interaction is a message component
|
||||
*/
|
||||
export function isMessageComponentInteraction(
|
||||
interaction: APIInteraction,
|
||||
): interaction is APIMessageComponentInteraction {
|
||||
return interaction.type === InteractionType.MessageComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for button message component interactions
|
||||
* @param interaction The message component interaction to check against
|
||||
* @returns A boolean that indicates if the message component is a button
|
||||
*/
|
||||
export function isMessageComponentButtonInteraction(
|
||||
interaction: APIMessageComponentInteraction,
|
||||
): interaction is APIMessageComponentButtonInteraction {
|
||||
return interaction.data.component_type === ComponentType.Button;
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for select menu message component interactions
|
||||
* @param interaction The message component interaction to check against
|
||||
* @returns A boolean that indicates if the message component is a select menu
|
||||
*/
|
||||
export function isMessageComponentSelectMenuInteraction(
|
||||
interaction: APIMessageComponentInteraction,
|
||||
): interaction is APIMessageComponentSelectMenuInteraction {
|
||||
return interaction.data.component_type === ComponentType.SelectMenu;
|
||||
}
|
||||
|
||||
// Application Commands
|
||||
|
||||
/**
|
||||
* A type-guard check for chat input application commands.
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the interaction is a chat input application command
|
||||
*/
|
||||
export function isChatInputApplicationCommandInteraction(
|
||||
interaction: APIApplicationCommandInteraction,
|
||||
): interaction is APIChatInputApplicationCommandInteraction {
|
||||
return interaction.data.type === ApplicationCommandType.ChatInput;
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for context menu application commands.
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the interaction is a context menu application command
|
||||
*/
|
||||
export function isContextMenuApplicationCommandInteraction(
|
||||
interaction: APIApplicationCommandInteraction,
|
||||
): interaction is APIContextMenuInteraction {
|
||||
return (
|
||||
interaction.data.type === ApplicationCommandType.Message || interaction.data.type === ApplicationCommandType.User
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,13 +5,20 @@ import {
|
||||
APIButtonComponent,
|
||||
APIButtonComponentWithCustomId,
|
||||
APIButtonComponentWithURL,
|
||||
APIChatInputApplicationCommandInteraction,
|
||||
APIContextMenuInteraction,
|
||||
APIDMInteraction,
|
||||
APIGuildInteraction,
|
||||
APIInteraction,
|
||||
APIMessageComponentButtonInteraction,
|
||||
APIMessageComponentDMInteraction,
|
||||
APIMessageComponentGuildInteraction,
|
||||
APIMessageComponentInteraction,
|
||||
APIMessageComponentSelectMenuInteraction,
|
||||
ApplicationCommandType,
|
||||
ButtonStyle,
|
||||
ComponentType,
|
||||
InteractionType,
|
||||
} from '../payloads/v9/mod.ts';
|
||||
|
||||
// Interactions
|
||||
@@ -101,3 +108,64 @@ export function isLinkButton(component: APIButtonComponent): component is APIBut
|
||||
export function isInteractionButton(component: APIButtonComponent): component is APIButtonComponentWithCustomId {
|
||||
return component.style !== ButtonStyle.Link;
|
||||
}
|
||||
|
||||
// Message Components
|
||||
|
||||
/**
|
||||
* A type-guard check for message component interactions
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the interaction is a message component
|
||||
*/
|
||||
export function isMessageComponentInteraction(
|
||||
interaction: APIInteraction,
|
||||
): interaction is APIMessageComponentInteraction {
|
||||
return interaction.type === InteractionType.MessageComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for button message component interactions
|
||||
* @param interaction The message component interaction to check against
|
||||
* @returns A boolean that indicates if the message component is a button
|
||||
*/
|
||||
export function isMessageComponentButtonInteraction(
|
||||
interaction: APIMessageComponentInteraction,
|
||||
): interaction is APIMessageComponentButtonInteraction {
|
||||
return interaction.data.component_type === ComponentType.Button;
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for select menu message component interactions
|
||||
* @param interaction The message component interaction to check against
|
||||
* @returns A boolean that indicates if the message component is a select menu
|
||||
*/
|
||||
export function isMessageComponentSelectMenuInteraction(
|
||||
interaction: APIMessageComponentInteraction,
|
||||
): interaction is APIMessageComponentSelectMenuInteraction {
|
||||
return interaction.data.component_type === ComponentType.SelectMenu;
|
||||
}
|
||||
|
||||
// Application Commands
|
||||
|
||||
/**
|
||||
* A type-guard check for chat input application commands.
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the interaction is a chat input application command
|
||||
*/
|
||||
export function isChatInputApplicationCommandInteraction(
|
||||
interaction: APIApplicationCommandInteraction,
|
||||
): interaction is APIChatInputApplicationCommandInteraction {
|
||||
return interaction.data.type === ApplicationCommandType.ChatInput;
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for context menu application commands.
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the interaction is a context menu application command
|
||||
*/
|
||||
export function isContextMenuApplicationCommandInteraction(
|
||||
interaction: APIApplicationCommandInteraction,
|
||||
): interaction is APIContextMenuInteraction {
|
||||
return (
|
||||
interaction.data.type === ApplicationCommandType.Message || interaction.data.type === ApplicationCommandType.User
|
||||
);
|
||||
}
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "discord-api-types",
|
||||
"version": "0.27.3",
|
||||
"version": "0.30.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "discord-api-types",
|
||||
"version": "0.27.3",
|
||||
"version": "0.30.0",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^16.1.0",
|
||||
|
||||
53
package.json
53
package.json
@@ -1,75 +1,92 @@
|
||||
{
|
||||
"name": "discord-api-types",
|
||||
"version": "0.27.3",
|
||||
"version": "0.30.0",
|
||||
"description": "Discord API typings that are kept up to date for use in bot library creation.",
|
||||
"exports": {
|
||||
"./globals": {
|
||||
"require": "./globals.js",
|
||||
"import": "./globals.mjs"
|
||||
"import": "./globals.mjs",
|
||||
"types": "./globals.d.ts"
|
||||
},
|
||||
"./v6": {
|
||||
"require": "./v6.js",
|
||||
"import": "./v6.mjs"
|
||||
"import": "./v6.mjs",
|
||||
"types": "./v6.d.ts"
|
||||
},
|
||||
"./v8": {
|
||||
"require": "./v8.js",
|
||||
"import": "./v8.mjs"
|
||||
"import": "./v8.mjs",
|
||||
"types": "./v8.d.ts"
|
||||
},
|
||||
"./v9": {
|
||||
"require": "./v9.js",
|
||||
"import": "./v9.mjs"
|
||||
"import": "./v9.mjs",
|
||||
"types": "./v9.d.ts"
|
||||
},
|
||||
"./v10": {
|
||||
"require": "./v10.js",
|
||||
"import": "./v10.mjs"
|
||||
"import": "./v10.mjs",
|
||||
"types": "./v10.d.ts"
|
||||
},
|
||||
"./gateway": {
|
||||
"require": "./gateway/index.js",
|
||||
"import": "./gateway/index.mjs"
|
||||
"import": "./gateway/index.mjs",
|
||||
"types": "./gateway/index.d.ts"
|
||||
},
|
||||
"./gateway/v*": {
|
||||
"require": "./gateway/v*.js",
|
||||
"import": "./gateway/v*.mjs"
|
||||
"import": "./gateway/v*.mjs",
|
||||
"types": "./gateway/v*.d.ts"
|
||||
},
|
||||
"./payloads": {
|
||||
"require": "./payloads/index.js",
|
||||
"import": "./payloads/index.mjs"
|
||||
"import": "./payloads/index.mjs",
|
||||
"types": "./payloads/index.d.ts"
|
||||
},
|
||||
"./payloads/v*": {
|
||||
"require": "./payloads/v*/index.js",
|
||||
"import": "./payloads/v*/index.mjs"
|
||||
"import": "./payloads/v*/index.mjs",
|
||||
"types": "./payloads/v*/index.d.ts"
|
||||
},
|
||||
"./rest": {
|
||||
"require": "./rest/index.js",
|
||||
"import": "./rest/index.mjs"
|
||||
"import": "./rest/index.mjs",
|
||||
"types": "./rest/index.d.ts"
|
||||
},
|
||||
"./rest/v*": {
|
||||
"require": "./rest/v*/index.js",
|
||||
"import": "./rest/v*/index.mjs"
|
||||
"import": "./rest/v*/index.mjs",
|
||||
"types": "./rest/v*/index.d.ts"
|
||||
},
|
||||
"./rpc": {
|
||||
"require": "./rpc/index.js",
|
||||
"import": "./rpc/index.mjs"
|
||||
"import": "./rpc/index.mjs",
|
||||
"types": "./rpc/index.d.ts"
|
||||
},
|
||||
"./rpc/v*": {
|
||||
"require": "./rpc/v*.js",
|
||||
"import": "./rpc/v*.mjs"
|
||||
"import": "./rpc/v*.mjs",
|
||||
"types": "./rpc/v*.d.ts"
|
||||
},
|
||||
"./voice": {
|
||||
"require": "./voice/index.js",
|
||||
"import": "./voice/index.mjs"
|
||||
"import": "./voice/index.mjs",
|
||||
"types": "./voice/index.d.ts"
|
||||
},
|
||||
"./voice/v*": {
|
||||
"require": "./voice/v*.js",
|
||||
"import": "./voice/v*.mjs"
|
||||
"import": "./voice/v*.mjs",
|
||||
"types": "./voice/v*.d.ts"
|
||||
},
|
||||
"./utils": {
|
||||
"require": "./utils/index.js",
|
||||
"import": "./utils/index.mjs"
|
||||
"import": "./utils/index.mjs",
|
||||
"types": "./utils/index.d.ts"
|
||||
},
|
||||
"./utils/v*": {
|
||||
"require": "./utils/v*.js",
|
||||
"import": "./utils/v*.mjs"
|
||||
"import": "./utils/v*.mjs",
|
||||
"types": "./utils/v*.d.ts"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { LocaleString } from '../v10';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags
|
||||
*
|
||||
@@ -45,7 +47,7 @@ export const PermissionFlagsBits = {
|
||||
CreatePrivateThreads: 1n << 36n,
|
||||
UseExternalStickers: 1n << 37n,
|
||||
SendMessagesInThreads: 1n << 38n,
|
||||
StartEmbeddedActivities: 1n << 39n,
|
||||
UseEmbeddedActivities: 1n << 39n,
|
||||
ModerateMembers: 1n << 40n,
|
||||
} as const;
|
||||
|
||||
@@ -54,3 +56,5 @@ export const PermissionFlagsBits = {
|
||||
* @internal
|
||||
*/
|
||||
Object.freeze(PermissionFlagsBits);
|
||||
|
||||
export type LocalizationMap = Partial<Record<LocaleString, string>>;
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import type { LocalizationMap } from '../../../../../v10';
|
||||
import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared';
|
||||
|
||||
export interface APIApplicationCommandOptionBase<Type extends ApplicationCommandOptionType> {
|
||||
type: Type;
|
||||
name: string;
|
||||
name_localizations?: LocalizationMap;
|
||||
description: string;
|
||||
description_localizations?: LocalizationMap;
|
||||
required?: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { LocalizationMap } from '../../../../../v10';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type
|
||||
*/
|
||||
@@ -20,5 +22,6 @@ export enum ApplicationCommandOptionType {
|
||||
*/
|
||||
export interface APIApplicationCommandOptionChoice<ValueType = string | number> {
|
||||
name: string;
|
||||
name_localizations?: LocalizationMap;
|
||||
value: ValueType;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { Permissions, Snowflake } from '../../../globals';
|
||||
import type { LocalizationMap } from '../../../v10';
|
||||
import type { APIPartialChannel, APIThreadMetadata } from '../channel';
|
||||
import type { APIGuildMember } from '../guild';
|
||||
import type { APIBaseInteraction } from './base';
|
||||
@@ -45,10 +46,18 @@ export interface APIApplicationCommand {
|
||||
* 1-32 character name; `CHAT_INPUT` command names must be all lowercase matching `^[\w-]{1,32}$`
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Localization dictionary for the name field. Values follow the same restrictions as name
|
||||
*/
|
||||
name_localizations?: LocalizationMap;
|
||||
/**
|
||||
* 1-100 character description for `CHAT_INPUT` commands, empty string for `USER` and `MESSAGE` commands
|
||||
*/
|
||||
description: string;
|
||||
/**
|
||||
* Localization dictionary for the description field. Values follow the same restrictions as description
|
||||
*/
|
||||
description_localizations?: LocalizationMap;
|
||||
/**
|
||||
* The parameters for the `CHAT_INPUT` command, max 25
|
||||
*/
|
||||
|
||||
@@ -13,6 +13,28 @@ export type APIMessageComponentInteraction = APIBaseInteraction<
|
||||
>
|
||||
>;
|
||||
|
||||
export type APIMessageComponentButtonInteraction = APIBaseInteraction<
|
||||
InteractionType.MessageComponent,
|
||||
APIMessageButtonInteractionData
|
||||
> &
|
||||
Required<
|
||||
Pick<
|
||||
APIBaseInteraction<InteractionType.MessageComponent, APIMessageButtonInteractionData>,
|
||||
'channel_id' | 'data' | 'message'
|
||||
>
|
||||
>;
|
||||
|
||||
export type APIMessageComponentSelectMenuInteraction = APIBaseInteraction<
|
||||
InteractionType.MessageComponent,
|
||||
APIMessageSelectMenuInteractionData
|
||||
> &
|
||||
Required<
|
||||
Pick<
|
||||
APIBaseInteraction<InteractionType.MessageComponent, APIMessageSelectMenuInteractionData>,
|
||||
'channel_id' | 'data' | 'message'
|
||||
>
|
||||
>;
|
||||
|
||||
export type APIMessageComponentInteractionData = APIMessageButtonInteractionData | APIMessageSelectMenuInteractionData;
|
||||
|
||||
export interface APIMessageComponentBaseInteractionData<CType extends ComponentType> {
|
||||
|
||||
@@ -1188,7 +1188,7 @@ export interface APIActionRowComponent<T extends APIActionRowComponentTypes>
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#buttons
|
||||
*/
|
||||
interface APIButtonComponentBase<Style extends ButtonStyle> extends APIBaseComponent<ComponentType.Button> {
|
||||
export interface APIButtonComponentBase<Style extends ButtonStyle> extends APIBaseComponent<ComponentType.Button> {
|
||||
/**
|
||||
* The label to be displayed on the button
|
||||
*/
|
||||
@@ -1273,7 +1273,7 @@ export interface APISelectMenuComponent extends APIBaseComponent<ComponentType.S
|
||||
*/
|
||||
options: APISelectMenuOption[];
|
||||
/**
|
||||
* Custom placeholder text if nothing is selected, max 100 characters
|
||||
* Custom placeholder text if nothing is selected, max 150 characters
|
||||
*/
|
||||
placeholder?: string;
|
||||
/**
|
||||
|
||||
@@ -681,7 +681,7 @@ export interface APIGuildIntegration {
|
||||
/**
|
||||
* Integration type
|
||||
*/
|
||||
type: APIGuildInteractionType;
|
||||
type: APIGuildIntegrationType;
|
||||
/**
|
||||
* Is this integration enabled
|
||||
*/
|
||||
@@ -760,7 +760,7 @@ export interface APIGuildIntegration {
|
||||
application?: APIGuildIntegrationApplication;
|
||||
}
|
||||
|
||||
export type APIGuildInteractionType = 'twitch' | 'youtube' | 'discord';
|
||||
export type APIGuildIntegrationType = 'twitch' | 'youtube' | 'discord';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors
|
||||
|
||||
@@ -26,7 +26,7 @@ interface APIGuildScheduledEventBase<Type extends GuildScheduledEventEntityType>
|
||||
/**
|
||||
* The description of the scheduled event
|
||||
*/
|
||||
description?: string;
|
||||
description?: string | null;
|
||||
/**
|
||||
* The time the scheduled event will start
|
||||
*/
|
||||
@@ -66,7 +66,7 @@ interface APIGuildScheduledEventBase<Type extends GuildScheduledEventEntityType>
|
||||
/**
|
||||
* The cover image of the scheduled event
|
||||
*/
|
||||
image: string | null;
|
||||
image?: string | null;
|
||||
}
|
||||
|
||||
export interface APIStageInstanceGuildScheduledEvent
|
||||
|
||||
@@ -4,11 +4,26 @@
|
||||
|
||||
import type { APIApplication } from './application';
|
||||
import type { APIPartialChannel } from './channel';
|
||||
import type { APIPartialGuild } from './guild';
|
||||
import type { APIGuild } from './guild';
|
||||
import type { APIGuildScheduledEvent } from './guildScheduledEvent';
|
||||
import type { APIInviteStageInstance } from './stageInstance';
|
||||
import type { APIUser } from './user';
|
||||
|
||||
export type APIInviteGuild = Pick<
|
||||
APIGuild,
|
||||
| 'id'
|
||||
| 'name'
|
||||
| 'splash'
|
||||
| 'banner'
|
||||
| 'icon'
|
||||
| 'vanity_url_code'
|
||||
| 'description'
|
||||
| 'features'
|
||||
| 'verification_level'
|
||||
| 'nsfw_level'
|
||||
| 'premium_subscription_count'
|
||||
>;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/invite#invite-object
|
||||
*/
|
||||
@@ -22,7 +37,7 @@ export interface APIInvite {
|
||||
*
|
||||
* See https://discord.com/developers/docs/resources/guild#guild-object
|
||||
*/
|
||||
guild?: APIPartialGuild;
|
||||
guild?: APIInviteGuild;
|
||||
/**
|
||||
* The channel this invite is for
|
||||
*
|
||||
|
||||
@@ -32,6 +32,10 @@ export interface APIStageInstance {
|
||||
* @deprecated
|
||||
*/
|
||||
discoverable_disabled: boolean;
|
||||
/**
|
||||
* The id of the scheduled event for this stage instance
|
||||
*/
|
||||
guild_scheduled_event_id?: Snowflake;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,7 +33,7 @@ export interface APISticker {
|
||||
* Previously the sticker asset hash, now an empty string
|
||||
* @deprecated
|
||||
*/
|
||||
asset: '';
|
||||
asset?: '';
|
||||
/**
|
||||
* Type of sticker
|
||||
*
|
||||
|
||||
@@ -4,11 +4,26 @@
|
||||
|
||||
import type { APIApplication } from './application';
|
||||
import type { APIPartialChannel } from './channel';
|
||||
import type { APIPartialGuild } from './guild';
|
||||
import type { APIGuild } from './guild';
|
||||
import type { APIGuildScheduledEvent } from './guildScheduledEvent';
|
||||
import type { APIInviteStageInstance } from './stageInstance';
|
||||
import type { APIUser } from './user';
|
||||
|
||||
export type APIInviteGuild = Pick<
|
||||
APIGuild,
|
||||
| 'id'
|
||||
| 'name'
|
||||
| 'splash'
|
||||
| 'banner'
|
||||
| 'icon'
|
||||
| 'vanity_url_code'
|
||||
| 'description'
|
||||
| 'features'
|
||||
| 'verification_level'
|
||||
| 'nsfw_level'
|
||||
| 'premium_subscription_count'
|
||||
>;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/invite#invite-object
|
||||
* @deprecated API and gateway v8 are deprecated and the types will not receive further updates, please update to v10.
|
||||
@@ -23,7 +38,7 @@ export interface APIInvite {
|
||||
*
|
||||
* See https://discord.com/developers/docs/resources/guild#guild-object
|
||||
*/
|
||||
guild?: APIPartialGuild;
|
||||
guild?: APIInviteGuild;
|
||||
/**
|
||||
* The channel this invite is for
|
||||
*
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import type { LocalizationMap } from '../../../../../v9';
|
||||
import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared';
|
||||
|
||||
export interface APIApplicationCommandOptionBase<Type extends ApplicationCommandOptionType> {
|
||||
type: Type;
|
||||
name: string;
|
||||
name_localizations?: LocalizationMap;
|
||||
description: string;
|
||||
description_localizations?: LocalizationMap;
|
||||
required?: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { LocalizationMap } from '../../../../../v9';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type
|
||||
*/
|
||||
@@ -20,5 +22,6 @@ export enum ApplicationCommandOptionType {
|
||||
*/
|
||||
export interface APIApplicationCommandOptionChoice<ValueType = string | number> {
|
||||
name: string;
|
||||
name_localizations?: LocalizationMap;
|
||||
value: ValueType;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { Permissions, Snowflake } from '../../../globals';
|
||||
import type { LocalizationMap } from '../../../v9';
|
||||
import type { APIPartialChannel, APIThreadMetadata } from '../channel';
|
||||
import type { APIGuildMember } from '../guild';
|
||||
import type { APIBaseInteraction } from './base';
|
||||
@@ -45,10 +46,18 @@ export interface APIApplicationCommand {
|
||||
* 1-32 character name; `CHAT_INPUT` command names must be all lowercase matching `^[\w-]{1,32}$`
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Localization dictionary for the name field. Values follow the same restrictions as name
|
||||
*/
|
||||
name_localizations?: LocalizationMap;
|
||||
/**
|
||||
* 1-100 character description for `CHAT_INPUT` commands, empty string for `USER` and `MESSAGE` commands
|
||||
*/
|
||||
description: string;
|
||||
/**
|
||||
* Localization dictionary for the description field. Values follow the same restrictions as description
|
||||
*/
|
||||
description_localizations?: LocalizationMap;
|
||||
/**
|
||||
* The parameters for the `CHAT_INPUT` command, max 25
|
||||
*/
|
||||
|
||||
@@ -13,6 +13,28 @@ export type APIMessageComponentInteraction = APIBaseInteraction<
|
||||
>
|
||||
>;
|
||||
|
||||
export type APIMessageComponentButtonInteraction = APIBaseInteraction<
|
||||
InteractionType.MessageComponent,
|
||||
APIMessageButtonInteractionData
|
||||
> &
|
||||
Required<
|
||||
Pick<
|
||||
APIBaseInteraction<InteractionType.MessageComponent, APIMessageButtonInteractionData>,
|
||||
'channel_id' | 'data' | 'message'
|
||||
>
|
||||
>;
|
||||
|
||||
export type APIMessageComponentSelectMenuInteraction = APIBaseInteraction<
|
||||
InteractionType.MessageComponent,
|
||||
APIMessageSelectMenuInteractionData
|
||||
> &
|
||||
Required<
|
||||
Pick<
|
||||
APIBaseInteraction<InteractionType.MessageComponent, APIMessageSelectMenuInteractionData>,
|
||||
'channel_id' | 'data' | 'message'
|
||||
>
|
||||
>;
|
||||
|
||||
export type APIMessageComponentInteractionData = APIMessageButtonInteractionData | APIMessageSelectMenuInteractionData;
|
||||
|
||||
export interface APIMessageComponentBaseInteractionData<CType extends ComponentType> {
|
||||
|
||||
@@ -1188,7 +1188,7 @@ export interface APIActionRowComponent<T extends APIActionRowComponentTypes>
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/message-components#buttons
|
||||
*/
|
||||
interface APIButtonComponentBase<Style extends ButtonStyle> extends APIBaseComponent<ComponentType.Button> {
|
||||
export interface APIButtonComponentBase<Style extends ButtonStyle> extends APIBaseComponent<ComponentType.Button> {
|
||||
/**
|
||||
* The label to be displayed on the button
|
||||
*/
|
||||
@@ -1273,7 +1273,7 @@ export interface APISelectMenuComponent extends APIBaseComponent<ComponentType.S
|
||||
*/
|
||||
options: APISelectMenuOption[];
|
||||
/**
|
||||
* Custom placeholder text if nothing is selected, max 100 characters
|
||||
* Custom placeholder text if nothing is selected, max 150 characters
|
||||
*/
|
||||
placeholder?: string;
|
||||
/**
|
||||
|
||||
@@ -681,7 +681,7 @@ export interface APIGuildIntegration {
|
||||
/**
|
||||
* Integration type
|
||||
*/
|
||||
type: APIGuildInteractionType;
|
||||
type: APIGuildIntegrationType;
|
||||
/**
|
||||
* Is this integration enabled
|
||||
*/
|
||||
@@ -760,7 +760,7 @@ export interface APIGuildIntegration {
|
||||
application?: APIGuildIntegrationApplication;
|
||||
}
|
||||
|
||||
export type APIGuildInteractionType = 'twitch' | 'youtube' | 'discord';
|
||||
export type APIGuildIntegrationType = 'twitch' | 'youtube' | 'discord';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors
|
||||
|
||||
@@ -26,7 +26,7 @@ interface APIGuildScheduledEventBase<Type extends GuildScheduledEventEntityType>
|
||||
/**
|
||||
* The description of the scheduled event
|
||||
*/
|
||||
description?: string;
|
||||
description?: string | null;
|
||||
/**
|
||||
* The time the scheduled event will start
|
||||
*/
|
||||
@@ -66,7 +66,7 @@ interface APIGuildScheduledEventBase<Type extends GuildScheduledEventEntityType>
|
||||
/**
|
||||
* The cover image of the scheduled event
|
||||
*/
|
||||
image: string | null;
|
||||
image?: string | null;
|
||||
}
|
||||
|
||||
export interface APIStageInstanceGuildScheduledEvent
|
||||
|
||||
@@ -4,11 +4,26 @@
|
||||
|
||||
import type { APIApplication } from './application';
|
||||
import type { APIPartialChannel } from './channel';
|
||||
import type { APIPartialGuild } from './guild';
|
||||
import type { APIGuild } from './guild';
|
||||
import type { APIGuildScheduledEvent } from './guildScheduledEvent';
|
||||
import type { APIInviteStageInstance } from './stageInstance';
|
||||
import type { APIUser } from './user';
|
||||
|
||||
export type APIInviteGuild = Pick<
|
||||
APIGuild,
|
||||
| 'id'
|
||||
| 'name'
|
||||
| 'splash'
|
||||
| 'banner'
|
||||
| 'icon'
|
||||
| 'vanity_url_code'
|
||||
| 'description'
|
||||
| 'features'
|
||||
| 'verification_level'
|
||||
| 'nsfw_level'
|
||||
| 'premium_subscription_count'
|
||||
>;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/invite#invite-object
|
||||
*/
|
||||
@@ -22,7 +37,7 @@ export interface APIInvite {
|
||||
*
|
||||
* See https://discord.com/developers/docs/resources/guild#guild-object
|
||||
*/
|
||||
guild?: APIPartialGuild;
|
||||
guild?: APIInviteGuild;
|
||||
/**
|
||||
* The channel this invite is for
|
||||
*
|
||||
|
||||
@@ -32,6 +32,10 @@ export interface APIStageInstance {
|
||||
* @deprecated
|
||||
*/
|
||||
discoverable_disabled: boolean;
|
||||
/**
|
||||
* The id of the scheduled event for this stage instance
|
||||
*/
|
||||
guild_scheduled_event_id?: Snowflake;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,7 +33,7 @@ export interface APISticker {
|
||||
* Previously the sticker asset hash, now an empty string
|
||||
* @deprecated
|
||||
*/
|
||||
asset: '';
|
||||
asset?: '';
|
||||
/**
|
||||
* Type of sticker
|
||||
*
|
||||
|
||||
@@ -47,7 +47,8 @@ export enum RESTJSONErrorCodes {
|
||||
UnknownInteraction = 10062,
|
||||
UnknownApplicationCommand,
|
||||
|
||||
UnknownApplicationCommandPermissions = 10066,
|
||||
UnknownVoiceState = 10065,
|
||||
UnknownApplicationCommandPermissions,
|
||||
UnknownStageInstance,
|
||||
UnknownGuildMemberVerificationForm,
|
||||
UnknownGuildWelcomeScreen,
|
||||
@@ -109,7 +110,7 @@ export enum RESTJSONErrorCodes {
|
||||
|
||||
MaximumNumberOfGuildWidgetSettingsUpdatesHasBeenReached = 30042,
|
||||
|
||||
MaxmimumNumberOfEditsToMessagesOlderThanOneHourReached = 30046,
|
||||
MaximumNumberOfEditsToMessagesOlderThanOneHourReached = 30046,
|
||||
|
||||
Unauthorized = 40001,
|
||||
VerifyYourAccount,
|
||||
@@ -133,7 +134,7 @@ export enum RESTJSONErrorCodes {
|
||||
CannotEditMessageAuthoredByAnotherUser,
|
||||
CannotSendAnEmptyMessage,
|
||||
CannotSendMessagesToThisUser,
|
||||
CannotSendMessagesInVoiceChannel,
|
||||
CannotSendMessagesInNonTextChannel,
|
||||
ChannelVerificationLevelTooHighForYouToGainAccess,
|
||||
OAuth2ApplicationDoesNotHaveBot,
|
||||
OAuth2ApplicationLimitReached,
|
||||
|
||||
@@ -95,6 +95,14 @@ export type RESTPatchAPIGuildScheduledEventJSONBody = StrictPartial<RESTPostAPIG
|
||||
* The status of the scheduled event
|
||||
*/
|
||||
status?: GuildScheduledEventStatus;
|
||||
/**
|
||||
* The entity metadata of the scheduled event
|
||||
*/
|
||||
entity_metadata?: APIGuildScheduledEventEntityMetadata | null;
|
||||
/**
|
||||
* The description of the guild event
|
||||
*/
|
||||
description?: string | null;
|
||||
}>;
|
||||
|
||||
/**
|
||||
|
||||
@@ -95,6 +95,14 @@ export type RESTPatchAPIGuildScheduledEventJSONBody = StrictPartial<RESTPostAPIG
|
||||
* The status of the scheduled event
|
||||
*/
|
||||
status?: GuildScheduledEventStatus;
|
||||
/**
|
||||
* The entity metadata of the scheduled event
|
||||
*/
|
||||
entity_metadata?: APIGuildScheduledEventEntityMetadata | null;
|
||||
/**
|
||||
* The description of the guild event
|
||||
*/
|
||||
description?: string | null;
|
||||
}>;
|
||||
|
||||
/**
|
||||
|
||||
68
utils/v10.ts
68
utils/v10.ts
@@ -5,13 +5,20 @@ import {
|
||||
APIButtonComponent,
|
||||
APIButtonComponentWithCustomId,
|
||||
APIButtonComponentWithURL,
|
||||
APIChatInputApplicationCommandInteraction,
|
||||
APIContextMenuInteraction,
|
||||
APIDMInteraction,
|
||||
APIGuildInteraction,
|
||||
APIInteraction,
|
||||
APIMessageComponentButtonInteraction,
|
||||
APIMessageComponentDMInteraction,
|
||||
APIMessageComponentGuildInteraction,
|
||||
APIMessageComponentInteraction,
|
||||
APIMessageComponentSelectMenuInteraction,
|
||||
ApplicationCommandType,
|
||||
ButtonStyle,
|
||||
ComponentType,
|
||||
InteractionType,
|
||||
} from '../payloads/v10/index';
|
||||
|
||||
// Interactions
|
||||
@@ -101,3 +108,64 @@ export function isLinkButton(component: APIButtonComponent): component is APIBut
|
||||
export function isInteractionButton(component: APIButtonComponent): component is APIButtonComponentWithCustomId {
|
||||
return component.style !== ButtonStyle.Link;
|
||||
}
|
||||
|
||||
// Message Components
|
||||
|
||||
/**
|
||||
* A type-guard check for message component interactions
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the interaction is a message component
|
||||
*/
|
||||
export function isMessageComponentInteraction(
|
||||
interaction: APIInteraction,
|
||||
): interaction is APIMessageComponentInteraction {
|
||||
return interaction.type === InteractionType.MessageComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for button message component interactions
|
||||
* @param interaction The message component interaction to check against
|
||||
* @returns A boolean that indicates if the message component is a button
|
||||
*/
|
||||
export function isMessageComponentButtonInteraction(
|
||||
interaction: APIMessageComponentInteraction,
|
||||
): interaction is APIMessageComponentButtonInteraction {
|
||||
return interaction.data.component_type === ComponentType.Button;
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for select menu message component interactions
|
||||
* @param interaction The message component interaction to check against
|
||||
* @returns A boolean that indicates if the message component is a select menu
|
||||
*/
|
||||
export function isMessageComponentSelectMenuInteraction(
|
||||
interaction: APIMessageComponentInteraction,
|
||||
): interaction is APIMessageComponentSelectMenuInteraction {
|
||||
return interaction.data.component_type === ComponentType.SelectMenu;
|
||||
}
|
||||
|
||||
// Application Commands
|
||||
|
||||
/**
|
||||
* A type-guard check for chat input application commands.
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the interaction is a chat input application command
|
||||
*/
|
||||
export function isChatInputApplicationCommandInteraction(
|
||||
interaction: APIApplicationCommandInteraction,
|
||||
): interaction is APIChatInputApplicationCommandInteraction {
|
||||
return interaction.data.type === ApplicationCommandType.ChatInput;
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for context menu application commands.
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the interaction is a context menu application command
|
||||
*/
|
||||
export function isContextMenuApplicationCommandInteraction(
|
||||
interaction: APIApplicationCommandInteraction,
|
||||
): interaction is APIContextMenuInteraction {
|
||||
return (
|
||||
interaction.data.type === ApplicationCommandType.Message || interaction.data.type === ApplicationCommandType.User
|
||||
);
|
||||
}
|
||||
|
||||
68
utils/v9.ts
68
utils/v9.ts
@@ -5,13 +5,20 @@ import {
|
||||
APIButtonComponent,
|
||||
APIButtonComponentWithCustomId,
|
||||
APIButtonComponentWithURL,
|
||||
APIChatInputApplicationCommandInteraction,
|
||||
APIContextMenuInteraction,
|
||||
APIDMInteraction,
|
||||
APIGuildInteraction,
|
||||
APIInteraction,
|
||||
APIMessageComponentButtonInteraction,
|
||||
APIMessageComponentDMInteraction,
|
||||
APIMessageComponentGuildInteraction,
|
||||
APIMessageComponentInteraction,
|
||||
APIMessageComponentSelectMenuInteraction,
|
||||
ApplicationCommandType,
|
||||
ButtonStyle,
|
||||
ComponentType,
|
||||
InteractionType,
|
||||
} from '../payloads/v9/index';
|
||||
|
||||
// Interactions
|
||||
@@ -101,3 +108,64 @@ export function isLinkButton(component: APIButtonComponent): component is APIBut
|
||||
export function isInteractionButton(component: APIButtonComponent): component is APIButtonComponentWithCustomId {
|
||||
return component.style !== ButtonStyle.Link;
|
||||
}
|
||||
|
||||
// Message Components
|
||||
|
||||
/**
|
||||
* A type-guard check for message component interactions
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the interaction is a message component
|
||||
*/
|
||||
export function isMessageComponentInteraction(
|
||||
interaction: APIInteraction,
|
||||
): interaction is APIMessageComponentInteraction {
|
||||
return interaction.type === InteractionType.MessageComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for button message component interactions
|
||||
* @param interaction The message component interaction to check against
|
||||
* @returns A boolean that indicates if the message component is a button
|
||||
*/
|
||||
export function isMessageComponentButtonInteraction(
|
||||
interaction: APIMessageComponentInteraction,
|
||||
): interaction is APIMessageComponentButtonInteraction {
|
||||
return interaction.data.component_type === ComponentType.Button;
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for select menu message component interactions
|
||||
* @param interaction The message component interaction to check against
|
||||
* @returns A boolean that indicates if the message component is a select menu
|
||||
*/
|
||||
export function isMessageComponentSelectMenuInteraction(
|
||||
interaction: APIMessageComponentInteraction,
|
||||
): interaction is APIMessageComponentSelectMenuInteraction {
|
||||
return interaction.data.component_type === ComponentType.SelectMenu;
|
||||
}
|
||||
|
||||
// Application Commands
|
||||
|
||||
/**
|
||||
* A type-guard check for chat input application commands.
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the interaction is a chat input application command
|
||||
*/
|
||||
export function isChatInputApplicationCommandInteraction(
|
||||
interaction: APIApplicationCommandInteraction,
|
||||
): interaction is APIChatInputApplicationCommandInteraction {
|
||||
return interaction.data.type === ApplicationCommandType.ChatInput;
|
||||
}
|
||||
|
||||
/**
|
||||
* A type-guard check for context menu application commands.
|
||||
* @param interaction The interaction to check against
|
||||
* @returns A boolean that indicates if the interaction is a context menu application command
|
||||
*/
|
||||
export function isContextMenuApplicationCommandInteraction(
|
||||
interaction: APIApplicationCommandInteraction,
|
||||
): interaction is APIContextMenuInteraction {
|
||||
return (
|
||||
interaction.data.type === ApplicationCommandType.Message || interaction.data.type === ApplicationCommandType.User
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user