@discordjs/builders
Advanced tools
Comparing version 0.13.0-dev.1648339720-520f471 to 0.13.0-dev.1648515278-ac4bc3a
1537
dist/index.js
@@ -1,4 +0,1535 @@ | ||
var Ke=Object.create;var M=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var Qe=Object.getOwnPropertyNames;var He=Object.getPrototypeOf,Xe=Object.prototype.hasOwnProperty;var Ye=(e,t,n)=>t in e?M(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var le=e=>M(e,"__esModule",{value:!0}),o=(e,t)=>M(e,"name",{value:t,configurable:!0});var T=(e,t)=>{for(var n in t)M(e,n,{get:t[n],enumerable:!0})},de=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Qe(t))!Xe.call(e,s)&&(n||s!=="default")&&M(e,s,{get:()=>t[s],enumerable:!(r=me(t,s))||r.enumerable});return e},ue=(e,t)=>de(le(M(e!=null?Ke(He(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),to=(e=>(t,n)=>e&&e.get(t)||(n=de(le({}),t,1),e&&e.set(t,n),n))(typeof WeakMap!="undefined"?new WeakMap:0),u=(e,t,n,r)=>{for(var s=r>1?void 0:r?me(t,n):t,E=e.length-1,k;E>=0;E--)(k=e[E])&&(s=(r?k(t,n,s):k(s))||s);return r&&s&&M(t,n,s),s};var i=(e,t,n)=>(Ye(e,typeof t!="symbol"?t+"":t,n),n);var Eo={};T(Eo,{ActionRowBuilder:()=>b,ButtonBuilder:()=>z,ComponentAssertions:()=>Jt,ComponentBuilder:()=>c,ContextMenuCommandAssertions:()=>se,ContextMenuCommandBuilder:()=>pe,EmbedAssertions:()=>Bt,EmbedBuilder:()=>wt,Faces:()=>fe,ModalAssertions:()=>Kt,ModalBuilder:()=>Qt,SelectMenuBuilder:()=>K,SelectMenuOptionBuilder:()=>Ht,SlashCommandAssertions:()=>te,SlashCommandAttachmentOption:()=>ot,SlashCommandBooleanOption:()=>Y,SlashCommandBuilder:()=>it,SlashCommandChannelOption:()=>B,SlashCommandIntegerOption:()=>w,SlashCommandMentionableOption:()=>tt,SlashCommandNumberOption:()=>v,SlashCommandRoleOption:()=>et,SlashCommandStringOption:()=>N,SlashCommandSubcommandBuilder:()=>f,SlashCommandSubcommandGroupBuilder:()=>I,SlashCommandUserOption:()=>nt,TextInputAssertions:()=>Wt,TextInputBuilder:()=>Z,TimestampStyles:()=>xo,UnsafeButtonBuilder:()=>Q,UnsafeEmbedBuilder:()=>U,UnsafeModalBuilder:()=>H,UnsafeSelectMenuBuilder:()=>X,UnsafeSelectMenuOptionBuilder:()=>l,UnsafeTextInputBuilder:()=>R,blockQuote:()=>po,bold:()=>io,channelMention:()=>bo,codeBlock:()=>eo,createComponentBuilder:()=>W,embedLength:()=>No,formatEmoji:()=>fo,hideLinkEmbed:()=>mo,hyperlink:()=>lo,inlineCode:()=>oo,isEquatable:()=>vo,isJSONEncodable:()=>wo,italic:()=>no,memberNicknameMention:()=>ho,quote:()=>so,roleMention:()=>Co,spoiler:()=>uo,strikethrough:()=>ao,time:()=>Ao,underscore:()=>ro,userMention:()=>co});var Bt={};T(Bt,{RGBPredicate:()=>pt,authorNamePredicate:()=>St,colorPredicate:()=>Pt,descriptionPredicate:()=>It,embedFieldPredicate:()=>be,embedFieldsArrayPredicate:()=>at,fieldInlinePredicate:()=>he,fieldLengthPredicate:()=>Ce,fieldNamePredicate:()=>rt,fieldValuePredicate:()=>ce,footerTextPredicate:()=>Mt,timestampPredicate:()=>Tt,titlePredicate:()=>Rt,urlPredicate:()=>y,validateFieldLength:()=>st});var d=require("zod"),rt=d.z.string().min(1).max(256),ce=d.z.string().min(1).max(1024),he=d.z.boolean().optional(),be=d.z.object({name:rt,value:ce,inline:he}),at=be.array(),Ce=d.z.number().lte(25);function st(e,t){Ce.parse((t?.length??0)+e)}o(st,"validateFieldLength");var St=rt.nullable(),y=d.z.string().url().nullish(),pt=d.z.number().int().gte(0).lte(255),Pt=d.z.number().int().gte(0).lte(16777215).nullable().or(d.z.tuple([pt,pt,pt])),It=d.z.string().min(1).max(4096).nullable(),Mt=d.z.string().min(1).max(2048).nullable(),Tt=d.z.union([d.z.number(),d.z.date()]).nullable(),Rt=rt.nullable();var U=class{constructor(t={}){i(this,"data");this.data={...t},t.timestamp&&(this.data.timestamp=new Date(t.timestamp).toISOString())}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.data.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}}};o(U,"UnsafeEmbedBuilder");var wt=class extends U{addFields(...t){return st(t.length,this.data.fields),super.addFields(...at.parse(t))}spliceFields(t,n,...r){return st(r.length-n,this.data.fields),super.spliceFields(t,n,...at.parse(r))}setAuthor(t){return t===null?super.setAuthor(null):(St.parse(t.name),y.parse(t.iconURL),y.parse(t.url),super.setAuthor(t))}setColor(t){return super.setColor(Pt.parse(t))}setDescription(t){return super.setDescription(It.parse(t))}setFooter(t){return t===null?super.setFooter(null):(Mt.parse(t.text),y.parse(t.iconURL),super.setFooter(t))}setImage(t){return super.setImage(y.parse(t))}setThumbnail(t){return super.setThumbnail(y.parse(t))}setTimestamp(t=Date.now()){return super.setTimestamp(Tt.parse(t))}setTitle(t){return super.setTitle(Rt.parse(t))}setURL(t){return super.setURL(y.parse(t))}};o(wt,"EmbedBuilder");function eo(e,t){return typeof t=="undefined"?`\`\`\` | ||
${e}\`\`\``:`\`\`\`${e} | ||
${t}\`\`\``}o(eo,"codeBlock");function oo(e){return`\`${e}\``}o(oo,"inlineCode");function no(e){return`_${e}_`}o(no,"italic");function io(e){return`**${e}**`}o(io,"bold");function ro(e){return`__${e}__`}o(ro,"underscore");function ao(e){return`~~${e}~~`}o(ao,"strikethrough");function so(e){return`> ${e}`}o(so,"quote");function po(e){return`>>> ${e}`}o(po,"blockQuote");function mo(e){return`<${e}>`}o(mo,"hideLinkEmbed");function lo(e,t,n){return n?`[${e}](${t} "${n}")`:`[${e}](${t})`}o(lo,"hyperlink");function uo(e){return`||${e}||`}o(uo,"spoiler");function co(e){return`<@${e}>`}o(co,"userMention");function ho(e){return`<@!${e}>`}o(ho,"memberNicknameMention");function bo(e){return`<#${e}>`}o(bo,"channelMention");function Co(e){return`<@&${e}>`}o(Co,"roleMention");function fo(e,t=!1){return`<${t?"a":""}:_:${e}>`}o(fo,"formatEmoji");function Ao(e,t){return typeof e!="number"&&(e=Math.floor((e?.getTime()??Date.now())/1e3)),typeof t=="string"?`<t:${e}:${t}>`:`<t:${e}>`}o(Ao,"time");var xo={ShortTime:"t",LongTime:"T",ShortDate:"d",LongDate:"D",ShortDateTime:"f",LongDateTime:"F",RelativeTime:"R"},fe=(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))(fe||{});var Jt={};T(Jt,{buttonLabelValidator:()=>vt,buttonStyleValidator:()=>Nt,customIdValidator:()=>h,defaultValidator:()=>Lt,disabledValidator:()=>q,emojiValidator:()=>V,labelValueDescriptionValidator:()=>dt,labelValueValidator:()=>F,minMaxValidator:()=>lt,optionValidator:()=>j,optionsLengthValidator:()=>ut,optionsValidator:()=>Ae,placeholderValidator:()=>Et,urlValidator:()=>Dt,validateRequiredButtonParameters:()=>_t,validateRequiredSelectMenuOptionParameters:()=>$t,validateRequiredSelectMenuParameters:()=>Vt});var mt=require("discord-api-types/v10"),p=require("zod");var l=class{constructor(t={}){this.data=t}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(l,"UnsafeSelectMenuOptionBuilder");var h=p.z.string().min(1).max(100),V=p.z.object({id:p.z.string(),name:p.z.string(),animated:p.z.boolean()}).partial().strict(),q=p.z.boolean(),vt=p.z.string().nonempty().max(80),Nt=p.z.number().int().min(mt.ButtonStyle.Primary).max(mt.ButtonStyle.Link),Et=p.z.string().max(150),lt=p.z.number().int().min(0).max(25),dt=p.z.string().min(1).max(100),j=p.z.union([p.z.object({label:dt,value:dt,description:dt.optional(),emoji:V.optional(),default:p.z.boolean().optional()}),p.z.instanceof(l)]),Ae=j.array().nonempty(),ut=p.z.number().int().min(0).max(25);function Vt(e,t){h.parse(t),Ae.parse(e)}o(Vt,"validateRequiredSelectMenuParameters");var F=p.z.string().min(1).max(100),Lt=p.z.boolean();function $t(e,t){F.parse(e),F.parse(t)}o($t,"validateRequiredSelectMenuOptionParameters");var Dt=p.z.string().url();function _t(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===mt.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(_t,"validateRequiredButtonParameters");var xe=require("discord-api-types/v10");var c=class{constructor(t){i(this,"data");this.data=t}};o(c,"ComponentBuilder");var G=require("discord-api-types/v10");function W(e){if(e instanceof c)return e;switch(e.type){case G.ComponentType.ActionRow:return new b(e);case G.ComponentType.Button:return new z(e);case G.ComponentType.SelectMenu:return new K(e);case G.ComponentType.TextInput:return new Z(e);default:throw new Error(`Cannot properly serialize component type: ${e.type}`)}}o(W,"createComponentBuilder");var b=class extends c{constructor({components:t,...n}={}){super({type:xe.ComponentType.ActionRow,...n});i(this,"components");this.components=t?.map(r=>W(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())}}};o(b,"ActionRowBuilder");var ye=require("discord-api-types/v10");var Q=class extends c{constructor(t){super({type:ye.ComponentType.Button,...t})}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}}};o(Q,"UnsafeButtonBuilder");var z=class extends Q{setStyle(t){return super.setStyle(Nt.parse(t))}setURL(t){return super.setURL(Dt.parse(t))}setCustomId(t){return super.setCustomId(h.parse(t))}setEmoji(t){return super.setEmoji(V.parse(t))}setDisabled(t=!0){return super.setDisabled(q.parse(t))}setLabel(t){return super.setLabel(vt.parse(t))}toJSON(){return _t(this.data.style,this.data.label,this.data.emoji,this.data.custom_id,this.data.url),super.toJSON()}};o(z,"ButtonBuilder");var Wt={};T(Wt,{labelValidator:()=>Se,maxLengthValidator:()=>Ut,minLengthValidator:()=>kt,placeholderValidator:()=>Ft,requiredValidator:()=>qt,textInputStyleValidator:()=>ge,validateRequiredParameters:()=>Gt,valueValidator:()=>jt});var Oe=require("discord-api-types/v10"),O=require("zod");var ge=O.z.nativeEnum(Oe.TextInputStyle),kt=O.z.number().int().min(0).max(4e3),Ut=O.z.number().int().min(1).max(4e3),qt=O.z.boolean(),jt=O.z.string().max(4e3),Ft=O.z.string().max(100),Se=O.z.string().min(1).max(45);function Gt(e,t,n){h.parse(e),ge.parse(t),Se.parse(n)}o(Gt,"validateRequiredParameters");var Pe=require("discord-api-types/v10");var zt=ue(require("fast-deep-equal")),R=class extends c{constructor(t){super({type:Pe.ComponentType.TextInput,...t})}setCustomId(t){return this.data.custom_id=t,this}setLabel(t){return this.data.label=t,this}setStyle(t){return this.data.style=t,this}setMinLength(t){return this.data.min_length=t,this}setMaxLength(t){return this.data.max_length=t,this}setPlaceholder(t){return this.data.placeholder=t,this}setValue(t){return this.data.value=t,this}setRequired(t=!0){return this.data.required=t,this}toJSON(){return{...this.data}}equals(t){return t instanceof R?(0,zt.default)(t.data,this.data):(0,zt.default)(t,this.data)}};o(R,"UnsafeTextInputBuilder");var Z=class extends R{setMinLength(t){return super.setMinLength(kt.parse(t))}setMaxLength(t){return super.setMaxLength(Ut.parse(t))}setRequired(t=!0){return super.setRequired(qt.parse(t))}setValue(t){return super.setValue(jt.parse(t))}setPlaceholder(t){return super.setPlaceholder(Ft.parse(t))}toJSON(){return Gt(this.data.custom_id,this.data.style,this.data.label),super.toJSON()}};o(Z,"TextInputBuilder");var H=class{constructor({components:t,...n}={}){i(this,"data");i(this,"components",[]);this.data={...n},this.components=t?.map(r=>W(r))??[]}setTitle(t){return this.data.title=t,this}setCustomId(t){return this.data.custom_id=t,this}addComponents(...t){return this.components.push(...t.map(n=>n instanceof b?n:new b(n))),this}setComponents(...t){return this.components.splice(0,this.components.length,...t),this}toJSON(){return{...this.data,components:this.components.map(t=>t.toJSON())}}};o(H,"UnsafeModalBuilder");var Kt={};T(Kt,{componentsValidator:()=>Ie,titleValidator:()=>ht,validateRequiredParameters:()=>Zt});var ct=require("zod");var ht=ct.z.string().min(1).max(45),Ie=ct.z.array(ct.z.instanceof(b)).min(1);function Zt(e,t,n){h.parse(e),ht.parse(t),Ie.parse(n)}o(Zt,"validateRequiredParameters");var Qt=class extends H{setCustomId(t){return super.setCustomId(h.parse(t))}setTitle(t){return super.setTitle(ht.parse(t))}toJSON(){return Zt(this.data.custom_id,this.data.title,this.components),super.toJSON()}};o(Qt,"ModalBuilder");var Me=require("discord-api-types/v10");var X=class extends c{constructor(t){let{options:n,...r}=t??{};super({type:Me.ComponentType.SelectMenu,...r});i(this,"options");this.options=n?.map(s=>new l(s))??[]}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 l?n:new l(n))),this}setOptions(...t){return this.options.splice(0,this.options.length,...t.map(n=>n instanceof l?n:new l(n))),this}toJSON(){return{...this.data,options:this.options.map(t=>t.toJSON())}}};o(X,"UnsafeSelectMenuBuilder");var K=class extends X{setPlaceholder(t){return super.setPlaceholder(Et.parse(t))}setMinValues(t){return super.setMinValues(lt.parse(t))}setMaxValues(t){return super.setMaxValues(lt.parse(t))}setCustomId(t){return super.setCustomId(h.parse(t))}setDisabled(t=!0){return super.setDisabled(q.parse(t))}addOptions(...t){return ut.parse(this.options.length+t.length),this.options.push(...t.map(n=>n instanceof l?n:new l(j.parse(n)))),this}setOptions(...t){return ut.parse(t.length),this.options.splice(0,this.options.length,...t.map(n=>n instanceof l?n:new l(j.parse(n)))),this}toJSON(){return Vt(this.options,this.data.custom_id),super.toJSON()}};o(K,"SelectMenuBuilder");var Ht=class extends l{setDescription(t){return super.setDescription(F.parse(t))}setDefault(t=!0){return super.setDefault(Lt.parse(t))}setEmoji(t){return super.setEmoji(V.parse(t))}toJSON(){return $t(this.data.label,this.data.value),super.toJSON()}};o(Ht,"SelectMenuOptionBuilder");var te={};T(te,{assertReturnOfBuilder:()=>S,validateChoicesLength:()=>Yt,validateDefaultPermission:()=>Xt,validateDescription:()=>ft,validateMaxOptionsLength:()=>A,validateName:()=>Ct,validateRequired:()=>At,validateRequiredParameters:()=>g});var bt=ue(require("@sindresorhus/is")),L=require("zod"),yo=L.z.string().min(1).max(32).regex(/^[\P{Lu}\p{N}_-]+$/u);function Ct(e){yo.parse(e)}o(Ct,"validateName");var Oo=L.z.string().min(1).max(100);function ft(e){Oo.parse(e)}o(ft,"validateDescription");var go=L.z.unknown().array().max(25);function A(e){go.parse(e)}o(A,"validateMaxOptionsLength");function g(e,t,n){Ct(e),ft(t),A(n)}o(g,"validateRequiredParameters");var Te=L.z.boolean();function Xt(e){Te.parse(e)}o(Xt,"validateDefaultPermission");function At(e){Te.parse(e)}o(At,"validateRequired");var So=L.z.number().lte(25);function Yt(e,t){So.parse((t?.length??0)+e)}o(Yt,"validateChoicesLength");function S(e,t){let n=t.name;if(bt.default.nullOrUndefined(e))throw new TypeError(`Expected to receive a ${n} builder, got ${e===null?"null":"undefined"} instead.`);if(bt.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=bt.default.function_(e)?e.name:r.constructor.name,E=Reflect.get(r,Symbol.toStringTag),k=E?`${s} [${E}]`:s;throw new TypeError(`Expected to receive a ${n} builder, got ${k} instead.`)}}o(S,"assertReturnOfBuilder");var Ze=require("ts-mixer");var Re=require("discord-api-types/v10");var x=class{constructor(){i(this,"name");i(this,"description")}setName(t){return Ct(t),Reflect.set(this,"name",t),this}setDescription(t){return ft(t),Reflect.set(this,"description",t),this}};o(x,"SharedNameAndDescription");var m=class extends x{constructor(){super(...arguments);i(this,"required",!1)}setRequired(t){return At(t),Reflect.set(this,"required",t),this}runRequiredValidations(){g(this.name,this.description,[]),At(this.required)}};o(m,"ApplicationCommandOptionBase");var Y=class extends m{constructor(){super(...arguments);i(this,"type",Re.ApplicationCommandOptionType.Boolean)}toJSON(){return this.runRequiredValidations(),{...this}}};o(Y,"SlashCommandBooleanOption");var Be=require("discord-api-types/v10"),we=require("ts-mixer");var C=require("discord-api-types/v10"),xt=require("zod"),Po=[C.ChannelType.GuildText,C.ChannelType.GuildVoice,C.ChannelType.GuildCategory,C.ChannelType.GuildNews,C.ChannelType.GuildStore,C.ChannelType.GuildNewsThread,C.ChannelType.GuildPublicThread,C.ChannelType.GuildPrivateThread,C.ChannelType.GuildStageVoice],Io=xt.z.array(xt.z.union(Po.map(e=>xt.z.literal(e)))),yt=class{constructor(){i(this,"channel_types")}addChannelTypes(...t){return this.channel_types===void 0&&Reflect.set(this,"channel_types",[]),Io.parse(t),this.channel_types.push(...t),this}};o(yt,"ApplicationCommandOptionChannelTypesMixin");var B=class extends m{constructor(){super(...arguments);i(this,"type",Be.ApplicationCommandOptionType.Channel)}toJSON(){return this.runRequiredValidations(),{...this}}};o(B,"SlashCommandChannelOption"),B=u([(0,we.mix)(yt)],B);var Ve=require("discord-api-types/v10"),Le=require("ts-mixer"),$e=require("zod");var $=class{constructor(){i(this,"max_value");i(this,"min_value")}};o($,"ApplicationCommandNumericOptionMinMaxValueMixin");var ve=require("discord-api-types/v10"),D=require("zod");var ee=D.z.string().min(1).max(100),Ne=D.z.number().gt(-1/0).lt(1/0),Ee=D.z.object({name:ee,value:D.z.union([ee,Ne])}).array(),Mo=D.z.boolean(),P=class{constructor(){i(this,"choices");i(this,"autocomplete");i(this,"type")}addChoices(...t){if(t.length>0&&this.autocomplete)throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");Ee.parse(t),this.choices===void 0&&Reflect.set(this,"choices",[]),Yt(t.length,this.choices);for(let{name:n,value:r}of t)this.type===ve.ApplicationCommandOptionType.String?ee.parse(r):Ne.parse(r),this.choices.push({name:n,value:r});return this}setChoices(...t){if(t.length>0&&this.autocomplete)throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");return Ee.parse(t),Reflect.set(this,"choices",[]),this.addChoices(...t),this}setAutocomplete(t){if(Mo.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(P,"ApplicationCommandOptionWithChoicesAndAutocompleteMixin");var De=$e.z.number().int(),w=class extends m{constructor(){super(...arguments);i(this,"type",Ve.ApplicationCommandOptionType.Integer)}setMaxValue(t){return De.parse(t),Reflect.set(this,"max_value",t),this}setMinValue(t){return De.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(w,"SlashCommandIntegerOption"),w=u([(0,Le.mix)($,P)],w);var _e=require("discord-api-types/v10");var tt=class extends m{constructor(){super(...arguments);i(this,"type",_e.ApplicationCommandOptionType.Mentionable)}toJSON(){return this.runRequiredValidations(),{...this}}};o(tt,"SlashCommandMentionableOption");var Je=require("discord-api-types/v10"),ke=require("ts-mixer"),Ue=require("zod");var qe=Ue.z.number(),v=class extends m{constructor(){super(...arguments);i(this,"type",Je.ApplicationCommandOptionType.Number)}setMaxValue(t){return qe.parse(t),Reflect.set(this,"max_value",t),this}setMinValue(t){return qe.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(v,"SlashCommandNumberOption"),v=u([(0,ke.mix)($,P)],v);var je=require("discord-api-types/v10");var et=class extends m{constructor(){super(...arguments);i(this,"type",je.ApplicationCommandOptionType.Role)}toJSON(){return this.runRequiredValidations(),{...this}}};o(et,"SlashCommandRoleOption");var Fe=require("discord-api-types/v10");var ot=class extends m{constructor(){super(...arguments);i(this,"type",Fe.ApplicationCommandOptionType.Attachment)}toJSON(){return this.runRequiredValidations(),{...this}}};o(ot,"SlashCommandAttachmentOption");var Ge=require("discord-api-types/v10"),We=require("ts-mixer");var N=class extends m{constructor(){super(...arguments);i(this,"type",Ge.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=u([(0,We.mix)(P)],N);var ze=require("discord-api-types/v10");var nt=class extends m{constructor(){super(...arguments);i(this,"type",ze.ApplicationCommandOptionType.User)}toJSON(){return this.runRequiredValidations(),{...this}}};o(nt,"SlashCommandUserOption");var _=class{constructor(){i(this,"options")}addBooleanOption(t){return this._sharedAddOptionMethod(t,Y)}addUserOption(t){return this._sharedAddOptionMethod(t,nt)}addChannelOption(t){return this._sharedAddOptionMethod(t,B)}addRoleOption(t){return this._sharedAddOptionMethod(t,et)}addAttachmentOption(t){return this._sharedAddOptionMethod(t,ot)}addMentionableOption(t){return this._sharedAddOptionMethod(t,tt)}addStringOption(t){return this._sharedAddOptionMethod(t,N)}addIntegerOption(t){return this._sharedAddOptionMethod(t,w)}addNumberOption(t){return this._sharedAddOptionMethod(t,v)}_sharedAddOptionMethod(t,n){let{options:r}=this;A(r);let s=typeof t=="function"?t(new n):t;return S(s,n),r.push(s),this}};o(_,"SharedSlashCommandOptions");var oe=require("discord-api-types/v10"),ne=require("ts-mixer");var I=class{constructor(){i(this,"name");i(this,"description");i(this,"options",[])}addSubcommand(t){let{options:n}=this;A(n);let r=typeof t=="function"?t(new f):t;return S(r,f),n.push(r),this}toJSON(){return g(this.name,this.description,this.options),{type:oe.ApplicationCommandOptionType.SubcommandGroup,name:this.name,description:this.description,options:this.options.map(t=>t.toJSON())}}};o(I,"SlashCommandSubcommandGroupBuilder"),I=u([(0,ne.mix)(x)],I);var f=class{constructor(){i(this,"name");i(this,"description");i(this,"options",[])}toJSON(){return g(this.name,this.description,this.options),{type:oe.ApplicationCommandOptionType.Subcommand,name:this.name,description:this.description,options:this.options.map(t=>t.toJSON())}}};o(f,"SlashCommandSubcommandBuilder"),f=u([(0,ne.mix)(x,_)],f);var it=class{constructor(){i(this,"name");i(this,"description");i(this,"options",[]);i(this,"defaultPermission")}toJSON(){return g(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 Xt(t),Reflect.set(this,"defaultPermission",t),this}addSubcommandGroup(t){let{options:n}=this;A(n);let r=typeof t=="function"?t(new I):t;return S(r,I),n.push(r),this}addSubcommand(t){let{options:n}=this;A(n);let r=typeof t=="function"?t(new f):t;return S(r,f),n.push(r),this}};o(it,"SlashCommandBuilder"),it=u([(0,Ze.mix)(_,x)],it);var se={};T(se,{validateDefaultPermission:()=>re,validateName:()=>Ot,validateRequiredParameters:()=>ae,validateType:()=>gt});var J=require("zod"),ie=require("discord-api-types/v10"),To=J.z.string().min(1).max(32).regex(/^( *[\p{L}\p{N}_-]+ *)+$/u),Ro=J.z.union([J.z.literal(ie.ApplicationCommandType.User),J.z.literal(ie.ApplicationCommandType.Message)]),Bo=J.z.boolean();function re(e){Bo.parse(e)}o(re,"validateDefaultPermission");function Ot(e){To.parse(e)}o(Ot,"validateName");function gt(e){Ro.parse(e)}o(gt,"validateType");function ae(e,t){Ot(e),gt(t)}o(ae,"validateRequiredParameters");var pe=class{constructor(){i(this,"name");i(this,"type");i(this,"defaultPermission")}setName(t){return Ot(t),Reflect.set(this,"name",t),this}setType(t){return gt(t),Reflect.set(this,"type",t),this}setDefaultPermission(t){return re(t),Reflect.set(this,"defaultPermission",t),this}toJSON(){return ae(this.name,this.type),{name:this.name,type:this.type,default_permission:this.defaultPermission}}};o(pe,"ContextMenuCommandBuilder");function wo(e){return e!==null&&typeof e=="object"&&"toJSON"in e}o(wo,"isJSONEncodable");function vo(e){return e!==null&&typeof e=="object"&&"equals"in e}o(vo,"isEquatable");function No(e){return(e.title?.length??0)+(e.description?.length??0)+(e.fields?.reduce((t,n)=>t+n.name.length+n.value.length,0)??0)+(e.footer?.text.length??0)+(e.author?.name.length??0)}o(No,"embedLength");module.exports=to(Eo);0&&(module.exports={ActionRowBuilder,ButtonBuilder,ComponentAssertions,ComponentBuilder,ContextMenuCommandAssertions,ContextMenuCommandBuilder,EmbedAssertions,EmbedBuilder,Faces,ModalAssertions,ModalBuilder,SelectMenuBuilder,SelectMenuOptionBuilder,SlashCommandAssertions,SlashCommandAttachmentOption,SlashCommandBooleanOption,SlashCommandBuilder,SlashCommandChannelOption,SlashCommandIntegerOption,SlashCommandMentionableOption,SlashCommandNumberOption,SlashCommandRoleOption,SlashCommandStringOption,SlashCommandSubcommandBuilder,SlashCommandSubcommandGroupBuilder,SlashCommandUserOption,TextInputAssertions,TextInputBuilder,TimestampStyles,UnsafeButtonBuilder,UnsafeEmbedBuilder,UnsafeModalBuilder,UnsafeSelectMenuBuilder,UnsafeSelectMenuOptionBuilder,UnsafeTextInputBuilder,blockQuote,bold,channelMention,codeBlock,createComponentBuilder,embedLength,formatEmoji,hideLinkEmbed,hyperlink,inlineCode,isEquatable,isJSONEncodable,italic,memberNicknameMention,quote,roleMention,spoiler,strikethrough,time,underscore,userMention}); | ||
"use strict"; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true }); | ||
var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __reExport = (target, module2, copyDefault, desc) => { | ||
if (module2 && typeof module2 === "object" || typeof module2 === "function") { | ||
for (let key of __getOwnPropNames(module2)) | ||
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default")) | ||
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable }); | ||
} | ||
return target; | ||
}; | ||
var __toESM = (module2, isNodeMode) => { | ||
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2); | ||
}; | ||
var __toCommonJS = /* @__PURE__ */ ((cache) => { | ||
return (module2, temp) => { | ||
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp); | ||
}; | ||
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0); | ||
var __decorateClass = (decorators, target, key, kind) => { | ||
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target; | ||
for (var i = decorators.length - 1, decorator; i >= 0; i--) | ||
if (decorator = decorators[i]) | ||
result = (kind ? decorator(target, key, result) : decorator(result)) || result; | ||
if (kind && result) | ||
__defProp(target, key, result); | ||
return result; | ||
}; | ||
var __publicField = (obj, key, value) => { | ||
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
return value; | ||
}; | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
ActionRowBuilder: () => ActionRowBuilder, | ||
ButtonBuilder: () => ButtonBuilder, | ||
ComponentAssertions: () => Assertions_exports2, | ||
ComponentBuilder: () => ComponentBuilder, | ||
ContextMenuCommandAssertions: () => Assertions_exports6, | ||
ContextMenuCommandBuilder: () => ContextMenuCommandBuilder, | ||
EmbedAssertions: () => Assertions_exports, | ||
EmbedBuilder: () => EmbedBuilder, | ||
Faces: () => Faces, | ||
ModalAssertions: () => Assertions_exports4, | ||
ModalBuilder: () => ModalBuilder, | ||
SelectMenuBuilder: () => SelectMenuBuilder, | ||
SelectMenuOptionBuilder: () => SelectMenuOptionBuilder, | ||
SlashCommandAssertions: () => Assertions_exports5, | ||
SlashCommandAttachmentOption: () => SlashCommandAttachmentOption, | ||
SlashCommandBooleanOption: () => SlashCommandBooleanOption, | ||
SlashCommandBuilder: () => SlashCommandBuilder, | ||
SlashCommandChannelOption: () => SlashCommandChannelOption, | ||
SlashCommandIntegerOption: () => SlashCommandIntegerOption, | ||
SlashCommandMentionableOption: () => SlashCommandMentionableOption, | ||
SlashCommandNumberOption: () => SlashCommandNumberOption, | ||
SlashCommandRoleOption: () => SlashCommandRoleOption, | ||
SlashCommandStringOption: () => SlashCommandStringOption, | ||
SlashCommandSubcommandBuilder: () => SlashCommandSubcommandBuilder, | ||
SlashCommandSubcommandGroupBuilder: () => SlashCommandSubcommandGroupBuilder, | ||
SlashCommandUserOption: () => SlashCommandUserOption, | ||
TextInputAssertions: () => Assertions_exports3, | ||
TextInputBuilder: () => TextInputBuilder, | ||
TimestampStyles: () => TimestampStyles, | ||
UnsafeButtonBuilder: () => UnsafeButtonBuilder, | ||
UnsafeEmbedBuilder: () => UnsafeEmbedBuilder, | ||
UnsafeModalBuilder: () => UnsafeModalBuilder, | ||
UnsafeSelectMenuBuilder: () => UnsafeSelectMenuBuilder, | ||
UnsafeSelectMenuOptionBuilder: () => UnsafeSelectMenuOptionBuilder, | ||
UnsafeTextInputBuilder: () => UnsafeTextInputBuilder, | ||
blockQuote: () => blockQuote, | ||
bold: () => bold, | ||
channelMention: () => channelMention, | ||
codeBlock: () => codeBlock, | ||
createComponentBuilder: () => createComponentBuilder, | ||
embedLength: () => embedLength, | ||
formatEmoji: () => formatEmoji, | ||
hideLinkEmbed: () => hideLinkEmbed, | ||
hyperlink: () => hyperlink, | ||
inlineCode: () => inlineCode, | ||
isEquatable: () => isEquatable, | ||
isJSONEncodable: () => isJSONEncodable, | ||
italic: () => italic, | ||
memberNicknameMention: () => memberNicknameMention, | ||
quote: () => quote, | ||
roleMention: () => roleMention, | ||
spoiler: () => spoiler, | ||
strikethrough: () => strikethrough, | ||
time: () => time, | ||
underscore: () => underscore, | ||
userMention: () => userMention | ||
}); | ||
// src/messages/embed/Assertions.ts | ||
var Assertions_exports = {}; | ||
__export(Assertions_exports, { | ||
RGBPredicate: () => RGBPredicate, | ||
authorNamePredicate: () => authorNamePredicate, | ||
colorPredicate: () => colorPredicate, | ||
descriptionPredicate: () => descriptionPredicate, | ||
embedFieldPredicate: () => embedFieldPredicate, | ||
embedFieldsArrayPredicate: () => embedFieldsArrayPredicate, | ||
fieldInlinePredicate: () => fieldInlinePredicate, | ||
fieldLengthPredicate: () => fieldLengthPredicate, | ||
fieldNamePredicate: () => fieldNamePredicate, | ||
fieldValuePredicate: () => fieldValuePredicate, | ||
footerTextPredicate: () => footerTextPredicate, | ||
timestampPredicate: () => timestampPredicate, | ||
titlePredicate: () => titlePredicate, | ||
urlPredicate: () => urlPredicate, | ||
validateFieldLength: () => validateFieldLength | ||
}); | ||
var import_zod = require("zod"); | ||
var fieldNamePredicate = import_zod.z.string().min(1).max(256); | ||
var fieldValuePredicate = import_zod.z.string().min(1).max(1024); | ||
var fieldInlinePredicate = import_zod.z.boolean().optional(); | ||
var embedFieldPredicate = import_zod.z.object({ | ||
name: fieldNamePredicate, | ||
value: fieldValuePredicate, | ||
inline: fieldInlinePredicate | ||
}); | ||
var embedFieldsArrayPredicate = embedFieldPredicate.array(); | ||
var fieldLengthPredicate = import_zod.z.number().lte(25); | ||
function validateFieldLength(amountAdding, fields) { | ||
fieldLengthPredicate.parse((fields?.length ?? 0) + amountAdding); | ||
} | ||
__name(validateFieldLength, "validateFieldLength"); | ||
var authorNamePredicate = fieldNamePredicate.nullable(); | ||
var urlPredicate = import_zod.z.string().url().nullish(); | ||
var RGBPredicate = import_zod.z.number().int().gte(0).lte(255); | ||
var colorPredicate = import_zod.z.number().int().gte(0).lte(16777215).nullable().or(import_zod.z.tuple([RGBPredicate, RGBPredicate, RGBPredicate])); | ||
var descriptionPredicate = import_zod.z.string().min(1).max(4096).nullable(); | ||
var footerTextPredicate = import_zod.z.string().min(1).max(2048).nullable(); | ||
var timestampPredicate = import_zod.z.union([import_zod.z.number(), import_zod.z.date()]).nullable(); | ||
var titlePredicate = fieldNamePredicate.nullable(); | ||
// src/messages/embed/UnsafeEmbed.ts | ||
var UnsafeEmbedBuilder = class { | ||
constructor(data = {}) { | ||
__publicField(this, "data"); | ||
this.data = { ...data }; | ||
if (data.timestamp) | ||
this.data.timestamp = new Date(data.timestamp).toISOString(); | ||
} | ||
addFields(...fields) { | ||
if (this.data.fields) | ||
this.data.fields.push(...fields); | ||
else | ||
this.data.fields = fields; | ||
return this; | ||
} | ||
spliceFields(index, deleteCount, ...fields) { | ||
if (this.data.fields) | ||
this.data.fields.splice(index, deleteCount, ...fields); | ||
else | ||
this.data.fields = fields; | ||
return this; | ||
} | ||
setFields(...fields) { | ||
this.spliceFields(0, this.data.fields?.length ?? 0, ...fields); | ||
return this; | ||
} | ||
setAuthor(options) { | ||
if (options === null) { | ||
this.data.author = void 0; | ||
return this; | ||
} | ||
this.data.author = { name: options.name, url: options.url, icon_url: options.iconURL }; | ||
return this; | ||
} | ||
setColor(color) { | ||
if (Array.isArray(color)) { | ||
const [red, green, blue] = color; | ||
this.data.color = (red << 16) + (green << 8) + blue; | ||
return this; | ||
} | ||
this.data.color = color ?? void 0; | ||
return this; | ||
} | ||
setDescription(description) { | ||
this.data.description = description ?? void 0; | ||
return this; | ||
} | ||
setFooter(options) { | ||
if (options === null) { | ||
this.data.footer = void 0; | ||
return this; | ||
} | ||
this.data.footer = { text: options.text, icon_url: options.iconURL }; | ||
return this; | ||
} | ||
setImage(url) { | ||
this.data.image = url ? { url } : void 0; | ||
return this; | ||
} | ||
setThumbnail(url) { | ||
this.data.thumbnail = url ? { url } : void 0; | ||
return this; | ||
} | ||
setTimestamp(timestamp = Date.now()) { | ||
this.data.timestamp = timestamp ? new Date(timestamp).toISOString() : void 0; | ||
return this; | ||
} | ||
setTitle(title) { | ||
this.data.title = title ?? void 0; | ||
return this; | ||
} | ||
setURL(url) { | ||
this.data.url = url ?? void 0; | ||
return this; | ||
} | ||
toJSON() { | ||
return { ...this.data }; | ||
} | ||
}; | ||
__name(UnsafeEmbedBuilder, "UnsafeEmbedBuilder"); | ||
// src/messages/embed/Embed.ts | ||
var EmbedBuilder = class extends UnsafeEmbedBuilder { | ||
addFields(...fields) { | ||
validateFieldLength(fields.length, this.data.fields); | ||
return super.addFields(...embedFieldsArrayPredicate.parse(fields)); | ||
} | ||
spliceFields(index, deleteCount, ...fields) { | ||
validateFieldLength(fields.length - deleteCount, this.data.fields); | ||
return super.spliceFields(index, deleteCount, ...embedFieldsArrayPredicate.parse(fields)); | ||
} | ||
setAuthor(options) { | ||
if (options === null) { | ||
return super.setAuthor(null); | ||
} | ||
authorNamePredicate.parse(options.name); | ||
urlPredicate.parse(options.iconURL); | ||
urlPredicate.parse(options.url); | ||
return super.setAuthor(options); | ||
} | ||
setColor(color) { | ||
return super.setColor(colorPredicate.parse(color)); | ||
} | ||
setDescription(description) { | ||
return super.setDescription(descriptionPredicate.parse(description)); | ||
} | ||
setFooter(options) { | ||
if (options === null) { | ||
return super.setFooter(null); | ||
} | ||
footerTextPredicate.parse(options.text); | ||
urlPredicate.parse(options.iconURL); | ||
return super.setFooter(options); | ||
} | ||
setImage(url) { | ||
return super.setImage(urlPredicate.parse(url)); | ||
} | ||
setThumbnail(url) { | ||
return super.setThumbnail(urlPredicate.parse(url)); | ||
} | ||
setTimestamp(timestamp = Date.now()) { | ||
return super.setTimestamp(timestampPredicate.parse(timestamp)); | ||
} | ||
setTitle(title) { | ||
return super.setTitle(titlePredicate.parse(title)); | ||
} | ||
setURL(url) { | ||
return super.setURL(urlPredicate.parse(url)); | ||
} | ||
}; | ||
__name(EmbedBuilder, "EmbedBuilder"); | ||
// src/messages/formatters.ts | ||
function codeBlock(language, content) { | ||
return typeof content === "undefined" ? `\`\`\` | ||
${language}\`\`\`` : `\`\`\`${language} | ||
${content}\`\`\``; | ||
} | ||
__name(codeBlock, "codeBlock"); | ||
function inlineCode(content) { | ||
return `\`${content}\``; | ||
} | ||
__name(inlineCode, "inlineCode"); | ||
function italic(content) { | ||
return `_${content}_`; | ||
} | ||
__name(italic, "italic"); | ||
function bold(content) { | ||
return `**${content}**`; | ||
} | ||
__name(bold, "bold"); | ||
function underscore(content) { | ||
return `__${content}__`; | ||
} | ||
__name(underscore, "underscore"); | ||
function strikethrough(content) { | ||
return `~~${content}~~`; | ||
} | ||
__name(strikethrough, "strikethrough"); | ||
function quote(content) { | ||
return `> ${content}`; | ||
} | ||
__name(quote, "quote"); | ||
function blockQuote(content) { | ||
return `>>> ${content}`; | ||
} | ||
__name(blockQuote, "blockQuote"); | ||
function hideLinkEmbed(url) { | ||
return `<${url}>`; | ||
} | ||
__name(hideLinkEmbed, "hideLinkEmbed"); | ||
function hyperlink(content, url, title) { | ||
return title ? `[${content}](${url} "${title}")` : `[${content}](${url})`; | ||
} | ||
__name(hyperlink, "hyperlink"); | ||
function spoiler(content) { | ||
return `||${content}||`; | ||
} | ||
__name(spoiler, "spoiler"); | ||
function userMention(userId) { | ||
return `<@${userId}>`; | ||
} | ||
__name(userMention, "userMention"); | ||
function memberNicknameMention(memberId) { | ||
return `<@!${memberId}>`; | ||
} | ||
__name(memberNicknameMention, "memberNicknameMention"); | ||
function channelMention(channelId) { | ||
return `<#${channelId}>`; | ||
} | ||
__name(channelMention, "channelMention"); | ||
function roleMention(roleId) { | ||
return `<@&${roleId}>`; | ||
} | ||
__name(roleMention, "roleMention"); | ||
function formatEmoji(emojiId, animated = false) { | ||
return `<${animated ? "a" : ""}:_:${emojiId}>`; | ||
} | ||
__name(formatEmoji, "formatEmoji"); | ||
function time(timeOrSeconds, style) { | ||
if (typeof timeOrSeconds !== "number") { | ||
timeOrSeconds = Math.floor((timeOrSeconds?.getTime() ?? Date.now()) / 1e3); | ||
} | ||
return typeof style === "string" ? `<t:${timeOrSeconds}:${style}>` : `<t:${timeOrSeconds}>`; | ||
} | ||
__name(time, "time"); | ||
var TimestampStyles = { | ||
ShortTime: "t", | ||
LongTime: "T", | ||
ShortDate: "d", | ||
LongDate: "D", | ||
ShortDateTime: "f", | ||
LongDateTime: "F", | ||
RelativeTime: "R" | ||
}; | ||
var Faces = /* @__PURE__ */ ((Faces2) => { | ||
Faces2["Shrug"] = "\xAF\\_(\u30C4)\\_/\xAF"; | ||
Faces2["Tableflip"] = "(\u256F\xB0\u25A1\xB0\uFF09\u256F\uFE35 \u253B\u2501\u253B"; | ||
Faces2["Unflip"] = "\u252C\u2500\u252C \u30CE( \u309C-\u309C\u30CE)"; | ||
return Faces2; | ||
})(Faces || {}); | ||
// src/components/Assertions.ts | ||
var Assertions_exports2 = {}; | ||
__export(Assertions_exports2, { | ||
buttonLabelValidator: () => buttonLabelValidator, | ||
buttonStyleValidator: () => buttonStyleValidator, | ||
customIdValidator: () => customIdValidator, | ||
defaultValidator: () => defaultValidator, | ||
disabledValidator: () => disabledValidator, | ||
emojiValidator: () => emojiValidator, | ||
labelValueDescriptionValidator: () => labelValueDescriptionValidator, | ||
labelValueValidator: () => labelValueValidator, | ||
minMaxValidator: () => minMaxValidator, | ||
optionValidator: () => optionValidator, | ||
optionsLengthValidator: () => optionsLengthValidator, | ||
optionsValidator: () => optionsValidator, | ||
placeholderValidator: () => placeholderValidator, | ||
urlValidator: () => urlValidator, | ||
validateRequiredButtonParameters: () => validateRequiredButtonParameters, | ||
validateRequiredSelectMenuOptionParameters: () => validateRequiredSelectMenuOptionParameters, | ||
validateRequiredSelectMenuParameters: () => validateRequiredSelectMenuParameters | ||
}); | ||
var import_v10 = require("discord-api-types/v10"); | ||
var import_zod2 = require("zod"); | ||
// src/components/selectMenu/UnsafeSelectMenuOption.ts | ||
var UnsafeSelectMenuOptionBuilder = class { | ||
constructor(data = {}) { | ||
this.data = data; | ||
} | ||
setLabel(label) { | ||
this.data.label = label; | ||
return this; | ||
} | ||
setValue(value) { | ||
this.data.value = value; | ||
return this; | ||
} | ||
setDescription(description) { | ||
this.data.description = description; | ||
return this; | ||
} | ||
setDefault(isDefault = true) { | ||
this.data.default = isDefault; | ||
return this; | ||
} | ||
setEmoji(emoji) { | ||
this.data.emoji = emoji; | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
...this.data | ||
}; | ||
} | ||
}; | ||
__name(UnsafeSelectMenuOptionBuilder, "UnsafeSelectMenuOptionBuilder"); | ||
// src/components/Assertions.ts | ||
var customIdValidator = import_zod2.z.string().min(1).max(100); | ||
var emojiValidator = import_zod2.z.object({ | ||
id: import_zod2.z.string(), | ||
name: import_zod2.z.string(), | ||
animated: import_zod2.z.boolean() | ||
}).partial().strict(); | ||
var disabledValidator = import_zod2.z.boolean(); | ||
var buttonLabelValidator = import_zod2.z.string().nonempty().max(80); | ||
var buttonStyleValidator = import_zod2.z.number().int().min(import_v10.ButtonStyle.Primary).max(import_v10.ButtonStyle.Link); | ||
var placeholderValidator = import_zod2.z.string().max(150); | ||
var minMaxValidator = import_zod2.z.number().int().min(0).max(25); | ||
var labelValueDescriptionValidator = import_zod2.z.string().min(1).max(100); | ||
var optionValidator = import_zod2.z.union([ | ||
import_zod2.z.object({ | ||
label: labelValueDescriptionValidator, | ||
value: labelValueDescriptionValidator, | ||
description: labelValueDescriptionValidator.optional(), | ||
emoji: emojiValidator.optional(), | ||
default: import_zod2.z.boolean().optional() | ||
}), | ||
import_zod2.z.instanceof(UnsafeSelectMenuOptionBuilder) | ||
]); | ||
var optionsValidator = optionValidator.array().nonempty(); | ||
var optionsLengthValidator = import_zod2.z.number().int().min(0).max(25); | ||
function validateRequiredSelectMenuParameters(options, customId) { | ||
customIdValidator.parse(customId); | ||
optionsValidator.parse(options); | ||
} | ||
__name(validateRequiredSelectMenuParameters, "validateRequiredSelectMenuParameters"); | ||
var labelValueValidator = import_zod2.z.string().min(1).max(100); | ||
var defaultValidator = import_zod2.z.boolean(); | ||
function validateRequiredSelectMenuOptionParameters(label, value) { | ||
labelValueValidator.parse(label); | ||
labelValueValidator.parse(value); | ||
} | ||
__name(validateRequiredSelectMenuOptionParameters, "validateRequiredSelectMenuOptionParameters"); | ||
var urlValidator = import_zod2.z.string().url(); | ||
function validateRequiredButtonParameters(style, label, emoji, customId, url) { | ||
if (url && customId) { | ||
throw new RangeError("URL and custom id are mutually exclusive"); | ||
} | ||
if (!label && !emoji) { | ||
throw new RangeError("Buttons must have a label and/or an emoji"); | ||
} | ||
if (style === import_v10.ButtonStyle.Link) { | ||
if (!url) { | ||
throw new RangeError("Link buttons must have a url"); | ||
} | ||
} else if (url) { | ||
throw new RangeError("Non-link buttons cannot have a url"); | ||
} | ||
} | ||
__name(validateRequiredButtonParameters, "validateRequiredButtonParameters"); | ||
// src/components/ActionRow.ts | ||
var import_v103 = require("discord-api-types/v10"); | ||
// src/components/Component.ts | ||
var ComponentBuilder = class { | ||
constructor(data) { | ||
__publicField(this, "data"); | ||
this.data = data; | ||
} | ||
}; | ||
__name(ComponentBuilder, "ComponentBuilder"); | ||
// src/components/Components.ts | ||
var import_v102 = require("discord-api-types/v10"); | ||
function createComponentBuilder(data) { | ||
if (data instanceof ComponentBuilder) { | ||
return data; | ||
} | ||
switch (data.type) { | ||
case import_v102.ComponentType.ActionRow: | ||
return new ActionRowBuilder(data); | ||
case import_v102.ComponentType.Button: | ||
return new ButtonBuilder(data); | ||
case import_v102.ComponentType.SelectMenu: | ||
return new SelectMenuBuilder(data); | ||
case import_v102.ComponentType.TextInput: | ||
return new TextInputBuilder(data); | ||
default: | ||
throw new Error(`Cannot properly serialize component type: ${data.type}`); | ||
} | ||
} | ||
__name(createComponentBuilder, "createComponentBuilder"); | ||
// src/components/ActionRow.ts | ||
var ActionRowBuilder = class extends ComponentBuilder { | ||
constructor({ | ||
components, | ||
...data | ||
} = {}) { | ||
super({ type: import_v103.ComponentType.ActionRow, ...data }); | ||
__publicField(this, "components"); | ||
this.components = components?.map((c) => createComponentBuilder(c)) ?? []; | ||
} | ||
addComponents(...components) { | ||
this.components.push(...components); | ||
return this; | ||
} | ||
setComponents(...components) { | ||
this.components.splice(0, this.components.length, ...components); | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
...this.data, | ||
components: this.components.map((component) => component.toJSON()) | ||
}; | ||
} | ||
}; | ||
__name(ActionRowBuilder, "ActionRowBuilder"); | ||
// src/components/button/UnsafeButton.ts | ||
var import_v104 = require("discord-api-types/v10"); | ||
var UnsafeButtonBuilder = class extends ComponentBuilder { | ||
constructor(data) { | ||
super({ type: import_v104.ComponentType.Button, ...data }); | ||
} | ||
setStyle(style) { | ||
this.data.style = style; | ||
return this; | ||
} | ||
setURL(url) { | ||
this.data.url = url; | ||
return this; | ||
} | ||
setCustomId(customId) { | ||
this.data.custom_id = customId; | ||
return this; | ||
} | ||
setEmoji(emoji) { | ||
this.data.emoji = emoji; | ||
return this; | ||
} | ||
setDisabled(disabled = true) { | ||
this.data.disabled = disabled; | ||
return this; | ||
} | ||
setLabel(label) { | ||
this.data.label = label; | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
...this.data | ||
}; | ||
} | ||
}; | ||
__name(UnsafeButtonBuilder, "UnsafeButtonBuilder"); | ||
// src/components/button/Button.ts | ||
var ButtonBuilder = class extends UnsafeButtonBuilder { | ||
setStyle(style) { | ||
return super.setStyle(buttonStyleValidator.parse(style)); | ||
} | ||
setURL(url) { | ||
return super.setURL(urlValidator.parse(url)); | ||
} | ||
setCustomId(customId) { | ||
return super.setCustomId(customIdValidator.parse(customId)); | ||
} | ||
setEmoji(emoji) { | ||
return super.setEmoji(emojiValidator.parse(emoji)); | ||
} | ||
setDisabled(disabled = true) { | ||
return super.setDisabled(disabledValidator.parse(disabled)); | ||
} | ||
setLabel(label) { | ||
return super.setLabel(buttonLabelValidator.parse(label)); | ||
} | ||
toJSON() { | ||
validateRequiredButtonParameters(this.data.style, this.data.label, this.data.emoji, this.data.custom_id, this.data.url); | ||
return super.toJSON(); | ||
} | ||
}; | ||
__name(ButtonBuilder, "ButtonBuilder"); | ||
// src/components/textInput/Assertions.ts | ||
var Assertions_exports3 = {}; | ||
__export(Assertions_exports3, { | ||
labelValidator: () => labelValidator, | ||
maxLengthValidator: () => maxLengthValidator, | ||
minLengthValidator: () => minLengthValidator, | ||
placeholderValidator: () => placeholderValidator2, | ||
requiredValidator: () => requiredValidator, | ||
textInputStyleValidator: () => textInputStyleValidator, | ||
validateRequiredParameters: () => validateRequiredParameters, | ||
valueValidator: () => valueValidator | ||
}); | ||
var import_v105 = require("discord-api-types/v10"); | ||
var import_zod3 = require("zod"); | ||
var textInputStyleValidator = import_zod3.z.nativeEnum(import_v105.TextInputStyle); | ||
var minLengthValidator = import_zod3.z.number().int().min(0).max(4e3); | ||
var maxLengthValidator = import_zod3.z.number().int().min(1).max(4e3); | ||
var requiredValidator = import_zod3.z.boolean(); | ||
var valueValidator = import_zod3.z.string().max(4e3); | ||
var placeholderValidator2 = import_zod3.z.string().max(100); | ||
var labelValidator = import_zod3.z.string().min(1).max(45); | ||
function validateRequiredParameters(customId, style, label) { | ||
customIdValidator.parse(customId); | ||
textInputStyleValidator.parse(style); | ||
labelValidator.parse(label); | ||
} | ||
__name(validateRequiredParameters, "validateRequiredParameters"); | ||
// src/components/textInput/UnsafeTextInput.ts | ||
var import_v106 = require("discord-api-types/v10"); | ||
var import_fast_deep_equal = __toESM(require("fast-deep-equal")); | ||
var UnsafeTextInputBuilder = class extends ComponentBuilder { | ||
constructor(data) { | ||
super({ type: import_v106.ComponentType.TextInput, ...data }); | ||
} | ||
setCustomId(customId) { | ||
this.data.custom_id = customId; | ||
return this; | ||
} | ||
setLabel(label) { | ||
this.data.label = label; | ||
return this; | ||
} | ||
setStyle(style) { | ||
this.data.style = style; | ||
return this; | ||
} | ||
setMinLength(minLength) { | ||
this.data.min_length = minLength; | ||
return this; | ||
} | ||
setMaxLength(maxLength) { | ||
this.data.max_length = maxLength; | ||
return this; | ||
} | ||
setPlaceholder(placeholder) { | ||
this.data.placeholder = placeholder; | ||
return this; | ||
} | ||
setValue(value) { | ||
this.data.value = value; | ||
return this; | ||
} | ||
setRequired(required = true) { | ||
this.data.required = required; | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
...this.data | ||
}; | ||
} | ||
equals(other) { | ||
if (other instanceof UnsafeTextInputBuilder) { | ||
return (0, import_fast_deep_equal.default)(other.data, this.data); | ||
} | ||
return (0, import_fast_deep_equal.default)(other, this.data); | ||
} | ||
}; | ||
__name(UnsafeTextInputBuilder, "UnsafeTextInputBuilder"); | ||
// src/components/textInput/TextInput.ts | ||
var TextInputBuilder = class extends UnsafeTextInputBuilder { | ||
setMinLength(minLength) { | ||
return super.setMinLength(minLengthValidator.parse(minLength)); | ||
} | ||
setMaxLength(maxLength) { | ||
return super.setMaxLength(maxLengthValidator.parse(maxLength)); | ||
} | ||
setRequired(required = true) { | ||
return super.setRequired(requiredValidator.parse(required)); | ||
} | ||
setValue(value) { | ||
return super.setValue(valueValidator.parse(value)); | ||
} | ||
setPlaceholder(placeholder) { | ||
return super.setPlaceholder(placeholderValidator2.parse(placeholder)); | ||
} | ||
toJSON() { | ||
validateRequiredParameters(this.data.custom_id, this.data.style, this.data.label); | ||
return super.toJSON(); | ||
} | ||
}; | ||
__name(TextInputBuilder, "TextInputBuilder"); | ||
// src/interactions/modals/UnsafeModal.ts | ||
var UnsafeModalBuilder = class { | ||
constructor({ components, ...data } = {}) { | ||
__publicField(this, "data"); | ||
__publicField(this, "components", []); | ||
this.data = { ...data }; | ||
this.components = components?.map((c) => createComponentBuilder(c)) ?? []; | ||
} | ||
setTitle(title) { | ||
this.data.title = title; | ||
return this; | ||
} | ||
setCustomId(customId) { | ||
this.data.custom_id = customId; | ||
return this; | ||
} | ||
addComponents(...components) { | ||
this.components.push(...components.map((component) => component instanceof ActionRowBuilder ? component : new ActionRowBuilder(component))); | ||
return this; | ||
} | ||
setComponents(...components) { | ||
this.components.splice(0, this.components.length, ...components); | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
...this.data, | ||
components: this.components.map((component) => component.toJSON()) | ||
}; | ||
} | ||
}; | ||
__name(UnsafeModalBuilder, "UnsafeModalBuilder"); | ||
// src/interactions/modals/Assertions.ts | ||
var Assertions_exports4 = {}; | ||
__export(Assertions_exports4, { | ||
componentsValidator: () => componentsValidator, | ||
titleValidator: () => titleValidator, | ||
validateRequiredParameters: () => validateRequiredParameters2 | ||
}); | ||
var import_zod4 = require("zod"); | ||
var titleValidator = import_zod4.z.string().min(1).max(45); | ||
var componentsValidator = import_zod4.z.array(import_zod4.z.instanceof(ActionRowBuilder)).min(1); | ||
function validateRequiredParameters2(customId, title, components) { | ||
customIdValidator.parse(customId); | ||
titleValidator.parse(title); | ||
componentsValidator.parse(components); | ||
} | ||
__name(validateRequiredParameters2, "validateRequiredParameters"); | ||
// src/interactions/modals/Modal.ts | ||
var ModalBuilder = class extends UnsafeModalBuilder { | ||
setCustomId(customId) { | ||
return super.setCustomId(customIdValidator.parse(customId)); | ||
} | ||
setTitle(title) { | ||
return super.setTitle(titleValidator.parse(title)); | ||
} | ||
toJSON() { | ||
validateRequiredParameters2(this.data.custom_id, this.data.title, this.components); | ||
return super.toJSON(); | ||
} | ||
}; | ||
__name(ModalBuilder, "ModalBuilder"); | ||
// src/components/selectMenu/UnsafeSelectMenu.ts | ||
var import_v107 = require("discord-api-types/v10"); | ||
var UnsafeSelectMenuBuilder = class extends ComponentBuilder { | ||
constructor(data) { | ||
const { options, ...initData } = data ?? {}; | ||
super({ type: import_v107.ComponentType.SelectMenu, ...initData }); | ||
__publicField(this, "options"); | ||
this.options = options?.map((o) => new UnsafeSelectMenuOptionBuilder(o)) ?? []; | ||
} | ||
setPlaceholder(placeholder) { | ||
this.data.placeholder = placeholder; | ||
return this; | ||
} | ||
setMinValues(minValues) { | ||
this.data.min_values = minValues; | ||
return this; | ||
} | ||
setMaxValues(maxValues) { | ||
this.data.max_values = maxValues; | ||
return this; | ||
} | ||
setCustomId(customId) { | ||
this.data.custom_id = customId; | ||
return this; | ||
} | ||
setDisabled(disabled = true) { | ||
this.data.disabled = disabled; | ||
return this; | ||
} | ||
addOptions(...options) { | ||
this.options.push(...options.map((option) => option instanceof UnsafeSelectMenuOptionBuilder ? option : new UnsafeSelectMenuOptionBuilder(option))); | ||
return this; | ||
} | ||
setOptions(...options) { | ||
this.options.splice(0, this.options.length, ...options.map((option) => option instanceof UnsafeSelectMenuOptionBuilder ? option : new UnsafeSelectMenuOptionBuilder(option))); | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
...this.data, | ||
options: this.options.map((o) => o.toJSON()) | ||
}; | ||
} | ||
}; | ||
__name(UnsafeSelectMenuBuilder, "UnsafeSelectMenuBuilder"); | ||
// src/components/selectMenu/SelectMenu.ts | ||
var SelectMenuBuilder = class extends UnsafeSelectMenuBuilder { | ||
setPlaceholder(placeholder) { | ||
return super.setPlaceholder(placeholderValidator.parse(placeholder)); | ||
} | ||
setMinValues(minValues) { | ||
return super.setMinValues(minMaxValidator.parse(minValues)); | ||
} | ||
setMaxValues(maxValues) { | ||
return super.setMaxValues(minMaxValidator.parse(maxValues)); | ||
} | ||
setCustomId(customId) { | ||
return super.setCustomId(customIdValidator.parse(customId)); | ||
} | ||
setDisabled(disabled = true) { | ||
return super.setDisabled(disabledValidator.parse(disabled)); | ||
} | ||
addOptions(...options) { | ||
optionsLengthValidator.parse(this.options.length + options.length); | ||
this.options.push(...options.map((option) => option instanceof UnsafeSelectMenuOptionBuilder ? option : new UnsafeSelectMenuOptionBuilder(optionValidator.parse(option)))); | ||
return this; | ||
} | ||
setOptions(...options) { | ||
optionsLengthValidator.parse(options.length); | ||
this.options.splice(0, this.options.length, ...options.map((option) => option instanceof UnsafeSelectMenuOptionBuilder ? option : new UnsafeSelectMenuOptionBuilder(optionValidator.parse(option)))); | ||
return this; | ||
} | ||
toJSON() { | ||
validateRequiredSelectMenuParameters(this.options, this.data.custom_id); | ||
return super.toJSON(); | ||
} | ||
}; | ||
__name(SelectMenuBuilder, "SelectMenuBuilder"); | ||
// src/components/selectMenu/SelectMenuOption.ts | ||
var SelectMenuOptionBuilder = class extends UnsafeSelectMenuOptionBuilder { | ||
setDescription(description) { | ||
return super.setDescription(labelValueValidator.parse(description)); | ||
} | ||
setDefault(isDefault = true) { | ||
return super.setDefault(defaultValidator.parse(isDefault)); | ||
} | ||
setEmoji(emoji) { | ||
return super.setEmoji(emojiValidator.parse(emoji)); | ||
} | ||
toJSON() { | ||
validateRequiredSelectMenuOptionParameters(this.data.label, this.data.value); | ||
return super.toJSON(); | ||
} | ||
}; | ||
__name(SelectMenuOptionBuilder, "SelectMenuOptionBuilder"); | ||
// src/interactions/slashCommands/Assertions.ts | ||
var Assertions_exports5 = {}; | ||
__export(Assertions_exports5, { | ||
assertReturnOfBuilder: () => assertReturnOfBuilder, | ||
validateChoicesLength: () => validateChoicesLength, | ||
validateDefaultPermission: () => validateDefaultPermission, | ||
validateDescription: () => validateDescription, | ||
validateMaxOptionsLength: () => validateMaxOptionsLength, | ||
validateName: () => validateName, | ||
validateRequired: () => validateRequired, | ||
validateRequiredParameters: () => validateRequiredParameters3 | ||
}); | ||
var import_is = __toESM(require("@sindresorhus/is")); | ||
var import_zod5 = require("zod"); | ||
var namePredicate = import_zod5.z.string().min(1).max(32).regex(/^[\P{Lu}\p{N}_-]+$/u); | ||
function validateName(name) { | ||
namePredicate.parse(name); | ||
} | ||
__name(validateName, "validateName"); | ||
var descriptionPredicate2 = import_zod5.z.string().min(1).max(100); | ||
function validateDescription(description) { | ||
descriptionPredicate2.parse(description); | ||
} | ||
__name(validateDescription, "validateDescription"); | ||
var maxArrayLengthPredicate = import_zod5.z.unknown().array().max(25); | ||
function validateMaxOptionsLength(options) { | ||
maxArrayLengthPredicate.parse(options); | ||
} | ||
__name(validateMaxOptionsLength, "validateMaxOptionsLength"); | ||
function validateRequiredParameters3(name, description, options) { | ||
validateName(name); | ||
validateDescription(description); | ||
validateMaxOptionsLength(options); | ||
} | ||
__name(validateRequiredParameters3, "validateRequiredParameters"); | ||
var booleanPredicate = import_zod5.z.boolean(); | ||
function validateDefaultPermission(value) { | ||
booleanPredicate.parse(value); | ||
} | ||
__name(validateDefaultPermission, "validateDefaultPermission"); | ||
function validateRequired(required) { | ||
booleanPredicate.parse(required); | ||
} | ||
__name(validateRequired, "validateRequired"); | ||
var choicesLengthPredicate = import_zod5.z.number().lte(25); | ||
function validateChoicesLength(amountAdding, choices) { | ||
choicesLengthPredicate.parse((choices?.length ?? 0) + amountAdding); | ||
} | ||
__name(validateChoicesLength, "validateChoicesLength"); | ||
function assertReturnOfBuilder(input, ExpectedInstanceOf) { | ||
const instanceName = ExpectedInstanceOf.name; | ||
if (import_is.default.nullOrUndefined(input)) { | ||
throw new TypeError(`Expected to receive a ${instanceName} builder, got ${input === null ? "null" : "undefined"} instead.`); | ||
} | ||
if (import_is.default.primitive(input)) { | ||
throw new TypeError(`Expected to receive a ${instanceName} builder, got a primitive (${typeof input}) instead.`); | ||
} | ||
if (!(input instanceof ExpectedInstanceOf)) { | ||
const casted = input; | ||
const constructorName = import_is.default.function_(input) ? input.name : casted.constructor.name; | ||
const stringTag = Reflect.get(casted, Symbol.toStringTag); | ||
const fullResultName = stringTag ? `${constructorName} [${stringTag}]` : constructorName; | ||
throw new TypeError(`Expected to receive a ${instanceName} builder, got ${fullResultName} instead.`); | ||
} | ||
} | ||
__name(assertReturnOfBuilder, "assertReturnOfBuilder"); | ||
// src/interactions/slashCommands/SlashCommandBuilder.ts | ||
var import_ts_mixer6 = require("ts-mixer"); | ||
// src/interactions/slashCommands/options/boolean.ts | ||
var import_v108 = require("discord-api-types/v10"); | ||
// src/interactions/slashCommands/mixins/NameAndDescription.ts | ||
var SharedNameAndDescription = class { | ||
constructor() { | ||
__publicField(this, "name"); | ||
__publicField(this, "description"); | ||
} | ||
setName(name) { | ||
validateName(name); | ||
Reflect.set(this, "name", name); | ||
return this; | ||
} | ||
setDescription(description) { | ||
validateDescription(description); | ||
Reflect.set(this, "description", description); | ||
return this; | ||
} | ||
}; | ||
__name(SharedNameAndDescription, "SharedNameAndDescription"); | ||
// src/interactions/slashCommands/mixins/ApplicationCommandOptionBase.ts | ||
var ApplicationCommandOptionBase = class extends SharedNameAndDescription { | ||
constructor() { | ||
super(...arguments); | ||
__publicField(this, "required", false); | ||
} | ||
setRequired(required) { | ||
validateRequired(required); | ||
Reflect.set(this, "required", required); | ||
return this; | ||
} | ||
runRequiredValidations() { | ||
validateRequiredParameters3(this.name, this.description, []); | ||
validateRequired(this.required); | ||
} | ||
}; | ||
__name(ApplicationCommandOptionBase, "ApplicationCommandOptionBase"); | ||
// src/interactions/slashCommands/options/boolean.ts | ||
var SlashCommandBooleanOption = class extends ApplicationCommandOptionBase { | ||
constructor() { | ||
super(...arguments); | ||
__publicField(this, "type", import_v108.ApplicationCommandOptionType.Boolean); | ||
} | ||
toJSON() { | ||
this.runRequiredValidations(); | ||
return { ...this }; | ||
} | ||
}; | ||
__name(SlashCommandBooleanOption, "SlashCommandBooleanOption"); | ||
// src/interactions/slashCommands/options/channel.ts | ||
var import_v1010 = require("discord-api-types/v10"); | ||
var import_ts_mixer = require("ts-mixer"); | ||
// src/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.ts | ||
var import_v109 = require("discord-api-types/v10"); | ||
var import_zod6 = require("zod"); | ||
var allowedChannelTypes = [ | ||
import_v109.ChannelType.GuildText, | ||
import_v109.ChannelType.GuildVoice, | ||
import_v109.ChannelType.GuildCategory, | ||
import_v109.ChannelType.GuildNews, | ||
import_v109.ChannelType.GuildStore, | ||
import_v109.ChannelType.GuildNewsThread, | ||
import_v109.ChannelType.GuildPublicThread, | ||
import_v109.ChannelType.GuildPrivateThread, | ||
import_v109.ChannelType.GuildStageVoice | ||
]; | ||
var channelTypesPredicate = import_zod6.z.array(import_zod6.z.union(allowedChannelTypes.map((type) => import_zod6.z.literal(type)))); | ||
var ApplicationCommandOptionChannelTypesMixin = class { | ||
constructor() { | ||
__publicField(this, "channel_types"); | ||
} | ||
addChannelTypes(...channelTypes) { | ||
if (this.channel_types === void 0) { | ||
Reflect.set(this, "channel_types", []); | ||
} | ||
channelTypesPredicate.parse(channelTypes); | ||
this.channel_types.push(...channelTypes); | ||
return this; | ||
} | ||
}; | ||
__name(ApplicationCommandOptionChannelTypesMixin, "ApplicationCommandOptionChannelTypesMixin"); | ||
// src/interactions/slashCommands/options/channel.ts | ||
var SlashCommandChannelOption = class extends ApplicationCommandOptionBase { | ||
constructor() { | ||
super(...arguments); | ||
__publicField(this, "type", import_v1010.ApplicationCommandOptionType.Channel); | ||
} | ||
toJSON() { | ||
this.runRequiredValidations(); | ||
return { ...this }; | ||
} | ||
}; | ||
__name(SlashCommandChannelOption, "SlashCommandChannelOption"); | ||
SlashCommandChannelOption = __decorateClass([ | ||
(0, import_ts_mixer.mix)(ApplicationCommandOptionChannelTypesMixin) | ||
], SlashCommandChannelOption); | ||
// src/interactions/slashCommands/options/integer.ts | ||
var import_v1012 = require("discord-api-types/v10"); | ||
var import_ts_mixer2 = require("ts-mixer"); | ||
var import_zod8 = require("zod"); | ||
// src/interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.ts | ||
var ApplicationCommandNumericOptionMinMaxValueMixin = class { | ||
constructor() { | ||
__publicField(this, "max_value"); | ||
__publicField(this, "min_value"); | ||
} | ||
}; | ||
__name(ApplicationCommandNumericOptionMinMaxValueMixin, "ApplicationCommandNumericOptionMinMaxValueMixin"); | ||
// src/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.ts | ||
var import_v1011 = require("discord-api-types/v10"); | ||
var import_zod7 = require("zod"); | ||
var stringPredicate = import_zod7.z.string().min(1).max(100); | ||
var numberPredicate = import_zod7.z.number().gt(-Infinity).lt(Infinity); | ||
var choicesPredicate = import_zod7.z.object({ name: stringPredicate, value: import_zod7.z.union([stringPredicate, numberPredicate]) }).array(); | ||
var booleanPredicate2 = import_zod7.z.boolean(); | ||
var ApplicationCommandOptionWithChoicesAndAutocompleteMixin = class { | ||
constructor() { | ||
__publicField(this, "choices"); | ||
__publicField(this, "autocomplete"); | ||
__publicField(this, "type"); | ||
} | ||
addChoices(...choices) { | ||
if (choices.length > 0 && this.autocomplete) { | ||
throw new RangeError("Autocomplete and choices are mutually exclusive to each other."); | ||
} | ||
choicesPredicate.parse(choices); | ||
if (this.choices === void 0) { | ||
Reflect.set(this, "choices", []); | ||
} | ||
validateChoicesLength(choices.length, this.choices); | ||
for (const { name, value } of choices) { | ||
if (this.type === import_v1011.ApplicationCommandOptionType.String) { | ||
stringPredicate.parse(value); | ||
} else { | ||
numberPredicate.parse(value); | ||
} | ||
this.choices.push({ name, value }); | ||
} | ||
return this; | ||
} | ||
setChoices(...choices) { | ||
if (choices.length > 0 && this.autocomplete) { | ||
throw new RangeError("Autocomplete and choices are mutually exclusive to each other."); | ||
} | ||
choicesPredicate.parse(choices); | ||
Reflect.set(this, "choices", []); | ||
this.addChoices(...choices); | ||
return this; | ||
} | ||
setAutocomplete(autocomplete) { | ||
booleanPredicate2.parse(autocomplete); | ||
if (autocomplete && Array.isArray(this.choices) && this.choices.length > 0) { | ||
throw new RangeError("Autocomplete and choices are mutually exclusive to each other."); | ||
} | ||
Reflect.set(this, "autocomplete", autocomplete); | ||
return this; | ||
} | ||
}; | ||
__name(ApplicationCommandOptionWithChoicesAndAutocompleteMixin, "ApplicationCommandOptionWithChoicesAndAutocompleteMixin"); | ||
// src/interactions/slashCommands/options/integer.ts | ||
var numberValidator = import_zod8.z.number().int(); | ||
var SlashCommandIntegerOption = class extends ApplicationCommandOptionBase { | ||
constructor() { | ||
super(...arguments); | ||
__publicField(this, "type", import_v1012.ApplicationCommandOptionType.Integer); | ||
} | ||
setMaxValue(max) { | ||
numberValidator.parse(max); | ||
Reflect.set(this, "max_value", max); | ||
return this; | ||
} | ||
setMinValue(min) { | ||
numberValidator.parse(min); | ||
Reflect.set(this, "min_value", min); | ||
return this; | ||
} | ||
toJSON() { | ||
this.runRequiredValidations(); | ||
if (this.autocomplete && Array.isArray(this.choices) && this.choices.length > 0) { | ||
throw new RangeError("Autocomplete and choices are mutually exclusive to each other."); | ||
} | ||
return { ...this }; | ||
} | ||
}; | ||
__name(SlashCommandIntegerOption, "SlashCommandIntegerOption"); | ||
SlashCommandIntegerOption = __decorateClass([ | ||
(0, import_ts_mixer2.mix)(ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin) | ||
], SlashCommandIntegerOption); | ||
// src/interactions/slashCommands/options/mentionable.ts | ||
var import_v1013 = require("discord-api-types/v10"); | ||
var SlashCommandMentionableOption = class extends ApplicationCommandOptionBase { | ||
constructor() { | ||
super(...arguments); | ||
__publicField(this, "type", import_v1013.ApplicationCommandOptionType.Mentionable); | ||
} | ||
toJSON() { | ||
this.runRequiredValidations(); | ||
return { ...this }; | ||
} | ||
}; | ||
__name(SlashCommandMentionableOption, "SlashCommandMentionableOption"); | ||
// src/interactions/slashCommands/options/number.ts | ||
var import_v1014 = require("discord-api-types/v10"); | ||
var import_ts_mixer3 = require("ts-mixer"); | ||
var import_zod9 = require("zod"); | ||
var numberValidator2 = import_zod9.z.number(); | ||
var SlashCommandNumberOption = class extends ApplicationCommandOptionBase { | ||
constructor() { | ||
super(...arguments); | ||
__publicField(this, "type", import_v1014.ApplicationCommandOptionType.Number); | ||
} | ||
setMaxValue(max) { | ||
numberValidator2.parse(max); | ||
Reflect.set(this, "max_value", max); | ||
return this; | ||
} | ||
setMinValue(min) { | ||
numberValidator2.parse(min); | ||
Reflect.set(this, "min_value", min); | ||
return this; | ||
} | ||
toJSON() { | ||
this.runRequiredValidations(); | ||
if (this.autocomplete && Array.isArray(this.choices) && this.choices.length > 0) { | ||
throw new RangeError("Autocomplete and choices are mutually exclusive to each other."); | ||
} | ||
return { ...this }; | ||
} | ||
}; | ||
__name(SlashCommandNumberOption, "SlashCommandNumberOption"); | ||
SlashCommandNumberOption = __decorateClass([ | ||
(0, import_ts_mixer3.mix)(ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin) | ||
], SlashCommandNumberOption); | ||
// src/interactions/slashCommands/options/role.ts | ||
var import_v1015 = require("discord-api-types/v10"); | ||
var SlashCommandRoleOption = class extends ApplicationCommandOptionBase { | ||
constructor() { | ||
super(...arguments); | ||
__publicField(this, "type", import_v1015.ApplicationCommandOptionType.Role); | ||
} | ||
toJSON() { | ||
this.runRequiredValidations(); | ||
return { ...this }; | ||
} | ||
}; | ||
__name(SlashCommandRoleOption, "SlashCommandRoleOption"); | ||
// src/interactions/slashCommands/options/attachment.ts | ||
var import_v1016 = require("discord-api-types/v10"); | ||
var SlashCommandAttachmentOption = class extends ApplicationCommandOptionBase { | ||
constructor() { | ||
super(...arguments); | ||
__publicField(this, "type", import_v1016.ApplicationCommandOptionType.Attachment); | ||
} | ||
toJSON() { | ||
this.runRequiredValidations(); | ||
return { ...this }; | ||
} | ||
}; | ||
__name(SlashCommandAttachmentOption, "SlashCommandAttachmentOption"); | ||
// src/interactions/slashCommands/options/string.ts | ||
var import_v1017 = require("discord-api-types/v10"); | ||
var import_ts_mixer4 = require("ts-mixer"); | ||
var SlashCommandStringOption = class extends ApplicationCommandOptionBase { | ||
constructor() { | ||
super(...arguments); | ||
__publicField(this, "type", import_v1017.ApplicationCommandOptionType.String); | ||
} | ||
toJSON() { | ||
this.runRequiredValidations(); | ||
if (this.autocomplete && Array.isArray(this.choices) && this.choices.length > 0) { | ||
throw new RangeError("Autocomplete and choices are mutually exclusive to each other."); | ||
} | ||
return { ...this }; | ||
} | ||
}; | ||
__name(SlashCommandStringOption, "SlashCommandStringOption"); | ||
SlashCommandStringOption = __decorateClass([ | ||
(0, import_ts_mixer4.mix)(ApplicationCommandOptionWithChoicesAndAutocompleteMixin) | ||
], SlashCommandStringOption); | ||
// src/interactions/slashCommands/options/user.ts | ||
var import_v1018 = require("discord-api-types/v10"); | ||
var SlashCommandUserOption = class extends ApplicationCommandOptionBase { | ||
constructor() { | ||
super(...arguments); | ||
__publicField(this, "type", import_v1018.ApplicationCommandOptionType.User); | ||
} | ||
toJSON() { | ||
this.runRequiredValidations(); | ||
return { ...this }; | ||
} | ||
}; | ||
__name(SlashCommandUserOption, "SlashCommandUserOption"); | ||
// src/interactions/slashCommands/mixins/SharedSlashCommandOptions.ts | ||
var SharedSlashCommandOptions = class { | ||
constructor() { | ||
__publicField(this, "options"); | ||
} | ||
addBooleanOption(input) { | ||
return this._sharedAddOptionMethod(input, SlashCommandBooleanOption); | ||
} | ||
addUserOption(input) { | ||
return this._sharedAddOptionMethod(input, SlashCommandUserOption); | ||
} | ||
addChannelOption(input) { | ||
return this._sharedAddOptionMethod(input, SlashCommandChannelOption); | ||
} | ||
addRoleOption(input) { | ||
return this._sharedAddOptionMethod(input, SlashCommandRoleOption); | ||
} | ||
addAttachmentOption(input) { | ||
return this._sharedAddOptionMethod(input, SlashCommandAttachmentOption); | ||
} | ||
addMentionableOption(input) { | ||
return this._sharedAddOptionMethod(input, SlashCommandMentionableOption); | ||
} | ||
addStringOption(input) { | ||
return this._sharedAddOptionMethod(input, SlashCommandStringOption); | ||
} | ||
addIntegerOption(input) { | ||
return this._sharedAddOptionMethod(input, SlashCommandIntegerOption); | ||
} | ||
addNumberOption(input) { | ||
return this._sharedAddOptionMethod(input, SlashCommandNumberOption); | ||
} | ||
_sharedAddOptionMethod(input, Instance) { | ||
const { options } = this; | ||
validateMaxOptionsLength(options); | ||
const result = typeof input === "function" ? input(new Instance()) : input; | ||
assertReturnOfBuilder(result, Instance); | ||
options.push(result); | ||
return this; | ||
} | ||
}; | ||
__name(SharedSlashCommandOptions, "SharedSlashCommandOptions"); | ||
// src/interactions/slashCommands/SlashCommandSubcommands.ts | ||
var import_v1019 = require("discord-api-types/v10"); | ||
var import_ts_mixer5 = require("ts-mixer"); | ||
var SlashCommandSubcommandGroupBuilder = class { | ||
constructor() { | ||
__publicField(this, "name"); | ||
__publicField(this, "description"); | ||
__publicField(this, "options", []); | ||
} | ||
addSubcommand(input) { | ||
const { options } = this; | ||
validateMaxOptionsLength(options); | ||
const result = typeof input === "function" ? input(new SlashCommandSubcommandBuilder()) : input; | ||
assertReturnOfBuilder(result, SlashCommandSubcommandBuilder); | ||
options.push(result); | ||
return this; | ||
} | ||
toJSON() { | ||
validateRequiredParameters3(this.name, this.description, this.options); | ||
return { | ||
type: import_v1019.ApplicationCommandOptionType.SubcommandGroup, | ||
name: this.name, | ||
description: this.description, | ||
options: this.options.map((option) => option.toJSON()) | ||
}; | ||
} | ||
}; | ||
__name(SlashCommandSubcommandGroupBuilder, "SlashCommandSubcommandGroupBuilder"); | ||
SlashCommandSubcommandGroupBuilder = __decorateClass([ | ||
(0, import_ts_mixer5.mix)(SharedNameAndDescription) | ||
], SlashCommandSubcommandGroupBuilder); | ||
var SlashCommandSubcommandBuilder = class { | ||
constructor() { | ||
__publicField(this, "name"); | ||
__publicField(this, "description"); | ||
__publicField(this, "options", []); | ||
} | ||
toJSON() { | ||
validateRequiredParameters3(this.name, this.description, this.options); | ||
return { | ||
type: import_v1019.ApplicationCommandOptionType.Subcommand, | ||
name: this.name, | ||
description: this.description, | ||
options: this.options.map((option) => option.toJSON()) | ||
}; | ||
} | ||
}; | ||
__name(SlashCommandSubcommandBuilder, "SlashCommandSubcommandBuilder"); | ||
SlashCommandSubcommandBuilder = __decorateClass([ | ||
(0, import_ts_mixer5.mix)(SharedNameAndDescription, SharedSlashCommandOptions) | ||
], SlashCommandSubcommandBuilder); | ||
// src/interactions/slashCommands/SlashCommandBuilder.ts | ||
var SlashCommandBuilder = class { | ||
constructor() { | ||
__publicField(this, "name"); | ||
__publicField(this, "description"); | ||
__publicField(this, "options", []); | ||
__publicField(this, "defaultPermission"); | ||
} | ||
toJSON() { | ||
validateRequiredParameters3(this.name, this.description, this.options); | ||
return { | ||
name: this.name, | ||
description: this.description, | ||
options: this.options.map((option) => option.toJSON()), | ||
default_permission: this.defaultPermission | ||
}; | ||
} | ||
setDefaultPermission(value) { | ||
validateDefaultPermission(value); | ||
Reflect.set(this, "defaultPermission", value); | ||
return this; | ||
} | ||
addSubcommandGroup(input) { | ||
const { options } = this; | ||
validateMaxOptionsLength(options); | ||
const result = typeof input === "function" ? input(new SlashCommandSubcommandGroupBuilder()) : input; | ||
assertReturnOfBuilder(result, SlashCommandSubcommandGroupBuilder); | ||
options.push(result); | ||
return this; | ||
} | ||
addSubcommand(input) { | ||
const { options } = this; | ||
validateMaxOptionsLength(options); | ||
const result = typeof input === "function" ? input(new SlashCommandSubcommandBuilder()) : input; | ||
assertReturnOfBuilder(result, SlashCommandSubcommandBuilder); | ||
options.push(result); | ||
return this; | ||
} | ||
}; | ||
__name(SlashCommandBuilder, "SlashCommandBuilder"); | ||
SlashCommandBuilder = __decorateClass([ | ||
(0, import_ts_mixer6.mix)(SharedSlashCommandOptions, SharedNameAndDescription) | ||
], SlashCommandBuilder); | ||
// src/interactions/contextMenuCommands/Assertions.ts | ||
var Assertions_exports6 = {}; | ||
__export(Assertions_exports6, { | ||
validateDefaultPermission: () => validateDefaultPermission2, | ||
validateName: () => validateName2, | ||
validateRequiredParameters: () => validateRequiredParameters4, | ||
validateType: () => validateType | ||
}); | ||
var import_zod10 = require("zod"); | ||
var import_v1020 = require("discord-api-types/v10"); | ||
var namePredicate2 = import_zod10.z.string().min(1).max(32).regex(/^( *[\p{L}\p{N}_-]+ *)+$/u); | ||
var typePredicate = import_zod10.z.union([import_zod10.z.literal(import_v1020.ApplicationCommandType.User), import_zod10.z.literal(import_v1020.ApplicationCommandType.Message)]); | ||
var booleanPredicate3 = import_zod10.z.boolean(); | ||
function validateDefaultPermission2(value) { | ||
booleanPredicate3.parse(value); | ||
} | ||
__name(validateDefaultPermission2, "validateDefaultPermission"); | ||
function validateName2(name) { | ||
namePredicate2.parse(name); | ||
} | ||
__name(validateName2, "validateName"); | ||
function validateType(type) { | ||
typePredicate.parse(type); | ||
} | ||
__name(validateType, "validateType"); | ||
function validateRequiredParameters4(name, type) { | ||
validateName2(name); | ||
validateType(type); | ||
} | ||
__name(validateRequiredParameters4, "validateRequiredParameters"); | ||
// src/interactions/contextMenuCommands/ContextMenuCommandBuilder.ts | ||
var ContextMenuCommandBuilder = class { | ||
constructor() { | ||
__publicField(this, "name"); | ||
__publicField(this, "type"); | ||
__publicField(this, "defaultPermission"); | ||
} | ||
setName(name) { | ||
validateName2(name); | ||
Reflect.set(this, "name", name); | ||
return this; | ||
} | ||
setType(type) { | ||
validateType(type); | ||
Reflect.set(this, "type", type); | ||
return this; | ||
} | ||
setDefaultPermission(value) { | ||
validateDefaultPermission2(value); | ||
Reflect.set(this, "defaultPermission", value); | ||
return this; | ||
} | ||
toJSON() { | ||
validateRequiredParameters4(this.name, this.type); | ||
return { | ||
name: this.name, | ||
type: this.type, | ||
default_permission: this.defaultPermission | ||
}; | ||
} | ||
}; | ||
__name(ContextMenuCommandBuilder, "ContextMenuCommandBuilder"); | ||
// src/util/jsonEncodable.ts | ||
function isJSONEncodable(maybeEncodable) { | ||
return maybeEncodable !== null && typeof maybeEncodable === "object" && "toJSON" in maybeEncodable; | ||
} | ||
__name(isJSONEncodable, "isJSONEncodable"); | ||
// src/util/equatable.ts | ||
function isEquatable(maybeEquatable) { | ||
return maybeEquatable !== null && typeof maybeEquatable === "object" && "equals" in maybeEquatable; | ||
} | ||
__name(isEquatable, "isEquatable"); | ||
// src/util/componentUtil.ts | ||
function embedLength(data) { | ||
return (data.title?.length ?? 0) + (data.description?.length ?? 0) + (data.fields?.reduce((prev, curr) => prev + curr.name.length + curr.value.length, 0) ?? 0) + (data.footer?.text.length ?? 0) + (data.author?.name.length ?? 0); | ||
} | ||
__name(embedLength, "embedLength"); | ||
module.exports = __toCommonJS(src_exports); | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
ActionRowBuilder, | ||
ButtonBuilder, | ||
ComponentAssertions, | ||
ComponentBuilder, | ||
ContextMenuCommandAssertions, | ||
ContextMenuCommandBuilder, | ||
EmbedAssertions, | ||
EmbedBuilder, | ||
Faces, | ||
ModalAssertions, | ||
ModalBuilder, | ||
SelectMenuBuilder, | ||
SelectMenuOptionBuilder, | ||
SlashCommandAssertions, | ||
SlashCommandAttachmentOption, | ||
SlashCommandBooleanOption, | ||
SlashCommandBuilder, | ||
SlashCommandChannelOption, | ||
SlashCommandIntegerOption, | ||
SlashCommandMentionableOption, | ||
SlashCommandNumberOption, | ||
SlashCommandRoleOption, | ||
SlashCommandStringOption, | ||
SlashCommandSubcommandBuilder, | ||
SlashCommandSubcommandGroupBuilder, | ||
SlashCommandUserOption, | ||
TextInputAssertions, | ||
TextInputBuilder, | ||
TimestampStyles, | ||
UnsafeButtonBuilder, | ||
UnsafeEmbedBuilder, | ||
UnsafeModalBuilder, | ||
UnsafeSelectMenuBuilder, | ||
UnsafeSelectMenuOptionBuilder, | ||
UnsafeTextInputBuilder, | ||
blockQuote, | ||
bold, | ||
channelMention, | ||
codeBlock, | ||
createComponentBuilder, | ||
embedLength, | ||
formatEmoji, | ||
hideLinkEmbed, | ||
hyperlink, | ||
inlineCode, | ||
isEquatable, | ||
isJSONEncodable, | ||
italic, | ||
memberNicknameMention, | ||
quote, | ||
roleMention, | ||
spoiler, | ||
strikethrough, | ||
time, | ||
underscore, | ||
userMention | ||
}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@discordjs/builders", | ||
"version": "0.13.0-dev.1648339720-520f471", | ||
"version": "0.13.0-dev.1648515278-ac4bc3a", | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
392155
4194
1
1