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.8.2 to 0.9.0

74

dist/index.d.ts

@@ -1,28 +0,45 @@

import * as ow from 'ow';
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 { z } from 'zod';
import { Snowflake } from 'discord-api-types/globals';
import { URL } from 'url';
declare const fieldNamePredicate: ow.StringPredicate;
declare const fieldValuePredicate: ow.StringPredicate;
declare const fieldInlinePredicate: ow.BooleanPredicate & ow.BasePredicate<boolean | undefined>;
declare const embedFieldPredicate: ow.ObjectPredicate<{
declare const fieldNamePredicate: z.ZodString;
declare const fieldValuePredicate: z.ZodString;
declare const fieldInlinePredicate: z.ZodOptional<z.ZodBoolean>;
declare const embedFieldPredicate: z.ZodObject<{
name: z.ZodString;
value: z.ZodString;
inline: z.ZodOptional<z.ZodBoolean>;
}, "strip", z.ZodTypeAny, {
inline?: boolean | undefined;
name: string;
value: string;
inline: boolean | undefined;
}, {
inline?: boolean | undefined;
name: string;
value: string;
}>;
declare const embedFieldsArrayPredicate: ow.ArrayPredicate<{
declare const embedFieldsArrayPredicate: z.ZodArray<z.ZodObject<{
name: z.ZodString;
value: z.ZodString;
inline: z.ZodOptional<z.ZodBoolean>;
}, "strip", z.ZodTypeAny, {
inline?: boolean | undefined;
name: string;
value: string;
inline: boolean | undefined;
}>;
}, {
inline?: boolean | undefined;
name: string;
value: string;
}>, "many">;
declare const fieldLengthPredicate: z.ZodNumber;
declare function validateFieldLength(fields: APIEmbedField[], amountAdding: number): void;
declare const authorNamePredicate: ow.AnyPredicate<string | null>;
declare const urlPredicate: ow.AnyPredicate<string | null | undefined>;
declare const colorPredicate: ow.AnyPredicate<number | null>;
declare const descriptionPredicate: ow.AnyPredicate<string | null>;
declare const footerTextPredicate: ow.AnyPredicate<string | null>;
declare const timestampPredicate: ow.AnyPredicate<number | Date | null>;
declare const titlePredicate: ow.AnyPredicate<string | null>;
declare const authorNamePredicate: z.ZodNullable<z.ZodString>;
declare const urlPredicate: z.ZodNullable<z.ZodOptional<z.ZodString>>;
declare const colorPredicate: z.ZodNullable<z.ZodNumber>;
declare const descriptionPredicate: z.ZodNullable<z.ZodString>;
declare const footerTextPredicate: z.ZodNullable<z.ZodString>;
declare const timestampPredicate: z.ZodNullable<z.ZodUnion<[z.ZodNumber, z.ZodDate]>>;
declare const titlePredicate: z.ZodNullable<z.ZodString>;

@@ -34,2 +51,3 @@ declare const Assertions$2_fieldNamePredicate: typeof fieldNamePredicate;

declare const Assertions$2_embedFieldsArrayPredicate: typeof embedFieldsArrayPredicate;
declare const Assertions$2_fieldLengthPredicate: typeof fieldLengthPredicate;
declare const Assertions$2_validateFieldLength: typeof validateFieldLength;

@@ -50,2 +68,3 @@ declare const Assertions$2_authorNamePredicate: typeof authorNamePredicate;

Assertions$2_embedFieldsArrayPredicate as embedFieldsArrayPredicate,
Assertions$2_fieldLengthPredicate as fieldLengthPredicate,
Assertions$2_validateFieldLength as validateFieldLength,

@@ -464,2 +483,3 @@ Assertions$2_authorNamePredicate as authorNamePredicate,

choices?: APIApplicationCommandOptionChoice[];
readonly autocomplete?: boolean;
/**

@@ -471,3 +491,3 @@ * Adds a choice for this option

*/
addChoice(name: string, value: T): this;
addChoice(name: string, value: T): Omit<this, 'setAutocomplete'>;
/**

@@ -478,5 +498,11 @@ * Adds multiple choices for this option

*/
addChoices(choices: [name: string, value: T][]): this;
addChoices(choices: [name: string, value: T][]): Omit<this, 'setAutocomplete'>;
/**
* Marks the option as autocompletable
* @param autocomplete If this option should be autocompletable
*/
setAutocomplete<U extends boolean>(autocomplete: U): U extends true ? Omit<this, 'addChoice' | 'addChoices'> : this & Pick<ApplicationCommandOptionWithChoicesBase<T>, 'addChoice' | 'addChoices'>;
toJSON(): {
choices: APIApplicationCommandOptionChoice[] | undefined;
autocomplete: boolean | undefined;
type: ApplicationCommandOptionType.String | ApplicationCommandOptionType.Integer | ApplicationCommandOptionType.Number;

@@ -489,2 +515,3 @@ name: string;

choices: APIApplicationCommandOptionChoice[] | undefined;
autocomplete: boolean | undefined;
type: ApplicationCommandOptionType.Subcommand | ApplicationCommandOptionType.SubcommandGroup;

@@ -498,2 +525,3 @@ options?: discord_api_types_v9.APIApplicationCommandOption[] | undefined;

choices: APIApplicationCommandOptionChoice[] | undefined;
autocomplete: boolean | undefined;
type: ApplicationCommandOptionType.Channel;

@@ -507,2 +535,3 @@ 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;

choices: APIApplicationCommandOptionChoice[] | undefined;
autocomplete: boolean | undefined;
type: ApplicationCommandOptionType.Boolean | ApplicationCommandOptionType.User | ApplicationCommandOptionType.Role | ApplicationCommandOptionType.Mentionable;

@@ -583,3 +612,3 @@ name: string;

*/
addStringOption(input: SlashCommandStringOption | ((builder: SlashCommandStringOption) => SlashCommandStringOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
addStringOption(input: SlashCommandStringOption | Omit<SlashCommandStringOption, 'setAutocomplete'> | Omit<SlashCommandStringOption, 'addChoice' | 'addChoices'> | ((builder: SlashCommandStringOption) => SlashCommandStringOption | Omit<SlashCommandStringOption, 'setAutocomplete'> | Omit<SlashCommandStringOption, 'addChoice' | 'addChoices'>)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
/**

@@ -590,3 +619,3 @@ * Adds an integer option

*/
addIntegerOption(input: SlashCommandIntegerOption | ((builder: SlashCommandIntegerOption) => SlashCommandIntegerOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
addIntegerOption(input: SlashCommandIntegerOption | Omit<SlashCommandIntegerOption, 'setAutocomplete'> | Omit<SlashCommandIntegerOption, 'addChoice' | 'addChoices'> | ((builder: SlashCommandIntegerOption) => SlashCommandIntegerOption | Omit<SlashCommandIntegerOption, 'setAutocomplete'> | Omit<SlashCommandIntegerOption, 'addChoice' | 'addChoices'>)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
/**

@@ -597,3 +626,3 @@ * Adds a number option

*/
addNumberOption(input: SlashCommandNumberOption | ((builder: SlashCommandNumberOption) => SlashCommandNumberOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
addNumberOption(input: SlashCommandNumberOption | Omit<SlashCommandNumberOption, 'setAutocomplete'> | Omit<SlashCommandNumberOption, 'addChoice' | 'addChoices'> | ((builder: SlashCommandNumberOption) => SlashCommandNumberOption | Omit<SlashCommandNumberOption, 'setAutocomplete'> | Omit<SlashCommandNumberOption, 'addChoice' | 'addChoices'>)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
private _sharedAddOptionMethod;

@@ -745,2 +774,3 @@ }

declare function validateDefaultPermission$1(value: unknown): asserts value is boolean;
declare function validateRequired(required: unknown): asserts required is boolean;
declare function validateMaxOptionsLength(options: unknown): asserts options is ToAPIApplicationCommandOptions[];

@@ -751,2 +781,3 @@ declare function validateMaxChoicesLength(choices: APIApplicationCommandOptionChoice[]): void;

declare const Assertions$1_validateDescription: typeof validateDescription;
declare const Assertions$1_validateRequired: typeof validateRequired;
declare const Assertions$1_validateMaxOptionsLength: typeof validateMaxOptionsLength;

@@ -761,2 +792,3 @@ declare const Assertions$1_validateMaxChoicesLength: typeof validateMaxChoicesLength;

validateDefaultPermission$1 as validateDefaultPermission,
Assertions$1_validateRequired as validateRequired,
Assertions$1_validateMaxOptionsLength as validateMaxOptionsLength,

@@ -763,0 +795,0 @@ Assertions$1_validateMaxChoicesLength as validateMaxChoicesLength,

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

var Ee=Object.create;var T=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var Re=Object.getOwnPropertyNames;var Me=Object.getPrototypeOf,De=Object.prototype.hasOwnProperty;var _e=(t,e,n)=>e in t?T(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var $e=t=>T(t,"__esModule",{value:!0});var L=(t,e)=>{$e(t);for(var n in e)T(t,n,{get:e[n],enumerable:!0})},ke=(t,e,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Re(e))!De.call(t,o)&&o!=="default"&&T(t,o,{get:()=>e[o],enumerable:!(n=ve(e,o))||n.enumerable});return t},s=t=>ke($e(T(t!=null?Ee(Me(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t),I=(t,e,n,o)=>{for(var p=o>1?void 0:o?ve(e,n):e,P=t.length-1,$;P>=0;P--)($=t[P])&&(p=(o?$(e,n,p):$(p))||p);return o&&p&&T(e,n,p),p};var i=(t,e,n)=>(_e(t,typeof e!="symbol"?e+"":e,n),n);L(exports,{ContextMenuCommandAssertions:()=>Te,ContextMenuCommandBuilder:()=>Le,Embed:()=>B,EmbedAssertions:()=>ie,Faces:()=>oe,SlashCommandAssertions:()=>ae,SlashCommandBooleanOption:()=>G,SlashCommandBuilder:()=>K,SlashCommandChannelOption:()=>F,SlashCommandIntegerOption:()=>J,SlashCommandMentionableOption:()=>q,SlashCommandNumberOption:()=>V,SlashCommandRoleOption:()=>W,SlashCommandStringOption:()=>j,SlashCommandSubcommandBuilder:()=>f,SlashCommandSubcommandGroupBuilder:()=>O,SlashCommandUserOption:()=>z,TimestampStyles:()=>nt,blockQuote:()=>je,bold:()=>Je,channelMention:()=>Ye,codeBlock:()=>Ue,formatEmoji:()=>et,hideLinkEmbed:()=>ze,hyperlink:()=>Ke,inlineCode:()=>Ge,italic:()=>Fe,memberNicknameMention:()=>Xe,quote:()=>We,roleMention:()=>Ze,spoiler:()=>Qe,strikethrough:()=>Ve,time:()=>tt,underscore:()=>qe,userMention:()=>He});var ie={};L(ie,{authorNamePredicate:()=>X,colorPredicate:()=>Y,descriptionPredicate:()=>Z,embedFieldPredicate:()=>Ie,embedFieldsArrayPredicate:()=>M,fieldInlinePredicate:()=>R,fieldNamePredicate:()=>v,fieldValuePredicate:()=>E,footerTextPredicate:()=>ee,timestampPredicate:()=>te,titlePredicate:()=>ne,urlPredicate:()=>b,validateFieldLength:()=>D});var r=s(require("ow")),v=r.default.string.minLength(1).maxLength(256),E=r.default.string.minLength(1).maxLength(1024),R=r.default.optional.boolean,Ie=r.default.object.exactShape({name:v,value:E,inline:R}),M=r.default.array.ofType(Ie);function D(t,e){(0,r.default)(t.length+e,"field amount",r.default.number.lessThanOrEqual(25))}var X=r.default.any(v,r.default.null),b=r.default.any(r.default.string.url,r.default.nullOrUndefined),Y=r.default.any(r.default.number.greaterThanOrEqual(0).lessThanOrEqual(16777215),r.default.null),Z=r.default.any(r.default.string.minLength(1).maxLength(4096),r.default.null),ee=r.default.any(r.default.string.minLength(1).maxLength(2048),r.default.null),te=r.default.any(r.default.number,r.default.date,r.default.null),ne=r.default.any(v,r.default.null);var m=s(require("ow"));var B=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(0,m.default)(e,"fields",M),D(this.fields,e.length),this.fields.push(...B.normalizeFields(...e)),this}spliceFields(e,n,...o){return(0,m.default)(o,"fields",M),D(this.fields,o.length-n),this.fields.splice(e,n,...B.normalizeFields(...o)),this}setAuthor(e){if(e===null)return this.author=void 0,this;let{name:n,iconURL:o,url:p}=e;return(0,m.default)(n,"name",X),(0,m.default)(o,"iconURL",b),(0,m.default)(p,"url",b),this.author={name:n,url:p,icon_url:o},this}setColor(e){return(0,m.default)(e,"color",Y),this.color=e??void 0,this}setDescription(e){return(0,m.default)(e,"description",Z),this.description=e??void 0,this}setFooter(e){if(e===null)return this.footer=void 0,this;let{text:n,iconURL:o}=e;return(0,m.default)(n,"text",ee),(0,m.default)(o,"iconURL",b),this.footer={text:n,icon_url:o},this}setImage(e){return(0,m.default)(e,"url",b),this.image=e?{url:e}:void 0,this}setThumbnail(e){return(0,m.default)(e,"url",b),this.thumbnail=e?{url:e}:void 0,this}setTimestamp(e=Date.now()){return(0,m.default)(e,"timestamp",te),this.timestamp=e?new Date(e).toISOString():void 0,this}setTitle(e){return(0,m.default)(e,"title",ne),this.title=e??void 0,this}setURL(e){return(0,m.default)(e,"url",b),this.url=e??void 0,this}toJSON(){return{...this}}static normalizeFields(...e){return e.flat(1/0).map(n=>((0,m.default)(n.name,"field name",v),(0,m.default)(n.value,"field value",E),(0,m.default)(n.inline,"field inline",R),{name:n.name,value:n.value,inline:n.inline??void 0}))}};function Ue(t,e){return typeof e=="undefined"?`\`\`\`
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"?`\`\`\`
${t}\`\`\``:`\`\`\`${t}
${e}\`\`\``}function Ge(t){return`\`${t}\``}function Fe(t){return`_${t}_`}function Je(t){return`**${t}**`}function qe(t){return`__${t}__`}function Ve(t){return`~~${t}~~`}function We(t){return`> ${t}`}function je(t){return`>>> ${t}`}function ze(t){return`<${t}>`}function Ke(t,e,n){return n?`[${t}](${e} "${n}")`:`[${t}](${e})`}function Qe(t){return`||${t}||`}function He(t){return`<@${t}>`}function Xe(t){return`<@!${t}>`}function Ye(t){return`<#${t}>`}function Ze(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"},oe;(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)"})(oe||(oe={}));var ae={};L(ae,{assertReturnOfBuilder:()=>y,validateDefaultPermission:()=>re,validateDescription:()=>U,validateMaxChoicesLength:()=>se,validateMaxOptionsLength:()=>C,validateName:()=>k,validateRequiredParameters:()=>x});var _=s(require("@sindresorhus/is")),h=s(require("ow"));function x(t,e,n){k(t),U(e),C(n)}var it=h.default.string.lowercase.minLength(1).maxLength(32).addValidator({message:(t,e)=>`Expected ${e} to match "^[\\p{L}\\p{N}_-]+$", got ${t} instead`,validator:t=>/^[\p{L}\p{N}_-]+$/u.test(t)});function k(t){(0,h.default)(t,"name",it)}var ot=h.default.string.minLength(1).maxLength(100);function U(t){(0,h.default)(t,"description",ot)}var rt=h.default.boolean;function re(t){(0,h.default)(t,"default_permission",rt)}var Be=h.default.array.maxLength(25);function C(t){(0,h.default)(t,"options",Be)}function se(t){(0,h.default)(t,"choices",Be)}function y(t,e){let n=e.name;if(_.default.nullOrUndefined(t))throw new TypeError(`Expected to receive a ${n} builder, got ${t===null?"null":"undefined"} instead.`);if(_.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,p=_.default.function_(t)?t.name:o.constructor.name,P=Reflect.get(o,Symbol.toStringTag),$=P?`${p} [${P}]`:p;throw new TypeError(`Expected to receive a ${n} builder, got ${$} instead.`)}}var we=s(require("ts-mixer"));var me=s(require("discord-api-types/v9"));var N=s(require("ow"));var S=class{constructor(){i(this,"name");i(this,"description")}setName(e){return k(e),Reflect.set(this,"name",e),this}setDescription(e){return U(e),Reflect.set(this,"description",e),this}};var d=class extends S{constructor(e){super();i(this,"required",!1);i(this,"type");this.type=e}setRequired(e){return(0,N.default)(e,"required",N.default.boolean),this.required=e,this}toJSON(){return x(this.name,this.description,[]),(0,N.default)(this.required,"required",N.default.boolean),{type:this.type,name:this.name,description:this.description,required:this.required}}};var G=class extends d{constructor(){super(me.ApplicationCommandOptionType.Boolean);i(this,"type",me.ApplicationCommandOptionType.Boolean)}};var le=s(require("discord-api-types/v9"));var l=s(require("discord-api-types/v9")),pe=s(require("ow"));var st=[l.ChannelType.GuildCategory,l.ChannelType.GuildNews,l.ChannelType.GuildNewsThread,l.ChannelType.GuildStore,l.ChannelType.GuildStageVoice,l.ChannelType.GuildText,l.ChannelType.GuildVoice,l.ChannelType.GuildPublicThread,l.ChannelType.GuildPrivateThread],at=pe.default.number.oneOf(st),de=class extends d{constructor(){super(...arguments);i(this,"channelTypes")}addChannelType(e){return this.channelTypes??=[],(0,pe.default)(e,"channel type",at),this.channelTypes.push(e),this}addChannelTypes(e){return e.forEach(n=>this.addChannelType(n)),this}toJSON(){return{...super.toJSON(),type:l.ApplicationCommandOptionType.Channel,channel_types:this.channelTypes}}};var F=class extends de{constructor(){super(le.ApplicationCommandOptionType.Channel);i(this,"type",le.ApplicationCommandOptionType.Channel)}};var he=s(require("discord-api-types/v9"));var c=s(require("discord-api-types/v9")),u=s(require("ow"));var ce=u.default.string.minLength(1).maxLength(100),Ne=u.default.number.finite,mt=u.default.array.ofType(u.default.array.exactShape([ce,u.default.any(u.default.string,Ne)])),g=class extends d{constructor(){super(...arguments);i(this,"choices")}addChoice(e,n){return this.choices??=[],se(this.choices),(0,u.default)(e,`${ue[this.type]} choice name`,ce),this.type===c.ApplicationCommandOptionType.String?(0,u.default)(n,"string choice value",ce):(0,u.default)(n,`${ue[this.type]} choice value`,Ne),this.choices.push({name:e,value:n}),this}addChoices(e){(0,u.default)(e,`${ue[this.type]} choices`,mt);for(let[n,o]of e)this.addChoice(n,o);return this}toJSON(){return{...super.toJSON(),choices:this.choices}}},ue={[c.ApplicationCommandOptionType.Subcommand]:"subcommand",[c.ApplicationCommandOptionType.SubcommandGroup]:"subcommand group",[c.ApplicationCommandOptionType.String]:"string",[c.ApplicationCommandOptionType.Integer]:"integer",[c.ApplicationCommandOptionType.Boolean]:"boolean",[c.ApplicationCommandOptionType.User]:"user",[c.ApplicationCommandOptionType.Channel]:"channel",[c.ApplicationCommandOptionType.Role]:"role",[c.ApplicationCommandOptionType.Mentionable]:"mentionable",[c.ApplicationCommandOptionType.Number]:"number"};var J=class extends g{constructor(){super(he.ApplicationCommandOptionType.Integer);i(this,"type",he.ApplicationCommandOptionType.Integer)}};var Ce=s(require("discord-api-types/v9"));var q=class extends d{constructor(){super(Ce.ApplicationCommandOptionType.Mentionable);i(this,"type",Ce.ApplicationCommandOptionType.Mentionable)}};var fe=s(require("discord-api-types/v9"));var V=class extends g{constructor(){super(fe.ApplicationCommandOptionType.Number);i(this,"type",fe.ApplicationCommandOptionType.Number)}};var be=s(require("discord-api-types/v9"));var W=class extends d{constructor(){super(be.ApplicationCommandOptionType.Role);i(this,"type",be.ApplicationCommandOptionType.Role)}};var xe=s(require("discord-api-types/v9"));var j=class extends g{constructor(){super(xe.ApplicationCommandOptionType.String);i(this,"type",xe.ApplicationCommandOptionType.String)}};var ye=s(require("discord-api-types/v9"));var z=class extends d{constructor(){super(ye.ApplicationCommandOptionType.User);i(this,"type",ye.ApplicationCommandOptionType.User)}};var w=class{constructor(){i(this,"options")}addBooleanOption(e){return this._sharedAddOptionMethod(e,G)}addUserOption(e){return this._sharedAddOptionMethod(e,z)}addChannelOption(e){return this._sharedAddOptionMethod(e,F)}addRoleOption(e){return this._sharedAddOptionMethod(e,W)}addMentionableOption(e){return this._sharedAddOptionMethod(e,q)}addStringOption(e){return this._sharedAddOptionMethod(e,j)}addIntegerOption(e){return this._sharedAddOptionMethod(e,J)}addNumberOption(e){return this._sharedAddOptionMethod(e,V)}_sharedAddOptionMethod(e,n){let{options:o}=this;C(o);let p=typeof e=="function"?e(new n):e;return y(p,n),o.push(p),this}};var Se=s(require("discord-api-types/v9")),ge=s(require("ts-mixer"));var O=class{constructor(){i(this,"name");i(this,"description");i(this,"options",[])}addSubcommand(e){let{options:n}=this;C(n);let o=typeof e=="function"?e(new f):e;return y(o,f),n.push(o),this}toJSON(){return x(this.name,this.description,this.options),{type:Se.ApplicationCommandOptionType.SubcommandGroup,name:this.name,description:this.description,options:this.options.map(e=>e.toJSON())}}};O=I([(0,ge.mix)(S)],O);var f=class{constructor(){i(this,"name");i(this,"description");i(this,"options",[])}toJSON(){return x(this.name,this.description,this.options),{type:Se.ApplicationCommandOptionType.Subcommand,name:this.name,description:this.description,options:this.options.map(e=>e.toJSON())}}};f=I([(0,ge.mix)(S,w)],f);var K=class{constructor(){i(this,"name");i(this,"description");i(this,"options",[]);i(this,"defaultPermission")}toJSON(){return x(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 re(e),Reflect.set(this,"defaultPermission",e),this}addSubcommandGroup(e){let{options:n}=this;C(n);let o=typeof e=="function"?e(new O):e;return y(o,O),n.push(o),this}addSubcommand(e){let{options:n}=this;C(n);let o=typeof e=="function"?e(new f):e;return y(o,f),n.push(o),this}};K=I([(0,we.mix)(w,S)],K);var Te={};L(Te,{validateDefaultPermission:()=>Pe,validateName:()=>Q,validateRequiredParameters:()=>Ae,validateType:()=>H});var A=s(require("ow")),Oe=s(require("discord-api-types/v9"));function Ae(t,e){Q(t),H(e)}var pt=A.default.string.minLength(1).maxLength(32).matches(/^( *[\p{L}\p{N}_-]+ *)+$/u);function Q(t){(0,A.default)(t,"name",pt)}var dt=A.default.number.oneOf([Oe.ApplicationCommandType.User,Oe.ApplicationCommandType.Message]);function H(t){(0,A.default)(t,"type",dt)}var lt=A.default.boolean;function Pe(t){(0,A.default)(t,"default_permission",lt)}var Le=class{constructor(){i(this,"name");i(this,"type");i(this,"defaultPermission")}setName(e){return Q(e),Reflect.set(this,"name",e),this}setType(e){return H(e),Reflect.set(this,"type",e),this}setDefaultPermission(e){return Pe(e),Reflect.set(this,"defaultPermission",e),this}toJSON(){return Ae(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});
${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
{
"name": "@discordjs/builders",
"version": "0.8.2",
"version": "0.9.0",
"description": "A set of builders that you can use when creating your bot",

@@ -60,5 +60,5 @@ "scripts": {

"discord-api-types": "^0.24.0",
"ow": "^0.27.0",
"ts-mixer": "^6.0.0",
"tslib": "^2.3.1"
"tslib": "^2.3.1",
"zod": "^3.11.6"
},

@@ -65,0 +65,0 @@ "devDependencies": {

@@ -9,4 +9,4 @@ <div align="center">

<a href="https://discord.gg/djs"><img src="https://img.shields.io/discord/222078108977594368?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
<a href="https://www.npmjs.com/package/@discordjs/builders"><img src="https://img.shields.io/npm/v/@discordjs/builders.svg?maxAge=3600" alt="NPM version" /></a>
<a href="https://www.npmjs.com/package/@discordjs/builders"><img src="https://img.shields.io/npm/dt/@discordjs/builders.svg?maxAge=3600" alt="NPM downloads" /></a>
<a href="https://www.npmjs.com/package/@discordjs/builders"><img src="https://img.shields.io/npm/v/@discordjs/builders.svg?maxAge=3600" alt="npm version" /></a>
<a href="https://www.npmjs.com/package/@discordjs/builders"><img src="https://img.shields.io/npm/dt/@discordjs/builders.svg?maxAge=3600" alt="npm downloads" /></a>
<a href="https://github.com/discordjs/builders/actions"><img src="https://github.com/discordjs/builders/workflows/Tests/badge.svg" alt="Build status" /></a>

@@ -42,3 +42,3 @@ <a href="https://codecov.io/gh/discordjs/builders"><img src="https://codecov.io/gh/discordjs/builders/branch/main/graph/badge.svg" alt="Code coverage" /></a>

- [GitHub](https://github.com/discordjs/builders)
- [NPM](https://www.npmjs.com/package/@discordjs/builders)
- [npm](https://www.npmjs.com/package/@discordjs/builders)
- [Related libraries](https://discord.com/developers/docs/topics/community-resources#libraries)

@@ -45,0 +45,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

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