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
1199
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.3.0 to 0.4.0

dist/interactions/slashCommands/SlashCommandSubcommands.d.ts

2

dist/index.d.ts
export * from './messages/formatters';
export * as SlashCommandAssertions from './interactions/slashCommands/Assertions';
export * from './interactions/slashCommands/SlashCommandBuilder';
export * from './interactions/slashCommands/SlashCommandSubCommands';
export * from './interactions/slashCommands/SlashCommandSubcommands';
export * from './interactions/slashCommands/options/boolean';

@@ -6,0 +6,0 @@ export * from './interactions/slashCommands/options/channel';

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

tslib_1.__exportStar(require("./interactions/slashCommands/SlashCommandBuilder"), exports);
tslib_1.__exportStar(require("./interactions/slashCommands/SlashCommandSubCommands"), exports);
tslib_1.__exportStar(require("./interactions/slashCommands/SlashCommandSubcommands"), exports);
tslib_1.__exportStar(require("./interactions/slashCommands/options/boolean"), exports);

@@ -11,0 +11,0 @@ tslib_1.__exportStar(require("./interactions/slashCommands/options/channel"), exports);

import type { APIApplicationCommandOptionChoice } from 'discord-api-types/v9';
import type { SlashCommandOptionBase } from './mixins/CommandOptionBase';
import type { ToAPIApplicationCommandOptions } from './SlashCommandBuilder';
import type { SlashCommandSubCommandBuilder, SlashCommandSubCommandGroupBuilder } from './SlashCommandSubCommands';
import type { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from './SlashCommandSubcommands';
export declare function validateRequiredParameters(name: string, description: string, options: ToAPIApplicationCommandOptions[]): void;

@@ -10,3 +10,3 @@ export declare function validateName(name: unknown): asserts name is string;

export declare function validateMaxChoicesLength(choices: APIApplicationCommandOptionChoice[]): void;
export declare function assertReturnOfBuilder<T extends SlashCommandOptionBase | SlashCommandSubCommandBuilder | SlashCommandSubCommandGroupBuilder>(input: unknown, ExpectedInstanceOf: new () => T): asserts input is T;
export declare function assertReturnOfBuilder<T extends SlashCommandOptionBase | SlashCommandSubcommandBuilder | SlashCommandSubcommandGroupBuilder>(input: unknown, ExpectedInstanceOf: new () => T): asserts input is T;
//# sourceMappingURL=Assertions.d.ts.map

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

import type { ToAPIApplicationCommandOptions } from '../SlashCommandBuilder';
export declare class SharedSlashCommandOptions<ShouldOmitSubCommandFunctions = true> {
export declare class SharedSlashCommandOptions<ShouldOmitSubcommandFunctions = true> {
readonly options: ToAPIApplicationCommandOptions[];

@@ -16,3 +16,3 @@ /**

*/
addBooleanOption(input: SlashCommandBooleanOption | ((builder: SlashCommandBooleanOption) => SlashCommandBooleanOption)): ShouldOmitSubCommandFunctions extends true ? Omit<this, "addSubCommand" | "addSubCommandGroup"> : this;
addBooleanOption(input: SlashCommandBooleanOption | ((builder: SlashCommandBooleanOption) => SlashCommandBooleanOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
/**

@@ -22,3 +22,3 @@ * Adds a user option

*/
addUserOption(input: SlashCommandUserOption | ((builder: SlashCommandUserOption) => SlashCommandUserOption)): ShouldOmitSubCommandFunctions extends true ? Omit<this, "addSubCommand" | "addSubCommandGroup"> : this;
addUserOption(input: SlashCommandUserOption | ((builder: SlashCommandUserOption) => SlashCommandUserOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
/**

@@ -28,3 +28,3 @@ * Adds a channel option

*/
addChannelOption(input: SlashCommandChannelOption | ((builder: SlashCommandChannelOption) => SlashCommandChannelOption)): ShouldOmitSubCommandFunctions extends true ? Omit<this, "addSubCommand" | "addSubCommandGroup"> : this;
addChannelOption(input: SlashCommandChannelOption | ((builder: SlashCommandChannelOption) => SlashCommandChannelOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
/**

@@ -34,3 +34,3 @@ * Adds a role option

*/
addRoleOption(input: SlashCommandRoleOption | ((builder: SlashCommandRoleOption) => SlashCommandRoleOption)): ShouldOmitSubCommandFunctions extends true ? Omit<this, "addSubCommand" | "addSubCommandGroup"> : this;
addRoleOption(input: SlashCommandRoleOption | ((builder: SlashCommandRoleOption) => SlashCommandRoleOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
/**

@@ -40,3 +40,3 @@ * Adds a mentionable option

*/
addMentionableOption(input: SlashCommandMentionableOption | ((builder: SlashCommandMentionableOption) => SlashCommandMentionableOption)): ShouldOmitSubCommandFunctions extends true ? Omit<this, "addSubCommand" | "addSubCommandGroup"> : this;
addMentionableOption(input: SlashCommandMentionableOption | ((builder: SlashCommandMentionableOption) => SlashCommandMentionableOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
/**

@@ -46,3 +46,3 @@ * Adds a string option

*/
addStringOption(input: SlashCommandStringOption | ((builder: SlashCommandStringOption) => SlashCommandStringOption)): ShouldOmitSubCommandFunctions extends true ? Omit<this, "addSubCommand" | "addSubCommandGroup"> : this;
addStringOption(input: SlashCommandStringOption | ((builder: SlashCommandStringOption) => SlashCommandStringOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
/**

@@ -52,5 +52,5 @@ * Adds an integer option

*/
addIntegerOption(input: SlashCommandIntegerOption | ((builder: SlashCommandIntegerOption) => SlashCommandIntegerOption)): ShouldOmitSubCommandFunctions extends true ? Omit<this, "addSubCommand" | "addSubCommandGroup"> : this;
addIntegerOption(input: SlashCommandIntegerOption | ((builder: SlashCommandIntegerOption) => SlashCommandIntegerOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
private _sharedAddOptionMethod;
}
//# sourceMappingURL=CommandOptions.d.ts.map
import type { APIApplicationCommandOption } from 'discord-api-types/v9';
import { SharedNameAndDescription } from './mixins/NameAndDescription';
import { SharedSlashCommandOptions } from './mixins/CommandOptions';
import { SlashCommandSubCommandBuilder, SlashCommandSubCommandGroupBuilder } from './SlashCommandSubCommands';
import { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from './SlashCommandSubcommands';
export declare class SlashCommandBuilder {

@@ -29,17 +29,17 @@ /**

/**
* Adds a new sub command group to this command
* @param input A function that returns a sub command group builder, or an already built builder
* 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)): SlashCommandSubcommandGroupsOnlyBuilder;
/**
* Adds a new sub command to this command
* @param input A function that returns a sub command builder, or an already built builder
* Adds a new subcommand to this command
* @param input A function that returns a subcommand builder, or an already built builder
*/
addSubCommand(input: SlashCommandSubCommandBuilder | ((subCommandGroup: SlashCommandSubCommandBuilder) => SlashCommandSubCommandBuilder)): SlashCommandSubCommandsOnlyBuilder;
addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): SlashCommandSubcommandsOnlyBuilder;
}
export interface SlashCommandBuilder extends SharedNameAndDescription, SharedSlashCommandOptions {
}
export interface SlashCommandSubCommandsOnlyBuilder extends SharedNameAndDescription, Pick<SlashCommandBuilder, 'toJSON' | 'addSubCommand'> {
export interface SlashCommandSubcommandsOnlyBuilder extends SharedNameAndDescription, Pick<SlashCommandBuilder, 'toJSON' | 'addSubcommand'> {
}
export interface SlashCommandSubCommandGroupsOnlyBuilder extends SharedNameAndDescription, Pick<SlashCommandBuilder, 'toJSON' | 'addSubCommandGroup'> {
export interface SlashCommandSubcommandGroupsOnlyBuilder extends SharedNameAndDescription, Pick<SlashCommandBuilder, 'toJSON' | 'addSubcommandGroup'> {
}

@@ -46,0 +46,0 @@ export interface SlashCommandOptionsOnlyBuilder extends SharedNameAndDescription, SharedSlashCommandOptions, Pick<SlashCommandBuilder, 'toJSON'> {

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

const CommandOptions_1 = require("./mixins/CommandOptions");
const SlashCommandSubCommands_1 = require("./SlashCommandSubCommands");
const SlashCommandSubcommands_1 = require("./SlashCommandSubcommands");
let SlashCommandBuilder = class SlashCommandBuilder {

@@ -55,16 +55,16 @@ constructor() {

/**
* Adds a new sub command group to this command
* @param input A function that returns a sub command group builder, or an already built builder
* 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) {
addSubcommandGroup(input) {
const { options } = this;
// First, assert options conditions - we cannot have more than 25 options
Assertions_1.validateMaxOptionsLength(options);
// Make sure there is no sub command 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 sub commands and sub command groups at the root level.`);
// 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
const result = typeof input === 'function' ? input(new SlashCommandSubCommands_1.SlashCommandSubCommandGroupBuilder()) : input;
Assertions_1.assertReturnOfBuilder(result, SlashCommandSubCommands_1.SlashCommandSubCommandGroupBuilder);
const result = typeof input === 'function' ? input(new SlashCommandSubcommands_1.SlashCommandSubcommandGroupBuilder()) : input;
Assertions_1.assertReturnOfBuilder(result, SlashCommandSubcommands_1.SlashCommandSubcommandGroupBuilder);
// Push it

@@ -75,16 +75,16 @@ options.push(result);

/**
* Adds a new sub command to this command
* @param input A function that returns a sub command builder, or an already built builder
* Adds a new subcommand to this command
* @param input A function that returns a subcommand builder, or an already built builder
*/
addSubCommand(input) {
addSubcommand(input) {
const { options } = this;
// First, assert options conditions - we cannot have more than 25 options
Assertions_1.validateMaxOptionsLength(options);
// Make sure there is no sub command 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 sub commands and sub command groups at the root level.`);
// 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
const result = typeof input === 'function' ? input(new SlashCommandSubCommands_1.SlashCommandSubCommandBuilder()) : input;
Assertions_1.assertReturnOfBuilder(result, SlashCommandSubCommands_1.SlashCommandSubCommandBuilder);
const result = typeof input === 'function' ? input(new SlashCommandSubcommands_1.SlashCommandSubcommandBuilder()) : input;
Assertions_1.assertReturnOfBuilder(result, SlashCommandSubcommands_1.SlashCommandSubcommandBuilder);
// Push it

@@ -91,0 +91,0 @@ options.push(result);

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

@@ -50,20 +50,20 @@ "main": "./dist/index.js",

"discord-api-types": "^0.22.0",
"ow": "^0.26.0",
"ts-mixer": "^5.4.1",
"ow": "^0.27.0",
"ts-mixer": "^6.0.0",
"tslib": "^2.3.0"
},
"devDependencies": {
"@babel/core": "^7.14.6",
"@babel/core": "^7.15.0",
"@babel/plugin-proposal-decorators": "^7.14.5",
"@babel/preset-env": "^7.14.7",
"@babel/preset-typescript": "^7.14.5",
"@commitlint/cli": "^12.1.4",
"@commitlint/config-angular": "^12.1.4",
"@babel/preset-env": "^7.15.0",
"@babel/preset-typescript": "^7.15.0",
"@commitlint/cli": "^13.1.0",
"@commitlint/config-angular": "^13.1.0",
"@types/jest": "^26.0.24",
"@types/node": "^16.0.1",
"@typescript-eslint/eslint-plugin": "^4.28.2",
"@typescript-eslint/parser": "^4.28.2",
"@types/node": "^16.4.12",
"@typescript-eslint/eslint-plugin": "^4.29.0",
"@typescript-eslint/parser": "^4.29.0",
"babel-jest": "^27.0.6",
"babel-plugin-transform-typescript-metadata": "^0.3.2",
"eslint": "^7.30.0",
"eslint": "^7.32.0",
"eslint-config-marine": "^9.0.6",

@@ -76,7 +76,7 @@ "eslint-config-prettier": "^8.3.0",

"jest": "^27.0.6",
"lint-staged": "^11.0.0",
"lint-staged": "^11.1.1",
"npm-run-all": "^4.1.5",
"prettier": "^2.3.2",
"rimraf": "^3.0.2",
"standard-version": "^9.3.0",
"standard-version": "^9.3.1",
"typescript": "^4.3.5"

@@ -83,0 +83,0 @@ },

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