Skip to content
This repository was archived by the owner on Oct 13, 2022. It is now read-only.

Commit 844a399

Browse files
committed
Add interfaces
1 parent d121aab commit 844a399

File tree

1 file changed

+234
-0
lines changed

1 file changed

+234
-0
lines changed

src/interfaces.ts

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
/*
2+
|--------------------------------------------------------------------------
3+
| Type definitions
4+
|--------------------------------------------------------------------------
5+
|
6+
| @url https://discord.com/developers/docs/interactions/application-commands
7+
|
8+
*/
9+
10+
export type Snowflake = string;
11+
12+
export type ApplicationCommandJSON = Omit<ApplicationCommandStructure, 'id' | 'application_id' | 'version'>;
13+
14+
/**
15+
* @url https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type
16+
*/
17+
export enum ApplicationCommandOptionTypes {
18+
Subcommand = 1,
19+
SubcommandGroup = 2,
20+
String = 3,
21+
/**
22+
* Any integer between -2^53 and 2^53
23+
*/
24+
Integer = 4,
25+
Boolean = 5,
26+
User = 6,
27+
/**
28+
* Includes all channel types + categories
29+
*/
30+
Channel = 7,
31+
Role = 8,
32+
/**
33+
* Includes users and roles
34+
*/
35+
Mentionable = 9,
36+
/**
37+
* Any double between -2^53 and 2^53
38+
*/
39+
Number = 10,
40+
}
41+
42+
/**
43+
* @url https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types
44+
*/
45+
export enum ApplicationCommandTypes {
46+
/**
47+
* Slash commands; a text-based command that shows up when a user types /
48+
*/
49+
ChatInput = 1,
50+
/**
51+
* A UI-based command that shows up when you right click or tap on a user
52+
*/
53+
User = 2,
54+
/**
55+
* A UI-based command that shows up when you right click or tap on a message
56+
*/
57+
Message = 3,
58+
}
59+
60+
/**
61+
* @url https://discord.com/developers/docs/resources/channel#channel-object-channel-types
62+
*/
63+
export enum ChannelTypes {
64+
/**
65+
* A text channel within a server
66+
*/
67+
GUILD_TEXT = 0,
68+
/**
69+
* A direct message between users
70+
*/
71+
DM = 1,
72+
/**
73+
* A voice channel within a server
74+
*/
75+
GUILD_VOICE = 2,
76+
/**
77+
* A direct message between multiple users
78+
*/
79+
GROUP_DM = 3,
80+
/**
81+
* An organizational category that contains up to 50 channels
82+
*/
83+
GUILD_CATEGORY = 4,
84+
/**
85+
* A channel that users can follow and crosspost into their own server
86+
*/
87+
GUILD_NEWS = 5,
88+
/**
89+
* A channel in which game developers can sell their game on Discord
90+
*/
91+
GUILD_STORE = 6,
92+
/**
93+
* A temporary sub-channel within a GUILD_NEWS channel
94+
*/
95+
GUILD_NEWS_THREAD = 10,
96+
/**
97+
* A temporary sub-channel within a GUILD_TEXT channel
98+
*/
99+
GUILD_PUBLIC_THREAD = 11,
100+
/**
101+
* A temporary sub-channel within a GUILD_TEXT channel that is only viewable by those invited and those with the MANAGE_THREADS permission
102+
*/
103+
GUILD_PRIVATE_THREAD = 12,
104+
/**
105+
* A voice channel for hosting events with an audience
106+
*/
107+
GUILD_STAGE_VOICE = 13,
108+
}
109+
110+
/**
111+
* @url https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-structure
112+
*/
113+
export interface ApplicationCommandStructure {
114+
/**
115+
* Unique id of the command
116+
*/
117+
id: Snowflake;
118+
/**
119+
* The type of command, defaults 1 if not set
120+
*/
121+
type?: ApplicationCommandTypes;
122+
/**
123+
* Unique id of the parent application
124+
*/
125+
application_id: Snowflake;
126+
/**
127+
* Guild id of the command, if not global
128+
*/
129+
guild_id?: Snowflake;
130+
/**
131+
* 1-32 character name
132+
*/
133+
name: string;
134+
/**
135+
* 1-100 character description for CHAT_INPUT commands, empty string for USER and MESSAGE commands
136+
*/
137+
description: string;
138+
/**
139+
* The parameters for the command, max 25
140+
*/
141+
options?: Array<ApplicationCommandOptionStructure>;
142+
/**
143+
* Whether the command is enabled by default when the app is added to a guild
144+
*/
145+
default_permission?: boolean;
146+
/**
147+
* Autoincrementing version identifier updated during substantial record changes
148+
*/
149+
version: Snowflake;
150+
}
151+
152+
/**
153+
* @url https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure
154+
*/
155+
export interface ApplicationCommandOptionStructure {
156+
/**
157+
* The type of option
158+
*/
159+
type: ApplicationCommandOptionTypes;
160+
/**
161+
* 1-32 character name
162+
*/
163+
name: string;
164+
/**
165+
* 1-100 character description
166+
*/
167+
description: string;
168+
/**
169+
* If the parameter is required or optional--default `false`
170+
*/
171+
required?: boolean;
172+
/**
173+
* Choices for `STRING`, `INTEGER`, and `NUMBER` types for the user to pick from, max 25
174+
*/
175+
choices?: Array<ApplicationCommandOptionChoiceStructure>;
176+
/**
177+
* If the option is a subcommand or subcommand group type, this nested options will be the parameters
178+
*/
179+
options?: Array<ApplicationCommandOptionStructure>;
180+
/**
181+
* If the option is a channel type, the channels shown will be restricted to these types
182+
*/
183+
channel_types?: Array<ChannelTypes>;
184+
}
185+
186+
/**
187+
* @url https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-choice-structure
188+
*/
189+
export interface ApplicationCommandOptionChoiceStructure {
190+
/**
191+
* 1-100 character choice name
192+
*/
193+
name: string;
194+
/**
195+
* Value of the choice, up to 100 characters if string
196+
*/
197+
value: number | string;
198+
}
199+
200+
/**
201+
* @url https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-interaction-data-option-structure
202+
*/
203+
export interface ApplicationCommandInteractionDataOptionStructure {
204+
/**
205+
* The name of the parameter
206+
*/
207+
name: string;
208+
/**
209+
* Value of application command option type
210+
*/
211+
type: number;
212+
/**
213+
* The value of the pair
214+
*/
215+
value?: ApplicationCommandOptionTypes;
216+
/**
217+
* Present if this option is a group or subcommand
218+
*/
219+
options?: Array<ApplicationCommandInteractionDataOptionStructure>;
220+
}
221+
222+
export interface CommonPropertiesAndMethods {
223+
type: ApplicationCommandOptionTypes | ApplicationCommandTypes;
224+
name: string;
225+
description: string;
226+
setName(value: string): this;
227+
setDescription(value: string): this;
228+
toJSON(): ApplicationCommandJSON | ApplicationCommandOptionStructure;
229+
}
230+
231+
export interface Choices<A> {
232+
name: string;
233+
value: A;
234+
}

0 commit comments

Comments
 (0)