/
applicationCommands.ts
188 lines (178 loc) · 5.54 KB
/
applicationCommands.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import type { Permissions, Snowflake } from '../../../globals';
import type { LocalizationMap } from '../../../v10';
import type {
APIApplicationCommandOption,
APIChatInputApplicationCommandDMInteraction,
APIChatInputApplicationCommandGuildInteraction,
APIChatInputApplicationCommandInteraction,
APIChatInputApplicationCommandInteractionData,
} from './_applicationCommands/chatInput';
import type {
APIContextMenuDMInteraction,
APIContextMenuGuildInteraction,
APIContextMenuInteraction,
APIContextMenuInteractionData,
} from './_applicationCommands/contextMenu';
import type { APIBaseInteraction } from './base';
import type { InteractionType } from './responses';
export * from './_applicationCommands/chatInput';
export * from './_applicationCommands/contextMenu';
export * from './_applicationCommands/permissions';
/**
* https://discord.com/developers/docs/interactions/application-commands#application-command-object
*/
export interface APIApplicationCommand {
/**
* Unique id of the command
*/
id: Snowflake;
/**
* Type of the command
*/
type: ApplicationCommandType;
/**
* Unique id of the parent application
*/
application_id: Snowflake;
/**
* Guild id of the command, if not global
*/
guild_id?: Snowflake;
/**
* 1-32 character name; `CHAT_INPUT` command names must be all lowercase matching `^[-_\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$`
*/
name: string;
/**
* Localization dictionary for the name field. Values follow the same restrictions as name
*/
name_localizations?: LocalizationMap | null;
/**
* The localized name
*/
name_localized?: string;
/**
* 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 | null;
/**
* The localized description
*/
description_localized?: string;
/**
* The parameters for the `CHAT_INPUT` command, max 25
*/
options?: APIApplicationCommandOption[];
/**
* Set of permissions represented as a bitset
*/
default_member_permissions: Permissions | null;
/**
* Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible
*
* @deprecated Use `contexts` instead
*/
dm_permission?: boolean;
/**
* Whether the command is enabled by default when the app is added to a guild
*
* If missing, this property should be assumed as `true`
*
* @deprecated Use `dm_permission` and/or `default_member_permissions` instead
*/
default_permission?: boolean;
/**
* Indicates whether the command is age-restricted, defaults to `false`
*/
nsfw?: boolean;
/**
* Installation context(s) where the command is available, only for globally-scoped commands. Defaults to `GUILD_INSTALL ([0])`
*
* @unstable
*/
integration_types?: ApplicationIntegrationType[];
/**
* Interaction context(s) where the command can be used, only for globally-scoped commands. By default, all interaction context types included for new commands `[0,1,2]`.
*
* @unstable
*/
contexts?: InteractionContextType[] | null;
/**
* Autoincrementing version identifier updated during substantial record changes
*/
version: Snowflake;
}
/**
* https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types
*/
export enum ApplicationCommandType {
ChatInput = 1,
User,
Message,
}
/**
* https://discord.com/developers/docs/resources/application#application-object-application-integration-types
*/
export enum ApplicationIntegrationType {
/**
* App is installable to servers
*/
GuildInstall = 0,
/**
* App is installable to users
*/
UserInstall = 1,
}
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-context-types
*/
export enum InteractionContextType {
/**
* Interaction can be used within servers
*/
Guild = 0,
/**
* Interaction can be used within DMs with the app's bot user
*/
BotDM = 1,
/**
* Interaction can be used within Group DMs and DMs other than the app's bot user
*/
PrivateChannel = 2,
}
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data
*/
export type APIApplicationCommandInteractionData =
| APIChatInputApplicationCommandInteractionData
| APIContextMenuInteractionData;
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
export type APIApplicationCommandInteractionWrapper<Data extends APIApplicationCommandInteractionData> =
APIBaseInteraction<InteractionType.ApplicationCommand, Data> &
Required<
Pick<
APIBaseInteraction<InteractionType.ApplicationCommand, Data>,
'app_permissions' | 'channel_id' | 'channel' | 'data'
>
>;
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
export type APIApplicationCommandInteraction = APIChatInputApplicationCommandInteraction | APIContextMenuInteraction;
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
export type APIApplicationCommandDMInteraction =
| APIChatInputApplicationCommandDMInteraction
| APIContextMenuDMInteraction;
/**
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
*/
export type APIApplicationCommandGuildInteraction =
| APIChatInputApplicationCommandGuildInteraction
| APIContextMenuGuildInteraction;