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.13.0-dev.1645877056.a8321d8 to 0.13.0-dev.1646222605.53defb8

6

dist/index.d.ts

@@ -173,8 +173,2 @@ import * as discord_api_types_v9 from 'discord-api-types/v9';

/**
* Adds a field to the embed (max 25)
*
* @param field The field to add.
*/
addField(field: APIEmbedField): this;
/**
* Adds fields to the embed (max 25)

@@ -181,0 +175,0 @@ *

2

dist/index.js

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

var Ee=Object.create;var I=Object.defineProperty;var zt=Object.getOwnPropertyDescriptor;var Be=Object.getOwnPropertyNames;var Ne=Object.getPrototypeOf,$e=Object.prototype.hasOwnProperty;var De=(e,t,n)=>t in e?I(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Zt=e=>I(e,"__esModule",{value:!0}),o=(e,t)=>I(e,"name",{value:t,configurable:!0});var U=(e,t)=>{for(var n in t)I(e,n,{get:t[n],enumerable:!0})},Kt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Be(t))!$e.call(e,s)&&(n||s!=="default")&&I(e,s,{get:()=>t[s],enumerable:!(r=zt(t,s))||r.enumerable});return e},J=(e,t)=>Kt(Zt(I(e!=null?Ee(Ne(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),Le=(e=>(t,n)=>e&&e.get(t)||(n=Kt(Zt({}),t,1),e&&e.set(t,n),n))(typeof WeakMap!="undefined"?new WeakMap:0),d=(e,t,n,r)=>{for(var s=r>1?void 0:r?zt(t,n):t,A=e.length-1,P;A>=0;A--)(P=e[A])&&(s=(r?P(t,n,s):P(s))||s);return r&&s&&I(t,n,s),s};var i=(e,t,n)=>(De(e,typeof t!="symbol"?t+"":t,n),n);var lo={};U(lo,{ActionRow:()=>M,ButtonComponent:()=>F,Component:()=>u,ComponentAssertions:()=>Bt,ContextMenuCommandAssertions:()=>Gt,ContextMenuCommandBuilder:()=>Wt,Embed:()=>St,EmbedAssertions:()=>Ot,Faces:()=>ee,SelectMenuComponent:()=>G,SelectMenuOption:()=>Dt,SlashCommandAssertions:()=>Vt,SlashCommandAttachmentOption:()=>Q,SlashCommandBooleanOption:()=>z,SlashCommandBuilder:()=>X,SlashCommandChannelOption:()=>w,SlashCommandIntegerOption:()=>E,SlashCommandMentionableOption:()=>Z,SlashCommandNumberOption:()=>B,SlashCommandRoleOption:()=>K,SlashCommandStringOption:()=>N,SlashCommandSubcommandBuilder:()=>b,SlashCommandSubcommandGroupBuilder:()=>S,SlashCommandUserOption:()=>H,TimestampStyles:()=>to,UnsafeButtonComponent:()=>R,UnsafeEmbed:()=>T,UnsafeSelectMenuComponent:()=>v,UnsafeSelectMenuOption:()=>c,blockQuote:()=>Fe,bold:()=>Je,channelMention:()=>Qe,codeBlock:()=>_e,createComponent:()=>Nt,formatEmoji:()=>Xe,hideLinkEmbed:()=>Ge,hyperlink:()=>We,inlineCode:()=>Ve,isJSONEncodable:()=>mo,italic:()=>Ue,memberNicknameMention:()=>Ke,quote:()=>je,roleMention:()=>He,spoiler:()=>ze,strikethrough:()=>ke,time:()=>Ye,underscore:()=>qe,userMention:()=>Ze});var Ot={};U(Ot,{RGBPredicate:()=>ot,authorNamePredicate:()=>ft,colorPredicate:()=>Ct,descriptionPredicate:()=>At,embedFieldPredicate:()=>Xt,embedFieldsArrayPredicate:()=>tt,fieldInlinePredicate:()=>Ht,fieldLengthPredicate:()=>Yt,fieldNamePredicate:()=>Y,fieldValuePredicate:()=>Qt,footerTextPredicate:()=>xt,timestampPredicate:()=>yt,titlePredicate:()=>gt,urlPredicate:()=>x,validateFieldLength:()=>et});var m=require("zod"),Y=m.z.string().min(1).max(256),Qt=m.z.string().min(1).max(1024),Ht=m.z.boolean().optional(),Xt=m.z.object({name:Y,value:Qt,inline:Ht}),tt=Xt.array(),Yt=m.z.number().lte(25);function et(e,t){Yt.parse((t?.length??0)+e)}o(et,"validateFieldLength");var ft=Y.nullable(),x=m.z.string().url().nullish(),ot=m.z.number().int().gte(0).lte(255),Ct=m.z.number().int().gte(0).lte(16777215).nullable().or(m.z.tuple([ot,ot,ot])),At=m.z.string().min(1).max(4096).nullable(),xt=m.z.string().min(1).max(2048).nullable(),yt=m.z.union([m.z.number(),m.z.date()]).nullable(),gt=Y.nullable();var te=J(require("fast-deep-equal")),T=class{constructor(t={}){i(this,"data");this.data={...t},t.timestamp&&(this.data.timestamp=new Date(t.timestamp).toISOString())}get fields(){return this.data.fields}get title(){return this.data.title}get description(){return this.data.description}get url(){return this.data.url}get color(){return this.data.color}get timestamp(){return this.data.timestamp}get thumbnail(){if(!!this.data.thumbnail)return{url:this.data.thumbnail.url,proxyURL:this.data.thumbnail.proxy_url,height:this.data.thumbnail.height,width:this.data.thumbnail.width}}get image(){if(!!this.data.image)return{url:this.data.image.url,proxyURL:this.data.image.proxy_url,height:this.data.image.height,width:this.data.image.width}}get video(){return this.data.video}get author(){if(!!this.data.author)return{name:this.data.author.name,url:this.data.author.url,iconURL:this.data.author.icon_url,proxyIconURL:this.data.author.proxy_icon_url}}get provider(){return this.data.provider}get footer(){if(!!this.data.footer)return{text:this.data.footer.text,iconURL:this.data.footer.icon_url,proxyIconURL:this.data.footer.proxy_icon_url}}get length(){return(this.data.title?.length??0)+(this.data.description?.length??0)+(this.data.fields?.reduce((t,n)=>t+n.name.length+n.value.length,0)??0)+(this.data.footer?.text.length??0)+(this.data.author?.name.length??0)}get hexColor(){return typeof this.data.color=="number"?`#${this.data.color.toString(16).padStart(6,"0")}`:this.data.color}addField(t){return this.addFields(t)}addFields(...t){return this.data.fields?this.data.fields.push(...t):this.data.fields=t,this}spliceFields(t,n,...r){return this.data.fields?this.data.fields.splice(t,n,...r):this.data.fields=r,this}setFields(...t){return this.spliceFields(0,this.fields?.length??0,...t),this}setAuthor(t){return t===null?(this.data.author=void 0,this):(this.data.author={name:t.name,url:t.url,icon_url:t.iconURL},this)}setColor(t){if(Array.isArray(t)){let[n,r,s]=t;return this.data.color=(n<<16)+(r<<8)+s,this}return this.data.color=t??void 0,this}setDescription(t){return this.data.description=t??void 0,this}setFooter(t){return t===null?(this.data.footer=void 0,this):(this.data.footer={text:t.text,icon_url:t.iconURL},this)}setImage(t){return this.data.image=t?{url:t}:void 0,this}setThumbnail(t){return this.data.thumbnail=t?{url:t}:void 0,this}setTimestamp(t=Date.now()){return this.data.timestamp=t?new Date(t).toISOString():void 0,this}setTitle(t){return this.data.title=t??void 0,this}setURL(t){return this.data.url=t??void 0,this}toJSON(){return{...this.data}}equals(t){let{image:n,thumbnail:r,...s}=this.data,A=t instanceof T?t.data:t,{image:P,thumbnail:ve,...we}=A;return(0,te.default)(we,s)&&P?.url===n?.url&&ve?.url===r?.url}};o(T,"UnsafeEmbed");var St=class extends T{addFields(...t){return et(t.length,this.fields),super.addFields(...tt.parse(t))}spliceFields(t,n,...r){return et(r.length-n,this.fields),super.spliceFields(t,n,...tt.parse(r))}setAuthor(t){return t===null?super.setAuthor(null):(ft.parse(t.name),x.parse(t.iconURL),x.parse(t.url),super.setAuthor(t))}setColor(t){return super.setColor(Ct.parse(t))}setDescription(t){return super.setDescription(At.parse(t))}setFooter(t){return t===null?super.setFooter(null):(xt.parse(t.text),x.parse(t.iconURL),super.setFooter(t))}setImage(t){return super.setImage(x.parse(t))}setThumbnail(t){return super.setThumbnail(x.parse(t))}setTimestamp(t=Date.now()){return super.setTimestamp(yt.parse(t))}setTitle(t){return super.setTitle(gt.parse(t))}setURL(t){return super.setURL(x.parse(t))}};o(St,"Embed");function _e(e,t){return typeof t=="undefined"?`\`\`\`
var Ee=Object.create;var I=Object.defineProperty;var zt=Object.getOwnPropertyDescriptor;var Be=Object.getOwnPropertyNames;var Ne=Object.getPrototypeOf,$e=Object.prototype.hasOwnProperty;var De=(e,t,n)=>t in e?I(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Zt=e=>I(e,"__esModule",{value:!0}),o=(e,t)=>I(e,"name",{value:t,configurable:!0});var U=(e,t)=>{for(var n in t)I(e,n,{get:t[n],enumerable:!0})},Kt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Be(t))!$e.call(e,s)&&(n||s!=="default")&&I(e,s,{get:()=>t[s],enumerable:!(r=zt(t,s))||r.enumerable});return e},J=(e,t)=>Kt(Zt(I(e!=null?Ee(Ne(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),Le=(e=>(t,n)=>e&&e.get(t)||(n=Kt(Zt({}),t,1),e&&e.set(t,n),n))(typeof WeakMap!="undefined"?new WeakMap:0),d=(e,t,n,r)=>{for(var s=r>1?void 0:r?zt(t,n):t,A=e.length-1,P;A>=0;A--)(P=e[A])&&(s=(r?P(t,n,s):P(s))||s);return r&&s&&I(t,n,s),s};var i=(e,t,n)=>(De(e,typeof t!="symbol"?t+"":t,n),n);var lo={};U(lo,{ActionRow:()=>M,ButtonComponent:()=>F,Component:()=>u,ComponentAssertions:()=>Bt,ContextMenuCommandAssertions:()=>Gt,ContextMenuCommandBuilder:()=>Wt,Embed:()=>St,EmbedAssertions:()=>Ot,Faces:()=>ee,SelectMenuComponent:()=>G,SelectMenuOption:()=>Dt,SlashCommandAssertions:()=>Vt,SlashCommandAttachmentOption:()=>Q,SlashCommandBooleanOption:()=>z,SlashCommandBuilder:()=>X,SlashCommandChannelOption:()=>w,SlashCommandIntegerOption:()=>E,SlashCommandMentionableOption:()=>Z,SlashCommandNumberOption:()=>B,SlashCommandRoleOption:()=>K,SlashCommandStringOption:()=>N,SlashCommandSubcommandBuilder:()=>b,SlashCommandSubcommandGroupBuilder:()=>S,SlashCommandUserOption:()=>H,TimestampStyles:()=>to,UnsafeButtonComponent:()=>R,UnsafeEmbed:()=>T,UnsafeSelectMenuComponent:()=>v,UnsafeSelectMenuOption:()=>c,blockQuote:()=>Fe,bold:()=>Je,channelMention:()=>Qe,codeBlock:()=>_e,createComponent:()=>Nt,formatEmoji:()=>Xe,hideLinkEmbed:()=>Ge,hyperlink:()=>We,inlineCode:()=>Ve,isJSONEncodable:()=>mo,italic:()=>Ue,memberNicknameMention:()=>Ke,quote:()=>je,roleMention:()=>He,spoiler:()=>ze,strikethrough:()=>ke,time:()=>Ye,underscore:()=>qe,userMention:()=>Ze});var Ot={};U(Ot,{RGBPredicate:()=>ot,authorNamePredicate:()=>ft,colorPredicate:()=>Ct,descriptionPredicate:()=>At,embedFieldPredicate:()=>Xt,embedFieldsArrayPredicate:()=>tt,fieldInlinePredicate:()=>Ht,fieldLengthPredicate:()=>Yt,fieldNamePredicate:()=>Y,fieldValuePredicate:()=>Qt,footerTextPredicate:()=>xt,timestampPredicate:()=>yt,titlePredicate:()=>gt,urlPredicate:()=>x,validateFieldLength:()=>et});var m=require("zod"),Y=m.z.string().min(1).max(256),Qt=m.z.string().min(1).max(1024),Ht=m.z.boolean().optional(),Xt=m.z.object({name:Y,value:Qt,inline:Ht}),tt=Xt.array(),Yt=m.z.number().lte(25);function et(e,t){Yt.parse((t?.length??0)+e)}o(et,"validateFieldLength");var ft=Y.nullable(),x=m.z.string().url().nullish(),ot=m.z.number().int().gte(0).lte(255),Ct=m.z.number().int().gte(0).lte(16777215).nullable().or(m.z.tuple([ot,ot,ot])),At=m.z.string().min(1).max(4096).nullable(),xt=m.z.string().min(1).max(2048).nullable(),yt=m.z.union([m.z.number(),m.z.date()]).nullable(),gt=Y.nullable();var te=J(require("fast-deep-equal")),T=class{constructor(t={}){i(this,"data");this.data={...t},t.timestamp&&(this.data.timestamp=new Date(t.timestamp).toISOString())}get fields(){return this.data.fields}get title(){return this.data.title}get description(){return this.data.description}get url(){return this.data.url}get color(){return this.data.color}get timestamp(){return this.data.timestamp}get thumbnail(){if(!!this.data.thumbnail)return{url:this.data.thumbnail.url,proxyURL:this.data.thumbnail.proxy_url,height:this.data.thumbnail.height,width:this.data.thumbnail.width}}get image(){if(!!this.data.image)return{url:this.data.image.url,proxyURL:this.data.image.proxy_url,height:this.data.image.height,width:this.data.image.width}}get video(){return this.data.video}get author(){if(!!this.data.author)return{name:this.data.author.name,url:this.data.author.url,iconURL:this.data.author.icon_url,proxyIconURL:this.data.author.proxy_icon_url}}get provider(){return this.data.provider}get footer(){if(!!this.data.footer)return{text:this.data.footer.text,iconURL:this.data.footer.icon_url,proxyIconURL:this.data.footer.proxy_icon_url}}get length(){return(this.data.title?.length??0)+(this.data.description?.length??0)+(this.data.fields?.reduce((t,n)=>t+n.name.length+n.value.length,0)??0)+(this.data.footer?.text.length??0)+(this.data.author?.name.length??0)}get hexColor(){return typeof this.data.color=="number"?`#${this.data.color.toString(16).padStart(6,"0")}`:this.data.color}addFields(...t){return this.data.fields?this.data.fields.push(...t):this.data.fields=t,this}spliceFields(t,n,...r){return this.data.fields?this.data.fields.splice(t,n,...r):this.data.fields=r,this}setFields(...t){return this.spliceFields(0,this.fields?.length??0,...t),this}setAuthor(t){return t===null?(this.data.author=void 0,this):(this.data.author={name:t.name,url:t.url,icon_url:t.iconURL},this)}setColor(t){if(Array.isArray(t)){let[n,r,s]=t;return this.data.color=(n<<16)+(r<<8)+s,this}return this.data.color=t??void 0,this}setDescription(t){return this.data.description=t??void 0,this}setFooter(t){return t===null?(this.data.footer=void 0,this):(this.data.footer={text:t.text,icon_url:t.iconURL},this)}setImage(t){return this.data.image=t?{url:t}:void 0,this}setThumbnail(t){return this.data.thumbnail=t?{url:t}:void 0,this}setTimestamp(t=Date.now()){return this.data.timestamp=t?new Date(t).toISOString():void 0,this}setTitle(t){return this.data.title=t??void 0,this}setURL(t){return this.data.url=t??void 0,this}toJSON(){return{...this.data}}equals(t){let{image:n,thumbnail:r,...s}=this.data,A=t instanceof T?t.data:t,{image:P,thumbnail:ve,...we}=A;return(0,te.default)(we,s)&&P?.url===n?.url&&ve?.url===r?.url}};o(T,"UnsafeEmbed");var St=class extends T{addFields(...t){return et(t.length,this.fields),super.addFields(...tt.parse(t))}spliceFields(t,n,...r){return et(r.length-n,this.fields),super.spliceFields(t,n,...tt.parse(r))}setAuthor(t){return t===null?super.setAuthor(null):(ft.parse(t.name),x.parse(t.iconURL),x.parse(t.url),super.setAuthor(t))}setColor(t){return super.setColor(Ct.parse(t))}setDescription(t){return super.setDescription(At.parse(t))}setFooter(t){return t===null?super.setFooter(null):(xt.parse(t.text),x.parse(t.iconURL),super.setFooter(t))}setImage(t){return super.setImage(x.parse(t))}setThumbnail(t){return super.setThumbnail(x.parse(t))}setTimestamp(t=Date.now()){return super.setTimestamp(yt.parse(t))}setTitle(t){return super.setTitle(gt.parse(t))}setURL(t){return super.setURL(x.parse(t))}};o(St,"Embed");function _e(e,t){return typeof t=="undefined"?`\`\`\`
${e}\`\`\``:`\`\`\`${e}
${t}\`\`\``}o(_e,"codeBlock");function Ve(e){return`\`${e}\``}o(Ve,"inlineCode");function Ue(e){return`_${e}_`}o(Ue,"italic");function Je(e){return`**${e}**`}o(Je,"bold");function qe(e){return`__${e}__`}o(qe,"underscore");function ke(e){return`~~${e}~~`}o(ke,"strikethrough");function je(e){return`> ${e}`}o(je,"quote");function Fe(e){return`>>> ${e}`}o(Fe,"blockQuote");function Ge(e){return`<${e}>`}o(Ge,"hideLinkEmbed");function We(e,t,n){return n?`[${e}](${t} "${n}")`:`[${e}](${t})`}o(We,"hyperlink");function ze(e){return`||${e}||`}o(ze,"spoiler");function Ze(e){return`<@${e}>`}o(Ze,"userMention");function Ke(e){return`<@!${e}>`}o(Ke,"memberNicknameMention");function Qe(e){return`<#${e}>`}o(Qe,"channelMention");function He(e){return`<@&${e}>`}o(He,"roleMention");function Xe(e,t=!1){return`<${t?"a":""}:_:${e}>`}o(Xe,"formatEmoji");function Ye(e,t){return typeof e!="number"&&(e=Math.floor((e?.getTime()??Date.now())/1e3)),typeof t=="string"?`<t:${e}:${t}>`:`<t:${e}>`}o(Ye,"time");var to={ShortTime:"t",LongTime:"T",ShortDate:"d",LongDate:"D",ShortDateTime:"f",LongDateTime:"F",RelativeTime:"R"},ee=(r=>(r.Shrug="\xAF\\_(\u30C4)\\_/\xAF",r.Tableflip="(\u256F\xB0\u25A1\xB0\uFF09\u256F\uFE35 \u253B\u2501\u253B",r.Unflip="\u252C\u2500\u252C \u30CE( \u309C-\u309C\u30CE)",r))(ee||{});var Bt={};U(Bt,{buttonLabelValidator:()=>Pt,buttonStyleValidator:()=>It,customIdValidator:()=>$,defaultValidator:()=>Rt,disabledValidator:()=>k,emojiValidator:()=>q,labelValueValidator:()=>j,minMaxValidator:()=>it,optionsValidator:()=>oe,placeholderValidator:()=>Tt,urlValidator:()=>wt,validateRequiredButtonParameters:()=>Et,validateRequiredSelectMenuOptionParameters:()=>vt,validateRequiredSelectMenuParameters:()=>Mt});var nt=require("discord-api-types/v9"),l=require("zod"),$=l.z.string().min(1).max(100),q=l.z.object({id:l.z.string(),name:l.z.string(),animated:l.z.boolean()}).partial().strict(),k=l.z.boolean(),Pt=l.z.string().nonempty().max(80),It=l.z.number().int().min(nt.ButtonStyle.Primary).max(nt.ButtonStyle.Link),Tt=l.z.string().max(100),it=l.z.number().int().min(0).max(25),oe=l.z.object({}).array().nonempty();function Mt(e,t){$.parse(t),oe.parse(e)}o(Mt,"validateRequiredSelectMenuParameters");var j=l.z.string().min(1).max(100),Rt=l.z.boolean();function vt(e,t){j.parse(e),j.parse(t)}o(vt,"validateRequiredSelectMenuOptionParameters");var wt=l.z.string().url();function Et(e,t,n,r,s){if(s&&r)throw new RangeError("URL and custom id are mutually exclusive");if(!t&&!n)throw new RangeError("Buttons must have a label and/or an emoji");if(e===nt.ButtonStyle.Link){if(!s)throw new RangeError("Link buttons must have a url")}else if(s)throw new RangeError("Non-link buttons cannot have a url")}o(Et,"validateRequiredButtonParameters");var ne=require("discord-api-types/v9");var u=class{constructor(t){i(this,"data");this.data=t}get type(){return this.data.type}};o(u,"Component");var rt=require("discord-api-types/v9");function Nt(e){if(e instanceof u)return e;switch(e.type){case rt.ComponentType.ActionRow:return new M(e);case rt.ComponentType.Button:return new F(e);case rt.ComponentType.SelectMenu:return new G(e);default:throw new Error(`Cannot serialize component type: ${e.type}`)}}o(Nt,"createComponent");var at=J(require("fast-deep-equal")),M=class extends u{constructor({components:t,...n}={}){super({type:ne.ComponentType.ActionRow,...n});i(this,"components");this.components=t?.map(r=>Nt(r))??[]}addComponents(...t){return this.components.push(...t),this}setComponents(...t){return this.components.splice(0,this.components.length,...t),this}toJSON(){return{...this.data,components:this.components.map(t=>t.toJSON())}}equals(t){return t instanceof M?(0,at.default)(t.data,this.data)&&(0,at.default)(t.components,this.components):(0,at.default)(t,{...this.data,components:this.components.map(n=>n.toJSON())})}};o(M,"ActionRow");var ie=require("discord-api-types/v9");var $t=J(require("fast-deep-equal")),R=class extends u{constructor(t){super({type:ie.ComponentType.Button,...t})}get style(){return this.data.style}get label(){return this.data.label}get emoji(){return this.data.emoji}get disabled(){return this.data.disabled}get customId(){return this.data.custom_id}get url(){return this.data.url}setStyle(t){return this.data.style=t,this}setURL(t){return this.data.url=t,this}setCustomId(t){return this.data.custom_id=t,this}setEmoji(t){return this.data.emoji=t,this}setDisabled(t=!0){return this.data.disabled=t,this}setLabel(t){return this.data.label=t,this}toJSON(){return{...this.data}}equals(t){return t instanceof R?(0,$t.default)(t.data,this.data):(0,$t.default)(t,this.data)}};o(R,"UnsafeButtonComponent");var F=class extends R{setStyle(t){return super.setStyle(It.parse(t))}setURL(t){return super.setURL(wt.parse(t))}setCustomId(t){return super.setCustomId($.parse(t))}setEmoji(t){return super.setEmoji(q.parse(t))}setDisabled(t=!0){return super.setDisabled(k.parse(t))}setLabel(t){return super.setLabel(Pt.parse(t))}toJSON(){return Et(this.style,this.label,this.emoji,this.customId,this.url),super.toJSON()}};o(F,"ButtonComponent");var re=require("discord-api-types/v9");var c=class{constructor(t={}){this.data=t}get label(){return this.data.label}get value(){return this.data.value}get description(){return this.data.description}get emoji(){return this.data.emoji}get default(){return this.data.default}setLabel(t){return this.data.label=t,this}setValue(t){return this.data.value=t,this}setDescription(t){return this.data.description=t,this}setDefault(t=!0){return this.data.default=t,this}setEmoji(t){return this.data.emoji=t,this}toJSON(){return{...this.data}}};o(c,"UnsafeSelectMenuOption");var st=J(require("fast-deep-equal")),v=class extends u{constructor(t){let{options:n,...r}=t??{};super({type:re.ComponentType.SelectMenu,...r});i(this,"options");this.options=n?.map(s=>new c(s))??[]}get placeholder(){return this.data.placeholder}get maxValues(){return this.data.max_values}get minValues(){return this.data.min_values}get customId(){return this.data.custom_id}get disabled(){return this.data.disabled}setPlaceholder(t){return this.data.placeholder=t,this}setMinValues(t){return this.data.min_values=t,this}setMaxValues(t){return this.data.max_values=t,this}setCustomId(t){return this.data.custom_id=t,this}setDisabled(t=!0){return this.data.disabled=t,this}addOptions(...t){return this.options.push(...t.map(n=>n instanceof c?n:new c(n))),this}setOptions(...t){return this.options.splice(0,this.options.length,...t.map(n=>n instanceof c?n:new c(n))),this}toJSON(){return{...this.data,options:this.options.map(t=>t.toJSON())}}equals(t){return t instanceof v?(0,st.default)(t.data,this.data)&&(0,st.default)(t.options,this.options):(0,st.default)(t,{...this.data,options:this.options.map(n=>n.toJSON())})}};o(v,"UnsafeSelectMenuComponent");var G=class extends v{setPlaceholder(t){return super.setPlaceholder(Tt.parse(t))}setMinValues(t){return super.setMinValues(it.parse(t))}setMaxValues(t){return super.setMaxValues(it.parse(t))}setCustomId(t){return super.setCustomId($.parse(t))}setDisabled(t=!0){return super.setDisabled(k.parse(t))}toJSON(){return Mt(this.options,this.customId),super.toJSON()}};o(G,"SelectMenuComponent");var Dt=class extends c{setDescription(t){return super.setDescription(j.parse(t))}setDefault(t=!0){return super.setDefault(Rt.parse(t))}setEmoji(t){return super.setEmoji(q.parse(t))}toJSON(){return vt(this.label,this.value),super.toJSON()}};o(Dt,"SelectMenuOption");var Vt={};U(Vt,{assertReturnOfBuilder:()=>g,validateDefaultPermission:()=>Lt,validateDescription:()=>lt,validateMaxChoicesLength:()=>_t,validateMaxOptionsLength:()=>f,validateName:()=>mt,validateRequired:()=>dt,validateRequiredParameters:()=>y});var pt=J(require("@sindresorhus/is")),W=require("zod"),eo=W.z.string().min(1).max(32).regex(/^[\P{Lu}\p{N}_-]+$/u);function mt(e){eo.parse(e)}o(mt,"validateName");var oo=W.z.string().min(1).max(100);function lt(e){oo.parse(e)}o(lt,"validateDescription");var ae=W.z.unknown().array().max(25);function f(e){ae.parse(e)}o(f,"validateMaxOptionsLength");function y(e,t,n){mt(e),lt(t),f(n)}o(y,"validateRequiredParameters");var se=W.z.boolean();function Lt(e){se.parse(e)}o(Lt,"validateDefaultPermission");function dt(e){se.parse(e)}o(dt,"validateRequired");function _t(e){ae.parse(e)}o(_t,"validateMaxChoicesLength");function g(e,t){let n=t.name;if(pt.default.nullOrUndefined(e))throw new TypeError(`Expected to receive a ${n} builder, got ${e===null?"null":"undefined"} instead.`);if(pt.default.primitive(e))throw new TypeError(`Expected to receive a ${n} builder, got a primitive (${typeof e}) instead.`);if(!(e instanceof t)){let r=e,s=pt.default.function_(e)?e.name:r.constructor.name,A=Reflect.get(r,Symbol.toStringTag),P=A?`${s} [${A}]`:s;throw new TypeError(`Expected to receive a ${n} builder, got ${P} instead.`)}}o(g,"assertReturnOfBuilder");var Re=require("ts-mixer");var pe=require("discord-api-types/v9");var C=class{constructor(){i(this,"name");i(this,"description")}setName(t){return mt(t),Reflect.set(this,"name",t),this}setDescription(t){return lt(t),Reflect.set(this,"description",t),this}};o(C,"SharedNameAndDescription");var p=class extends C{constructor(){super(...arguments);i(this,"required",!1)}setRequired(t){return dt(t),Reflect.set(this,"required",t),this}runRequiredValidations(){y(this.name,this.description,[]),dt(this.required)}};o(p,"ApplicationCommandOptionBase");var z=class extends p{constructor(){super(...arguments);i(this,"type",pe.ApplicationCommandOptionType.Boolean)}toJSON(){return this.runRequiredValidations(),{...this}}};o(z,"SlashCommandBooleanOption");var me=require("discord-api-types/v9"),le=require("ts-mixer");var h=require("discord-api-types/v9"),Ut=require("zod"),no=[h.ChannelType.GuildText,h.ChannelType.GuildVoice,h.ChannelType.GuildCategory,h.ChannelType.GuildNews,h.ChannelType.GuildStore,h.ChannelType.GuildNewsThread,h.ChannelType.GuildPublicThread,h.ChannelType.GuildPrivateThread,h.ChannelType.GuildStageVoice],io=Ut.z.union(no.map(e=>Ut.z.literal(e))),ut=class{constructor(){i(this,"channel_types")}addChannelType(t){return this.channel_types===void 0&&Reflect.set(this,"channel_types",[]),io.parse(t),this.channel_types.push(t),this}addChannelTypes(t){return t.forEach(n=>this.addChannelType(n)),this}};o(ut,"ApplicationCommandOptionChannelTypesMixin");var w=class extends p{constructor(){super(...arguments);i(this,"type",me.ApplicationCommandOptionType.Channel)}toJSON(){return this.runRequiredValidations(),{...this}}};o(w,"SlashCommandChannelOption"),w=d([(0,le.mix)(ut)],w);var he=require("discord-api-types/v9"),be=require("ts-mixer"),fe=require("zod");var D=class{constructor(){i(this,"max_value");i(this,"min_value")}};o(D,"ApplicationCommandNumericOptionMinMaxValueMixin");var de=require("discord-api-types/v9"),L=require("zod");var ct=L.z.string().min(1).max(100),ue=L.z.number().gt(-1/0).lt(1/0),ce=L.z.object({name:ct,value:L.z.union([ct,ue])}).array(),ro=L.z.boolean(),O=class{constructor(){i(this,"choices");i(this,"autocomplete");i(this,"type")}addChoice(t){let{name:n,value:r}=t;if(this.autocomplete)throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");return this.choices===void 0&&Reflect.set(this,"choices",[]),_t(this.choices),ct.parse(n),this.type===de.ApplicationCommandOptionType.String?ct.parse(r):ue.parse(r),this.choices.push({name:n,value:r}),this}addChoices(...t){if(this.autocomplete)throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");ce.parse(t);for(let n of t)this.addChoice(n);return this}setChoices(...t){if(t.length>0&&this.autocomplete)throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");ce.parse(t),Reflect.set(this,"choices",[]);for(let n of t)this.addChoice(n);return this}setAutocomplete(t){if(ro.parse(t),t&&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",t),this}};o(O,"ApplicationCommandOptionWithChoicesAndAutocompleteMixin");var Ce=fe.z.number().int(),E=class extends p{constructor(){super(...arguments);i(this,"type",he.ApplicationCommandOptionType.Integer)}setMaxValue(t){return Ce.parse(t),Reflect.set(this,"max_value",t),this}setMinValue(t){return Ce.parse(t),Reflect.set(this,"min_value",t),this}toJSON(){if(this.runRequiredValidations(),this.autocomplete&&Array.isArray(this.choices)&&this.choices.length>0)throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");return{...this}}};o(E,"SlashCommandIntegerOption"),E=d([(0,be.mix)(D,O)],E);var Ae=require("discord-api-types/v9");var Z=class extends p{constructor(){super(...arguments);i(this,"type",Ae.ApplicationCommandOptionType.Mentionable)}toJSON(){return this.runRequiredValidations(),{...this}}};o(Z,"SlashCommandMentionableOption");var xe=require("discord-api-types/v9"),ye=require("ts-mixer"),ge=require("zod");var Oe=ge.z.number(),B=class extends p{constructor(){super(...arguments);i(this,"type",xe.ApplicationCommandOptionType.Number)}setMaxValue(t){return Oe.parse(t),Reflect.set(this,"max_value",t),this}setMinValue(t){return Oe.parse(t),Reflect.set(this,"min_value",t),this}toJSON(){if(this.runRequiredValidations(),this.autocomplete&&Array.isArray(this.choices)&&this.choices.length>0)throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");return{...this}}};o(B,"SlashCommandNumberOption"),B=d([(0,ye.mix)(D,O)],B);var Se=require("discord-api-types/v9");var K=class extends p{constructor(){super(...arguments);i(this,"type",Se.ApplicationCommandOptionType.Role)}toJSON(){return this.runRequiredValidations(),{...this}}};o(K,"SlashCommandRoleOption");var Pe=require("discord-api-types/v9");var Q=class extends p{constructor(){super(...arguments);i(this,"type",Pe.ApplicationCommandOptionType.Attachment)}toJSON(){return this.runRequiredValidations(),{...this}}};o(Q,"SlashCommandAttachmentOption");var Ie=require("discord-api-types/v9"),Te=require("ts-mixer");var N=class extends p{constructor(){super(...arguments);i(this,"type",Ie.ApplicationCommandOptionType.String)}toJSON(){if(this.runRequiredValidations(),this.autocomplete&&Array.isArray(this.choices)&&this.choices.length>0)throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");return{...this}}};o(N,"SlashCommandStringOption"),N=d([(0,Te.mix)(O)],N);var Me=require("discord-api-types/v9");var H=class extends p{constructor(){super(...arguments);i(this,"type",Me.ApplicationCommandOptionType.User)}toJSON(){return this.runRequiredValidations(),{...this}}};o(H,"SlashCommandUserOption");var _=class{constructor(){i(this,"options")}addBooleanOption(t){return this._sharedAddOptionMethod(t,z)}addUserOption(t){return this._sharedAddOptionMethod(t,H)}addChannelOption(t){return this._sharedAddOptionMethod(t,w)}addRoleOption(t){return this._sharedAddOptionMethod(t,K)}addAttachmentOption(t){return this._sharedAddOptionMethod(t,Q)}addMentionableOption(t){return this._sharedAddOptionMethod(t,Z)}addStringOption(t){return this._sharedAddOptionMethod(t,N)}addIntegerOption(t){return this._sharedAddOptionMethod(t,E)}addNumberOption(t){return this._sharedAddOptionMethod(t,B)}_sharedAddOptionMethod(t,n){let{options:r}=this;f(r);let s=typeof t=="function"?t(new n):t;return g(s,n),r.push(s),this}};o(_,"SharedSlashCommandOptions");var Jt=require("discord-api-types/v9"),qt=require("ts-mixer");var S=class{constructor(){i(this,"name");i(this,"description");i(this,"options",[])}addSubcommand(t){let{options:n}=this;f(n);let r=typeof t=="function"?t(new b):t;return g(r,b),n.push(r),this}toJSON(){return y(this.name,this.description,this.options),{type:Jt.ApplicationCommandOptionType.SubcommandGroup,name:this.name,description:this.description,options:this.options.map(t=>t.toJSON())}}};o(S,"SlashCommandSubcommandGroupBuilder"),S=d([(0,qt.mix)(C)],S);var b=class{constructor(){i(this,"name");i(this,"description");i(this,"options",[])}toJSON(){return y(this.name,this.description,this.options),{type:Jt.ApplicationCommandOptionType.Subcommand,name:this.name,description:this.description,options:this.options.map(t=>t.toJSON())}}};o(b,"SlashCommandSubcommandBuilder"),b=d([(0,qt.mix)(C,_)],b);var X=class{constructor(){i(this,"name");i(this,"description");i(this,"options",[]);i(this,"defaultPermission")}toJSON(){return y(this.name,this.description,this.options),{name:this.name,description:this.description,options:this.options.map(t=>t.toJSON()),default_permission:this.defaultPermission}}setDefaultPermission(t){return Lt(t),Reflect.set(this,"defaultPermission",t),this}addSubcommandGroup(t){let{options:n}=this;f(n);let r=typeof t=="function"?t(new S):t;return g(r,S),n.push(r),this}addSubcommand(t){let{options:n}=this;f(n);let r=typeof t=="function"?t(new b):t;return g(r,b),n.push(r),this}};o(X,"SlashCommandBuilder"),X=d([(0,Re.mix)(_,C)],X);var Gt={};U(Gt,{validateDefaultPermission:()=>jt,validateName:()=>ht,validateRequiredParameters:()=>Ft,validateType:()=>bt});var V=require("zod"),kt=require("discord-api-types/v9"),ao=V.z.string().min(1).max(32).regex(/^( *[\p{L}\p{N}_-]+ *)+$/u),so=V.z.union([V.z.literal(kt.ApplicationCommandType.User),V.z.literal(kt.ApplicationCommandType.Message)]),po=V.z.boolean();function jt(e){po.parse(e)}o(jt,"validateDefaultPermission");function ht(e){ao.parse(e)}o(ht,"validateName");function bt(e){so.parse(e)}o(bt,"validateType");function Ft(e,t){ht(e),bt(t)}o(Ft,"validateRequiredParameters");var Wt=class{constructor(){i(this,"name");i(this,"type");i(this,"defaultPermission")}setName(t){return ht(t),Reflect.set(this,"name",t),this}setType(t){return bt(t),Reflect.set(this,"type",t),this}setDefaultPermission(t){return jt(t),Reflect.set(this,"defaultPermission",t),this}toJSON(){return Ft(this.name,this.type),{name:this.name,type:this.type,default_permission:this.defaultPermission}}};o(Wt,"ContextMenuCommandBuilder");function mo(e){return e!==null&&typeof e=="object"&&"toJSON"in e}o(mo,"isJSONEncodable");module.exports=Le(lo);0&&(module.exports={ActionRow,ButtonComponent,Component,ComponentAssertions,ContextMenuCommandAssertions,ContextMenuCommandBuilder,Embed,EmbedAssertions,Faces,SelectMenuComponent,SelectMenuOption,SlashCommandAssertions,SlashCommandAttachmentOption,SlashCommandBooleanOption,SlashCommandBuilder,SlashCommandChannelOption,SlashCommandIntegerOption,SlashCommandMentionableOption,SlashCommandNumberOption,SlashCommandRoleOption,SlashCommandStringOption,SlashCommandSubcommandBuilder,SlashCommandSubcommandGroupBuilder,SlashCommandUserOption,TimestampStyles,UnsafeButtonComponent,UnsafeEmbed,UnsafeSelectMenuComponent,UnsafeSelectMenuOption,blockQuote,bold,channelMention,codeBlock,createComponent,formatEmoji,hideLinkEmbed,hyperlink,inlineCode,isJSONEncodable,italic,memberNicknameMention,quote,roleMention,spoiler,strikethrough,time,underscore,userMention});
//# sourceMappingURL=index.js.map
{
"name": "@discordjs/builders",
"version": "0.13.0-dev.1645877056.a8321d8",
"version": "0.13.0-dev.1646222605.53defb8",
"description": "A set of builders that you can use when creating your bot",

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

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