Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@discordjs/builders

Package Overview
Dependencies
Maintainers
2
Versions
1197
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@discordjs/builders - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

dist/interactions/slashCommands/options/number.d.ts

3

dist/index.d.ts

@@ -0,1 +1,3 @@

export * as EmbedAssertions from './messages/embed/Assertions';
export * from './messages/embed/Embed';
export * from './messages/formatters';

@@ -9,2 +11,3 @@ export * as SlashCommandAssertions from './interactions/slashCommands/Assertions';

export * from './interactions/slashCommands/options/mentionable';
export * from './interactions/slashCommands/options/number';
export * from './interactions/slashCommands/options/role';

@@ -11,0 +14,0 @@ export * from './interactions/slashCommands/options/string';

5

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SlashCommandAssertions = void 0;
exports.SlashCommandAssertions = exports.EmbedAssertions = void 0;
const tslib_1 = require("tslib");
exports.EmbedAssertions = tslib_1.__importStar(require("./messages/embed/Assertions"));
tslib_1.__exportStar(require("./messages/embed/Embed"), exports);
tslib_1.__exportStar(require("./messages/formatters"), exports);

@@ -13,2 +15,3 @@ exports.SlashCommandAssertions = tslib_1.__importStar(require("./interactions/slashCommands/Assertions"));

tslib_1.__exportStar(require("./interactions/slashCommands/options/mentionable"), exports);
tslib_1.__exportStar(require("./interactions/slashCommands/options/number"), exports);
tslib_1.__exportStar(require("./interactions/slashCommands/options/role"), exports);

@@ -15,0 +18,0 @@ tslib_1.__exportStar(require("./interactions/slashCommands/options/string"), exports);

@@ -8,2 +8,3 @@ import type { APIApplicationCommandOptionChoice } from 'discord-api-types/v9';

export declare function validateDescription(description: unknown): asserts description is string;
export declare function validateDefaultPermission(value: unknown): asserts value is boolean;
export declare function validateMaxOptionsLength(options: unknown): asserts options is ToAPIApplicationCommandOptions[];

@@ -10,0 +11,0 @@ export declare function validateMaxChoicesLength(choices: APIApplicationCommandOptionChoice[]): void;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.assertReturnOfBuilder = exports.validateMaxChoicesLength = exports.validateMaxOptionsLength = exports.validateDescription = exports.validateName = exports.validateRequiredParameters = void 0;
exports.assertReturnOfBuilder = exports.validateMaxChoicesLength = exports.validateMaxOptionsLength = exports.validateDefaultPermission = exports.validateDescription = exports.validateName = exports.validateRequiredParameters = void 0;
const tslib_1 = require("tslib");

@@ -32,2 +32,7 @@ const is_1 = tslib_1.__importDefault(require("@sindresorhus/is"));

exports.validateDescription = validateDescription;
const defaultPermissionPredicate = ow_1.default.boolean;
function validateDefaultPermission(value) {
ow_1.default(value, 'default_permission', defaultPermissionPredicate);
}
exports.validateDefaultPermission = validateDefaultPermission;
const maxArrayLengthPredicate = ow_1.default.array.maxLength(25);

