From 3f7a969b8c2064e3c426121e49993c0e69432103 Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Tue, 22 Aug 2023 18:52:16 +0100 Subject: [PATCH] feat: add to core --- packages/core/src/api/application.ts | 28 ++++++++++++++++++++++++++++ packages/core/src/api/index.ts | 5 +++++ 2 files changed, 33 insertions(+) create mode 100644 packages/core/src/api/application.ts diff --git a/packages/core/src/api/application.ts b/packages/core/src/api/application.ts new file mode 100644 index 0000000000000..892d76de9c522 --- /dev/null +++ b/packages/core/src/api/application.ts @@ -0,0 +1,28 @@ +/* eslint-disable jsdoc/check-param-names */ + +import type { RequestData, REST } from '@discordjs/rest'; +import { + // @ts-expect-error discord-api-types + type RESTPatchCurrentApplicationJSONBody, + // @ts-expect-error discord-api-types + type RESTPatchCurrentApplicationResult, + Routes, +} from 'discord-api-types/v10'; + +export class ApplicationsAPI { + public constructor(private readonly rest: REST) {} + + /** + * Edits properties of the application associated with the requesting bot user. + * + * @see {@link https://discord.com/developers/docs/resources/application#edit-current-application} + * @param body - The new application data + * @param options - The options for editing the application + */ + public async edit(body: RESTPatchCurrentApplicationJSONBody, { signal }: Pick = {}) { + return this.rest.patch(Routes.currentApplication(), { + body, + signal, + }) as Promise; + } +} diff --git a/packages/core/src/api/index.ts b/packages/core/src/api/index.ts index 01812a65ce728..a1a13bbfbcedd 100644 --- a/packages/core/src/api/index.ts +++ b/packages/core/src/api/index.ts @@ -1,4 +1,5 @@ import type { REST } from '@discordjs/rest'; +import { ApplicationsAPI } from './application.js'; import { ApplicationCommandsAPI } from './applicationCommands.js'; import { ChannelsAPI } from './channel.js'; import { GuildsAPI } from './guild.js'; @@ -13,6 +14,7 @@ import { UsersAPI } from './user.js'; import { VoiceAPI } from './voice.js'; import { WebhooksAPI } from './webhook.js'; +export * from './application.js'; export * from './applicationCommands.js'; export * from './channel.js'; export * from './guild.js'; @@ -28,6 +30,8 @@ export * from './voice.js'; export * from './webhook.js'; export class API { + public readonly application: ApplicationsAPI; + public readonly applicationCommands: ApplicationCommandsAPI; public readonly channels: ChannelsAPI; @@ -55,6 +59,7 @@ export class API { public readonly webhooks: WebhooksAPI; public constructor(public readonly rest: REST) { + this.application = new ApplicationsAPI(rest); this.applicationCommands = new ApplicationCommandsAPI(rest); this.channels = new ChannelsAPI(rest); this.guilds = new GuildsAPI(rest);