oceanic.js
Version:
A NodeJS library for interfacing with Discord.
192 lines (191 loc) • 9.68 kB
TypeScript
/** @module ClientApplication */
import Base from "./Base";
import type ApplicationCommand from "./ApplicationCommand";
import TestEntitlement from "./TestEntitlement";
import Entitlement from "./Entitlement";
import type SKU from "./SKU";
import type Application from "./Application";
import type Client from "../Client";
import type { RoleConnection, RoleConnectionMetadata, UpdateUserApplicationRoleConnectionOptions } from "../types/oauth";
import type { AnyApplicationCommand, ApplicationCommandOptionConversion, CreateApplicationCommandOptions, CreateGuildApplicationCommandOptions, EditApplicationCommandOptions, EditApplicationCommandPermissionsOptions, EditGuildApplicationCommandOptions, GetApplicationCommandOptions, RESTGuildApplicationCommandPermissions, CreateTestEntitlementOptions, RawEntitlement, RawTestEntitlement, SearchEntitlementsOptions, RawClientApplication, EditApplicationOptions, ApplicationEmoji, ApplicationEmojis, CreateApplicationEmojiOptions, EditApplicationEmojiOptions, ActivityInstance } from "../types/applications";
import type { JSONClientApplication } from "../types/json";
import type { ApplicationCommandTypes } from "../Constants";
import TypedCollection from "../util/TypedCollection";
/** A representation of the authorized client's application (typically received via gateway). */
export default class ClientApplication extends Base {
/** The entitlements for this application. This will almost certainly be empty unless you fetch entitlements, or recieve new/updated entitlements. */
entitlements: TypedCollection<RawEntitlement | RawTestEntitlement, Entitlement | TestEntitlement>;
/** This application's [flags](https://discord.com/developers/docs/resources/application#application-object-application-flags). */
flags: number;
constructor(data: RawClientApplication, client: Client);
protected update(data: Partial<RawClientApplication>): void;
/**
* Overwrite all existing global application commands.
* @param options The commands.
*/
bulkEditGlobalCommands(options: Array<CreateApplicationCommandOptions>): Promise<Array<ApplicationCommand<ApplicationCommandTypes>>>;
/**
* Overwrite all existing application commands in a guild.
* @param guildID The ID of the guild.
* @param options The commands.
*/
bulkEditGuildCommands(guildID: string, options: Array<CreateGuildApplicationCommandOptions>): Promise<Array<ApplicationCommand<ApplicationCommandTypes>>>;
/**
* Mark an entitlement as consumed.
* @param entitlementID The ID of the entitlement to consume.
*/
consumeEntitlement(entitlementID: string): Promise<void>;
/**
* Create an emoji for this application.
* @param options The options for creating the emoji.
* @caching This method **does not** cache its result.
*/
createEmoji(options: CreateApplicationEmojiOptions): Promise<ApplicationEmoji>;
/**
* Create a global application command.
* @param options The options for creating the command.
*/
createGlobalCommand<T extends CreateApplicationCommandOptions = CreateApplicationCommandOptions>(options: T): Promise<ApplicationCommandOptionConversion<T>>;
/**
* Create a guild application command.
* @param guildID The ID of the guild.
* @param options The options for creating the command.
*/
createGuildCommand<T extends CreateGuildApplicationCommandOptions = CreateGuildApplicationCommandOptions>(guildID: string, options: T): Promise<ApplicationCommandOptionConversion<T>>;
/**
* Create a test entitlement.
* @param options The options for creating the test entitlement.
*/
createTestEntitlement(options: CreateTestEntitlementOptions): Promise<TestEntitlement>;
/**
* Delete an emoji for this application.
* @param emojiID The ID of the emoji to be deleted.
* @caching This method **does not** cache its result.
*/
deleteEmoji(emojiID: string): Promise<void>;
/**
* Delete a global application command.
* @param commandID The ID of the command.
*/
deleteGlobalCommand(commandID: string): Promise<void>;
/**
* Delete a guild application command.
* @param guildID The ID of the guild.
* @param commandID The ID of the command.
*/
deleteGuildCommand(guildID: string, commandID: string): Promise<void>;
/**
* Delete a test entitlement.
* @param entitlementID The ID of the entitlement to delete.
*/
deleteTestEntitlement(entitlementID: string): Promise<void>;
/**
* Edit this application.
* @param options The options for editing the application.
*/
edit(options: EditApplicationOptions): Promise<Application>;
/**
* Edit an existing emoji for this application.
* @param emojiID The ID of the emoji to be edited.
* @param options The options for editing the emoji.
* @caching This method **does not** cache its result.
*/
editEmoji(emojiID: string, options: EditApplicationEmojiOptions): Promise<ApplicationEmoji>;
/**
* Edit a global application command.
* @param commandID The ID of the command.
* @param options The options for editing the command.
*/
editGlobalCommand<T extends EditApplicationCommandOptions = EditApplicationCommandOptions>(commandID: string, options: T): Promise<ApplicationCommandOptionConversion<T>>;
/**
* Edit a guild application command.
* @param guildID The ID of the guild.
* @param commandID The ID of the command.
* @param options The options for editing the command.
*/
editGuildCommand<T extends EditGuildApplicationCommandOptions = EditGuildApplicationCommandOptions>(guildID: string, commandID: string, options: T): Promise<ApplicationCommandOptionConversion<T>>;
/**
* Edit a guild application command's permissions. This requires a bearer token with the `applications.commands.permissions.update` scope.
* @param guildID The ID of the guild.
* @param commandID The ID of the command.
* @param options The options for editing the permissions.
*/
editGuildCommandPermissions(guildID: string, commandID: string, options: EditApplicationCommandPermissionsOptions): Promise<RESTGuildApplicationCommandPermissions>;
/**
* Get an activity instance.
* @param instanceID The ID of the instance.
*/
getActivityInstance(instanceID: string): Promise<ActivityInstance>;
/**
* Get an emoji for this application.
* @param emojiID The ID of the emoji to get.
*/
getEmoji(emojiID: string): Promise<ApplicationEmoji>;
/**
* Get the emojis for this application.
*/
getEmojis(): Promise<ApplicationEmojis>;
/**
* Get the entitlements for this application.
* @param options The options for getting the entitlements.
*/
getEntitlements(options?: SearchEntitlementsOptions): Promise<Array<Entitlement | TestEntitlement>>;
/**
* Get a global application command.
* @param commandID The ID of the command.
* @param options The options for getting the command.
*/
getGlobalCommand<T extends AnyApplicationCommand = AnyApplicationCommand>(commandID: string, options?: GetApplicationCommandOptions): Promise<T>;
/**
* Get this application's global commands.
* @param options The options for getting the command.
*/
getGlobalCommands(options?: GetApplicationCommandOptions): Promise<Array<AnyApplicationCommand>>;
/**
* Get a global application command.
* @param guildID The ID of the guild.
* @param commandID The ID of the command.
* @param options The options for getting the command.
*/
getGuildCommand<T extends AnyApplicationCommand = AnyApplicationCommand>(guildID: string, commandID: string, options?: GetApplicationCommandOptions): Promise<T>;
/**
* Get this application's commands in a specific guild.
* @param guildID The ID of the guild.
* @param options The options for getting the command.
*/
getGuildCommands(guildID: string, options?: GetApplicationCommandOptions): Promise<Array<AnyApplicationCommand>>;
/**
* Get a command's permissions in a guild.
* @param guildID The ID of the guild.
* @param commandID The ID of the command.
*/
getGuildPermission(guildID: string, commandID: string): Promise<RESTGuildApplicationCommandPermissions>;
/**
* Get the permissions for all commands in a guild.
* @param guildID The ID of the guild.
*/
getGuildPermissions(guildID: string): Promise<Array<RESTGuildApplicationCommandPermissions>>;
/**
* Get this application's role connection metadata records.
*/
getRoleConnectionsMetadata(): Promise<Array<RoleConnectionMetadata>>;
/**
* Get the SKUs for this application.
*/
getSKUs(): Promise<Array<SKU>>;
/**
* Get the authenticated user's role connection object for this application. This requires the `role_connections.write` scope.
*/
getUserRoleConnection(): Promise<RoleConnection>;
toJSON(): JSONClientApplication;
/**
* Update this application's role connections metadata.
* @param metadata The metadata records.
*/
updateRoleConnectionsMetadata(metadata: Array<RoleConnectionMetadata>): Promise<Array<RoleConnectionMetadata>>;
/**
* Update the authenticated user's role connection object for an application. This requires the `role_connections.write` scope.
* @param data The metadata to update.
*/
updateUserRoleConnection(data: UpdateUserApplicationRoleConnectionOptions): Promise<RoleConnection>;
}