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
1206
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.9.0 to 0.10.0

100

dist/index.d.ts

@@ -1,6 +0,6 @@

import * as discord_api_types_v9 from 'discord-api-types/v9';
import { APIEmbedField, APIEmbed, APIEmbedThumbnail, APIEmbedImage, APIEmbedVideo, APIEmbedAuthor, APIEmbedProvider, APIEmbedFooter, ApplicationCommandOptionType, ChannelType, APIApplicationCommandChannelOptions, APIApplicationCommandOptionChoice, APIApplicationCommandSubCommandOptions, RESTPostAPIApplicationCommandsJSONBody, APIApplicationCommandOption, ApplicationCommandType } from 'discord-api-types/v9';
import { APIEmbedField, APIEmbed, APIEmbedThumbnail, APIEmbedImage, APIEmbedVideo, APIEmbedAuthor, APIEmbedProvider, APIEmbedFooter, ApplicationCommandOptionType, ChannelType, APIApplicationCommandChannelOptions, APIApplicationCommandOptionChoice, APIApplicationCommandOption, APIApplicationCommandSubCommandOptions, RESTPostAPIApplicationCommandsJSONBody, ApplicationCommandType } from 'discord-api-types/v9';
import { z } from 'zod';
import { Snowflake } from 'discord-api-types/globals';
import { URL } from 'url';
import * as discord_api_types from 'discord-api-types';

@@ -457,3 +457,3 @@ declare const fieldNamePredicate: z.ZodString;

