mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 09:33:32 +01:00
feat: add auth option in api methods (#10717)
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: Denis-Adrian Cristea <didinele.dev@gmail.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -42,9 +42,10 @@ export class ApplicationCommandsAPI {
|
||||
public async getGlobalCommands(
|
||||
applicationId: Snowflake,
|
||||
query: RESTGetAPIApplicationCommandsQuery = {},
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
|
||||
) {
|
||||
return this.rest.get(Routes.applicationCommands(applicationId), {
|
||||
auth,
|
||||
query: makeURLSearchParams(query),
|
||||
signal,
|
||||
}) as Promise<RESTGetAPIApplicationCommandsResult>;
|
||||
@@ -61,9 +62,10 @@ export class ApplicationCommandsAPI {
|
||||
public async createGlobalCommand(
|
||||
applicationId: Snowflake,
|
||||
body: RESTPostAPIApplicationCommandsJSONBody,
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
|
||||
) {
|
||||
return this.rest.post(Routes.applicationCommands(applicationId), {
|
||||
auth,
|
||||
body,
|
||||
signal,
|
||||
}) as Promise<RESTPostAPIApplicationCommandsResult>;
|
||||
@@ -80,9 +82,10 @@ export class ApplicationCommandsAPI {
|
||||
public async getGlobalCommand(
|
||||
applicationId: Snowflake,
|
||||
commandId: Snowflake,
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
|
||||
) {
|
||||
return this.rest.get(Routes.applicationCommand(applicationId, commandId), {
|
||||
auth,
|
||||
signal,
|
||||
}) as Promise<RESTGetAPIApplicationCommandResult>;
|
||||
}
|
||||
@@ -100,9 +103,10 @@ export class ApplicationCommandsAPI {
|
||||
applicationId: Snowflake,
|
||||
commandId: Snowflake,
|
||||
body: RESTPatchAPIApplicationCommandJSONBody,
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
|
||||
) {
|
||||
return this.rest.patch(Routes.applicationCommand(applicationId, commandId), {
|
||||
auth,
|
||||
body,
|
||||
signal,
|
||||
}) as Promise<RESTPatchAPIApplicationCommandResult>;
|
||||
@@ -119,9 +123,9 @@ export class ApplicationCommandsAPI {
|
||||
public async deleteGlobalCommand(
|
||||
applicationId: Snowflake,
|
||||
commandId: Snowflake,
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
|
||||
) {
|
||||
await this.rest.delete(Routes.applicationCommand(applicationId, commandId), { signal });
|
||||
await this.rest.delete(Routes.applicationCommand(applicationId, commandId), { auth, signal });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,9 +139,10 @@ export class ApplicationCommandsAPI {
|
||||
public async bulkOverwriteGlobalCommands(
|
||||
applicationId: Snowflake,
|
||||
body: RESTPutAPIApplicationCommandsJSONBody,
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
|
||||
) {
|
||||
return this.rest.put(Routes.applicationCommands(applicationId), {
|
||||
auth,
|
||||
body,
|
||||
signal,
|
||||
}) as Promise<RESTPutAPIApplicationCommandsResult>;
|
||||
@@ -156,9 +161,10 @@ export class ApplicationCommandsAPI {
|
||||
applicationId: Snowflake,
|
||||
guildId: Snowflake,
|
||||
query: RESTGetAPIApplicationGuildCommandsQuery = {},
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
|
||||
) {
|
||||
return this.rest.get(Routes.applicationGuildCommands(applicationId, guildId), {
|
||||
auth,
|
||||
query: makeURLSearchParams(query),
|
||||
signal,
|
||||
}) as Promise<RESTGetAPIApplicationGuildCommandsResult>;
|
||||
@@ -177,9 +183,10 @@ export class ApplicationCommandsAPI {
|
||||
applicationId: Snowflake,
|
||||
guildId: Snowflake,
|
||||
body: RESTPostAPIApplicationGuildCommandsJSONBody,
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
|
||||
) {
|
||||
return this.rest.post(Routes.applicationGuildCommands(applicationId, guildId), {
|
||||
auth,
|
||||
body,
|
||||
signal,
|
||||
}) as Promise<RESTPostAPIApplicationGuildCommandsResult>;
|
||||
@@ -198,9 +205,10 @@ export class ApplicationCommandsAPI {
|
||||
applicationId: Snowflake,
|
||||
guildId: Snowflake,
|
||||
commandId: Snowflake,
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
|
||||
) {
|
||||
return this.rest.get(Routes.applicationGuildCommand(applicationId, guildId, commandId), {
|
||||
auth,
|
||||
signal,
|
||||
}) as Promise<RESTGetAPIApplicationGuildCommandResult>;
|
||||
}
|
||||
@@ -220,9 +228,10 @@ export class ApplicationCommandsAPI {
|
||||
guildId: Snowflake,
|
||||
commandId: Snowflake,
|
||||
body: RESTPatchAPIApplicationGuildCommandJSONBody,
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
|
||||
) {
|
||||
return this.rest.patch(Routes.applicationGuildCommand(applicationId, guildId, commandId), {
|
||||
auth,
|
||||
body,
|
||||
signal,
|
||||
}) as Promise<RESTPatchAPIApplicationGuildCommandResult>;
|
||||
@@ -241,9 +250,9 @@ export class ApplicationCommandsAPI {
|
||||
applicationId: Snowflake,
|
||||
guildId: Snowflake,
|
||||
commandId: Snowflake,
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
|
||||
) {
|
||||
await this.rest.delete(Routes.applicationGuildCommand(applicationId, guildId, commandId), { signal });
|
||||
await this.rest.delete(Routes.applicationGuildCommand(applicationId, guildId, commandId), { auth, signal });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -259,9 +268,10 @@ export class ApplicationCommandsAPI {
|
||||
applicationId: Snowflake,
|
||||
guildId: Snowflake,
|
||||
body: RESTPutAPIApplicationGuildCommandsJSONBody,
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
|
||||
) {
|
||||
return this.rest.put(Routes.applicationGuildCommands(applicationId, guildId), {
|
||||
auth,
|
||||
body,
|
||||
signal,
|
||||
}) as Promise<RESTPutAPIApplicationGuildCommandsResult>;
|
||||
@@ -280,9 +290,10 @@ export class ApplicationCommandsAPI {
|
||||
applicationId: Snowflake,
|
||||
guildId: Snowflake,
|
||||
commandId: Snowflake,
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
|
||||
) {
|
||||
return this.rest.get(Routes.applicationCommandPermissions(applicationId, guildId, commandId), {
|
||||
auth,
|
||||
signal,
|
||||
}) as Promise<RESTGetAPIApplicationCommandPermissionsResult>;
|
||||
}
|
||||
@@ -298,9 +309,10 @@ export class ApplicationCommandsAPI {
|
||||
public async getGuildCommandsPermissions(
|
||||
applicationId: Snowflake,
|
||||
guildId: Snowflake,
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {},
|
||||
) {
|
||||
return this.rest.get(Routes.guildApplicationCommandsPermissions(applicationId, guildId), {
|
||||
auth,
|
||||
signal,
|
||||
}) as Promise<RESTGetAPIGuildApplicationCommandsPermissionsResult>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user