@oceanicjs/builders
Version:
Helpful builders for various Discord related things.
53 lines (52 loc) • 2.98 kB
TypeScript
import ApplicationCommandOptionBuilder from "./ApplicationCommandOptionBuilder";
import { ApplicationCommandOptions, ApplicationCommandOptionTypes, ApplicationCommandTypes, CreateApplicationCommandOptions, Permission, PermissionName } from "oceanic.js";
export default class ApplicationCommandBuilder<T extends ApplicationCommandTypes = ApplicationCommandTypes> {
defaultMemberPermissions?: string;
description?: string;
descriptionLocalizations?: Record<string, string>;
dmPermission?: boolean;
name: string;
nameLocalizations?: Record<string, string>;
options: Array<ApplicationCommandOptions>;
type: T;
constructor(type: T, name: string);
/**
* Add a description localization.
* @param locale The [locale](https://discord.com/developers/docs/reference#locales) of the localization.
* @param description The localized description.
*/
addDescriptionLocalization(locale: string, description: string): this;
/**
* Add a name localization.
* @param locale The [locale](https://discord.com/developers/docs/reference#locales) of the localization.
* @param name The localized name.
*/
addNameLocalization(locale: string, name: string): this;
/** Add an option. */
addOption<O extends ApplicationCommandOptionTypes = ApplicationCommandOptionTypes>(option: ApplicationCommandOptionBuilder<O> | ApplicationCommandOptions): this;
addOption<O extends ApplicationCommandOptionTypes = ApplicationCommandOptionTypes>(name: string, type: O, extra?: ((this: ApplicationCommandBuilder<T>, option: ApplicationCommandOptionBuilder<O>) => void) | ApplicationCommandOptions): this;
/** Allow this command to be used in direct messages. */
allowDMUsage(): this;
/** Disallow this command from being used in direct messages. */
disallowDMUsage(): this;
/** Set if this command can be used in direct messages. */
setDMPermission(dmPermission: boolean): this;
/** Set the default permissions required to use this command. */
setDefaultMemberPermissions(...permissions: [bigint | string | Permission | Array<PermissionName>] | Array<PermissionName>): this;
/** Set the description of this command. */
setDescription(description: string): this;
/**
* Set the description localizations for this command.
* @param localizations A map of [locales](https://discord.com/developers/docs/reference#locales) to localized description strings.
*/
setDescriptionLocalizations(localizations: Record<string, string>): this;
/** Set the name of this command.*/
setName(name: string): this;
/**
* Set the name localizations for this command.
* @param localizations A map of [locales](https://discord.com/developers/docs/reference#locales) to localized name strings.
*/
setNameLocalizations(localizations: Record<string, string>): this;
/** Convert this command to JSON. */
toJSON(): CreateApplicationCommandOptions;
}