mirror of
https://github.com/discordjs/discord-api-types.git
synced 2026-05-22 19:30:09 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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:
|
||||
|
||||
16
CHANGELOG.md
16
CHANGELOG.md
@@ -1,3 +1,19 @@
|
||||
# [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,19 @@
|
||||
# [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
|
||||
|
||||
@@ -45,7 +45,7 @@ export const PermissionFlagsBits = {
|
||||
CreatePrivateThreads: 1n << 36n,
|
||||
UseExternalStickers: 1n << 37n,
|
||||
SendMessagesInThreads: 1n << 38n,
|
||||
StartEmbeddedActivities: 1n << 39n,
|
||||
UseEmbeddedActivities: 1n << 39n,
|
||||
ModerateMembers: 1n << 40n,
|
||||
} as const;
|
||||
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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.28.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "discord-api-types",
|
||||
"version": "0.27.3",
|
||||
"version": "0.28.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.28.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": {
|
||||
|
||||
@@ -45,7 +45,7 @@ export const PermissionFlagsBits = {
|
||||
CreatePrivateThreads: 1n << 36n,
|
||||
UseExternalStickers: 1n << 37n,
|
||||
SendMessagesInThreads: 1n << 38n,
|
||||
StartEmbeddedActivities: 1n << 39n,
|
||||
UseEmbeddedActivities: 1n << 39n,
|
||||
ModerateMembers: 1n << 40n,
|
||||
} as const;
|
||||
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
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