@@ -34,0 +39,0 @@ function validateMaxOptionsLength(options) {

@@ -5,2 +5,3 @@ import { SlashCommandBooleanOption } from '../options/boolean';

import { SlashCommandMentionableOption } from '../options/mentionable';
import { SlashCommandNumberOption } from '../options/number';
import { SlashCommandRoleOption } from '../options/role';

@@ -47,4 +48,9 @@ import { SlashCommandStringOption } from '../options/string';

addIntegerOption(input: SlashCommandIntegerOption | ((builder: SlashCommandIntegerOption) => SlashCommandIntegerOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
/**
* Adds a number option
* @param input A function that returns an option builder, or an already built builder
*/
addNumberOption(input: SlashCommandNumberOption | ((builder: SlashCommandNumberOption) => SlashCommandNumberOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
private _sharedAddOptionMethod;
}
//# sourceMappingURL=CommandOptions.d.ts.map

@@ -9,2 +9,3 @@ "use strict";

const mentionable_1 = require("../options/mentionable");
const number_1 = require("../options/number");
const role_1 = require("../options/role");

@@ -71,2 +72,9 @@ const string_1 = require("../options/string");

}
/**
* Adds a number option
* @param input A function that returns an option builder, or an already built builder
*/
addNumberOption(input) {
return this._sharedAddOptionMethod(input, number_1.SlashCommandNumberOption);
}
_sharedAddOptionMethod(input, Instance) {

@@ -73,0 +81,0 @@ const { options } = this;

@@ -32,3 +32,3 @@ "use strict";

// Validate name
ow_1.default(name, `${this.type === 3 /* String */ ? 'string' : 'integer'} choice name`, stringPredicate);
ow_1.default(name, `${ApplicationCommandOptionTypeNames[this.type]} choice name`, stringPredicate);
// Validate the value

@@ -38,3 +38,3 @@ if (this.type === 3 /* String */)

else
ow_1.default(value, 'integer choice value', integerPredicate);
ow_1.default(value, `${ApplicationCommandOptionTypeNames[this.type]} choice value`, integerPredicate);
this.choices.push({ name, value });

@@ -48,3 +48,3 @@ return this;

addChoices(choices) {
ow_1.default(choices, `${this.type === 3 /* String */ ? 'string' : 'integer'} choices`, choicesPredicate);
ow_1.default(choices, `${ApplicationCommandOptionTypeNames[this.type]} choices`, choicesPredicate);
for (const [label, value] of choices)

@@ -62,2 +62,14 @@ this.addChoice(label, value);

exports.ApplicationCommandOptionWithChoicesBase = ApplicationCommandOptionWithChoicesBase;
const ApplicationCommandOptionTypeNames = {
[1 /* Subcommand */]: 'subcommand',
[2 /* SubcommandGroup */]: 'subcommand group',
[3 /* String */]: 'string',
[4 /* Integer */]: 'integer',
[5 /* Boolean */]: 'boolean',
[6 /* User */]: 'user',
[7 /* Channel */]: 'channel',
[8 /* Role */]: 'role',
[9 /* Mentionable */]: 'mentionable',
[10 /* Number */]: 'number',
};
//# sourceMappingURL=CommandOptionWithChoices.js.map
import type { APIApplicationCommandOption } from 'discord-api-types/v9';
import { SharedSlashCommandOptions } from './mixins/CommandOptions';
import { SharedNameAndDescription } from './mixins/NameAndDescription';
import { SharedSlashCommandOptions } from './mixins/CommandOptions';
import { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from './SlashCommandSubcommands';

@@ -19,2 +19,7 @@ export declare class SlashCommandBuilder {

/**
* Whether the command is enabled by default when the app is added to a guild
* @default true
*/
readonly defaultPermission: boolean | undefined;
/**
* Returns the final data that should be sent to Discord.

@@ -28,8 +33,18 @@ *

options: APIApplicationCommandOption[];
default_permission: boolean | undefined;
};
/**
* Sets whether the command is enabled by default when the application is added to a guild.
*
* **Note**: If set to `false`, you will have to later have to `PUT` the permissions for this command.
* @param value Whether or not to enable this command by default
*
* @see https://discord.com/developers/docs/interactions/slash-commands#permissions
*/
setDefaultPermission(value: boolean): this;
/**
* Adds a new subcommand group to this command
* @param input A function that returns a subcommand group builder, or an already built builder
*/
addSubcommandGroup(input: SlashCommandSubcommandGroupBuilder | ((subcommandGroup: SlashCommandSubcommandGroupBuilder) => SlashCommandSubcommandGroupBuilder)): SlashCommandSubcommandGroupsOnlyBuilder;
addSubcommandGroup(input: SlashCommandSubcommandGroupBuilder | ((subcommandGroup: SlashCommandSubcommandGroupBuilder) => SlashCommandSubcommandGroupBuilder)): SlashCommandSubcommandsOnlyBuilder;
/**

@@ -43,6 +58,4 @@ * Adds a new subcommand to this command

}
export interface SlashCommandSubcommandsOnlyBuilder extends SharedNameAndDescription, Pick<SlashCommandBuilder, 'toJSON' | 'addSubcommand'> {
export interface SlashCommandSubcommandsOnlyBuilder extends SharedNameAndDescription, Pick<SlashCommandBuilder, 'toJSON' | 'addSubcommand' | 'addSubcommandGroup'> {
}
export interface SlashCommandSubcommandGroupsOnlyBuilder extends SharedNameAndDescription, Pick<SlashCommandBuilder, 'toJSON' | 'addSubcommandGroup'> {
}
export interface SlashCommandOptionsOnlyBuilder extends SharedNameAndDescription, SharedSlashCommandOptions, Pick<SlashCommandBuilder, 'toJSON'> {

@@ -49,0 +62,0 @@ }

@@ -7,4 +7,4 @@ "use strict";

const Assertions_1 = require("./Assertions");
const CommandOptions_1 = require("./mixins/CommandOptions");
const NameAndDescription_1 = require("./mixins/NameAndDescription");
const CommandOptions_1 = require("./mixins/CommandOptions");
const SlashCommandSubcommands_1 = require("./SlashCommandSubcommands");

@@ -40,2 +40,12 @@ let SlashCommandBuilder = class SlashCommandBuilder {

});
/**
* Whether the command is enabled by default when the app is added to a guild
* @default true
*/
Object.defineProperty(this, "defaultPermission", {
enumerable: true,
configurable: true,
writable: true,
value: undefined
});
}

@@ -53,5 +63,20 @@ /**

options: this.options.map((option) => option.toJSON()),
default_permission: this.defaultPermission,
};
}
/**
* Sets whether the command is enabled by default when the application is added to a guild.
*
* **Note**: If set to `false`, you will have to later have to `PUT` the permissions for this command.
* @param value Whether or not to enable this command by default
*
* @see https://discord.com/developers/docs/interactions/slash-commands#permissions
*/
setDefaultPermission(value) {
// Assert the value matches the conditions
Assertions_1.validateDefaultPermission(value);
Reflect.set(this, 'defaultPermission', value);
return this;
}
/**
* Adds a new subcommand group to this command

@@ -64,6 +89,2 @@ * @param input A function that returns a subcommand group builder, or an already built builder

Assertions_1.validateMaxOptionsLength(options);
// Make sure there is no subcommand at the root level - if there is, throw
const hasSubcommands = options.some((item) => item instanceof SlashCommandSubcommands_1.SlashCommandSubcommandBuilder);
if (hasSubcommands)
throw new RangeError(`You cannot mix subcommands and subcommand groups at the root level.`);
// Get the final result

@@ -84,6 +105,2 @@ const result = typeof input === 'function' ? input(new SlashCommandSubcommands_1.SlashCommandSubcommandGroupBuilder()) : input;

Assertions_1.validateMaxOptionsLength(options);
// Make sure there is no subcommand at the root level - if there is, throw
const hasSubcommandGroups = options.some((item) => item instanceof SlashCommandSubcommands_1.SlashCommandSubcommandGroupBuilder);
if (hasSubcommandGroups)
throw new RangeError(`You cannot mix subcommands and subcommand groups at the root level.`);
// Get the final result

@@ -90,0 +107,0 @@ const result = typeof input === 'function' ? input(new SlashCommandSubcommands_1.SlashCommandSubcommandBuilder()) : input;

@@ -7,3 +7,2 @@ /// <reference types="node" />

* @param content The content to wrap.
* @returns The formatted content.
*/

@@ -15,3 +14,2 @@ export declare function codeBlock<C extends string>(content: C): `\`\`\`\n${C}\`\`\``;

* @param content The content to wrap.
* @returns The formatted content.
*/

@@ -22,3 +20,2 @@ export declare function codeBlock<L extends string, C extends string>(language: L, content: C): `\`\`\`${L}\n${C}\`\`\``;

* @param content The content to wrap.
* @returns The formatted content.
*/

@@ -29,3 +26,2 @@ export declare function inlineCode<C extends string>(content: C): `\`${C}\``;

* @param content The content to wrap.
* @returns The formatted content.
*/

@@ -36,3 +32,2 @@ export declare function italic<C extends string>(content: C): `_${C}_`;

* @param content The content to wrap.
* @returns The formatted content.
*/

@@ -43,3 +38,2 @@ export declare function bold<C extends string>(content: C): `**${C}**`;

* @param content The content to wrap.
* @returns The formatted content.
*/

@@ -50,3 +44,2 @@ export declare function underscore<C extends string>(content: C): `__${C}__`;

* @param content The content to wrap.
* @returns The formatted content.
*/

@@ -57,3 +50,2 @@ export declare function strikethrough<C extends string>(content: C): `~~${C}~~`;

* @param content The content to wrap.
* @returns The formatted content.
*/

@@ -64,3 +56,2 @@ export declare function quote<C extends string>(content: C): `> ${C}`;

* @param content The content to wrap.
* @returns The formatted content.
*/

@@ -71,3 +62,2 @@ export declare function blockQuote<C extends string>(content: C): `>>> ${C}`;

* @param url The URL to wrap.
* @returns The formatted content.
*/

@@ -78,3 +68,2 @@ export declare function hideLinkEmbed<C extends string>(url: C): `<${C}>`;

* @param url The URL to wrap.
* @returns The formatted content.
*/

@@ -86,3 +75,2 @@ export declare function hideLinkEmbed(url: URL): `<${string}>`;

* @param url The URL the content links to.
* @returns The formatted content.
*/

@@ -94,3 +82,2 @@ export declare function hyperlink<C extends string>(content: C, url: URL): `[${C}](${string})`;

* @param url The URL the content links to.
* @returns The formatted content.
*/

@@ -103,3 +90,2 @@ export declare function hyperlink<C extends string, U extends string>(content: C, url: U): `[${C}](${U})`;

* @param title The title shown when hovering on the masked link.
* @returns The formatted content.
*/

@@ -112,3 +98,2 @@ export declare function hyperlink<C extends string, T extends string>(content: C, url: URL, title: T): `[${C}](${string} "${T}")`;

* @param title The title shown when hovering on the masked link.
* @returns The formatted content.
*/

@@ -119,3 +104,2 @@ export declare function hyperlink<C extends string, U extends string, T extends string>(content: C, url: U, title: T): `[${C}](${U} "${T}")`;

* @param content The content to wrap.
* @returns The formatted content.
*/

@@ -126,3 +110,2 @@ export declare function spoiler<C extends string>(content: C): `||${C}||`;

* @param userId The user ID to format.
* @returns The formatted user mention.
*/

@@ -133,3 +116,2 @@ export declare function userMention<C extends Snowflake>(userId: C): `<@${C}>`;

* @param memberId The user ID to format.
* @returns The formatted member-nickname mention.
*/

@@ -140,3 +122,2 @@ export declare function memberNicknameMention<C extends Snowflake>(memberId: C): `<@!${C}>`;

* @param channelId The channel ID to format.
* @returns The formatted channel mention.
*/

@@ -147,3 +128,2 @@ export declare function channelMention<C extends Snowflake>(channelId: C): `<#${C}>`;

* @param roleId The role ID to format.
* @returns The formatted role mention.
*/

@@ -154,3 +134,2 @@ export declare function roleMention<C extends Snowflake>(roleId: C): `<@&${C}>`;

* @param emojiId The emoji ID to format.
* @returns The formatted emoji.
*/

@@ -162,3 +141,2 @@ export declare function formatEmoji<C extends Snowflake>(emojiId: C, animated?: false): `<:_:${C}>`;

* @param animated Whether the emoji is animated or not. Defaults to `false`
* @returns The formatted emoji.
*/

@@ -165,0 +143,0 @@ export declare function formatEmoji<C extends Snowflake>(emojiId: C, animated?: true): `<a:_:${C}>`;

@@ -11,3 +11,2 @@ "use strict";

* @param content The content to wrap.
* @returns The formatted content.
*/

@@ -21,3 +20,2 @@ function inlineCode(content) {

* @param content The content to wrap.
* @returns The formatted content.
*/

@@ -31,3 +29,2 @@ function italic(content) {

* @param content The content to wrap.
* @returns The formatted content.
*/

@@ -41,3 +38,2 @@ function bold(content) {

* @param content The content to wrap.
* @returns The formatted content.
*/

@@ -51,3 +47,2 @@ function underscore(content) {

* @param content The content to wrap.
* @returns The formatted content.
*/

@@ -61,3 +56,2 @@ function strikethrough(content) {

* @param content The content to wrap.
* @returns The formatted content.
*/

@@ -71,3 +65,2 @@ function quote(content) {

* @param content The content to wrap.
* @returns The formatted content.
*/

@@ -91,3 +84,2 @@ function blockQuote(content) {

* @param content The content to wrap.
* @returns The formatted content.
*/

@@ -101,3 +93,2 @@ function spoiler(content) {

* @param userId The user ID to format.
* @returns The formatted user mention.
*/

@@ -111,3 +102,2 @@ function userMention(userId) {

* @param memberId The user ID to format.
* @returns The formatted member-nickname mention.
*/

@@ -121,3 +111,2 @@ function memberNicknameMention(memberId) {

* @param channelId The channel ID to format.
* @returns The formatted channel mention.
*/

@@ -131,3 +120,2 @@ function channelMention(channelId) {

* @param roleId The role ID to format.
* @returns The formatted role mention.
*/

@@ -142,3 +130,2 @@ function roleMention(roleId) {

* @param animated Whether the emoji is animated or not. Defaults to `false`
* @returns The formatted emoji.
*/

@@ -145,0 +132,0 @@ function formatEmoji(emojiId, animated = false) {

{
"name": "@discordjs/builders",
"version": "0.5.0",
"version": "0.6.0",
"description": "A set of builders that you can use when creating your bot.",

@@ -52,3 +52,3 @@ "main": "./dist/index.js",

"ts-mixer": "^6.0.0",
"tslib": "^2.3.0"
"tslib": "^2.3.1"
},

@@ -62,6 +62,6 @@ "devDependencies": {

"@commitlint/config-angular": "^13.1.0",
"@types/jest": "^26.0.24",
"@types/node": "^16.4.12",
"@typescript-eslint/eslint-plugin": "^4.29.0",
"@typescript-eslint/parser": "^4.29.0",
"@types/jest": "^27.0.1",
"@types/node": "^16.7.1",
"@typescript-eslint/eslint-plugin": "^4.29.3",
"@typescript-eslint/parser": "^4.29.3",
"babel-jest": "^27.0.6",

@@ -72,3 +72,3 @@ "babel-plugin-transform-typescript-metadata": "^0.3.2",

"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-prettier": "^3.4.1",
"gen-esm-wrapper": "^1.1.2",

@@ -78,3 +78,3 @@ "husky": "^7.0.1",

"jest": "^27.0.6",
"lint-staged": "^11.1.1",
"lint-staged": "^11.1.2",
"npm-run-all": "^4.1.5",

@@ -81,0 +81,0 @@ "prettier": "^2.3.2",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc