Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement GET current application #9797

Merged
merged 3 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/core/src/api/applications.ts
Original file line number Diff line number Diff line change
@@ -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<RequestData, 'signal'> = {}) {
return this.rest.get(Routes.currentApplication(), { signal }) as Promise<RESTGetCurrentApplicationResult>;
}
}
5 changes: 5 additions & 0 deletions packages/core/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';
Expand All @@ -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;
Expand All @@ -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);
Expand Down