Skip to content

Commit 670667d

Browse files
almeidxJiralitedidinelekodiakhq[bot]
authored
feat: add auth option in api methods (#10717)
Co-authored-by: Jiralite <[email protected]> Co-authored-by: Denis-Adrian Cristea <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 54d8750 commit 670667d

File tree

16 files changed

+482
-256
lines changed

16 files changed

+482
-256
lines changed

packages/core/src/api/applicationCommands.ts

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ export class ApplicationCommandsAPI {
4242
public async getGlobalCommands(
4343
applicationId: Snowflake,
4444
query: RESTGetAPIApplicationCommandsQuery = {},
45-
{ signal }: Pick<RequestData, 'signal'> = {},
45+
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
4646
) {
4747
return this.rest.get(Routes.applicationCommands(applicationId), {
48+
auth,
4849
query: makeURLSearchParams(query),
4950
signal,
5051
}) as Promise<RESTGetAPIApplicationCommandsResult>;
@@ -61,9 +62,10 @@ export class ApplicationCommandsAPI {
6162
public async createGlobalCommand(
6263
applicationId: Snowflake,
6364
body: RESTPostAPIApplicationCommandsJSONBody,
64-
{ signal }: Pick<RequestData, 'signal'> = {},
65+
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
6566
) {
6667
return this.rest.post(Routes.applicationCommands(applicationId), {
68+
auth,
6769
body,
6870
signal,
6971
}) as Promise<RESTPostAPIApplicationCommandsResult>;
@@ -80,9 +82,10 @@ export class ApplicationCommandsAPI {
8082
public async getGlobalCommand(
8183
applicationId: Snowflake,
8284
commandId: Snowflake,
83-
{ signal }: Pick<RequestData, 'signal'> = {},
85+
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
8486
) {
8587
return this.rest.get(Routes.applicationCommand(applicationId, commandId), {
88+
auth,
8689
signal,
8790
}) as Promise<RESTGetAPIApplicationCommandResult>;
8891
}
@@ -100,9 +103,10 @@ export class ApplicationCommandsAPI {
100103
applicationId: Snowflake,
101104
commandId: Snowflake,
102105
body: RESTPatchAPIApplicationCommandJSONBody,
103-
{ signal }: Pick<RequestData, 'signal'> = {},
106+
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
104107
) {
105108
return this.rest.patch(Routes.applicationCommand(applicationId, commandId), {
109+
auth,
106110
body,
107111
signal,
108112
}) as Promise<RESTPatchAPIApplicationCommandResult>;
@@ -119,9 +123,9 @@ export class ApplicationCommandsAPI {
119123
public async deleteGlobalCommand(
120124
applicationId: Snowflake,
121125
commandId: Snowflake,
122-
{ signal }: Pick<RequestData, 'signal'> = {},
126+
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
123127
) {
124-
await this.rest.delete(Routes.applicationCommand(applicationId, commandId), { signal });
128+
await this.rest.delete(Routes.applicationCommand(applicationId, commandId), { auth, signal });
125129
}
126130

127131
/**
@@ -135,9 +139,10 @@ export class ApplicationCommandsAPI {
135139
public async bulkOverwriteGlobalCommands(
136140
applicationId: Snowflake,
137141
body: RESTPutAPIApplicationCommandsJSONBody,
138-
{ signal }: Pick<RequestData, 'signal'> = {},
142+
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
139143
) {
140144
return this.rest.put(Routes.applicationCommands(applicationId), {
145+
auth,
141146
body,
142147
signal,
143148
}) as Promise<RESTPutAPIApplicationCommandsResult>;
@@ -156,9 +161,10 @@ export class ApplicationCommandsAPI {
156161
applicationId: Snowflake,
157162
guildId: Snowflake,
158163
query: RESTGetAPIApplicationGuildCommandsQuery = {},
159-
{ signal }: Pick<RequestData, 'signal'> = {},
164+
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
160165
) {
161166
return this.rest.get(Routes.applicationGuildCommands(applicationId, guildId), {
167+
auth,
162168
query: makeURLSearchParams(query),
163169
signal,
164170
}) as Promise<RESTGetAPIApplicationGuildCommandsResult>;
@@ -177,9 +183,10 @@ export class ApplicationCommandsAPI {
177183
applicationId: Snowflake,
178184
guildId: Snowflake,
179185
body: RESTPostAPIApplicationGuildCommandsJSONBody,
180-
{ signal }: Pick<RequestData, 'signal'> = {},
186+
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
181187
) {
182188
return this.rest.post(Routes.applicationGuildCommands(applicationId, guildId), {
189+
auth,
183190
body,
184191
signal,
185192
}) as Promise<RESTPostAPIApplicationGuildCommandsResult>;
@@ -198,9 +205,10 @@ export class ApplicationCommandsAPI {
198205
applicationId: Snowflake,
199206
guildId: Snowflake,
200207
commandId: Snowflake,
201-
{ signal }: Pick<RequestData, 'signal'> = {},
208+
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
202209
) {
203210
return this.rest.get(Routes.applicationGuildCommand(applicationId, guildId, commandId), {
211+
auth,
204212
signal,
205213
}) as Promise<RESTGetAPIApplicationGuildCommandResult>;
206214
}
@@ -220,9 +228,10 @@ export class ApplicationCommandsAPI {
220228
guildId: Snowflake,
221229
commandId: Snowflake,
222230
body: RESTPatchAPIApplicationGuildCommandJSONBody,
223-
{ signal }: Pick<RequestData, 'signal'> = {},
231+
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
224232
) {
225233
return this.rest.patch(Routes.applicationGuildCommand(applicationId, guildId, commandId), {
234+
auth,
226235
body,
227236
signal,
228237
}) as Promise<RESTPatchAPIApplicationGuildCommandResult>;
@@ -241,9 +250,9 @@ export class ApplicationCommandsAPI {
241250
applicationId: Snowflake,
242251
guildId: Snowflake,
243252
commandId: Snowflake,
244-
{ signal }: Pick<RequestData, 'signal'> = {},
253+
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
245254
) {
246-
await this.rest.delete(Routes.applicationGuildCommand(applicationId, guildId, commandId), { signal });
255+
await this.rest.delete(Routes.applicationGuildCommand(applicationId, guildId, commandId), { auth, signal });
247256
}
248257

249258
/**
@@ -259,9 +268,10 @@ export class ApplicationCommandsAPI {
259268
applicationId: Snowflake,
260269
guildId: Snowflake,
261270
body: RESTPutAPIApplicationGuildCommandsJSONBody,
262-
{ signal }: Pick<RequestData, 'signal'> = {},
271+
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
263272
) {
264273
return this.rest.put(Routes.applicationGuildCommands(applicationId, guildId), {
274+
auth,
265275
body,
266276
signal,
267277
}) as Promise<RESTPutAPIApplicationGuildCommandsResult>;
@@ -280,9 +290,10 @@ export class ApplicationCommandsAPI {
280290
applicationId: Snowflake,
281291
guildId: Snowflake,
282292
commandId: Snowflake,
283-
{ signal }: Pick<RequestData, 'signal'> = {},
293+
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
284294
) {
285295
return this.rest.get(Routes.applicationCommandPermissions(applicationId, guildId, commandId), {
296+
auth,
286297
signal,
287298
}) as Promise<RESTGetAPIApplicationCommandPermissionsResult>;
288299
}
@@ -298,9 +309,10 @@ export class ApplicationCommandsAPI {
298309
public async getGuildCommandsPermissions(
299310
applicationId: Snowflake,
300311
guildId: Snowflake,
301-
{ signal }: Pick<RequestData, 'signal'> = {},
312+
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
302313
) {
303314
return this.rest.get(Routes.guildApplicationCommandsPermissions(applicationId, guildId), {
315+
auth,
304316
signal,
305317
}) as Promise<RESTGetAPIGuildApplicationCommandsPermissionsResult>;
306318
}

packages/core/src/api/applications.ts

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export class ApplicationsAPI {
2424
* @see {@link https://discord.com/developers/docs/resources/application#get-current-application}
2525
* @param options - The options for fetching the application
2626
*/
27-
public async getCurrent({ signal }: Pick<RequestData, 'signal'> = {}) {
28-
return this.rest.get(Routes.currentApplication(), { signal }) as Promise<RESTGetCurrentApplicationResult>;
27+
public async getCurrent({ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {}) {
28+
return this.rest.get(Routes.currentApplication(), { auth, signal }) as Promise<RESTGetCurrentApplicationResult>;
2929
}
3030

3131
/**
@@ -35,8 +35,12 @@ export class ApplicationsAPI {
3535
* @param body - The new application data
3636
* @param options - The options for editing the application
3737
*/
38-
public async editCurrent(body: RESTPatchCurrentApplicationJSONBody, { signal }: Pick<RequestData, 'signal'> = {}) {
38+
public async editCurrent(
39+
body: RESTPatchCurrentApplicationJSONBody,
40+
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
41+
) {
3942
return this.rest.patch(Routes.currentApplication(), {
43+
auth,
4044
body,
4145
signal,
4246
}) as Promise<RESTPatchCurrentApplicationResult>;
@@ -49,8 +53,9 @@ export class ApplicationsAPI {
4953
* @param applicationId - The id of the application to fetch the emojis of
5054
* @param options - The options for fetching the emojis
5155
*/
52-
public async getEmojis(applicationId: Snowflake, { signal }: Pick<RequestData, 'signal'> = {}) {
56+
public async getEmojis(applicationId: Snowflake, { auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {}) {
5357
return this.rest.get(Routes.applicationEmojis(applicationId), {
58+
auth,
5459
signal,
5560
}) as Promise<RESTGetAPIApplicationEmojisResult>;
5661
}
@@ -63,8 +68,13 @@ export class ApplicationsAPI {
6368
* @param emojiId - The id of the emoji to fetch
6469
* @param options - The options for fetching the emoji
6570
*/
66-
public async getEmoji(applicationId: Snowflake, emojiId: Snowflake, { signal }: Pick<RequestData, 'signal'> = {}) {
71+
public async getEmoji(
72+
applicationId: Snowflake,
73+
emojiId: Snowflake,
74+
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
75+
) {
6776
return this.rest.get(Routes.applicationEmoji(applicationId, emojiId), {
77+
auth,
6878
signal,
6979
}) as Promise<RESTGetAPIApplicationEmojiResult>;
7080
}
@@ -80,9 +90,10 @@ export class ApplicationsAPI {
8090
public async createEmoji(
8191
applicationId: Snowflake,
8292
body: RESTPostAPIApplicationEmojiJSONBody,
83-
{ signal }: Pick<RequestData, 'signal'> = {},
93+
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
8494
) {
8595
return this.rest.post(Routes.applicationEmojis(applicationId), {
96+
auth,
8697
body,
8798
signal,
8899
}) as Promise<RESTPostAPIApplicationEmojiResult>;
@@ -101,9 +112,10 @@ export class ApplicationsAPI {
101112
applicationId: Snowflake,
102113
emojiId: Snowflake,
103114
body: RESTPatchAPIApplicationEmojiJSONBody,
104-
{ signal }: Pick<RequestData, 'signal'> = {},
115+
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
105116
) {
106117
return this.rest.patch(Routes.applicationEmoji(applicationId, emojiId), {
118+
auth,
107119
body,
108120
signal,
109121
}) as Promise<RESTPatchAPIApplicationEmojiResult>;
@@ -117,7 +129,11 @@ export class ApplicationsAPI {
117129
* @param emojiId - The id of the emoji to delete
118130
* @param options - The options for deleting the emoji
119131
*/
120-
public async deleteEmoji(applicationId: Snowflake, emojiId: Snowflake, { signal }: Pick<RequestData, 'signal'> = {}) {
121-
await this.rest.delete(Routes.applicationEmoji(applicationId, emojiId), { signal });
132+
public async deleteEmoji(
133+
applicationId: Snowflake,
134+
emojiId: Snowflake,
135+
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
136+
) {
137+
await this.rest.delete(Routes.applicationEmoji(applicationId, emojiId), { auth, signal });
122138
}
123139
}

0 commit comments

Comments
 (0)