forked from Dougley/slshx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.ts
179 lines (167 loc) · 5.72 KB
/
commands.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
import type {
RESTGetAPIApplicationCommandResult,
RESTGetAPIApplicationCommandsResult,
RESTGetAPIApplicationGuildCommandResult,
RESTGetAPIApplicationGuildCommandsResult,
RESTPatchAPIApplicationCommandJSONBody,
RESTPatchAPIApplicationCommandResult,
RESTPatchAPIApplicationGuildCommandJSONBody,
RESTPatchAPIApplicationGuildCommandResult,
RESTPostAPIApplicationCommandsJSONBody,
RESTPostAPIApplicationCommandsResult,
RESTPostAPIApplicationGuildCommandsJSONBody,
RESTPostAPIApplicationGuildCommandsResult,
RESTPutAPIApplicationCommandsJSONBody,
RESTPutAPIApplicationCommandsResult,
RESTPutAPIApplicationGuildCommandsJSONBody,
RESTPutAPIApplicationGuildCommandsResult,
Snowflake,
} from "discord-api-types/v9";
import { APIBearerAuth, call } from "./helpers";
/** @see https://discord.com/developers/docs/interactions/application-commands#get-global-application-commands */
export function getGlobalApplicationCommands(
applicationId: Snowflake,
auth: APIBearerAuth
): Promise<RESTGetAPIApplicationCommandsResult> {
return call("GET", `/applications/${applicationId}/commands`, 0, auth);
}
/** @see https://discord.com/developers/docs/interactions/application-commands#create-global-application-command */
export function createGlobalApplicationCommand(
applicationId: Snowflake,
command: RESTPostAPIApplicationCommandsJSONBody,
auth: APIBearerAuth
): Promise<RESTPostAPIApplicationCommandsResult> {
return call("POST", `/applications/${applicationId}/commands`, command, auth);
}
/** @see https://discord.com/developers/docs/interactions/application-commands#get-global-application-command */
export function getGlobalApplicationCommand(
applicationId: Snowflake,
commandId: Snowflake,
auth: APIBearerAuth
): Promise<RESTGetAPIApplicationCommandResult> {
return call(
"GET",
`/applications/${applicationId}/commands/${commandId}`,
0,
auth
);
}
/** @see https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command */
export function editGlobalApplicationCommand(
applicationId: Snowflake,
commandId: Snowflake,
command: RESTPatchAPIApplicationCommandJSONBody,
auth: APIBearerAuth
): Promise<RESTPatchAPIApplicationCommandResult> {
return call(
"PATCH",
`/applications/${applicationId}/commands/${commandId}`,
command,
auth
);
}
/** @see https://discord.com/developers/docs/interactions/application-commands#delete-global-application-command */
export function deleteGlobalApplicationCommand(
applicationId: Snowflake,
commandId: Snowflake,
auth: APIBearerAuth
): Promise<void> {
return call(
"DELETE",
`/applications/${applicationId}/commands/${commandId}`,
0,
auth
);
}
/** @see https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-global-application-commands */
export function bulkOverwriteGlobalApplicationCommands(
applicationId: Snowflake,
commands: RESTPutAPIApplicationCommandsJSONBody,
auth: APIBearerAuth
): Promise<RESTPutAPIApplicationCommandsResult> {
return call("PUT", `/applications/${applicationId}/commands`, commands, auth);
}
/** @see https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands */
export function getGuildApplicationCommands(
applicationId: Snowflake,
guildId: Snowflake,
auth: APIBearerAuth
): Promise<RESTGetAPIApplicationGuildCommandsResult> {
return call(
"GET",
`/applications/${applicationId}/guilds/${guildId}/commands`,
0,
auth
);
}
/** @see https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command */
export function createGuildApplicationCommand(
applicationId: Snowflake,
guildId: Snowflake,
command: RESTPostAPIApplicationGuildCommandsJSONBody,
auth: APIBearerAuth
): Promise<RESTPostAPIApplicationGuildCommandsResult> {
return call(
"POST",
`/applications/${applicationId}/guilds/${guildId}/commands`,
command,
auth
);
}
/** @see https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command */
export function getGuildApplicationCommand(
applicationId: Snowflake,
guildId: Snowflake,
commandId: Snowflake,
auth: APIBearerAuth
): Promise<RESTGetAPIApplicationGuildCommandResult> {
return call(
"GET",
`/applications/${applicationId}/guilds/${guildId}/commands/${commandId}`,
0,
auth
);
}
/** @see https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command */
export function editGuildApplicationCommand(
applicationId: Snowflake,
guildId: Snowflake,
commandId: Snowflake,
command: RESTPatchAPIApplicationGuildCommandJSONBody,
auth: APIBearerAuth
): Promise<RESTPatchAPIApplicationGuildCommandResult> {
return call(
"PATCH",
`/applications/${applicationId}/guilds/${guildId}/commands/${commandId}`,
command,
auth
);
}
/** @see https://discord.com/developers/docs/interactions/application-commands#delete-guild-application-command */
export function deleteGuildApplicationCommand(
applicationId: Snowflake,
guildId: Snowflake,
commandId: Snowflake,
auth: APIBearerAuth
): Promise<void> {
return call(
"DELETE",
`/applications/${applicationId}/guilds/${guildId}/commands/${commandId}`,
0,
auth
);
}
/** @see https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands */
export function bulkOverwriteGuildApplicationCommands(
applicationId: Snowflake,
guildId: Snowflake,
commands: RESTPutAPIApplicationGuildCommandsJSONBody,
auth: APIBearerAuth
): Promise<RESTPutAPIApplicationGuildCommandsResult> {
return call(
"PUT",
`/applications/${applicationId}/guilds/${guildId}/commands`,
commands,
auth
);
}