Skip to content

Commit

Permalink
feat: add to core
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiralite committed Oct 7, 2023
1 parent da4ef0f commit 3931d8a
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion packages/core/src/api/applications.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
/* eslint-disable jsdoc/check-param-names */

import type { RequestData, REST } from '@discordjs/rest';
import { type RESTGetCurrentApplicationResult, Routes } from 'discord-api-types/v10';
import {
type RESTGetCurrentApplicationResult,
// @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) {}
Expand All @@ -15,4 +22,18 @@ export class ApplicationsAPI {
public async getCurrent({ signal }: Pick<RequestData, 'signal'> = {}) {
return this.rest.get(Routes.currentApplication(), { signal }) as Promise<RESTGetCurrentApplicationResult>;
}

/**
* 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 editCurrent(body: RESTPatchCurrentApplicationJSONBody, { signal }: Pick<RequestData, 'signal'> = {}) {
return this.rest.patch(Routes.currentApplication(), {
body,
signal,
}) as Promise<RESTPatchCurrentApplicationResult>;
}
}

0 comments on commit 3931d8a

Please sign in to comment.