declare abstract class ApplicationCommandOptionWithChannelTypesBase extends SlashCommandOptionBase implements ToAPIApplicationCommandOptions {
declare abstract class ApplicationCommandOptionWithChannelTypesBase extends SlashCommandOptionBase<ApplicationCommandOptionType.Channel> implements ToAPIApplicationCommandOptions {
channelTypes?: Exclude<ChannelType, ChannelType.DM | ChannelType.GroupDM>[];

@@ -480,3 +480,3 @@ /**

declare abstract class ApplicationCommandOptionWithChoicesBase<T extends string | number> extends SlashCommandOptionBase implements ToAPIApplicationCommandOptions {
declare abstract class ApplicationCommandOptionWithChoicesBase<T extends string | number> extends SlashCommandOptionBase<ApplicationCommandOptionType.String | ApplicationCommandOptionType.Number | ApplicationCommandOptionType.Integer> implements ToAPIApplicationCommandOptions {
choices?: APIApplicationCommandOptionChoice[];

@@ -502,42 +502,86 @@ readonly autocomplete?: boolean;

setAutocomplete<U extends boolean>(autocomplete: U): U extends true ? Omit<this, 'addChoice' | 'addChoices'> : this & Pick<ApplicationCommandOptionWithChoicesBase<T>, 'addChoice' | 'addChoices'>;
toJSON(): APIApplicationCommandOption;
}
declare abstract class ApplicationCommandNumberOptionBase extends ApplicationCommandOptionWithChoicesBase<number> {
protected maxValue?: number;
protected minValue?: number;
/**
* Sets the maximum number value of this option
* @param max The maximum value this option can be
*/
abstract setMaxValue(max: number): this;
/**
* Sets the minimum number value of this option
* @param min The minimum value this option can be
*/
abstract setMinValue(min: number): this;
toJSON(): {
choices: APIApplicationCommandOptionChoice[] | undefined;
autocomplete: boolean | undefined;
type: ApplicationCommandOptionType.String | ApplicationCommandOptionType.Integer | ApplicationCommandOptionType.Number;
min_value: number | undefined;
max_value: number | undefined;
type: discord_api_types.ApplicationCommandOptionType.String | discord_api_types.ApplicationCommandOptionType.Integer | discord_api_types.ApplicationCommandOptionType.Number;
choices?: discord_api_types.APIApplicationCommandOptionChoice[] | undefined;
autocomplete?: false | undefined;
name: string;
description: string;
default?: boolean | undefined;
required?: boolean | undefined;
} | {
choices: APIApplicationCommandOptionChoice[] | undefined;
autocomplete: boolean | undefined;
type: ApplicationCommandOptionType.Subcommand | ApplicationCommandOptionType.SubcommandGroup;
options?: discord_api_types_v9.APIApplicationCommandOption[] | undefined;
min_value: number | undefined;
max_value: number | undefined;
type: discord_api_types.ApplicationCommandOptionType.Subcommand | discord_api_types.ApplicationCommandOptionType.SubcommandGroup;
options?: discord_api_types.APIApplicationCommandOption[] | undefined;
name: string;
description: string;
default?: boolean | undefined;
required?: boolean | undefined;
autocomplete?: undefined;
} | {
choices: APIApplicationCommandOptionChoice[] | undefined;
autocomplete: boolean | undefined;
type: ApplicationCommandOptionType.Channel;
channel_types?: (discord_api_types_v9.ChannelType.GuildText | discord_api_types_v9.ChannelType.GuildVoice | discord_api_types_v9.ChannelType.GuildCategory | discord_api_types_v9.ChannelType.GuildNews | discord_api_types_v9.ChannelType.GuildStore | discord_api_types_v9.ChannelType.GuildNewsThread | discord_api_types_v9.ChannelType.GuildPublicThread | discord_api_types_v9.ChannelType.GuildPrivateThread | discord_api_types_v9.ChannelType.GuildStageVoice)[] | undefined;
min_value: number | undefined;
max_value: number | undefined;
type: discord_api_types.ApplicationCommandOptionType.Boolean | discord_api_types.ApplicationCommandOptionType.User | discord_api_types.ApplicationCommandOptionType.Role | discord_api_types.ApplicationCommandOptionType.Mentionable;
name: string;
description: string;
default?: boolean | undefined;
required?: boolean | undefined;
autocomplete?: undefined;
} | {
choices: APIApplicationCommandOptionChoice[] | undefined;
autocomplete: boolean | undefined;
type: ApplicationCommandOptionType.Boolean | ApplicationCommandOptionType.User | ApplicationCommandOptionType.Role | ApplicationCommandOptionType.Mentionable;
min_value: number | undefined;
max_value: number | undefined;
type: discord_api_types.ApplicationCommandOptionType.Channel;
channel_types?: (discord_api_types.ChannelType.GuildText | discord_api_types.ChannelType.GuildVoice | discord_api_types.ChannelType.GuildCategory | discord_api_types.ChannelType.GuildNews | discord_api_types.ChannelType.GuildStore | discord_api_types.ChannelType.GuildNewsThread | discord_api_types.ChannelType.GuildPublicThread | discord_api_types.ChannelType.GuildPrivateThread | discord_api_types.ChannelType.GuildStageVoice)[] | undefined;
name: string;
description: string;
default?: boolean | undefined;
required?: boolean | undefined;
autocomplete?: undefined;
} | {
min_value: number | undefined;
max_value: number | undefined;
type: discord_api_types.ApplicationCommandOptionType.Integer | discord_api_types.ApplicationCommandOptionType.Number;
choices?: discord_api_types.APIApplicationCommandOptionChoice[] | undefined;
autocomplete?: false | undefined;
name: string;
description: string;
required?: boolean | undefined;
} | {
min_value: number | undefined;
max_value: number | undefined;
type: discord_api_types.ApplicationCommandOptionType.String;
autocomplete: true;
name: string;
description: string;
required?: boolean | undefined;
} | {
min_value: number | undefined;
max_value: number | undefined;
type: discord_api_types.ApplicationCommandOptionType.Integer | discord_api_types.ApplicationCommandOptionType.Number;
autocomplete: true;
name: string;
description: string;
required?: boolean | undefined;
};
}
declare class SlashCommandIntegerOption extends ApplicationCommandOptionWithChoicesBase<number> {
declare class SlashCommandIntegerOption extends ApplicationCommandNumberOptionBase {
readonly type: ApplicationCommandOptionType.Integer;
constructor();
setMaxValue(max: number): this;
setMinValue(min: number): this;
}

@@ -550,5 +594,7 @@

declare class SlashCommandNumberOption extends ApplicationCommandOptionWithChoicesBase<number> {
declare class SlashCommandNumberOption extends ApplicationCommandNumberOptionBase {
readonly type: ApplicationCommandOptionType.Number;
constructor();
setMaxValue(max: number): this;
setMinValue(min: number): this;
}

@@ -750,6 +796,6 @@

declare class SlashCommandOptionBase extends SharedNameAndDescription implements ToAPIApplicationCommandOptions {
declare class SlashCommandOptionBase<OptionType extends ApplicationCommandOptionType = ApplicationCommandOptionType> extends SharedNameAndDescription implements ToAPIApplicationCommandOptions {
required: boolean;
readonly type: ApplicationCommandOptionType;
constructor(type: ApplicationCommandOptionType);
readonly type: OptionType;
constructor(type: OptionType);
/**

@@ -756,0 +802,0 @@ * Marks the option as required

@@ -1,4 +0,4 @@

var we=Object.create;var O=Object.defineProperty;var ge=Object.getOwnPropertyDescriptor;var Me=Object.getOwnPropertyNames;var De=Object.getPrototypeOf,ke=Object.prototype.hasOwnProperty;var Le=(t,e,n)=>e in t?O(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Pe=t=>O(t,"__esModule",{value:!0});var B=(t,e)=>{Pe(t);for(var n in e)O(t,n,{get:e[n],enumerable:!0})},_e=(t,e,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Me(e))!ke.call(t,o)&&o!=="default"&&O(t,o,{get:()=>e[o],enumerable:!(n=ge(e,o))||n.enumerable});return t},s=t=>_e(Pe(O(t!=null?we(De(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t),T=(t,e,n,o)=>{for(var a=o>1?void 0:o?ge(e,n):e,S=t.length-1,P;S>=0;S--)(P=t[S])&&(a=(o?P(e,n,a):P(a))||a);return o&&a&&O(e,n,a),a};var i=(t,e,n)=>(Le(t,typeof e!="symbol"?e+"":e,n),n);B(exports,{ContextMenuCommandAssertions:()=>Ae,ContextMenuCommandBuilder:()=>Ee,Embed:()=>v,EmbedAssertions:()=>ne,Faces:()=>ie,SlashCommandAssertions:()=>se,SlashCommandBooleanOption:()=>_,SlashCommandBuilder:()=>V,SlashCommandChannelOption:()=>U,SlashCommandIntegerOption:()=>F,SlashCommandMentionableOption:()=>J,SlashCommandNumberOption:()=>q,SlashCommandRoleOption:()=>z,SlashCommandStringOption:()=>W,SlashCommandSubcommandBuilder:()=>c,SlashCommandSubcommandGroupBuilder:()=>x,SlashCommandUserOption:()=>j,TimestampStyles:()=>nt,blockQuote:()=>je,bold:()=>Je,channelMention:()=>Xe,codeBlock:()=>Ue,formatEmoji:()=>et,hideLinkEmbed:()=>Ve,hyperlink:()=>Ze,inlineCode:()=>Ge,italic:()=>Fe,memberNicknameMention:()=>He,quote:()=>We,roleMention:()=>Ye,spoiler:()=>Ke,strikethrough:()=>ze,time:()=>tt,underscore:()=>qe,userMention:()=>Qe});var ne={};B(ne,{authorNamePredicate:()=>Q,colorPredicate:()=>H,descriptionPredicate:()=>X,embedFieldPredicate:()=>Te,embedFieldsArrayPredicate:()=>E,fieldInlinePredicate:()=>R,fieldLengthPredicate:()=>ve,fieldNamePredicate:()=>y,fieldValuePredicate:()=>N,footerTextPredicate:()=>Y,timestampPredicate:()=>ee,titlePredicate:()=>te,urlPredicate:()=>u,validateFieldLength:()=>w});var m=s(require("zod")),y=m.z.string().min(1).max(256),N=m.z.string().min(1).max(1024),R=m.z.boolean().optional(),Te=m.z.object({name:y,value:N,inline:R}),E=Te.array(),ve=m.z.number().lte(25);function w(t,e){ve.parse(t.length+e)}var Q=y.nullable(),u=m.z.string().url().nullish(),H=m.z.number().gte(0).lte(16777215).nullable(),X=m.z.string().min(1).max(4096).nullable(),Y=m.z.string().min(1).max(2048).nullable(),ee=m.z.union([m.z.number(),m.z.date()]).nullable(),te=y.nullable();var v=class{constructor(e={}){i(this,"fields");i(this,"title");i(this,"description");i(this,"url");i(this,"color");i(this,"timestamp");i(this,"thumbnail");i(this,"image");i(this,"video");i(this,"author");i(this,"provider");i(this,"footer");this.title=e.title,this.description=e.description,this.url=e.url,this.color=e.color,this.thumbnail=e.thumbnail,this.image=e.image,this.video=e.video,this.author=e.author,this.provider=e.provider,this.footer=e.footer,this.fields=e.fields??[],e.timestamp&&(this.timestamp=new Date(e.timestamp).toISOString())}get length(){return(this.title?.length??0)+(this.description?.length??0)+this.fields.reduce((e,n)=>e+n.name.length+n.value.length,0)+(this.footer?.text.length??0)+(this.author?.name.length??0)}addField(e){return this.addFields(e)}addFields(...e){return E.parse(e),w(this.fields,e.length),this.fields.push(...v.normalizeFields(...e)),this}spliceFields(e,n,...o){return E.parse(o),w(this.fields,o.length-n),this.fields.splice(e,n,...v.normalizeFields(...o)),this}setAuthor(e){if(e===null)return this.author=void 0,this;let{name:n,iconURL:o,url:a}=e;return Q.parse(n),u.parse(o),u.parse(a),this.author={name:n,url:a,icon_url:o},this}setColor(e){return H.parse(e),this.color=e??void 0,this}setDescription(e){return X.parse(e),this.description=e??void 0,this}setFooter(e){if(e===null)return this.footer=void 0,this;let{text:n,iconURL:o}=e;return Y.parse(n),u.parse(o),this.footer={text:n,icon_url:o},this}setImage(e){return u.parse(e),this.image=e?{url:e}:void 0,this}setThumbnail(e){return u.parse(e),this.thumbnail=e?{url:e}:void 0,this}setTimestamp(e=Date.now()){return ee.parse(e),this.timestamp=e?new Date(e).toISOString():void 0,this}setTitle(e){return te.parse(e),this.title=e??void 0,this}setURL(e){return u.parse(e),this.url=e??void 0,this}toJSON(){return{...this}}static normalizeFields(...e){return e.flat(1/0).map(n=>(y.parse(n.name),N.parse(n.value),R.parse(n.inline),{name:n.name,value:n.value,inline:n.inline??void 0}))}};function Ue(t,e){return typeof e=="undefined"?`\`\`\`
var _e=Object.create;var x=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var Fe=Object.getPrototypeOf,Ge=Object.prototype.hasOwnProperty;var Je=(t,e,n)=>e in t?x(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ge=t=>x(t,"__esModule",{value:!0});var N=(t,e)=>{for(var n in e)x(t,n,{get:e[n],enumerable:!0})},Pe=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ue(e))!Ge.call(t,r)&&(n||r!=="default")&&x(t,r,{get:()=>e[r],enumerable:!(o=Ae(e,r))||o.enumerable});return t},Ve=(t,e)=>Pe(ge(x(t!=null?_e(Fe(t)):{},"default",!e&&t&&t.__esModule?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t),qe=(t=>(e,n)=>t&&t.get(e)||(n=Pe(ge({}),e,1),t&&t.set(e,n),n))(typeof WeakMap!="undefined"?new WeakMap:0),g=(t,e,n,o)=>{for(var r=o>1?void 0:o?Ae(e,n):e,f=t.length-1,A;f>=0;f--)(A=t[f])&&(r=(o?A(e,n,r):A(r))||r);return o&&r&&x(e,n,r),r};var i=(t,e,n)=>(Je(t,typeof e!="symbol"?e+"":e,n),n);var xt={};N(xt,{ContextMenuCommandAssertions:()=>ye,ContextMenuCommandBuilder:()=>Le,Embed:()=>P,EmbedAssertions:()=>ne,Faces:()=>ve,SlashCommandAssertions:()=>re,SlashCommandBooleanOption:()=>_,SlashCommandBuilder:()=>W,SlashCommandChannelOption:()=>U,SlashCommandIntegerOption:()=>G,SlashCommandMentionableOption:()=>J,SlashCommandNumberOption:()=>V,SlashCommandRoleOption:()=>q,SlashCommandStringOption:()=>z,SlashCommandSubcommandBuilder:()=>l,SlashCommandSubcommandGroupBuilder:()=>b,SlashCommandUserOption:()=>j,TimestampStyles:()=>pt,blockQuote:()=>Xe,bold:()=>Ze,channelMention:()=>ot,codeBlock:()=>ze,formatEmoji:()=>at,hideLinkEmbed:()=>Ye,hyperlink:()=>et,inlineCode:()=>je,italic:()=>We,memberNicknameMention:()=>it,quote:()=>He,roleMention:()=>rt,spoiler:()=>tt,strikethrough:()=>Qe,time:()=>st,underscore:()=>Ke,userMention:()=>nt});var ne={};N(ne,{authorNamePredicate:()=>Q,colorPredicate:()=>H,descriptionPredicate:()=>X,embedFieldPredicate:()=>Te,embedFieldsArrayPredicate:()=>M,fieldInlinePredicate:()=>R,fieldLengthPredicate:()=>Ie,fieldNamePredicate:()=>S,fieldValuePredicate:()=>B,footerTextPredicate:()=>Y,timestampPredicate:()=>ee,titlePredicate:()=>te,urlPredicate:()=>u,validateFieldLength:()=>E});var s=require("zod"),S=s.z.string().min(1).max(256),B=s.z.string().min(1).max(1024),R=s.z.boolean().optional(),Te=s.z.object({name:S,value:B,inline:R}),M=Te.array(),Ie=s.z.number().lte(25);function E(t,e){Ie.parse(t.length+e)}var Q=S.nullable(),u=s.z.string().url().nullish(),H=s.z.number().gte(0).lte(16777215).nullable(),X=s.z.string().min(1).max(4096).nullable(),Y=s.z.string().min(1).max(2048).nullable(),ee=s.z.union([s.z.number(),s.z.date()]).nullable(),te=S.nullable();var P=class{constructor(e={}){i(this,"fields");i(this,"title");i(this,"description");i(this,"url");i(this,"color");i(this,"timestamp");i(this,"thumbnail");i(this,"image");i(this,"video");i(this,"author");i(this,"provider");i(this,"footer");this.title=e.title,this.description=e.description,this.url=e.url,this.color=e.color,this.thumbnail=e.thumbnail,this.image=e.image,this.video=e.video,this.author=e.author,this.provider=e.provider,this.footer=e.footer,this.fields=e.fields??[],e.timestamp&&(this.timestamp=new Date(e.timestamp).toISOString())}get length(){return(this.title?.length??0)+(this.description?.length??0)+this.fields.reduce((e,n)=>e+n.name.length+n.value.length,0)+(this.footer?.text.length??0)+(this.author?.name.length??0)}addField(e){return this.addFields(e)}addFields(...e){return M.parse(e),E(this.fields,e.length),this.fields.push(...P.normalizeFields(...e)),this}spliceFields(e,n,...o){return M.parse(o),E(this.fields,o.length-n),this.fields.splice(e,n,...P.normalizeFields(...o)),this}setAuthor(e){if(e===null)return this.author=void 0,this;let{name:n,iconURL:o,url:r}=e;return Q.parse(n),u.parse(o),u.parse(r),this.author={name:n,url:r,icon_url:o},this}setColor(e){return H.parse(e),this.color=e??void 0,this}setDescription(e){return X.parse(e),this.description=e??void 0,this}setFooter(e){if(e===null)return this.footer=void 0,this;let{text:n,iconURL:o}=e;return Y.parse(n),u.parse(o),this.footer={text:n,icon_url:o},this}setImage(e){return u.parse(e),this.image=e?{url:e}:void 0,this}setThumbnail(e){return u.parse(e),this.thumbnail=e?{url:e}:void 0,this}setTimestamp(e=Date.now()){return ee.parse(e),this.timestamp=e?new Date(e).toISOString():void 0,this}setTitle(e){return te.parse(e),this.title=e??void 0,this}setURL(e){return u.parse(e),this.url=e??void 0,this}toJSON(){return{...this}}static normalizeFields(...e){return e.flat(1/0).map(n=>(S.parse(n.name),B.parse(n.value),R.parse(n.inline),{name:n.name,value:n.value,inline:n.inline??void 0}))}};function ze(t,e){return typeof e=="undefined"?`\`\`\`
${t}\`\`\``:`\`\`\`${t}
${e}\`\`\``}function Ge(t){return`\`${t}\``}function Fe(t){return`_${t}_`}function Je(t){return`**${t}**`}function qe(t){return`__${t}__`}function ze(t){return`~~${t}~~`}function We(t){return`> ${t}`}function je(t){return`>>> ${t}`}function Ve(t){return`<${t}>`}function Ze(t,e,n){return n?`[${t}](${e} "${n}")`:`[${t}](${e})`}function Ke(t){return`||${t}||`}function Qe(t){return`<@${t}>`}function He(t){return`<@!${t}>`}function Xe(t){return`<#${t}>`}function Ye(t){return`<@&${t}>`}function et(t,e=!1){return`<${e?"a":""}:_:${t}>`}function tt(t,e){return typeof t!="number"&&(t=Math.floor((t?.getTime()??Date.now())/1e3)),typeof e=="string"?`<t:${t}:${e}>`:`<t:${t}>`}var nt={ShortTime:"t",LongTime:"T",ShortDate:"d",LongDate:"D",ShortDateTime:"f",LongDateTime:"F",RelativeTime:"R"},ie;(function(o){o.Shrug="\xAF\\_(\u30C4)\\_/\xAF",o.Tableflip="(\u256F\xB0\u25A1\xB0\uFF09\u256F\uFE35 \u253B\u2501\u253B",o.Unflip="\u252C\u2500\u252C \u30CE( \u309C-\u309C\u30CE)"})(ie||(ie={}));var se={};B(se,{assertReturnOfBuilder:()=>C,validateDefaultPermission:()=>oe,validateDescription:()=>k,validateMaxChoicesLength:()=>re,validateMaxOptionsLength:()=>l,validateName:()=>D,validateRequired:()=>L,validateRequiredParameters:()=>h});var M=s(require("@sindresorhus/is")),I=s(require("zod"));function h(t,e,n){D(t),k(e),l(n)}var it=I.z.string().min(1).max(32).regex(/^[\P{Lu}\p{N}_-]+$/u);function D(t){it.parse(t)}var ot=I.z.string().min(1).max(100);function k(t){ot.parse(t)}var Ie=I.z.boolean();function oe(t){Ie.parse(t)}function L(t){Ie.parse(t)}var $e=I.z.unknown().array().max(25);function l(t){$e.parse(t)}function re(t){$e.parse(t)}function C(t,e){let n=e.name;if(M.default.nullOrUndefined(t))throw new TypeError(`Expected to receive a ${n} builder, got ${t===null?"null":"undefined"} instead.`);if(M.default.primitive(t))throw new TypeError(`Expected to receive a ${n} builder, got a primitive (${typeof t}) instead.`);if(!(t instanceof e)){let o=t,a=M.default.function_(t)?t.name:o.constructor.name,S=Reflect.get(o,Symbol.toStringTag),P=S?`${a} [${S}]`:a;throw new TypeError(`Expected to receive a ${n} builder, got ${P} instead.`)}}var Re=s(require("ts-mixer"));var ae=s(require("discord-api-types/v9"));var f=class{constructor(){i(this,"name");i(this,"description")}setName(e){return D(e),Reflect.set(this,"name",e),this}setDescription(e){return k(e),Reflect.set(this,"description",e),this}};var p=class extends f{constructor(e){super();i(this,"required",!1);i(this,"type");this.type=e}setRequired(e){return L(e),this.required=e,this}toJSON(){return h(this.name,this.description,[]),L(this.required),{type:this.type,name:this.name,description:this.description,required:this.required}}};var _=class extends p{constructor(){super(ae.ApplicationCommandOptionType.Boolean);i(this,"type",ae.ApplicationCommandOptionType.Boolean)}};var de=s(require("discord-api-types/v9"));var d=s(require("discord-api-types/v9")),me=s(require("zod"));var rt=[d.ChannelType.GuildCategory,d.ChannelType.GuildNews,d.ChannelType.GuildNewsThread,d.ChannelType.GuildStore,d.ChannelType.GuildStageVoice,d.ChannelType.GuildText,d.ChannelType.GuildVoice,d.ChannelType.GuildPublicThread,d.ChannelType.GuildPrivateThread],st=me.z.union(rt.map(t=>me.z.literal(t))),pe=class extends p{constructor(){super(...arguments);i(this,"channelTypes")}addChannelType(e){return this.channelTypes??=[],st.parse(e),this.channelTypes.push(e),this}addChannelTypes(e){return e.forEach(n=>this.addChannelType(n)),this}toJSON(){return{...super.toJSON(),type:d.ApplicationCommandOptionType.Channel,channel_types:this.channelTypes}}};var U=class extends pe{constructor(){super(de.ApplicationCommandOptionType.Channel);i(this,"type",de.ApplicationCommandOptionType.Channel)}};var le=s(require("discord-api-types/v9"));var Be=s(require("discord-api-types/v9")),A=s(require("zod"));var G=A.z.string().min(1).max(100),Ne=A.z.number().gt(-1/0).lt(1/0),at=A.z.tuple([G,A.z.union([G,Ne])]).array(),mt=A.z.boolean(),b=class extends p{constructor(){super(...arguments);i(this,"choices");i(this,"autocomplete")}addChoice(e,n){if(this.autocomplete)throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");return this.choices??=[],re(this.choices),G.parse(e),this.type===Be.ApplicationCommandOptionType.String?G.parse(n):Ne.parse(n),this.choices.push({name:e,value:n}),this}addChoices(e){if(this.autocomplete)throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");at.parse(e);for(let[n,o]of e)this.addChoice(n,o);return this}setAutocomplete(e){if(mt.parse(e),e&&Array.isArray(this.choices)&&this.choices.length>0)throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");return Reflect.set(this,"autocomplete",e),this}toJSON(){if(this.autocomplete&&Array.isArray(this.choices)&&this.choices.length>0)throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");return{...super.toJSON(),choices:this.choices,autocomplete:this.autocomplete}}};var F=class extends b{constructor(){super(le.ApplicationCommandOptionType.Integer);i(this,"type",le.ApplicationCommandOptionType.Integer)}};var ce=s(require("discord-api-types/v9"));var J=class extends p{constructor(){super(ce.ApplicationCommandOptionType.Mentionable);i(this,"type",ce.ApplicationCommandOptionType.Mentionable)}};var ue=s(require("discord-api-types/v9"));var q=class extends b{constructor(){super(ue.ApplicationCommandOptionType.Number);i(this,"type",ue.ApplicationCommandOptionType.Number)}};var he=s(require("discord-api-types/v9"));var z=class extends p{constructor(){super(he.ApplicationCommandOptionType.Role);i(this,"type",he.ApplicationCommandOptionType.Role)}};var Ce=s(require("discord-api-types/v9"));var W=class extends b{constructor(){super(Ce.ApplicationCommandOptionType.String);i(this,"type",Ce.ApplicationCommandOptionType.String)}};var fe=s(require("discord-api-types/v9"));var j=class extends p{constructor(){super(fe.ApplicationCommandOptionType.User);i(this,"type",fe.ApplicationCommandOptionType.User)}};var $=class{constructor(){i(this,"options")}addBooleanOption(e){return this._sharedAddOptionMethod(e,_)}addUserOption(e){return this._sharedAddOptionMethod(e,j)}addChannelOption(e){return this._sharedAddOptionMethod(e,U)}addRoleOption(e){return this._sharedAddOptionMethod(e,z)}addMentionableOption(e){return this._sharedAddOptionMethod(e,J)}addStringOption(e){return this._sharedAddOptionMethod(e,W)}addIntegerOption(e){return this._sharedAddOptionMethod(e,F)}addNumberOption(e){return this._sharedAddOptionMethod(e,q)}_sharedAddOptionMethod(e,n){let{options:o}=this;l(o);let a=typeof e=="function"?e(new n):e;return C(a,n),o.push(a),this}};var be=s(require("discord-api-types/v9")),xe=s(require("ts-mixer"));var x=class{constructor(){i(this,"name");i(this,"description");i(this,"options",[])}addSubcommand(e){let{options:n}=this;l(n);let o=typeof e=="function"?e(new c):e;return C(o,c),n.push(o),this}toJSON(){return h(this.name,this.description,this.options),{type:be.ApplicationCommandOptionType.SubcommandGroup,name:this.name,description:this.description,options:this.options.map(e=>e.toJSON())}}};x=T([(0,xe.mix)(f)],x);var c=class{constructor(){i(this,"name");i(this,"description");i(this,"options",[])}toJSON(){return h(this.name,this.description,this.options),{type:be.ApplicationCommandOptionType.Subcommand,name:this.name,description:this.description,options:this.options.map(e=>e.toJSON())}}};c=T([(0,xe.mix)(f,$)],c);var V=class{constructor(){i(this,"name");i(this,"description");i(this,"options",[]);i(this,"defaultPermission")}toJSON(){return h(this.name,this.description,this.options),{name:this.name,description:this.description,options:this.options.map(e=>e.toJSON()),default_permission:this.defaultPermission}}setDefaultPermission(e){return oe(e),Reflect.set(this,"defaultPermission",e),this}addSubcommandGroup(e){let{options:n}=this;l(n);let o=typeof e=="function"?e(new x):e;return C(o,x),n.push(o),this}addSubcommand(e){let{options:n}=this;l(n);let o=typeof e=="function"?e(new c):e;return C(o,c),n.push(o),this}};V=T([(0,Re.mix)($,f)],V);var Ae={};B(Ae,{validateDefaultPermission:()=>ye,validateName:()=>Z,validateRequiredParameters:()=>Oe,validateType:()=>K});var g=s(require("zod")),Se=s(require("discord-api-types/v9"));function Oe(t,e){Z(t),K(e)}var pt=g.z.string().min(1).max(32).regex(/^( *[\p{L}\p{N}_-]+ *)+$/u);function Z(t){pt.parse(t)}var dt=g.z.union([g.z.literal(Se.ApplicationCommandType.User),g.z.literal(Se.ApplicationCommandType.Message)]);function K(t){dt.parse(t)}var lt=g.z.boolean();function ye(t){lt.parse(t)}var Ee=class{constructor(){i(this,"name");i(this,"type");i(this,"defaultPermission")}setName(e){return Z(e),Reflect.set(this,"name",e),this}setType(e){return K(e),Reflect.set(this,"type",e),this}setDefaultPermission(e){return ye(e),Reflect.set(this,"defaultPermission",e),this}toJSON(){return Oe(this.name,this.type),{name:this.name,type:this.type,default_permission:this.defaultPermission}}};0&&(module.exports={ContextMenuCommandAssertions,ContextMenuCommandBuilder,Embed,EmbedAssertions,Faces,SlashCommandAssertions,SlashCommandBooleanOption,SlashCommandBuilder,SlashCommandChannelOption,SlashCommandIntegerOption,SlashCommandMentionableOption,SlashCommandNumberOption,SlashCommandRoleOption,SlashCommandStringOption,SlashCommandSubcommandBuilder,SlashCommandSubcommandGroupBuilder,SlashCommandUserOption,TimestampStyles,blockQuote,bold,channelMention,codeBlock,formatEmoji,hideLinkEmbed,hyperlink,inlineCode,italic,memberNicknameMention,quote,roleMention,spoiler,strikethrough,time,underscore,userMention});
//# sourceMappingURL=index.js.map
${e}\`\`\``}function je(t){return`\`${t}\``}function We(t){return`_${t}_`}function Ze(t){return`**${t}**`}function Ke(t){return`__${t}__`}function Qe(t){return`~~${t}~~`}function He(t){return`> ${t}`}function Xe(t){return`>>> ${t}`}function Ye(t){return`<${t}>`}function et(t,e,n){return n?`[${t}](${e} "${n}")`:`[${t}](${e})`}function tt(t){return`||${t}||`}function nt(t){return`<@${t}>`}function it(t){return`<@!${t}>`}function ot(t){return`<#${t}>`}function rt(t){return`<@&${t}>`}function at(t,e=!1){return`<${e?"a":""}:_:${t}>`}function st(t,e){return typeof t!="number"&&(t=Math.floor((t?.getTime()??Date.now())/1e3)),typeof e=="string"?`<t:${t}:${e}>`:`<t:${t}>`}var pt={ShortTime:"t",LongTime:"T",ShortDate:"d",LongDate:"D",ShortDateTime:"f",LongDateTime:"F",RelativeTime:"R"},ve=(o=>(o.Shrug="\xAF\\_(\u30C4)\\_/\xAF",o.Tableflip="(\u256F\xB0\u25A1\xB0\uFF09\u256F\uFE35 \u253B\u2501\u253B",o.Unflip="\u252C\u2500\u252C \u30CE( \u309C-\u309C\u30CE)",o))(ve||{});var re={};N(re,{assertReturnOfBuilder:()=>h,validateDefaultPermission:()=>ie,validateDescription:()=>D,validateMaxChoicesLength:()=>oe,validateMaxOptionsLength:()=>d,validateName:()=>k,validateRequired:()=>L,validateRequiredParameters:()=>c});var w=Ve(require("@sindresorhus/is")),T=require("zod");function c(t,e,n){k(t),D(e),d(n)}var mt=T.z.string().min(1).max(32).regex(/^[\P{Lu}\p{N}_-]+$/u);function k(t){mt.parse(t)}var dt=T.z.string().min(1).max(100);function D(t){dt.parse(t)}var $e=T.z.boolean();function ie(t){$e.parse(t)}function L(t){$e.parse(t)}var Ne=T.z.unknown().array().max(25);function d(t){Ne.parse(t)}function oe(t){Ne.parse(t)}function h(t,e){let n=e.name;if(w.default.nullOrUndefined(t))throw new TypeError(`Expected to receive a ${n} builder, got ${t===null?"null":"undefined"} instead.`);if(w.default.primitive(t))throw new TypeError(`Expected to receive a ${n} builder, got a primitive (${typeof t}) instead.`);if(!(t instanceof e)){let o=t,r=w.default.function_(t)?t.name:o.constructor.name,f=Reflect.get(o,Symbol.toStringTag),A=f?`${r} [${f}]`:r;throw new TypeError(`Expected to receive a ${n} builder, got ${A} instead.`)}}var De=require("ts-mixer");var ae=require("discord-api-types/v9");var C=class{constructor(){i(this,"name");i(this,"description")}setName(e){return k(e),Reflect.set(this,"name",e),this}setDescription(e){return D(e),Reflect.set(this,"description",e),this}};var p=class extends C{constructor(e){super();i(this,"required",!1);i(this,"type");this.type=e}setRequired(e){return L(e),this.required=e,this}toJSON(){return c(this.name,this.description,[]),L(this.required),{type:this.type,name:this.name,description:this.description,required:this.required}}};var _=class extends p{constructor(){super(ae.ApplicationCommandOptionType.Boolean);i(this,"type",ae.ApplicationCommandOptionType.Boolean)}};var me=require("discord-api-types/v9");var m=require("discord-api-types/v9"),se=require("zod");var lt=[m.ChannelType.GuildCategory,m.ChannelType.GuildNews,m.ChannelType.GuildNewsThread,m.ChannelType.GuildStore,m.ChannelType.GuildStageVoice,m.ChannelType.GuildText,m.ChannelType.GuildVoice,m.ChannelType.GuildPublicThread,m.ChannelType.GuildPrivateThread],ut=se.z.union(lt.map(t=>se.z.literal(t))),pe=class extends p{constructor(){super(...arguments);i(this,"channelTypes")}addChannelType(e){return this.channelTypes??=[],ut.parse(e),this.channelTypes.push(e),this}addChannelTypes(e){return e.forEach(n=>this.addChannelType(n)),this}toJSON(){return{...super.toJSON(),type:this.type,channel_types:this.channelTypes}}};var U=class extends pe{constructor(){super(me.ApplicationCommandOptionType.Channel);i(this,"type",me.ApplicationCommandOptionType.Channel)}};var de=require("discord-api-types/v9");var Be=require("discord-api-types/v9"),O=require("zod");var F=O.z.string().min(1).max(100),Re=O.z.number().gt(-1/0).lt(1/0),ct=O.z.tuple([F,O.z.union([F,Re])]).array(),ht=O.z.boolean(),I=class extends p{constructor(){super(...arguments);i(this,"choices");i(this,"autocomplete")}addChoice(e,n){if(this.autocomplete)throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");return this.choices??=[],oe(this.choices),F.parse(e),this.type===Be.ApplicationCommandOptionType.String?F.parse(n):Re.parse(n),this.choices.push({name:e,value:n}),this}addChoices(e){if(this.autocomplete)throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");ct.parse(e);for(let[n,o]of e)this.addChoice(n,o);return this}setAutocomplete(e){if(ht.parse(e),e&&Array.isArray(this.choices)&&this.choices.length>0)throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");return Reflect.set(this,"autocomplete",e),this}toJSON(){if(this.autocomplete&&Array.isArray(this.choices)&&this.choices.length>0)throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");return{...super.toJSON(),choices:this.choices,autocomplete:this.autocomplete}}};var v=class extends I{constructor(){super(...arguments);i(this,"maxValue");i(this,"minValue")}toJSON(){return{...super.toJSON(),min_value:this.minValue,max_value:this.maxValue}}};var Me=require("zod"),Ee=Me.z.number().int().nonnegative(),G=class extends v{constructor(){super(de.ApplicationCommandOptionType.Integer);i(this,"type",de.ApplicationCommandOptionType.Integer)}setMaxValue(e){return Ee.parse(e),this.maxValue=e,this}setMinValue(e){return Ee.parse(e),this.minValue=e,this}};var le=require("discord-api-types/v9");var J=class extends p{constructor(){super(le.ApplicationCommandOptionType.Mentionable);i(this,"type",le.ApplicationCommandOptionType.Mentionable)}};var ue=require("discord-api-types/v9");var we=require("zod"),ke=we.z.number().nonnegative(),V=class extends v{constructor(){super(ue.ApplicationCommandOptionType.Number);i(this,"type",ue.ApplicationCommandOptionType.Number)}setMaxValue(e){return ke.parse(e),this.maxValue=e,this}setMinValue(e){return ke.parse(e),this.minValue=e,this}};var ce=require("discord-api-types/v9");var q=class extends p{constructor(){super(ce.ApplicationCommandOptionType.Role);i(this,"type",ce.ApplicationCommandOptionType.Role)}};var he=require("discord-api-types/v9");var z=class extends I{constructor(){super(he.ApplicationCommandOptionType.String);i(this,"type",he.ApplicationCommandOptionType.String)}};var Ce=require("discord-api-types/v9");var j=class extends p{constructor(){super(Ce.ApplicationCommandOptionType.User);i(this,"type",Ce.ApplicationCommandOptionType.User)}};var $=class{constructor(){i(this,"options")}addBooleanOption(e){return this._sharedAddOptionMethod(e,_)}addUserOption(e){return this._sharedAddOptionMethod(e,j)}addChannelOption(e){return this._sharedAddOptionMethod(e,U)}addRoleOption(e){return this._sharedAddOptionMethod(e,q)}addMentionableOption(e){return this._sharedAddOptionMethod(e,J)}addStringOption(e){return this._sharedAddOptionMethod(e,z)}addIntegerOption(e){return this._sharedAddOptionMethod(e,G)}addNumberOption(e){return this._sharedAddOptionMethod(e,V)}_sharedAddOptionMethod(e,n){let{options:o}=this;d(o);let r=typeof e=="function"?e(new n):e;return h(r,n),o.push(r),this}};var be=require("discord-api-types/v9"),fe=require("ts-mixer");var b=class{constructor(){i(this,"name");i(this,"description");i(this,"options",[])}addSubcommand(e){let{options:n}=this;d(n);let o=typeof e=="function"?e(new l):e;return h(o,l),n.push(o),this}toJSON(){return c(this.name,this.description,this.options),{type:be.ApplicationCommandOptionType.SubcommandGroup,name:this.name,description:this.description,options:this.options.map(e=>e.toJSON())}}};b=g([(0,fe.mix)(C)],b);var l=class{constructor(){i(this,"name");i(this,"description");i(this,"options",[])}toJSON(){return c(this.name,this.description,this.options),{type:be.ApplicationCommandOptionType.Subcommand,name:this.name,description:this.description,options:this.options.map(e=>e.toJSON())}}};l=g([(0,fe.mix)(C,$)],l);var W=class{constructor(){i(this,"name");i(this,"description");i(this,"options",[]);i(this,"defaultPermission")}toJSON(){return c(this.name,this.description,this.options),{name:this.name,description:this.description,options:this.options.map(e=>e.toJSON()),default_permission:this.defaultPermission}}setDefaultPermission(e){return ie(e),Reflect.set(this,"defaultPermission",e),this}addSubcommandGroup(e){let{options:n}=this;d(n);let o=typeof e=="function"?e(new b):e;return h(o,b),n.push(o),this}addSubcommand(e){let{options:n}=this;d(n);let o=typeof e=="function"?e(new l):e;return h(o,l),n.push(o),this}};W=g([(0,De.mix)($,C)],W);var ye={};N(ye,{validateDefaultPermission:()=>Oe,validateName:()=>Z,validateRequiredParameters:()=>Se,validateType:()=>K});var y=require("zod"),xe=require("discord-api-types/v9");function Se(t,e){Z(t),K(e)}var Ct=y.z.string().min(1).max(32).regex(/^( *[\p{L}\p{N}_-]+ *)+$/u);function Z(t){Ct.parse(t)}var bt=y.z.union([y.z.literal(xe.ApplicationCommandType.User),y.z.literal(xe.ApplicationCommandType.Message)]);function K(t){bt.parse(t)}var ft=y.z.boolean();function Oe(t){ft.parse(t)}var Le=class{constructor(){i(this,"name");i(this,"type");i(this,"defaultPermission")}setName(e){return Z(e),Reflect.set(this,"name",e),this}setType(e){return K(e),Reflect.set(this,"type",e),this}setDefaultPermission(e){return Oe(e),Reflect.set(this,"defaultPermission",e),this}toJSON(){return Se(this.name,this.type),{name:this.name,type:this.type,default_permission:this.defaultPermission}}};module.exports=qe(xt);0&&(module.exports={ContextMenuCommandAssertions,ContextMenuCommandBuilder,Embed,EmbedAssertions,Faces,SlashCommandAssertions,SlashCommandBooleanOption,SlashCommandBuilder,SlashCommandChannelOption,SlashCommandIntegerOption,SlashCommandMentionableOption,SlashCommandNumberOption,SlashCommandRoleOption,SlashCommandStringOption,SlashCommandSubcommandBuilder,SlashCommandSubcommandGroupBuilder,SlashCommandUserOption,TimestampStyles,blockQuote,bold,channelMention,codeBlock,formatEmoji,hideLinkEmbed,hyperlink,inlineCode,italic,memberNicknameMention,quote,roleMention,spoiler,strikethrough,time,underscore,userMention});
//# sourceMappingURL=index.js.map
{
"name": "@discordjs/builders",
"version": "0.9.0",
"version": "0.10.0",
"description": "A set of builders that you can use when creating your bot",

@@ -59,3 +59,3 @@ "scripts": {

"@sindresorhus/is": "^4.2.0",
"discord-api-types": "^0.24.0",
"discord-api-types": "^0.25.2",
"ts-mixer": "^6.0.0",

@@ -66,16 +66,16 @@ "tslib": "^2.3.1",

"devDependencies": {
"@babel/core": "^7.15.8",
"@babel/plugin-proposal-decorators": "^7.15.8",
"@babel/preset-env": "^7.15.8",
"@babel/preset-typescript": "^7.15.0",
"@commitlint/cli": "^13.2.1",
"@commitlint/config-angular": "^13.2.0",
"@discordjs/ts-docgen": "^0.3.2",
"@types/jest": "^27.0.2",
"@babel/core": "^7.16.5",
"@babel/plugin-proposal-decorators": "^7.16.5",
"@babel/preset-env": "^7.16.5",
"@babel/preset-typescript": "^7.16.5",
"@commitlint/cli": "^15.0.0",
"@commitlint/config-angular": "^15.0.0",
"@discordjs/ts-docgen": "^0.3.4",
"@types/jest": "^27.0.3",
"@types/node": "^16.11.6",
"@typescript-eslint/eslint-plugin": "^5.2.0",
"@typescript-eslint/parser": "^5.2.0",
"@typescript-eslint/eslint-plugin": "^5.8.0",
"@typescript-eslint/parser": "^5.8.0",
"babel-plugin-transform-typescript-metadata": "^0.3.2",
"eslint": "^8.1.0",
"eslint-config-marine": "^9.0.6",
"eslint": "^8.5.0",
"eslint-config-marine": "^9.1.0",
"eslint-config-prettier": "^8.3.0",

@@ -85,9 +85,9 @@ "eslint-plugin-prettier": "^4.0.0",

"is-ci": "^3.0.1",
"jest": "^27.3.1",
"lint-staged": "^11.2.6",
"prettier": "^2.4.1",
"jest": "^27.4.5",
"lint-staged": "^12.1.4",
"prettier": "^2.5.1",
"standard-version": "^9.3.2",
"tsup": "^5.5.0",
"typedoc": "^0.22.7",
"typescript": "^4.4.4"
"tsup": "^5.11.8",
"typedoc": "^0.22.10",
"typescript": "^4.5.4"
},

@@ -94,0 +94,0 @@ "engines": {

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