UNPKG

oceanic.js

Version:

A NodeJS library for interfacing with Discord.

232 lines (231 loc) 12.4 kB
import type { AnyApplicationCommand, ApplicationCommandOptionConversion, CreateApplicationCommandOptions, EditApplicationCommandOptions, EditApplicationCommandPermissionsOptions, RESTGuildApplicationCommandPermissions, CreateGuildApplicationCommandOptions, EditGuildApplicationCommandOptions, GetApplicationCommandOptions, CreateTestEntitlementOptions, SearchEntitlementsOptions } from "../types/applications"; import ApplicationCommand from "../structures/ApplicationCommand"; import type RESTManager from "../rest/RESTManager"; import SKU from "../structures/SKU"; import Entitlement from "../structures/Entitlement"; import TestEntitlement from "../structures/TestEntitlement"; import ClientApplication from "../structures/ClientApplication"; import type { ActivityInstance, ApplicationEmoji, ApplicationEmojis, CreateApplicationEmojiOptions, EditApplicationEmojiOptions, EditApplicationOptions, SearchSKUSubscriptions } from "../types"; import Application from "../structures/Application"; import Subscription from "../structures/Subscription"; /** Various methods for interacting with application commands. Located at {@link Client#rest | Client#rest}{@link RESTManager#applications | .applications}. */ export default class Applications { private _manager; constructor(manager: RESTManager); /** * Overwrite all existing global application commands. * @param applicationID The ID of the application. * @param options The commands. * @caching This method **does not** cache its result. */ bulkEditGlobalCommands(applicationID: string, options: Array<CreateApplicationCommandOptions>): Promise<Array<ApplicationCommand>>; /** * Overwrite all existing application commands in a guild. * @param applicationID The ID of the application. * @param guildID The ID of the guild. * @param options The commands. * @caching This method **does not** cache its result. */ bulkEditGuildCommands(applicationID: string, guildID: string, options: Array<CreateGuildApplicationCommandOptions>): Promise<Array<ApplicationCommand>>; /** * Mark an entitlement as consumed. * @param applicationID The ID of the application to the entitlement is for. * @param entitlementID The ID of the entitlement to consume. */ consumeEntitlement(applicationID: string, entitlementID: string): Promise<void>; /** * Create an emoji for an application. * @param applicationID The ID of the application. * @param options The options for creating the emoji. * @caching This method **does not** cache its result. */ createEmoji(applicationID: string, options: CreateApplicationEmojiOptions): Promise<ApplicationEmoji>; /** * Create a global application command. * @param applicationID The ID of the application. * @param options The options for the command. * @caching This method **does not** cache its result. */ createGlobalCommand<T extends CreateApplicationCommandOptions = CreateApplicationCommandOptions>(applicationID: string, options: T): Promise<ApplicationCommandOptionConversion<T>>; /** * Create a guild application command. * @param applicationID The ID of the application. * @param guildID The ID of the guild. * @param options The options for the command. * @caching This method **does not** cache its result. */ createGuildCommand<T extends CreateGuildApplicationCommandOptions = CreateGuildApplicationCommandOptions>(applicationID: string, guildID: string, options: T): Promise<ApplicationCommandOptionConversion<T>>; /** * Create a test entitlement. * @param applicationID The ID of the application to create the entitlement for. * @param options The options for creating the test entitlement. */ createTestEntitlement(applicationID: string, options: CreateTestEntitlementOptions): Promise<TestEntitlement>; /** * Delete an emoji for an application. * @param applicationID The ID of the application. * @param emojiID The ID of the emoji to be deleted. * @caching This method **does not** cache its result. */ deleteEmoji(applicationID: string, emojiID: string): Promise<void>; /** * Delete a global application command. * @param applicationID The ID of the application. * @param commandID The ID the command to delete. * @caching This method **does not** cache its result. */ deleteGlobalCommand(applicationID: string, commandID: string): Promise<void>; /** * Delete a guild application command. * @param applicationID The ID of the application. * @param guildID The ID of the guild. * @param commandID The ID of the command to delete. * @caching This method **does not** cache its result. */ deleteGuildCommand(applicationID: string, guildID: string, commandID: string): Promise<void>; /** * Delete an entitlement. * @param applicationID The ID of the application to delete the entitlement from. * @param entitlementID The ID of the entitlement to delete. */ deleteTestEntitlement(applicationID: string, entitlementID: string): Promise<void>; /** * Edit the currently authenticated bot's application info. * @param options The options for editing the application. * @caching This method **does not** cache its result. */ editCurrent(options: EditApplicationOptions): Promise<Application>; /** * Edit an existing emoji for an application. * @param applicationID The ID of the 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(applicationID: string, emojiID: string, options: EditApplicationEmojiOptions): Promise<ApplicationEmoji>; /** * Edit a global application command. * @param applicationID The ID of the application. * @param commandID The ID of the command to edit. * @param options The options for editing the command. * @caching This method **does not** cache its result. */ editGlobalCommand<T extends EditApplicationCommandOptions = EditApplicationCommandOptions>(applicationID: string, commandID: string, options: T): Promise<ApplicationCommandOptionConversion<T>>; /** * Edit a guild application command. * @param applicationID The ID of the application. * @param guildID The ID of the guild. * @param commandID The ID of the command to edit. * @param options The options for editing the command. * @caching This method **does not** cache its result. */ editGuildCommand<T extends EditGuildApplicationCommandOptions = EditGuildApplicationCommandOptions>(applicationID: string, 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 applicationID The ID of the application. * @param guildID The ID of the guild. * @param commandID The ID of the command. * @param options The options for editing the permissions. * @caching This method **does not** cache its result. */ editGuildCommandPermissions(applicationID: string, guildID: string, commandID: string, options: EditApplicationCommandPermissionsOptions): Promise<RESTGuildApplicationCommandPermissions>; /** * Get an activity instance. * @param applicationID The ID of the application. * @param instanceID The ID of the instance. */ getActivityInstance(applicationID: string, instanceID: string): Promise<ActivityInstance>; /** * Get the currently authenticated bot's application info as a bare {@link ClientApplication | ClientApplication}. * @caching This method **does not** cache its result. */ getClient(): Promise<ClientApplication>; /** * Get the currently authenticated bot's application info. * @caching This method **does not** cache its result. */ getCurrent(): Promise<Application>; /** * Get an emoji for an application. * @param applicationID The ID of the application to get the emojis of. * @param emojiID The ID of the emoji to get. * @caching This method **does not** cache its result. */ getEmoji(applicationID: string, emojiID: string): Promise<ApplicationEmoji>; /** * Get the emojis for an application. * @param applicationID The ID of the application to get the emojis of. * @caching This method **does not** cache its result. */ getEmojis(applicationID: string): Promise<ApplicationEmojis>; /** * Get the entitlements for an application. * @param applicationID The ID of the application to get the entitlements of. * @param options The options for getting the entitlements. */ getEntitlements(applicationID: string, options?: SearchEntitlementsOptions): Promise<Array<Entitlement | TestEntitlement>>; /** * Get a global application command. * @param applicationID The ID of the application. * @param commandID The ID of the command. * @param options The options for getting the command. * @caching This method **does not** cache its result. */ getGlobalCommand<T extends AnyApplicationCommand = AnyApplicationCommand>(applicationID: string, commandID: string, options?: GetApplicationCommandOptions): Promise<T>; /** * Get an application's global commands. * @param applicationID The ID of the application. * @param options The options for getting the command. * @caching This method **does not** cache its result. */ getGlobalCommands(applicationID: string, options?: GetApplicationCommandOptions): Promise<Array<AnyApplicationCommand>>; /** * Get a global application command. * @param applicationID The ID of the application. * @param guildID The ID of the guild. * @param commandID The ID of the command. * @param options The options for getting the command. * @caching This method **does not** cache its result. */ getGuildCommand<T extends AnyApplicationCommand = AnyApplicationCommand>(applicationID: string, guildID: string, commandID: string, options?: GetApplicationCommandOptions): Promise<T>; /** * Get an application's application commands in a specific guild. * @param applicationID The ID of the application. * @param guildID The ID of the guild. * @param options The options for getting the command. * @caching This method **does not** cache its result. */ getGuildCommands(applicationID: string, guildID: string, options?: GetApplicationCommandOptions): Promise<Array<AnyApplicationCommand>>; /** * Get an application command's permissions in a guild. * @param applicationID The ID of the application. * @param guildID The ID of the guild. * @param commandID The ID of the command. * @caching This method **does not** cache its result. */ getGuildPermission(applicationID: string, guildID: string, commandID: string): Promise<RESTGuildApplicationCommandPermissions>; /** * Get the permissions for all application commands in a guild. * @param applicationID The ID of the application. * @param guildID The ID of the guild. * @caching This method **does not** cache its result. */ getGuildPermissions(applicationID: string, guildID: string): Promise<Array<RESTGuildApplicationCommandPermissions>>; /** * Get the subscription for an SKU. * @param skuID The ID of the SKU to get the subscription of. * @param subscriptionID The ID of the subscription to get. */ getSKUSubscription(skuID: string, subscriptionID: string): Promise<Subscription>; /** * Get the subscriptions for an SKU. * @param skuID The ID of the SKU to get the subscriptions of. * @param options The options for getting the subscriptions. */ getSKUSubscriptions(skuID: string, options: SearchSKUSubscriptions): Promise<Array<Subscription>>; /** * Get the SKUs for an application. * @param applicationID The ID of the application to get the SKUs of. */ getSKUs(applicationID: string): Promise<Array<SKU>>; }