From c8825886ea524809c4e366748c81a9bcaeb330c7 Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Fri, 25 Aug 2023 10:33:33 +0100 Subject: [PATCH] feat: Implement `GET` current application (#9797) * feat: implement current application route * refactor: pluralisation Co-authored-by: Suneet Tipirneni <77477100+suneettipirneni@users.noreply.github.com> --------- Co-authored-by: Suneet Tipirneni <77477100+suneettipirneni@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- packages/core/src/api/applications.ts | 18 ++++++++++++++++++ packages/core/src/api/index.ts | 5 +++++ 2 files changed, 23 insertions(+) create mode 100644 packages/core/src/api/applications.ts diff --git a/packages/core/src/api/applications.ts b/packages/core/src/api/applications.ts new file mode 100644 index 0000000000000..1bf8622ae9d9f --- /dev/null +++ b/packages/core/src/api/applications.ts @@ -0,0 +1,18 @@ +/* eslint-disable jsdoc/check-param-names */ + +import type { RequestData, REST } from '@discordjs/rest'; +import { type RESTGetCurrentApplicationResult, Routes } from 'discord-api-types/v10'; + +export class ApplicationsAPI { + public constructor(private readonly rest: REST) {} + + /** + * Fetches the application associated with the requesting bot user. + * + * @see {@link https://discord.com/developers/docs/resources/application#get-current-application} + * @param options - The options for editing the application + */ + public async getCurrent({ signal }: Pick = {}) { + return this.rest.get(Routes.currentApplication(), { signal }) as Promise; + } +} diff --git a/packages/core/src/api/index.ts b/packages/core/src/api/index.ts index 01812a65ce728..dec7f5e8d2cab 100644 --- a/packages/core/src/api/index.ts +++ b/packages/core/src/api/index.ts @@ -1,5 +1,6 @@ import type { REST } from '@discordjs/rest'; import { ApplicationCommandsAPI } from './applicationCommands.js'; +import { ApplicationsAPI } from './applications.js'; import { ChannelsAPI } from './channel.js'; import { GuildsAPI } from './guild.js'; import { InteractionsAPI } from './interactions.js'; @@ -14,6 +15,7 @@ import { VoiceAPI } from './voice.js'; import { WebhooksAPI } from './webhook.js'; export * from './applicationCommands.js'; +export * from './applications.js'; export * from './channel.js'; export * from './guild.js'; export * from './interactions.js'; @@ -30,6 +32,8 @@ export * from './webhook.js'; export class API { public readonly applicationCommands: ApplicationCommandsAPI; + public readonly applications: ApplicationsAPI; + public readonly channels: ChannelsAPI; public readonly guilds: GuildsAPI; @@ -56,6 +60,7 @@ export class API { public constructor(public readonly rest: REST) { this.applicationCommands = new ApplicationCommandsAPI(rest); + this.applications = new ApplicationsAPI(rest); this.channels = new ChannelsAPI(rest); this.guilds = new GuildsAPI(rest); this.invites = new InvitesAPI(rest);