@discordjs/builders 0.13.0-dev.1648166909.cedd053 → 0.13.0-dev.1649030892-5748dbe
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1534 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1455 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,1456 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
${t}\`\`\``}o(ho,"codeBlock");function bo(e){return`\`${e}\``}o(bo,"inlineCode");function Co(e){return`_${e}_`}o(Co,"italic");function fo(e){return`**${e}**`}o(fo,"bold");function Ao(e){return`__${e}__`}o(Ao,"underscore");function xo(e){return`~~${e}~~`}o(xo,"strikethrough");function yo(e){return`> ${e}`}o(yo,"quote");function Oo(e){return`>>> ${e}`}o(Oo,"blockQuote");function go(e){return`<${e}>`}o(go,"hideLinkEmbed");function So(e,t,n){return n?`[${e}](${t} "${n}")`:`[${e}](${t})`}o(So,"hyperlink");function Po(e){return`||${e}||`}o(Po,"spoiler");function Io(e){return`<@${e}>`}o(Io,"userMention");function Mo(e){return`<@!${e}>`}o(Mo,"memberNicknameMention");function To(e){return`<#${e}>`}o(To,"channelMention");function Ro(e){return`<@&${e}>`}o(Ro,"roleMention");function Bo(e,t=!1){return`<${t?"a":""}:_:${e}>`}o(Bo,"formatEmoji");function wo(e,t){return typeof e!="number"&&(e=Math.floor((e?.getTime()??Date.now())/1e3)),typeof t=="string"?`<t:${e}:${t}>`:`<t:${e}>`}o(wo,"time");var vo={ShortTime:"t",LongTime:"T",ShortDate:"d",LongDate:"D",ShortDateTime:"f",LongDateTime:"F",RelativeTime:"R"},Ie=(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))(Ie||{});var ne={};R(ne,{buttonLabelValidator:()=>Tt,buttonStyleValidator:()=>Rt,customIdValidator:()=>h,defaultValidator:()=>vt,disabledValidator:()=>_,emojiValidator:()=>B,labelValueDescriptionValidator:()=>H,labelValueValidator:()=>k,minMaxValidator:()=>Q,optionValidator:()=>J,optionsLengthValidator:()=>X,optionsValidator:()=>oe,placeholderValidator:()=>Bt,urlValidator:()=>Et,validateRequiredButtonParameters:()=>Vt,validateRequiredSelectMenuOptionParameters:()=>Nt,validateRequiredSelectMenuParameters:()=>wt});import{ButtonStyle as Mt}from"discord-api-types/v10";import{z as l}from"zod";var d=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(d,"UnsafeSelectMenuOptionBuilder");var h=l.string().min(1).max(100),B=l.object({id:l.string(),name:l.string(),animated:l.boolean()}).partial().strict(),_=l.boolean(),Tt=l.string().nonempty().max(80),Rt=l.number().int().min(Mt.Primary).max(Mt.Link),Bt=l.string().max(150),Q=l.number().int().min(0).max(25),H=l.string().min(1).max(100),J=l.union([l.object({label:H,value:H,description:H.optional(),emoji:B.optional(),default:l.boolean().optional()}),l.instanceof(d)]),oe=J.array().nonempty(),X=l.number().int().min(0).max(25);function wt(e,t){h.parse(t),oe.parse(e)}o(wt,"validateRequiredSelectMenuParameters");var k=l.string().min(1).max(100),vt=l.boolean();function Nt(e,t){k.parse(e),k.parse(t)}o(Nt,"validateRequiredSelectMenuOptionParameters");var Et=l.string().url();function Vt(e,t,n,r,p){if(p&&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.Link){if(!p)throw new RangeError("Link buttons must have a url")}else if(p)throw new RangeError("Non-link buttons cannot have a url")}o(Vt,"validateRequiredButtonParameters");import{ComponentType as Me}from"discord-api-types/v10";var b=class{constructor(t){i(this,"data");this.data=t}};o(b,"ComponentBuilder");import{ComponentType as Y}from"discord-api-types/v10";function tt(e){if(e instanceof b)return e;switch(e.type){case Y.ActionRow:return new C(e);case Y.Button:return new et(e);case Y.SelectMenu:return new nt(e);case Y.TextInput:return new ot(e);default:throw new Error(`Cannot properly serialize component type: ${e.type}`)}}o(tt,"createComponentBuilder");var C=class extends b{constructor({components:t,...n}={}){super({type:Me.ActionRow,...n});i(this,"components");this.components=t?.map(r=>tt(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(C,"ActionRowBuilder");import{ComponentType as Te}from"discord-api-types/v10";var it=class extends b{constructor(t){super({type:Te.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(it,"UnsafeButtonBuilder");var et=class extends it{setStyle(t){return super.setStyle(Rt.parse(t))}setURL(t){return super.setURL(Et.parse(t))}setCustomId(t){return super.setCustomId(h.parse(t))}setEmoji(t){return super.setEmoji(B.parse(t))}setDisabled(t=!0){return super.setDisabled(_.parse(t))}setLabel(t){return super.setLabel(Tt.parse(t))}toJSON(){return Vt(this.data.style,this.data.label,this.data.emoji,this.data.custom_id,this.data.url),super.toJSON()}};o(et,"ButtonBuilder");var ae={};R(ae,{labelValidator:()=>re,maxLengthValidator:()=>$t,minLengthValidator:()=>Lt,placeholderValidator:()=>Jt,requiredValidator:()=>Dt,textInputStyleValidator:()=>ie,validateRequiredParameters:()=>kt,valueValidator:()=>_t});import{TextInputStyle as Re}from"discord-api-types/v10";import{z as I}from"zod";var ie=I.nativeEnum(Re),Lt=I.number().int().min(0).max(4e3),$t=I.number().int().min(1).max(4e3),Dt=I.boolean(),_t=I.string().max(4e3),Jt=I.string().max(100),re=I.string().min(1).max(45);function kt(e,t,n){h.parse(e),ie.parse(t),re.parse(n)}o(kt,"validateRequiredParameters");import{ComponentType as Be}from"discord-api-types/v10";import se from"fast-deep-equal";var w=class extends b{constructor(t){super({type:Be.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 w?se(t.data,this.data):se(t,this.data)}};o(w,"UnsafeTextInputBuilder");var ot=class extends w{setMinLength(t){return super.setMinLength(Lt.parse(t))}setMaxLength(t){return super.setMaxLength($t.parse(t))}setRequired(t=!0){return super.setRequired(Dt.parse(t))}setValue(t){return super.setValue(_t.parse(t))}setPlaceholder(t){return super.setPlaceholder(Jt.parse(t))}toJSON(){return kt(this.data.custom_id,this.data.style,this.data.label),super.toJSON()}};o(ot,"TextInputBuilder");var rt=class{constructor({components:t,...n}={}){i(this,"data");i(this,"components",[]);this.data={...n},this.components=t?.map(r=>tt(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 C?n:new C(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(rt,"UnsafeModalBuilder");var me={};R(me,{componentsValidator:()=>pe,titleValidator:()=>at,validateRequiredParameters:()=>qt});import{z as Ut}from"zod";var at=Ut.string().min(1).max(45),pe=Ut.array(Ut.instanceof(C)).min(1);function qt(e,t,n){h.parse(e),at.parse(t),pe.parse(n)}o(qt,"validateRequiredParameters");var le=class extends rt{setCustomId(t){return super.setCustomId(h.parse(t))}setTitle(t){return super.setTitle(at.parse(t))}toJSON(){return qt(this.data.custom_id,this.data.title,this.components),super.toJSON()}};o(le,"ModalBuilder");import{ComponentType as we}from"discord-api-types/v10";var st=class extends b{constructor(t){let{options:n,...r}=t??{};super({type:we.SelectMenu,...r});i(this,"options");this.options=n?.map(p=>new d(p))??[]}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 d?n:new d(n))),this}setOptions(...t){return this.options.splice(0,this.options.length,...t.map(n=>n instanceof d?n:new d(n))),this}toJSON(){return{...this.data,options:this.options.map(t=>t.toJSON())}}};o(st,"UnsafeSelectMenuBuilder");var nt=class extends st{setPlaceholder(t){return super.setPlaceholder(Bt.parse(t))}setMinValues(t){return super.setMinValues(Q.parse(t))}setMaxValues(t){return super.setMaxValues(Q.parse(t))}setCustomId(t){return super.setCustomId(h.parse(t))}setDisabled(t=!0){return super.setDisabled(_.parse(t))}addOptions(...t){return X.parse(this.options.length+t.length),this.options.push(...t.map(n=>n instanceof d?n:new d(J.parse(n)))),this}setOptions(...t){return X.parse(t.length),this.options.splice(0,this.options.length,...t.map(n=>n instanceof d?n:new d(J.parse(n)))),this}toJSON(){return wt(this.options,this.data.custom_id),super.toJSON()}};o(nt,"SelectMenuBuilder");var de=class extends d{setDescription(t){return super.setDescription(k.parse(t))}setDefault(t=!0){return super.setDefault(vt.parse(t))}setEmoji(t){return super.setEmoji(B.parse(t))}toJSON(){return Nt(this.data.label,this.data.value),super.toJSON()}};o(de,"SelectMenuOptionBuilder");var ce={};R(ce,{assertReturnOfBuilder:()=>S,validateChoicesLength:()=>Gt,validateDefaultPermission:()=>Ft,validateDescription:()=>mt,validateMaxOptionsLength:()=>f,validateName:()=>pt,validateRequired:()=>lt,validateRequiredParameters:()=>g});import jt from"@sindresorhus/is";import{z as U}from"zod";var ve=U.string().min(1).max(32).regex(/^[\P{Lu}\p{N}_-]+$/u);function pt(e){ve.parse(e)}o(pt,"validateName");var Ne=U.string().min(1).max(100);function mt(e){Ne.parse(e)}o(mt,"validateDescription");var Ee=U.unknown().array().max(25);function f(e){Ee.parse(e)}o(f,"validateMaxOptionsLength");function g(e,t,n){pt(e),mt(t),f(n)}o(g,"validateRequiredParameters");var ue=U.boolean();function Ft(e){ue.parse(e)}o(Ft,"validateDefaultPermission");function lt(e){ue.parse(e)}o(lt,"validateRequired");var Ve=U.number().lte(25);function Gt(e,t){Ve.parse((t?.length??0)+e)}o(Gt,"validateChoicesLength");function S(e,t){let n=t.name;if(jt.nullOrUndefined(e))throw new TypeError(`Expected to receive a ${n} builder, got ${e===null?"null":"undefined"} instead.`);if(jt.primitive(e))throw new TypeError(`Expected to receive a ${n} builder, got a primitive (${typeof e}) instead.`);if(!(e instanceof t)){let r=e,p=jt.function_(e)?e.name:r.constructor.name,T=Reflect.get(r,Symbol.toStringTag),D=T?`${p} [${T}]`:p;throw new TypeError(`Expected to receive a ${n} builder, got ${D} instead.`)}}o(S,"assertReturnOfBuilder");import{mix as to}from"ts-mixer";import{ApplicationCommandOptionType as Le}from"discord-api-types/v10";var A=class{constructor(){i(this,"name");i(this,"description")}setName(t){return pt(t),Reflect.set(this,"name",t),this}setDescription(t){return mt(t),Reflect.set(this,"description",t),this}};o(A,"SharedNameAndDescription");var m=class extends A{constructor(){super(...arguments);i(this,"required",!1)}setRequired(t){return lt(t),Reflect.set(this,"required",t),this}runRequiredValidations(){g(this.name,this.description,[]),lt(this.required)}};o(m,"ApplicationCommandOptionBase");var dt=class extends m{constructor(){super(...arguments);i(this,"type",Le.Boolean)}toJSON(){return this.runRequiredValidations(),{...this}}};o(dt,"SlashCommandBooleanOption");import{ApplicationCommandOptionType as _e}from"discord-api-types/v10";import{mix as Je}from"ts-mixer";import{ChannelType as x}from"discord-api-types/v10";import{z as Wt}from"zod";var $e=[x.GuildText,x.GuildVoice,x.GuildCategory,x.GuildNews,x.GuildStore,x.GuildNewsThread,x.GuildPublicThread,x.GuildPrivateThread,x.GuildStageVoice],De=Wt.array(Wt.union($e.map(e=>Wt.literal(e)))),ut=class{constructor(){i(this,"channel_types")}addChannelTypes(...t){return this.channel_types===void 0&&Reflect.set(this,"channel_types",[]),De.parse(t),this.channel_types.push(...t),this}};o(ut,"ApplicationCommandOptionChannelTypesMixin");var v=class extends m{constructor(){super(...arguments);i(this,"type",_e.Channel)}toJSON(){return this.runRequiredValidations(),{...this}}};o(v,"SlashCommandChannelOption"),v=c([Je(ut)],v);import{ApplicationCommandOptionType as qe}from"discord-api-types/v10";import{mix as je}from"ts-mixer";import{z as Fe}from"zod";var N=class{constructor(){i(this,"max_value");i(this,"min_value")}};o(N,"ApplicationCommandNumericOptionMinMaxValueMixin");import{ApplicationCommandOptionType as ke}from"discord-api-types/v10";import{z as q}from"zod";var zt=q.string().min(1).max(100),he=q.number().gt(-1/0).lt(1/0),be=q.object({name:zt,value:q.union([zt,he])}).array(),Ue=q.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.");be.parse(t),this.choices===void 0&&Reflect.set(this,"choices",[]),Gt(t.length,this.choices);for(let{name:n,value:r}of t)this.type===ke.String?zt.parse(r):he.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 be.parse(t),Reflect.set(this,"choices",[]),this.addChoices(...t),this}setAutocomplete(t){if(Ue.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 Ce=Fe.number().int(),E=class extends m{constructor(){super(...arguments);i(this,"type",qe.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=c([je(N,P)],E);import{ApplicationCommandOptionType as Ge}from"discord-api-types/v10";var ct=class extends m{constructor(){super(...arguments);i(this,"type",Ge.Mentionable)}toJSON(){return this.runRequiredValidations(),{...this}}};o(ct,"SlashCommandMentionableOption");import{ApplicationCommandOptionType as We}from"discord-api-types/v10";import{mix as ze}from"ts-mixer";import{z as Ze}from"zod";var fe=Ze.number(),V=class extends m{constructor(){super(...arguments);i(this,"type",We.Number)}setMaxValue(t){return fe.parse(t),Reflect.set(this,"max_value",t),this}setMinValue(t){return fe.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=c([ze(N,P)],V);import{ApplicationCommandOptionType as Ke}from"discord-api-types/v10";var ht=class extends m{constructor(){super(...arguments);i(this,"type",Ke.Role)}toJSON(){return this.runRequiredValidations(),{...this}}};o(ht,"SlashCommandRoleOption");import{ApplicationCommandOptionType as Qe}from"discord-api-types/v10";var bt=class extends m{constructor(){super(...arguments);i(this,"type",Qe.Attachment)}toJSON(){return this.runRequiredValidations(),{...this}}};o(bt,"SlashCommandAttachmentOption");import{ApplicationCommandOptionType as He}from"discord-api-types/v10";import{mix as Xe}from"ts-mixer";var L=class extends m{constructor(){super(...arguments);i(this,"type",He.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(L,"SlashCommandStringOption"),L=c([Xe(P)],L);import{ApplicationCommandOptionType as Ye}from"discord-api-types/v10";var Ct=class extends m{constructor(){super(...arguments);i(this,"type",Ye.User)}toJSON(){return this.runRequiredValidations(),{...this}}};o(Ct,"SlashCommandUserOption");var $=class{constructor(){i(this,"options")}addBooleanOption(t){return this._sharedAddOptionMethod(t,dt)}addUserOption(t){return this._sharedAddOptionMethod(t,Ct)}addChannelOption(t){return this._sharedAddOptionMethod(t,v)}addRoleOption(t){return this._sharedAddOptionMethod(t,ht)}addAttachmentOption(t){return this._sharedAddOptionMethod(t,bt)}addMentionableOption(t){return this._sharedAddOptionMethod(t,ct)}addStringOption(t){return this._sharedAddOptionMethod(t,L)}addIntegerOption(t){return this._sharedAddOptionMethod(t,E)}addNumberOption(t){return this._sharedAddOptionMethod(t,V)}_sharedAddOptionMethod(t,n){let{options:r}=this;f(r);let p=typeof t=="function"?t(new n):t;return S(p,n),r.push(p),this}};o($,"SharedSlashCommandOptions");import{ApplicationCommandOptionType as Ae}from"discord-api-types/v10";import{mix as xe}from"ts-mixer";var M=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 y):t;return S(r,y),n.push(r),this}toJSON(){return g(this.name,this.description,this.options),{type:Ae.SubcommandGroup,name:this.name,description:this.description,options:this.options.map(t=>t.toJSON())}}};o(M,"SlashCommandSubcommandGroupBuilder"),M=c([xe(A)],M);var y=class{constructor(){i(this,"name");i(this,"description");i(this,"options",[])}toJSON(){return g(this.name,this.description,this.options),{type:Ae.Subcommand,name:this.name,description:this.description,options:this.options.map(t=>t.toJSON())}}};o(y,"SlashCommandSubcommandBuilder"),y=c([xe(A,$)],y);var ft=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 Ft(t),Reflect.set(this,"defaultPermission",t),this}addSubcommandGroup(t){let{options:n}=this;f(n);let r=typeof t=="function"?t(new M):t;return S(r,M),n.push(r),this}addSubcommand(t){let{options:n}=this;f(n);let r=typeof t=="function"?t(new y):t;return S(r,y),n.push(r),this}};o(ft,"SlashCommandBuilder"),ft=c([to($,A)],ft);var Oe={};R(Oe,{validateDefaultPermission:()=>Zt,validateName:()=>At,validateRequiredParameters:()=>Kt,validateType:()=>xt});import{z as j}from"zod";import{ApplicationCommandType as ye}from"discord-api-types/v10";var eo=j.string().min(1).max(32).regex(/^( *[\p{L}\p{N}_-]+ *)+$/u),oo=j.union([j.literal(ye.User),j.literal(ye.Message)]),no=j.boolean();function Zt(e){no.parse(e)}o(Zt,"validateDefaultPermission");function At(e){eo.parse(e)}o(At,"validateName");function xt(e){oo.parse(e)}o(xt,"validateType");function Kt(e,t){At(e),xt(t)}o(Kt,"validateRequiredParameters");var ge=class{constructor(){i(this,"name");i(this,"type");i(this,"defaultPermission")}setName(t){return At(t),Reflect.set(this,"name",t),this}setType(t){return xt(t),Reflect.set(this,"type",t),this}setDefaultPermission(t){return Zt(t),Reflect.set(this,"defaultPermission",t),this}toJSON(){return Kt(this.name,this.type),{name:this.name,type:this.type,default_permission:this.defaultPermission}}};o(ge,"ContextMenuCommandBuilder");function Sr(e){return e!==null&&typeof e=="object"&&"toJSON"in e}o(Sr,"isJSONEncodable");function Ir(e){return e!==null&&typeof e=="object"&&"equals"in e}o(Ir,"isEquatable");function Tr(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(Tr,"embedLength");export{C as ActionRowBuilder,et as ButtonBuilder,ne as ComponentAssertions,b as ComponentBuilder,Oe as ContextMenuCommandAssertions,ge as ContextMenuCommandBuilder,te as EmbedAssertions,ee as EmbedBuilder,Ie as Faces,me as ModalAssertions,le as ModalBuilder,nt as SelectMenuBuilder,de as SelectMenuOptionBuilder,ce as SlashCommandAssertions,bt as SlashCommandAttachmentOption,dt as SlashCommandBooleanOption,ft as SlashCommandBuilder,v as SlashCommandChannelOption,E as SlashCommandIntegerOption,ct as SlashCommandMentionableOption,V as SlashCommandNumberOption,ht as SlashCommandRoleOption,L as SlashCommandStringOption,y as SlashCommandSubcommandBuilder,M as SlashCommandSubcommandGroupBuilder,Ct as SlashCommandUserOption,ae as TextInputAssertions,ot as TextInputBuilder,vo as TimestampStyles,it as UnsafeButtonBuilder,K as UnsafeEmbedBuilder,rt as UnsafeModalBuilder,st as UnsafeSelectMenuBuilder,d as UnsafeSelectMenuOptionBuilder,w as UnsafeTextInputBuilder,Oo as blockQuote,fo as bold,To as channelMention,ho as codeBlock,tt as createComponentBuilder,Tr as embedLength,Bo as formatEmoji,go as hideLinkEmbed,So as hyperlink,bo as inlineCode,Ir as isEquatable,Sr as isJSONEncodable,Co as italic,Mo as memberNicknameMention,yo as quote,Ro as roleMention,Po as spoiler,xo as strikethrough,wo as time,Ao as underscore,Io as userMention};
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
10
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
11
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
12
|
+
if (decorator = decorators[i])
|
|
13
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
14
|
+
if (kind && result)
|
|
15
|
+
__defProp(target, key, result);
|
|
16
|
+
return result;
|
|
17
|
+
};
|
|
18
|
+
var __publicField = (obj, key, value) => {
|
|
19
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
20
|
+
return value;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// src/messages/embed/Assertions.ts
|
|
24
|
+
var Assertions_exports = {};
|
|
25
|
+
__export(Assertions_exports, {
|
|
26
|
+
RGBPredicate: () => RGBPredicate,
|
|
27
|
+
authorNamePredicate: () => authorNamePredicate,
|
|
28
|
+
colorPredicate: () => colorPredicate,
|
|
29
|
+
descriptionPredicate: () => descriptionPredicate,
|
|
30
|
+
embedFieldPredicate: () => embedFieldPredicate,
|
|
31
|
+
embedFieldsArrayPredicate: () => embedFieldsArrayPredicate,
|
|
32
|
+
fieldInlinePredicate: () => fieldInlinePredicate,
|
|
33
|
+
fieldLengthPredicate: () => fieldLengthPredicate,
|
|
34
|
+
fieldNamePredicate: () => fieldNamePredicate,
|
|
35
|
+
fieldValuePredicate: () => fieldValuePredicate,
|
|
36
|
+
footerTextPredicate: () => footerTextPredicate,
|
|
37
|
+
timestampPredicate: () => timestampPredicate,
|
|
38
|
+
titlePredicate: () => titlePredicate,
|
|
39
|
+
urlPredicate: () => urlPredicate,
|
|
40
|
+
validateFieldLength: () => validateFieldLength
|
|
41
|
+
});
|
|
42
|
+
import { z } from "zod";
|
|
43
|
+
var fieldNamePredicate = z.string().min(1).max(256);
|
|
44
|
+
var fieldValuePredicate = z.string().min(1).max(1024);
|
|
45
|
+
var fieldInlinePredicate = z.boolean().optional();
|
|
46
|
+
var embedFieldPredicate = z.object({
|
|
47
|
+
name: fieldNamePredicate,
|
|
48
|
+
value: fieldValuePredicate,
|
|
49
|
+
inline: fieldInlinePredicate
|
|
50
|
+
});
|
|
51
|
+
var embedFieldsArrayPredicate = embedFieldPredicate.array();
|
|
52
|
+
var fieldLengthPredicate = z.number().lte(25);
|
|
53
|
+
function validateFieldLength(amountAdding, fields) {
|
|
54
|
+
fieldLengthPredicate.parse((fields?.length ?? 0) + amountAdding);
|
|
55
|
+
}
|
|
56
|
+
__name(validateFieldLength, "validateFieldLength");
|
|
57
|
+
var authorNamePredicate = fieldNamePredicate.nullable();
|
|
58
|
+
var urlPredicate = z.string().url().nullish();
|
|
59
|
+
var RGBPredicate = z.number().int().gte(0).lte(255);
|
|
60
|
+
var colorPredicate = z.number().int().gte(0).lte(16777215).nullable().or(z.tuple([RGBPredicate, RGBPredicate, RGBPredicate]));
|
|
61
|
+
var descriptionPredicate = z.string().min(1).max(4096).nullable();
|
|
62
|
+
var footerTextPredicate = z.string().min(1).max(2048).nullable();
|
|
63
|
+
var timestampPredicate = z.union([z.number(), z.date()]).nullable();
|
|
64
|
+
var titlePredicate = fieldNamePredicate.nullable();
|
|
65
|
+
|
|
66
|
+
// src/messages/embed/UnsafeEmbed.ts
|
|
67
|
+
var UnsafeEmbedBuilder = class {
|
|
68
|
+
constructor(data = {}) {
|
|
69
|
+
__publicField(this, "data");
|
|
70
|
+
this.data = { ...data };
|
|
71
|
+
if (data.timestamp)
|
|
72
|
+
this.data.timestamp = new Date(data.timestamp).toISOString();
|
|
73
|
+
}
|
|
74
|
+
addFields(...fields) {
|
|
75
|
+
if (this.data.fields)
|
|
76
|
+
this.data.fields.push(...fields);
|
|
77
|
+
else
|
|
78
|
+
this.data.fields = fields;
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
spliceFields(index, deleteCount, ...fields) {
|
|
82
|
+
if (this.data.fields)
|
|
83
|
+
this.data.fields.splice(index, deleteCount, ...fields);
|
|
84
|
+
else
|
|
85
|
+
this.data.fields = fields;
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
setFields(...fields) {
|
|
89
|
+
this.spliceFields(0, this.data.fields?.length ?? 0, ...fields);
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
setAuthor(options) {
|
|
93
|
+
if (options === null) {
|
|
94
|
+
this.data.author = void 0;
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
this.data.author = { name: options.name, url: options.url, icon_url: options.iconURL };
|
|
98
|
+
return this;
|
|
99
|
+
}
|
|
100
|
+
setColor(color) {
|
|
101
|
+
if (Array.isArray(color)) {
|
|
102
|
+
const [red, green, blue] = color;
|
|
103
|
+
this.data.color = (red << 16) + (green << 8) + blue;
|
|
104
|
+
return this;
|
|
105
|
+
}
|
|
106
|
+
this.data.color = color ?? void 0;
|
|
107
|
+
return this;
|
|
108
|
+
}
|
|
109
|
+
setDescription(description) {
|
|
110
|
+
this.data.description = description ?? void 0;
|
|
111
|
+
return this;
|
|
112
|
+
}
|
|
113
|
+
setFooter(options) {
|
|
114
|
+
if (options === null) {
|
|
115
|
+
this.data.footer = void 0;
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
118
|
+
this.data.footer = { text: options.text, icon_url: options.iconURL };
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
setImage(url) {
|
|
122
|
+
this.data.image = url ? { url } : void 0;
|
|
123
|
+
return this;
|
|
124
|
+
}
|
|
125
|
+
setThumbnail(url) {
|
|
126
|
+
this.data.thumbnail = url ? { url } : void 0;
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
129
|
+
setTimestamp(timestamp = Date.now()) {
|
|
130
|
+
this.data.timestamp = timestamp ? new Date(timestamp).toISOString() : void 0;
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
setTitle(title) {
|
|
134
|
+
this.data.title = title ?? void 0;
|
|
135
|
+
return this;
|
|
136
|
+
}
|
|
137
|
+
setURL(url) {
|
|
138
|
+
this.data.url = url ?? void 0;
|
|
139
|
+
return this;
|
|
140
|
+
}
|
|
141
|
+
toJSON() {
|
|
142
|
+
return { ...this.data };
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
__name(UnsafeEmbedBuilder, "UnsafeEmbedBuilder");
|
|
146
|
+
|
|
147
|
+
// src/messages/embed/Embed.ts
|
|
148
|
+
var EmbedBuilder = class extends UnsafeEmbedBuilder {
|
|
149
|
+
addFields(...fields) {
|
|
150
|
+
validateFieldLength(fields.length, this.data.fields);
|
|
151
|
+
return super.addFields(...embedFieldsArrayPredicate.parse(fields));
|
|
152
|
+
}
|
|
153
|
+
spliceFields(index, deleteCount, ...fields) {
|
|
154
|
+
validateFieldLength(fields.length - deleteCount, this.data.fields);
|
|
155
|
+
return super.spliceFields(index, deleteCount, ...embedFieldsArrayPredicate.parse(fields));
|
|
156
|
+
}
|
|
157
|
+
setAuthor(options) {
|
|
158
|
+
if (options === null) {
|
|
159
|
+
return super.setAuthor(null);
|
|
160
|
+
}
|
|
161
|
+
authorNamePredicate.parse(options.name);
|
|
162
|
+
urlPredicate.parse(options.iconURL);
|
|
163
|
+
urlPredicate.parse(options.url);
|
|
164
|
+
return super.setAuthor(options);
|
|
165
|
+
}
|
|
166
|
+
setColor(color) {
|
|
167
|
+
return super.setColor(colorPredicate.parse(color));
|
|
168
|
+
}
|
|
169
|
+
setDescription(description) {
|
|
170
|
+
return super.setDescription(descriptionPredicate.parse(description));
|
|
171
|
+
}
|
|
172
|
+
setFooter(options) {
|
|
173
|
+
if (options === null) {
|
|
174
|
+
return super.setFooter(null);
|
|
175
|
+
}
|
|
176
|
+
footerTextPredicate.parse(options.text);
|
|
177
|
+
urlPredicate.parse(options.iconURL);
|
|
178
|
+
return super.setFooter(options);
|
|
179
|
+
}
|
|
180
|
+
setImage(url) {
|
|
181
|
+
return super.setImage(urlPredicate.parse(url));
|
|
182
|
+
}
|
|
183
|
+
setThumbnail(url) {
|
|
184
|
+
return super.setThumbnail(urlPredicate.parse(url));
|
|
185
|
+
}
|
|
186
|
+
setTimestamp(timestamp = Date.now()) {
|
|
187
|
+
return super.setTimestamp(timestampPredicate.parse(timestamp));
|
|
188
|
+
}
|
|
189
|
+
setTitle(title) {
|
|
190
|
+
return super.setTitle(titlePredicate.parse(title));
|
|
191
|
+
}
|
|
192
|
+
setURL(url) {
|
|
193
|
+
return super.setURL(urlPredicate.parse(url));
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
__name(EmbedBuilder, "EmbedBuilder");
|
|
197
|
+
|
|
198
|
+
// src/messages/formatters.ts
|
|
199
|
+
function codeBlock(language, content) {
|
|
200
|
+
return typeof content === "undefined" ? `\`\`\`
|
|
201
|
+
${language}\`\`\`` : `\`\`\`${language}
|
|
202
|
+
${content}\`\`\``;
|
|
203
|
+
}
|
|
204
|
+
__name(codeBlock, "codeBlock");
|
|
205
|
+
function inlineCode(content) {
|
|
206
|
+
return `\`${content}\``;
|
|
207
|
+
}
|
|
208
|
+
__name(inlineCode, "inlineCode");
|
|
209
|
+
function italic(content) {
|
|
210
|
+
return `_${content}_`;
|
|
211
|
+
}
|
|
212
|
+
__name(italic, "italic");
|
|
213
|
+
function bold(content) {
|
|
214
|
+
return `**${content}**`;
|
|
215
|
+
}
|
|
216
|
+
__name(bold, "bold");
|
|
217
|
+
function underscore(content) {
|
|
218
|
+
return `__${content}__`;
|
|
219
|
+
}
|
|
220
|
+
__name(underscore, "underscore");
|
|
221
|
+
function strikethrough(content) {
|
|
222
|
+
return `~~${content}~~`;
|
|
223
|
+
}
|
|
224
|
+
__name(strikethrough, "strikethrough");
|
|
225
|
+
function quote(content) {
|
|
226
|
+
return `> ${content}`;
|
|
227
|
+
}
|
|
228
|
+
__name(quote, "quote");
|
|
229
|
+
function blockQuote(content) {
|
|
230
|
+
return `>>> ${content}`;
|
|
231
|
+
}
|
|
232
|
+
__name(blockQuote, "blockQuote");
|
|
233
|
+
function hideLinkEmbed(url) {
|
|
234
|
+
return `<${url}>`;
|
|
235
|
+
}
|
|
236
|
+
__name(hideLinkEmbed, "hideLinkEmbed");
|
|
237
|
+
function hyperlink(content, url, title) {
|
|
238
|
+
return title ? `[${content}](${url} "${title}")` : `[${content}](${url})`;
|
|
239
|
+
}
|
|
240
|
+
__name(hyperlink, "hyperlink");
|
|
241
|
+
function spoiler(content) {
|
|
242
|
+
return `||${content}||`;
|
|
243
|
+
}
|
|
244
|
+
__name(spoiler, "spoiler");
|
|
245
|
+
function userMention(userId) {
|
|
246
|
+
return `<@${userId}>`;
|
|
247
|
+
}
|
|
248
|
+
__name(userMention, "userMention");
|
|
249
|
+
function memberNicknameMention(memberId) {
|
|
250
|
+
return `<@!${memberId}>`;
|
|
251
|
+
}
|
|
252
|
+
__name(memberNicknameMention, "memberNicknameMention");
|
|
253
|
+
function channelMention(channelId) {
|
|
254
|
+
return `<#${channelId}>`;
|
|
255
|
+
}
|
|
256
|
+
__name(channelMention, "channelMention");
|
|
257
|
+
function roleMention(roleId) {
|
|
258
|
+
return `<@&${roleId}>`;
|
|
259
|
+
}
|
|
260
|
+
__name(roleMention, "roleMention");
|
|
261
|
+
function formatEmoji(emojiId, animated = false) {
|
|
262
|
+
return `<${animated ? "a" : ""}:_:${emojiId}>`;
|
|
263
|
+
}
|
|
264
|
+
__name(formatEmoji, "formatEmoji");
|
|
265
|
+
function time(timeOrSeconds, style) {
|
|
266
|
+
if (typeof timeOrSeconds !== "number") {
|
|
267
|
+
timeOrSeconds = Math.floor((timeOrSeconds?.getTime() ?? Date.now()) / 1e3);
|
|
268
|
+
}
|
|
269
|
+
return typeof style === "string" ? `<t:${timeOrSeconds}:${style}>` : `<t:${timeOrSeconds}>`;
|
|
270
|
+
}
|
|
271
|
+
__name(time, "time");
|
|
272
|
+
var TimestampStyles = {
|
|
273
|
+
ShortTime: "t",
|
|
274
|
+
LongTime: "T",
|
|
275
|
+
ShortDate: "d",
|
|
276
|
+
LongDate: "D",
|
|
277
|
+
ShortDateTime: "f",
|
|
278
|
+
LongDateTime: "F",
|
|
279
|
+
RelativeTime: "R"
|
|
280
|
+
};
|
|
281
|
+
var Faces = /* @__PURE__ */ ((Faces2) => {
|
|
282
|
+
Faces2["Shrug"] = "\xAF\\_(\u30C4)\\_/\xAF";
|
|
283
|
+
Faces2["Tableflip"] = "(\u256F\xB0\u25A1\xB0\uFF09\u256F\uFE35 \u253B\u2501\u253B";
|
|
284
|
+
Faces2["Unflip"] = "\u252C\u2500\u252C \u30CE( \u309C-\u309C\u30CE)";
|
|
285
|
+
return Faces2;
|
|
286
|
+
})(Faces || {});
|
|
287
|
+
|
|
288
|
+
// src/components/Assertions.ts
|
|
289
|
+
var Assertions_exports2 = {};
|
|
290
|
+
__export(Assertions_exports2, {
|
|
291
|
+
buttonLabelValidator: () => buttonLabelValidator,
|
|
292
|
+
buttonStyleValidator: () => buttonStyleValidator,
|
|
293
|
+
customIdValidator: () => customIdValidator,
|
|
294
|
+
defaultValidator: () => defaultValidator,
|
|
295
|
+
disabledValidator: () => disabledValidator,
|
|
296
|
+
emojiValidator: () => emojiValidator,
|
|
297
|
+
labelValueDescriptionValidator: () => labelValueDescriptionValidator,
|
|
298
|
+
labelValueValidator: () => labelValueValidator,
|
|
299
|
+
minMaxValidator: () => minMaxValidator,
|
|
300
|
+
optionValidator: () => optionValidator,
|
|
301
|
+
optionsLengthValidator: () => optionsLengthValidator,
|
|
302
|
+
optionsValidator: () => optionsValidator,
|
|
303
|
+
placeholderValidator: () => placeholderValidator,
|
|
304
|
+
urlValidator: () => urlValidator,
|
|
305
|
+
validateRequiredButtonParameters: () => validateRequiredButtonParameters,
|
|
306
|
+
validateRequiredSelectMenuOptionParameters: () => validateRequiredSelectMenuOptionParameters,
|
|
307
|
+
validateRequiredSelectMenuParameters: () => validateRequiredSelectMenuParameters
|
|
308
|
+
});
|
|
309
|
+
import { ButtonStyle } from "discord-api-types/v10";
|
|
310
|
+
import { z as z2 } from "zod";
|
|
311
|
+
|
|
312
|
+
// src/components/selectMenu/UnsafeSelectMenuOption.ts
|
|
313
|
+
var UnsafeSelectMenuOptionBuilder = class {
|
|
314
|
+
constructor(data = {}) {
|
|
315
|
+
this.data = data;
|
|
316
|
+
}
|
|
317
|
+
setLabel(label) {
|
|
318
|
+
this.data.label = label;
|
|
319
|
+
return this;
|
|
320
|
+
}
|
|
321
|
+
setValue(value) {
|
|
322
|
+
this.data.value = value;
|
|
323
|
+
return this;
|
|
324
|
+
}
|
|
325
|
+
setDescription(description) {
|
|
326
|
+
this.data.description = description;
|
|
327
|
+
return this;
|
|
328
|
+
}
|
|
329
|
+
setDefault(isDefault = true) {
|
|
330
|
+
this.data.default = isDefault;
|
|
331
|
+
return this;
|
|
332
|
+
}
|
|
333
|
+
setEmoji(emoji) {
|
|
334
|
+
this.data.emoji = emoji;
|
|
335
|
+
return this;
|
|
336
|
+
}
|
|
337
|
+
toJSON() {
|
|
338
|
+
return {
|
|
339
|
+
...this.data
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
__name(UnsafeSelectMenuOptionBuilder, "UnsafeSelectMenuOptionBuilder");
|
|
344
|
+
|
|
345
|
+
// src/components/Assertions.ts
|
|
346
|
+
var customIdValidator = z2.string().min(1).max(100);
|
|
347
|
+
var emojiValidator = z2.object({
|
|
348
|
+
id: z2.string(),
|
|
349
|
+
name: z2.string(),
|
|
350
|
+
animated: z2.boolean()
|
|
351
|
+
}).partial().strict();
|
|
352
|
+
var disabledValidator = z2.boolean();
|
|
353
|
+
var buttonLabelValidator = z2.string().nonempty().max(80);
|
|
354
|
+
var buttonStyleValidator = z2.number().int().min(ButtonStyle.Primary).max(ButtonStyle.Link);
|
|
355
|
+
var placeholderValidator = z2.string().max(150);
|
|
356
|
+
var minMaxValidator = z2.number().int().min(0).max(25);
|
|
357
|
+
var labelValueDescriptionValidator = z2.string().min(1).max(100);
|
|
358
|
+
var optionValidator = z2.union([
|
|
359
|
+
z2.object({
|
|
360
|
+
label: labelValueDescriptionValidator,
|
|
361
|
+
value: labelValueDescriptionValidator,
|
|
362
|
+
description: labelValueDescriptionValidator.optional(),
|
|
363
|
+
emoji: emojiValidator.optional(),
|
|
364
|
+
default: z2.boolean().optional()
|
|
365
|
+
}),
|
|
366
|
+
z2.instanceof(UnsafeSelectMenuOptionBuilder)
|
|
367
|
+
]);
|
|
368
|
+
var optionsValidator = optionValidator.array().nonempty();
|
|
369
|
+
var optionsLengthValidator = z2.number().int().min(0).max(25);
|
|
370
|
+
function validateRequiredSelectMenuParameters(options, customId) {
|
|
371
|
+
customIdValidator.parse(customId);
|
|
372
|
+
optionsValidator.parse(options);
|
|
373
|
+
}
|
|
374
|
+
__name(validateRequiredSelectMenuParameters, "validateRequiredSelectMenuParameters");
|
|
375
|
+
var labelValueValidator = z2.string().min(1).max(100);
|
|
376
|
+
var defaultValidator = z2.boolean();
|
|
377
|
+
function validateRequiredSelectMenuOptionParameters(label, value) {
|
|
378
|
+
labelValueValidator.parse(label);
|
|
379
|
+
labelValueValidator.parse(value);
|
|
380
|
+
}
|
|
381
|
+
__name(validateRequiredSelectMenuOptionParameters, "validateRequiredSelectMenuOptionParameters");
|
|
382
|
+
var urlValidator = z2.string().url();
|
|
383
|
+
function validateRequiredButtonParameters(style, label, emoji, customId, url) {
|
|
384
|
+
if (url && customId) {
|
|
385
|
+
throw new RangeError("URL and custom id are mutually exclusive");
|
|
386
|
+
}
|
|
387
|
+
if (!label && !emoji) {
|
|
388
|
+
throw new RangeError("Buttons must have a label and/or an emoji");
|
|
389
|
+
}
|
|
390
|
+
if (style === ButtonStyle.Link) {
|
|
391
|
+
if (!url) {
|
|
392
|
+
throw new RangeError("Link buttons must have a url");
|
|
393
|
+
}
|
|
394
|
+
} else if (url) {
|
|
395
|
+
throw new RangeError("Non-link buttons cannot have a url");
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
__name(validateRequiredButtonParameters, "validateRequiredButtonParameters");
|
|
399
|
+
|
|
400
|
+
// src/components/ActionRow.ts
|
|
401
|
+
import {
|
|
402
|
+
ComponentType as ComponentType2
|
|
403
|
+
} from "discord-api-types/v10";
|
|
404
|
+
|
|
405
|
+
// src/components/Component.ts
|
|
406
|
+
var ComponentBuilder = class {
|
|
407
|
+
constructor(data) {
|
|
408
|
+
__publicField(this, "data");
|
|
409
|
+
this.data = data;
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
__name(ComponentBuilder, "ComponentBuilder");
|
|
413
|
+
|
|
414
|
+
// src/components/Components.ts
|
|
415
|
+
import { ComponentType } from "discord-api-types/v10";
|
|
416
|
+
function createComponentBuilder(data) {
|
|
417
|
+
if (data instanceof ComponentBuilder) {
|
|
418
|
+
return data;
|
|
419
|
+
}
|
|
420
|
+
switch (data.type) {
|
|
421
|
+
case ComponentType.ActionRow:
|
|
422
|
+
return new ActionRowBuilder(data);
|
|
423
|
+
case ComponentType.Button:
|
|
424
|
+
return new ButtonBuilder(data);
|
|
425
|
+
case ComponentType.SelectMenu:
|
|
426
|
+
return new SelectMenuBuilder(data);
|
|
427
|
+
case ComponentType.TextInput:
|
|
428
|
+
return new TextInputBuilder(data);
|
|
429
|
+
default:
|
|
430
|
+
throw new Error(`Cannot properly serialize component type: ${data.type}`);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
__name(createComponentBuilder, "createComponentBuilder");
|
|
434
|
+
|
|
435
|
+
// src/components/ActionRow.ts
|
|
436
|
+
var ActionRowBuilder = class extends ComponentBuilder {
|
|
437
|
+
constructor({
|
|
438
|
+
components,
|
|
439
|
+
...data
|
|
440
|
+
} = {}) {
|
|
441
|
+
super({ type: ComponentType2.ActionRow, ...data });
|
|
442
|
+
__publicField(this, "components");
|
|
443
|
+
this.components = components?.map((c) => createComponentBuilder(c)) ?? [];
|
|
444
|
+
}
|
|
445
|
+
addComponents(...components) {
|
|
446
|
+
this.components.push(...components);
|
|
447
|
+
return this;
|
|
448
|
+
}
|
|
449
|
+
setComponents(...components) {
|
|
450
|
+
this.components.splice(0, this.components.length, ...components);
|
|
451
|
+
return this;
|
|
452
|
+
}
|
|
453
|
+
toJSON() {
|
|
454
|
+
return {
|
|
455
|
+
...this.data,
|
|
456
|
+
components: this.components.map((component) => component.toJSON())
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
__name(ActionRowBuilder, "ActionRowBuilder");
|
|
461
|
+
|
|
462
|
+
// src/components/button/UnsafeButton.ts
|
|
463
|
+
import {
|
|
464
|
+
ComponentType as ComponentType3
|
|
465
|
+
} from "discord-api-types/v10";
|
|
466
|
+
var UnsafeButtonBuilder = class extends ComponentBuilder {
|
|
467
|
+
constructor(data) {
|
|
468
|
+
super({ type: ComponentType3.Button, ...data });
|
|
469
|
+
}
|
|
470
|
+
setStyle(style) {
|
|
471
|
+
this.data.style = style;
|
|
472
|
+
return this;
|
|
473
|
+
}
|
|
474
|
+
setURL(url) {
|
|
475
|
+
this.data.url = url;
|
|
476
|
+
return this;
|
|
477
|
+
}
|
|
478
|
+
setCustomId(customId) {
|
|
479
|
+
this.data.custom_id = customId;
|
|
480
|
+
return this;
|
|
481
|
+
}
|
|
482
|
+
setEmoji(emoji) {
|
|
483
|
+
this.data.emoji = emoji;
|
|
484
|
+
return this;
|
|
485
|
+
}
|
|
486
|
+
setDisabled(disabled = true) {
|
|
487
|
+
this.data.disabled = disabled;
|
|
488
|
+
return this;
|
|
489
|
+
}
|
|
490
|
+
setLabel(label) {
|
|
491
|
+
this.data.label = label;
|
|
492
|
+
return this;
|
|
493
|
+
}
|
|
494
|
+
toJSON() {
|
|
495
|
+
return {
|
|
496
|
+
...this.data
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
__name(UnsafeButtonBuilder, "UnsafeButtonBuilder");
|
|
501
|
+
|
|
502
|
+
// src/components/button/Button.ts
|
|
503
|
+
var ButtonBuilder = class extends UnsafeButtonBuilder {
|
|
504
|
+
setStyle(style) {
|
|
505
|
+
return super.setStyle(buttonStyleValidator.parse(style));
|
|
506
|
+
}
|
|
507
|
+
setURL(url) {
|
|
508
|
+
return super.setURL(urlValidator.parse(url));
|
|
509
|
+
}
|
|
510
|
+
setCustomId(customId) {
|
|
511
|
+
return super.setCustomId(customIdValidator.parse(customId));
|
|
512
|
+
}
|
|
513
|
+
setEmoji(emoji) {
|
|
514
|
+
return super.setEmoji(emojiValidator.parse(emoji));
|
|
515
|
+
}
|
|
516
|
+
setDisabled(disabled = true) {
|
|
517
|
+
return super.setDisabled(disabledValidator.parse(disabled));
|
|
518
|
+
}
|
|
519
|
+
setLabel(label) {
|
|
520
|
+
return super.setLabel(buttonLabelValidator.parse(label));
|
|
521
|
+
}
|
|
522
|
+
toJSON() {
|
|
523
|
+
validateRequiredButtonParameters(this.data.style, this.data.label, this.data.emoji, this.data.custom_id, this.data.url);
|
|
524
|
+
return super.toJSON();
|
|
525
|
+
}
|
|
526
|
+
};
|
|
527
|
+
__name(ButtonBuilder, "ButtonBuilder");
|
|
528
|
+
|
|
529
|
+
// src/components/textInput/Assertions.ts
|
|
530
|
+
var Assertions_exports3 = {};
|
|
531
|
+
__export(Assertions_exports3, {
|
|
532
|
+
labelValidator: () => labelValidator,
|
|
533
|
+
maxLengthValidator: () => maxLengthValidator,
|
|
534
|
+
minLengthValidator: () => minLengthValidator,
|
|
535
|
+
placeholderValidator: () => placeholderValidator2,
|
|
536
|
+
requiredValidator: () => requiredValidator,
|
|
537
|
+
textInputStyleValidator: () => textInputStyleValidator,
|
|
538
|
+
validateRequiredParameters: () => validateRequiredParameters,
|
|
539
|
+
valueValidator: () => valueValidator
|
|
540
|
+
});
|
|
541
|
+
import { TextInputStyle } from "discord-api-types/v10";
|
|
542
|
+
import { z as z3 } from "zod";
|
|
543
|
+
var textInputStyleValidator = z3.nativeEnum(TextInputStyle);
|
|
544
|
+
var minLengthValidator = z3.number().int().min(0).max(4e3);
|
|
545
|
+
var maxLengthValidator = z3.number().int().min(1).max(4e3);
|
|
546
|
+
var requiredValidator = z3.boolean();
|
|
547
|
+
var valueValidator = z3.string().max(4e3);
|
|
548
|
+
var placeholderValidator2 = z3.string().max(100);
|
|
549
|
+
var labelValidator = z3.string().min(1).max(45);
|
|
550
|
+
function validateRequiredParameters(customId, style, label) {
|
|
551
|
+
customIdValidator.parse(customId);
|
|
552
|
+
textInputStyleValidator.parse(style);
|
|
553
|
+
labelValidator.parse(label);
|
|
554
|
+
}
|
|
555
|
+
__name(validateRequiredParameters, "validateRequiredParameters");
|
|
556
|
+
|
|
557
|
+
// src/components/textInput/UnsafeTextInput.ts
|
|
558
|
+
import { ComponentType as ComponentType4 } from "discord-api-types/v10";
|
|
559
|
+
import isEqual from "fast-deep-equal";
|
|
560
|
+
var UnsafeTextInputBuilder = class extends ComponentBuilder {
|
|
561
|
+
constructor(data) {
|
|
562
|
+
super({ type: ComponentType4.TextInput, ...data });
|
|
563
|
+
}
|
|
564
|
+
setCustomId(customId) {
|
|
565
|
+
this.data.custom_id = customId;
|
|
566
|
+
return this;
|
|
567
|
+
}
|
|
568
|
+
setLabel(label) {
|
|
569
|
+
this.data.label = label;
|
|
570
|
+
return this;
|
|
571
|
+
}
|
|
572
|
+
setStyle(style) {
|
|
573
|
+
this.data.style = style;
|
|
574
|
+
return this;
|
|
575
|
+
}
|
|
576
|
+
setMinLength(minLength) {
|
|
577
|
+
this.data.min_length = minLength;
|
|
578
|
+
return this;
|
|
579
|
+
}
|
|
580
|
+
setMaxLength(maxLength) {
|
|
581
|
+
this.data.max_length = maxLength;
|
|
582
|
+
return this;
|
|
583
|
+
}
|
|
584
|
+
setPlaceholder(placeholder) {
|
|
585
|
+
this.data.placeholder = placeholder;
|
|
586
|
+
return this;
|
|
587
|
+
}
|
|
588
|
+
setValue(value) {
|
|
589
|
+
this.data.value = value;
|
|
590
|
+
return this;
|
|
591
|
+
}
|
|
592
|
+
setRequired(required = true) {
|
|
593
|
+
this.data.required = required;
|
|
594
|
+
return this;
|
|
595
|
+
}
|
|
596
|
+
toJSON() {
|
|
597
|
+
return {
|
|
598
|
+
...this.data
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
equals(other) {
|
|
602
|
+
if (other instanceof UnsafeTextInputBuilder) {
|
|
603
|
+
return isEqual(other.data, this.data);
|
|
604
|
+
}
|
|
605
|
+
return isEqual(other, this.data);
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
__name(UnsafeTextInputBuilder, "UnsafeTextInputBuilder");
|
|
609
|
+
|
|
610
|
+
// src/components/textInput/TextInput.ts
|
|
611
|
+
var TextInputBuilder = class extends UnsafeTextInputBuilder {
|
|
612
|
+
setMinLength(minLength) {
|
|
613
|
+
return super.setMinLength(minLengthValidator.parse(minLength));
|
|
614
|
+
}
|
|
615
|
+
setMaxLength(maxLength) {
|
|
616
|
+
return super.setMaxLength(maxLengthValidator.parse(maxLength));
|
|
617
|
+
}
|
|
618
|
+
setRequired(required = true) {
|
|
619
|
+
return super.setRequired(requiredValidator.parse(required));
|
|
620
|
+
}
|
|
621
|
+
setValue(value) {
|
|
622
|
+
return super.setValue(valueValidator.parse(value));
|
|
623
|
+
}
|
|
624
|
+
setPlaceholder(placeholder) {
|
|
625
|
+
return super.setPlaceholder(placeholderValidator2.parse(placeholder));
|
|
626
|
+
}
|
|
627
|
+
toJSON() {
|
|
628
|
+
validateRequiredParameters(this.data.custom_id, this.data.style, this.data.label);
|
|
629
|
+
return super.toJSON();
|
|
630
|
+
}
|
|
631
|
+
};
|
|
632
|
+
__name(TextInputBuilder, "TextInputBuilder");
|
|
633
|
+
|
|
634
|
+
// src/interactions/modals/UnsafeModal.ts
|
|
635
|
+
var UnsafeModalBuilder = class {
|
|
636
|
+
constructor({ components, ...data } = {}) {
|
|
637
|
+
__publicField(this, "data");
|
|
638
|
+
__publicField(this, "components", []);
|
|
639
|
+
this.data = { ...data };
|
|
640
|
+
this.components = components?.map((c) => createComponentBuilder(c)) ?? [];
|
|
641
|
+
}
|
|
642
|
+
setTitle(title) {
|
|
643
|
+
this.data.title = title;
|
|
644
|
+
return this;
|
|
645
|
+
}
|
|
646
|
+
setCustomId(customId) {
|
|
647
|
+
this.data.custom_id = customId;
|
|
648
|
+
return this;
|
|
649
|
+
}
|
|
650
|
+
addComponents(...components) {
|
|
651
|
+
this.components.push(...components.map((component) => component instanceof ActionRowBuilder ? component : new ActionRowBuilder(component)));
|
|
652
|
+
return this;
|
|
653
|
+
}
|
|
654
|
+
setComponents(...components) {
|
|
655
|
+
this.components.splice(0, this.components.length, ...components);
|
|
656
|
+
return this;
|
|
657
|
+
}
|
|
658
|
+
toJSON() {
|
|
659
|
+
return {
|
|
660
|
+
...this.data,
|
|
661
|
+
components: this.components.map((component) => component.toJSON())
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
__name(UnsafeModalBuilder, "UnsafeModalBuilder");
|
|
666
|
+
|
|
667
|
+
// src/interactions/modals/Assertions.ts
|
|
668
|
+
var Assertions_exports4 = {};
|
|
669
|
+
__export(Assertions_exports4, {
|
|
670
|
+
componentsValidator: () => componentsValidator,
|
|
671
|
+
titleValidator: () => titleValidator,
|
|
672
|
+
validateRequiredParameters: () => validateRequiredParameters2
|
|
673
|
+
});
|
|
674
|
+
import { z as z4 } from "zod";
|
|
675
|
+
var titleValidator = z4.string().min(1).max(45);
|
|
676
|
+
var componentsValidator = z4.array(z4.instanceof(ActionRowBuilder)).min(1);
|
|
677
|
+
function validateRequiredParameters2(customId, title, components) {
|
|
678
|
+
customIdValidator.parse(customId);
|
|
679
|
+
titleValidator.parse(title);
|
|
680
|
+
componentsValidator.parse(components);
|
|
681
|
+
}
|
|
682
|
+
__name(validateRequiredParameters2, "validateRequiredParameters");
|
|
683
|
+
|
|
684
|
+
// src/interactions/modals/Modal.ts
|
|
685
|
+
var ModalBuilder = class extends UnsafeModalBuilder {
|
|
686
|
+
setCustomId(customId) {
|
|
687
|
+
return super.setCustomId(customIdValidator.parse(customId));
|
|
688
|
+
}
|
|
689
|
+
setTitle(title) {
|
|
690
|
+
return super.setTitle(titleValidator.parse(title));
|
|
691
|
+
}
|
|
692
|
+
toJSON() {
|
|
693
|
+
validateRequiredParameters2(this.data.custom_id, this.data.title, this.components);
|
|
694
|
+
return super.toJSON();
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
__name(ModalBuilder, "ModalBuilder");
|
|
698
|
+
|
|
699
|
+
// src/components/selectMenu/UnsafeSelectMenu.ts
|
|
700
|
+
import { ComponentType as ComponentType5 } from "discord-api-types/v10";
|
|
701
|
+
var UnsafeSelectMenuBuilder = class extends ComponentBuilder {
|
|
702
|
+
constructor(data) {
|
|
703
|
+
const { options, ...initData } = data ?? {};
|
|
704
|
+
super({ type: ComponentType5.SelectMenu, ...initData });
|
|
705
|
+
__publicField(this, "options");
|
|
706
|
+
this.options = options?.map((o) => new UnsafeSelectMenuOptionBuilder(o)) ?? [];
|
|
707
|
+
}
|
|
708
|
+
setPlaceholder(placeholder) {
|
|
709
|
+
this.data.placeholder = placeholder;
|
|
710
|
+
return this;
|
|
711
|
+
}
|
|
712
|
+
setMinValues(minValues) {
|
|
713
|
+
this.data.min_values = minValues;
|
|
714
|
+
return this;
|
|
715
|
+
}
|
|
716
|
+
setMaxValues(maxValues) {
|
|
717
|
+
this.data.max_values = maxValues;
|
|
718
|
+
return this;
|
|
719
|
+
}
|
|
720
|
+
setCustomId(customId) {
|
|
721
|
+
this.data.custom_id = customId;
|
|
722
|
+
return this;
|
|
723
|
+
}
|
|
724
|
+
setDisabled(disabled = true) {
|
|
725
|
+
this.data.disabled = disabled;
|
|
726
|
+
return this;
|
|
727
|
+
}
|
|
728
|
+
addOptions(...options) {
|
|
729
|
+
this.options.push(...options.map((option) => option instanceof UnsafeSelectMenuOptionBuilder ? option : new UnsafeSelectMenuOptionBuilder(option)));
|
|
730
|
+
return this;
|
|
731
|
+
}
|
|
732
|
+
setOptions(...options) {
|
|
733
|
+
this.options.splice(0, this.options.length, ...options.map((option) => option instanceof UnsafeSelectMenuOptionBuilder ? option : new UnsafeSelectMenuOptionBuilder(option)));
|
|
734
|
+
return this;
|
|
735
|
+
}
|
|
736
|
+
toJSON() {
|
|
737
|
+
return {
|
|
738
|
+
...this.data,
|
|
739
|
+
options: this.options.map((o) => o.toJSON())
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
};
|
|
743
|
+
__name(UnsafeSelectMenuBuilder, "UnsafeSelectMenuBuilder");
|
|
744
|
+
|
|
745
|
+
// src/components/selectMenu/SelectMenu.ts
|
|
746
|
+
var SelectMenuBuilder = class extends UnsafeSelectMenuBuilder {
|
|
747
|
+
setPlaceholder(placeholder) {
|
|
748
|
+
return super.setPlaceholder(placeholderValidator.parse(placeholder));
|
|
749
|
+
}
|
|
750
|
+
setMinValues(minValues) {
|
|
751
|
+
return super.setMinValues(minMaxValidator.parse(minValues));
|
|
752
|
+
}
|
|
753
|
+
setMaxValues(maxValues) {
|
|
754
|
+
return super.setMaxValues(minMaxValidator.parse(maxValues));
|
|
755
|
+
}
|
|
756
|
+
setCustomId(customId) {
|
|
757
|
+
return super.setCustomId(customIdValidator.parse(customId));
|
|
758
|
+
}
|
|
759
|
+
setDisabled(disabled = true) {
|
|
760
|
+
return super.setDisabled(disabledValidator.parse(disabled));
|
|
761
|
+
}
|
|
762
|
+
addOptions(...options) {
|
|
763
|
+
optionsLengthValidator.parse(this.options.length + options.length);
|
|
764
|
+
this.options.push(...options.map((option) => option instanceof UnsafeSelectMenuOptionBuilder ? option : new UnsafeSelectMenuOptionBuilder(optionValidator.parse(option))));
|
|
765
|
+
return this;
|
|
766
|
+
}
|
|
767
|
+
setOptions(...options) {
|
|
768
|
+
optionsLengthValidator.parse(options.length);
|
|
769
|
+
this.options.splice(0, this.options.length, ...options.map((option) => option instanceof UnsafeSelectMenuOptionBuilder ? option : new UnsafeSelectMenuOptionBuilder(optionValidator.parse(option))));
|
|
770
|
+
return this;
|
|
771
|
+
}
|
|
772
|
+
toJSON() {
|
|
773
|
+
validateRequiredSelectMenuParameters(this.options, this.data.custom_id);
|
|
774
|
+
return super.toJSON();
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
__name(SelectMenuBuilder, "SelectMenuBuilder");
|
|
778
|
+
|
|
779
|
+
// src/components/selectMenu/SelectMenuOption.ts
|
|
780
|
+
var SelectMenuOptionBuilder = class extends UnsafeSelectMenuOptionBuilder {
|
|
781
|
+
setDescription(description) {
|
|
782
|
+
return super.setDescription(labelValueValidator.parse(description));
|
|
783
|
+
}
|
|
784
|
+
setDefault(isDefault = true) {
|
|
785
|
+
return super.setDefault(defaultValidator.parse(isDefault));
|
|
786
|
+
}
|
|
787
|
+
setEmoji(emoji) {
|
|
788
|
+
return super.setEmoji(emojiValidator.parse(emoji));
|
|
789
|
+
}
|
|
790
|
+
toJSON() {
|
|
791
|
+
validateRequiredSelectMenuOptionParameters(this.data.label, this.data.value);
|
|
792
|
+
return super.toJSON();
|
|
793
|
+
}
|
|
794
|
+
};
|
|
795
|
+
__name(SelectMenuOptionBuilder, "SelectMenuOptionBuilder");
|
|
796
|
+
|
|
797
|
+
// src/interactions/slashCommands/Assertions.ts
|
|
798
|
+
var Assertions_exports5 = {};
|
|
799
|
+
__export(Assertions_exports5, {
|
|
800
|
+
assertReturnOfBuilder: () => assertReturnOfBuilder,
|
|
801
|
+
validateChoicesLength: () => validateChoicesLength,
|
|
802
|
+
validateDefaultPermission: () => validateDefaultPermission,
|
|
803
|
+
validateDescription: () => validateDescription,
|
|
804
|
+
validateMaxOptionsLength: () => validateMaxOptionsLength,
|
|
805
|
+
validateName: () => validateName,
|
|
806
|
+
validateRequired: () => validateRequired,
|
|
807
|
+
validateRequiredParameters: () => validateRequiredParameters3
|
|
808
|
+
});
|
|
809
|
+
import is from "@sindresorhus/is";
|
|
810
|
+
import { z as z5 } from "zod";
|
|
811
|
+
var namePredicate = z5.string().min(1).max(32).regex(/^[\P{Lu}\p{N}_-]+$/u);
|
|
812
|
+
function validateName(name) {
|
|
813
|
+
namePredicate.parse(name);
|
|
814
|
+
}
|
|
815
|
+
__name(validateName, "validateName");
|
|
816
|
+
var descriptionPredicate2 = z5.string().min(1).max(100);
|
|
817
|
+
function validateDescription(description) {
|
|
818
|
+
descriptionPredicate2.parse(description);
|
|
819
|
+
}
|
|
820
|
+
__name(validateDescription, "validateDescription");
|
|
821
|
+
var maxArrayLengthPredicate = z5.unknown().array().max(25);
|
|
822
|
+
function validateMaxOptionsLength(options) {
|
|
823
|
+
maxArrayLengthPredicate.parse(options);
|
|
824
|
+
}
|
|
825
|
+
__name(validateMaxOptionsLength, "validateMaxOptionsLength");
|
|
826
|
+
function validateRequiredParameters3(name, description, options) {
|
|
827
|
+
validateName(name);
|
|
828
|
+
validateDescription(description);
|
|
829
|
+
validateMaxOptionsLength(options);
|
|
830
|
+
}
|
|
831
|
+
__name(validateRequiredParameters3, "validateRequiredParameters");
|
|
832
|
+
var booleanPredicate = z5.boolean();
|
|
833
|
+
function validateDefaultPermission(value) {
|
|
834
|
+
booleanPredicate.parse(value);
|
|
835
|
+
}
|
|
836
|
+
__name(validateDefaultPermission, "validateDefaultPermission");
|
|
837
|
+
function validateRequired(required) {
|
|
838
|
+
booleanPredicate.parse(required);
|
|
839
|
+
}
|
|
840
|
+
__name(validateRequired, "validateRequired");
|
|
841
|
+
var choicesLengthPredicate = z5.number().lte(25);
|
|
842
|
+
function validateChoicesLength(amountAdding, choices) {
|
|
843
|
+
choicesLengthPredicate.parse((choices?.length ?? 0) + amountAdding);
|
|
844
|
+
}
|
|
845
|
+
__name(validateChoicesLength, "validateChoicesLength");
|
|
846
|
+
function assertReturnOfBuilder(input, ExpectedInstanceOf) {
|
|
847
|
+
const instanceName = ExpectedInstanceOf.name;
|
|
848
|
+
if (is.nullOrUndefined(input)) {
|
|
849
|
+
throw new TypeError(`Expected to receive a ${instanceName} builder, got ${input === null ? "null" : "undefined"} instead.`);
|
|
850
|
+
}
|
|
851
|
+
if (is.primitive(input)) {
|
|
852
|
+
throw new TypeError(`Expected to receive a ${instanceName} builder, got a primitive (${typeof input}) instead.`);
|
|
853
|
+
}
|
|
854
|
+
if (!(input instanceof ExpectedInstanceOf)) {
|
|
855
|
+
const casted = input;
|
|
856
|
+
const constructorName = is.function_(input) ? input.name : casted.constructor.name;
|
|
857
|
+
const stringTag = Reflect.get(casted, Symbol.toStringTag);
|
|
858
|
+
const fullResultName = stringTag ? `${constructorName} [${stringTag}]` : constructorName;
|
|
859
|
+
throw new TypeError(`Expected to receive a ${instanceName} builder, got ${fullResultName} instead.`);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
__name(assertReturnOfBuilder, "assertReturnOfBuilder");
|
|
863
|
+
|
|
864
|
+
// src/interactions/slashCommands/SlashCommandBuilder.ts
|
|
865
|
+
import { mix as mix6 } from "ts-mixer";
|
|
866
|
+
|
|
867
|
+
// src/interactions/slashCommands/options/boolean.ts
|
|
868
|
+
import { ApplicationCommandOptionType } from "discord-api-types/v10";
|
|
869
|
+
|
|
870
|
+
// src/interactions/slashCommands/mixins/NameAndDescription.ts
|
|
871
|
+
var SharedNameAndDescription = class {
|
|
872
|
+
constructor() {
|
|
873
|
+
__publicField(this, "name");
|
|
874
|
+
__publicField(this, "description");
|
|
875
|
+
}
|
|
876
|
+
setName(name) {
|
|
877
|
+
validateName(name);
|
|
878
|
+
Reflect.set(this, "name", name);
|
|
879
|
+
return this;
|
|
880
|
+
}
|
|
881
|
+
setDescription(description) {
|
|
882
|
+
validateDescription(description);
|
|
883
|
+
Reflect.set(this, "description", description);
|
|
884
|
+
return this;
|
|
885
|
+
}
|
|
886
|
+
};
|
|
887
|
+
__name(SharedNameAndDescription, "SharedNameAndDescription");
|
|
888
|
+
|
|
889
|
+
// src/interactions/slashCommands/mixins/ApplicationCommandOptionBase.ts
|
|
890
|
+
var ApplicationCommandOptionBase = class extends SharedNameAndDescription {
|
|
891
|
+
constructor() {
|
|
892
|
+
super(...arguments);
|
|
893
|
+
__publicField(this, "required", false);
|
|
894
|
+
}
|
|
895
|
+
setRequired(required) {
|
|
896
|
+
validateRequired(required);
|
|
897
|
+
Reflect.set(this, "required", required);
|
|
898
|
+
return this;
|
|
899
|
+
}
|
|
900
|
+
runRequiredValidations() {
|
|
901
|
+
validateRequiredParameters3(this.name, this.description, []);
|
|
902
|
+
validateRequired(this.required);
|
|
903
|
+
}
|
|
904
|
+
};
|
|
905
|
+
__name(ApplicationCommandOptionBase, "ApplicationCommandOptionBase");
|
|
906
|
+
|
|
907
|
+
// src/interactions/slashCommands/options/boolean.ts
|
|
908
|
+
var SlashCommandBooleanOption = class extends ApplicationCommandOptionBase {
|
|
909
|
+
constructor() {
|
|
910
|
+
super(...arguments);
|
|
911
|
+
__publicField(this, "type", ApplicationCommandOptionType.Boolean);
|
|
912
|
+
}
|
|
913
|
+
toJSON() {
|
|
914
|
+
this.runRequiredValidations();
|
|
915
|
+
return { ...this };
|
|
916
|
+
}
|
|
917
|
+
};
|
|
918
|
+
__name(SlashCommandBooleanOption, "SlashCommandBooleanOption");
|
|
919
|
+
|
|
920
|
+
// src/interactions/slashCommands/options/channel.ts
|
|
921
|
+
import { ApplicationCommandOptionType as ApplicationCommandOptionType2 } from "discord-api-types/v10";
|
|
922
|
+
import { mix } from "ts-mixer";
|
|
923
|
+
|
|
924
|
+
// src/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.ts
|
|
925
|
+
import { ChannelType } from "discord-api-types/v10";
|
|
926
|
+
import { z as z6 } from "zod";
|
|
927
|
+
var allowedChannelTypes = [
|
|
928
|
+
ChannelType.GuildText,
|
|
929
|
+
ChannelType.GuildVoice,
|
|
930
|
+
ChannelType.GuildCategory,
|
|
931
|
+
ChannelType.GuildNews,
|
|
932
|
+
ChannelType.GuildStore,
|
|
933
|
+
ChannelType.GuildNewsThread,
|
|
934
|
+
ChannelType.GuildPublicThread,
|
|
935
|
+
ChannelType.GuildPrivateThread,
|
|
936
|
+
ChannelType.GuildStageVoice
|
|
937
|
+
];
|
|
938
|
+
var channelTypesPredicate = z6.array(z6.union(allowedChannelTypes.map((type) => z6.literal(type))));
|
|
939
|
+
var ApplicationCommandOptionChannelTypesMixin = class {
|
|
940
|
+
constructor() {
|
|
941
|
+
__publicField(this, "channel_types");
|
|
942
|
+
}
|
|
943
|
+
addChannelTypes(...channelTypes) {
|
|
944
|
+
if (this.channel_types === void 0) {
|
|
945
|
+
Reflect.set(this, "channel_types", []);
|
|
946
|
+
}
|
|
947
|
+
channelTypesPredicate.parse(channelTypes);
|
|
948
|
+
this.channel_types.push(...channelTypes);
|
|
949
|
+
return this;
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
__name(ApplicationCommandOptionChannelTypesMixin, "ApplicationCommandOptionChannelTypesMixin");
|
|
953
|
+
|
|
954
|
+
// src/interactions/slashCommands/options/channel.ts
|
|
955
|
+
var SlashCommandChannelOption = class extends ApplicationCommandOptionBase {
|
|
956
|
+
constructor() {
|
|
957
|
+
super(...arguments);
|
|
958
|
+
__publicField(this, "type", ApplicationCommandOptionType2.Channel);
|
|
959
|
+
}
|
|
960
|
+
toJSON() {
|
|
961
|
+
this.runRequiredValidations();
|
|
962
|
+
return { ...this };
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
__name(SlashCommandChannelOption, "SlashCommandChannelOption");
|
|
966
|
+
SlashCommandChannelOption = __decorateClass([
|
|
967
|
+
mix(ApplicationCommandOptionChannelTypesMixin)
|
|
968
|
+
], SlashCommandChannelOption);
|
|
969
|
+
|
|
970
|
+
// src/interactions/slashCommands/options/integer.ts
|
|
971
|
+
import { ApplicationCommandOptionType as ApplicationCommandOptionType4 } from "discord-api-types/v10";
|
|
972
|
+
import { mix as mix2 } from "ts-mixer";
|
|
973
|
+
import { z as z8 } from "zod";
|
|
974
|
+
|
|
975
|
+
// src/interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.ts
|
|
976
|
+
var ApplicationCommandNumericOptionMinMaxValueMixin = class {
|
|
977
|
+
constructor() {
|
|
978
|
+
__publicField(this, "max_value");
|
|
979
|
+
__publicField(this, "min_value");
|
|
980
|
+
}
|
|
981
|
+
};
|
|
982
|
+
__name(ApplicationCommandNumericOptionMinMaxValueMixin, "ApplicationCommandNumericOptionMinMaxValueMixin");
|
|
983
|
+
|
|
984
|
+
// src/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.ts
|
|
985
|
+
import { ApplicationCommandOptionType as ApplicationCommandOptionType3 } from "discord-api-types/v10";
|
|
986
|
+
import { z as z7 } from "zod";
|
|
987
|
+
var stringPredicate = z7.string().min(1).max(100);
|
|
988
|
+
var numberPredicate = z7.number().gt(-Infinity).lt(Infinity);
|
|
989
|
+
var choicesPredicate = z7.object({ name: stringPredicate, value: z7.union([stringPredicate, numberPredicate]) }).array();
|
|
990
|
+
var booleanPredicate2 = z7.boolean();
|
|
991
|
+
var ApplicationCommandOptionWithChoicesAndAutocompleteMixin = class {
|
|
992
|
+
constructor() {
|
|
993
|
+
__publicField(this, "choices");
|
|
994
|
+
__publicField(this, "autocomplete");
|
|
995
|
+
__publicField(this, "type");
|
|
996
|
+
}
|
|
997
|
+
addChoices(...choices) {
|
|
998
|
+
if (choices.length > 0 && this.autocomplete) {
|
|
999
|
+
throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");
|
|
1000
|
+
}
|
|
1001
|
+
choicesPredicate.parse(choices);
|
|
1002
|
+
if (this.choices === void 0) {
|
|
1003
|
+
Reflect.set(this, "choices", []);
|
|
1004
|
+
}
|
|
1005
|
+
validateChoicesLength(choices.length, this.choices);
|
|
1006
|
+
for (const { name, value } of choices) {
|
|
1007
|
+
if (this.type === ApplicationCommandOptionType3.String) {
|
|
1008
|
+
stringPredicate.parse(value);
|
|
1009
|
+
} else {
|
|
1010
|
+
numberPredicate.parse(value);
|
|
1011
|
+
}
|
|
1012
|
+
this.choices.push({ name, value });
|
|
1013
|
+
}
|
|
1014
|
+
return this;
|
|
1015
|
+
}
|
|
1016
|
+
setChoices(...choices) {
|
|
1017
|
+
if (choices.length > 0 && this.autocomplete) {
|
|
1018
|
+
throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");
|
|
1019
|
+
}
|
|
1020
|
+
choicesPredicate.parse(choices);
|
|
1021
|
+
Reflect.set(this, "choices", []);
|
|
1022
|
+
this.addChoices(...choices);
|
|
1023
|
+
return this;
|
|
1024
|
+
}
|
|
1025
|
+
setAutocomplete(autocomplete) {
|
|
1026
|
+
booleanPredicate2.parse(autocomplete);
|
|
1027
|
+
if (autocomplete && Array.isArray(this.choices) && this.choices.length > 0) {
|
|
1028
|
+
throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");
|
|
1029
|
+
}
|
|
1030
|
+
Reflect.set(this, "autocomplete", autocomplete);
|
|
1031
|
+
return this;
|
|
1032
|
+
}
|
|
1033
|
+
};
|
|
1034
|
+
__name(ApplicationCommandOptionWithChoicesAndAutocompleteMixin, "ApplicationCommandOptionWithChoicesAndAutocompleteMixin");
|
|
1035
|
+
|
|
1036
|
+
// src/interactions/slashCommands/options/integer.ts
|
|
1037
|
+
var numberValidator = z8.number().int();
|
|
1038
|
+
var SlashCommandIntegerOption = class extends ApplicationCommandOptionBase {
|
|
1039
|
+
constructor() {
|
|
1040
|
+
super(...arguments);
|
|
1041
|
+
__publicField(this, "type", ApplicationCommandOptionType4.Integer);
|
|
1042
|
+
}
|
|
1043
|
+
setMaxValue(max) {
|
|
1044
|
+
numberValidator.parse(max);
|
|
1045
|
+
Reflect.set(this, "max_value", max);
|
|
1046
|
+
return this;
|
|
1047
|
+
}
|
|
1048
|
+
setMinValue(min) {
|
|
1049
|
+
numberValidator.parse(min);
|
|
1050
|
+
Reflect.set(this, "min_value", min);
|
|
1051
|
+
return this;
|
|
1052
|
+
}
|
|
1053
|
+
toJSON() {
|
|
1054
|
+
this.runRequiredValidations();
|
|
1055
|
+
if (this.autocomplete && Array.isArray(this.choices) && this.choices.length > 0) {
|
|
1056
|
+
throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");
|
|
1057
|
+
}
|
|
1058
|
+
return { ...this };
|
|
1059
|
+
}
|
|
1060
|
+
};
|
|
1061
|
+
__name(SlashCommandIntegerOption, "SlashCommandIntegerOption");
|
|
1062
|
+
SlashCommandIntegerOption = __decorateClass([
|
|
1063
|
+
mix2(ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin)
|
|
1064
|
+
], SlashCommandIntegerOption);
|
|
1065
|
+
|
|
1066
|
+
// src/interactions/slashCommands/options/mentionable.ts
|
|
1067
|
+
import { ApplicationCommandOptionType as ApplicationCommandOptionType5 } from "discord-api-types/v10";
|
|
1068
|
+
var SlashCommandMentionableOption = class extends ApplicationCommandOptionBase {
|
|
1069
|
+
constructor() {
|
|
1070
|
+
super(...arguments);
|
|
1071
|
+
__publicField(this, "type", ApplicationCommandOptionType5.Mentionable);
|
|
1072
|
+
}
|
|
1073
|
+
toJSON() {
|
|
1074
|
+
this.runRequiredValidations();
|
|
1075
|
+
return { ...this };
|
|
1076
|
+
}
|
|
1077
|
+
};
|
|
1078
|
+
__name(SlashCommandMentionableOption, "SlashCommandMentionableOption");
|
|
1079
|
+
|
|
1080
|
+
// src/interactions/slashCommands/options/number.ts
|
|
1081
|
+
import { ApplicationCommandOptionType as ApplicationCommandOptionType6 } from "discord-api-types/v10";
|
|
1082
|
+
import { mix as mix3 } from "ts-mixer";
|
|
1083
|
+
import { z as z9 } from "zod";
|
|
1084
|
+
var numberValidator2 = z9.number();
|
|
1085
|
+
var SlashCommandNumberOption = class extends ApplicationCommandOptionBase {
|
|
1086
|
+
constructor() {
|
|
1087
|
+
super(...arguments);
|
|
1088
|
+
__publicField(this, "type", ApplicationCommandOptionType6.Number);
|
|
1089
|
+
}
|
|
1090
|
+
setMaxValue(max) {
|
|
1091
|
+
numberValidator2.parse(max);
|
|
1092
|
+
Reflect.set(this, "max_value", max);
|
|
1093
|
+
return this;
|
|
1094
|
+
}
|
|
1095
|
+
setMinValue(min) {
|
|
1096
|
+
numberValidator2.parse(min);
|
|
1097
|
+
Reflect.set(this, "min_value", min);
|
|
1098
|
+
return this;
|
|
1099
|
+
}
|
|
1100
|
+
toJSON() {
|
|
1101
|
+
this.runRequiredValidations();
|
|
1102
|
+
if (this.autocomplete && Array.isArray(this.choices) && this.choices.length > 0) {
|
|
1103
|
+
throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");
|
|
1104
|
+
}
|
|
1105
|
+
return { ...this };
|
|
1106
|
+
}
|
|
1107
|
+
};
|
|
1108
|
+
__name(SlashCommandNumberOption, "SlashCommandNumberOption");
|
|
1109
|
+
SlashCommandNumberOption = __decorateClass([
|
|
1110
|
+
mix3(ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin)
|
|
1111
|
+
], SlashCommandNumberOption);
|
|
1112
|
+
|
|
1113
|
+
// src/interactions/slashCommands/options/role.ts
|
|
1114
|
+
import { ApplicationCommandOptionType as ApplicationCommandOptionType7 } from "discord-api-types/v10";
|
|
1115
|
+
var SlashCommandRoleOption = class extends ApplicationCommandOptionBase {
|
|
1116
|
+
constructor() {
|
|
1117
|
+
super(...arguments);
|
|
1118
|
+
__publicField(this, "type", ApplicationCommandOptionType7.Role);
|
|
1119
|
+
}
|
|
1120
|
+
toJSON() {
|
|
1121
|
+
this.runRequiredValidations();
|
|
1122
|
+
return { ...this };
|
|
1123
|
+
}
|
|
1124
|
+
};
|
|
1125
|
+
__name(SlashCommandRoleOption, "SlashCommandRoleOption");
|
|
1126
|
+
|
|
1127
|
+
// src/interactions/slashCommands/options/attachment.ts
|
|
1128
|
+
import { ApplicationCommandOptionType as ApplicationCommandOptionType8 } from "discord-api-types/v10";
|
|
1129
|
+
var SlashCommandAttachmentOption = class extends ApplicationCommandOptionBase {
|
|
1130
|
+
constructor() {
|
|
1131
|
+
super(...arguments);
|
|
1132
|
+
__publicField(this, "type", ApplicationCommandOptionType8.Attachment);
|
|
1133
|
+
}
|
|
1134
|
+
toJSON() {
|
|
1135
|
+
this.runRequiredValidations();
|
|
1136
|
+
return { ...this };
|
|
1137
|
+
}
|
|
1138
|
+
};
|
|
1139
|
+
__name(SlashCommandAttachmentOption, "SlashCommandAttachmentOption");
|
|
1140
|
+
|
|
1141
|
+
// src/interactions/slashCommands/options/string.ts
|
|
1142
|
+
import { ApplicationCommandOptionType as ApplicationCommandOptionType9 } from "discord-api-types/v10";
|
|
1143
|
+
import { mix as mix4 } from "ts-mixer";
|
|
1144
|
+
var SlashCommandStringOption = class extends ApplicationCommandOptionBase {
|
|
1145
|
+
constructor() {
|
|
1146
|
+
super(...arguments);
|
|
1147
|
+
__publicField(this, "type", ApplicationCommandOptionType9.String);
|
|
1148
|
+
}
|
|
1149
|
+
toJSON() {
|
|
1150
|
+
this.runRequiredValidations();
|
|
1151
|
+
if (this.autocomplete && Array.isArray(this.choices) && this.choices.length > 0) {
|
|
1152
|
+
throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");
|
|
1153
|
+
}
|
|
1154
|
+
return { ...this };
|
|
1155
|
+
}
|
|
1156
|
+
};
|
|
1157
|
+
__name(SlashCommandStringOption, "SlashCommandStringOption");
|
|
1158
|
+
SlashCommandStringOption = __decorateClass([
|
|
1159
|
+
mix4(ApplicationCommandOptionWithChoicesAndAutocompleteMixin)
|
|
1160
|
+
], SlashCommandStringOption);
|
|
1161
|
+
|
|
1162
|
+
// src/interactions/slashCommands/options/user.ts
|
|
1163
|
+
import { ApplicationCommandOptionType as ApplicationCommandOptionType10 } from "discord-api-types/v10";
|
|
1164
|
+
var SlashCommandUserOption = class extends ApplicationCommandOptionBase {
|
|
1165
|
+
constructor() {
|
|
1166
|
+
super(...arguments);
|
|
1167
|
+
__publicField(this, "type", ApplicationCommandOptionType10.User);
|
|
1168
|
+
}
|
|
1169
|
+
toJSON() {
|
|
1170
|
+
this.runRequiredValidations();
|
|
1171
|
+
return { ...this };
|
|
1172
|
+
}
|
|
1173
|
+
};
|
|
1174
|
+
__name(SlashCommandUserOption, "SlashCommandUserOption");
|
|
1175
|
+
|
|
1176
|
+
// src/interactions/slashCommands/mixins/SharedSlashCommandOptions.ts
|
|
1177
|
+
var SharedSlashCommandOptions = class {
|
|
1178
|
+
constructor() {
|
|
1179
|
+
__publicField(this, "options");
|
|
1180
|
+
}
|
|
1181
|
+
addBooleanOption(input) {
|
|
1182
|
+
return this._sharedAddOptionMethod(input, SlashCommandBooleanOption);
|
|
1183
|
+
}
|
|
1184
|
+
addUserOption(input) {
|
|
1185
|
+
return this._sharedAddOptionMethod(input, SlashCommandUserOption);
|
|
1186
|
+
}
|
|
1187
|
+
addChannelOption(input) {
|
|
1188
|
+
return this._sharedAddOptionMethod(input, SlashCommandChannelOption);
|
|
1189
|
+
}
|
|
1190
|
+
addRoleOption(input) {
|
|
1191
|
+
return this._sharedAddOptionMethod(input, SlashCommandRoleOption);
|
|
1192
|
+
}
|
|
1193
|
+
addAttachmentOption(input) {
|
|
1194
|
+
return this._sharedAddOptionMethod(input, SlashCommandAttachmentOption);
|
|
1195
|
+
}
|
|
1196
|
+
addMentionableOption(input) {
|
|
1197
|
+
return this._sharedAddOptionMethod(input, SlashCommandMentionableOption);
|
|
1198
|
+
}
|
|
1199
|
+
addStringOption(input) {
|
|
1200
|
+
return this._sharedAddOptionMethod(input, SlashCommandStringOption);
|
|
1201
|
+
}
|
|
1202
|
+
addIntegerOption(input) {
|
|
1203
|
+
return this._sharedAddOptionMethod(input, SlashCommandIntegerOption);
|
|
1204
|
+
}
|
|
1205
|
+
addNumberOption(input) {
|
|
1206
|
+
return this._sharedAddOptionMethod(input, SlashCommandNumberOption);
|
|
1207
|
+
}
|
|
1208
|
+
_sharedAddOptionMethod(input, Instance) {
|
|
1209
|
+
const { options } = this;
|
|
1210
|
+
validateMaxOptionsLength(options);
|
|
1211
|
+
const result = typeof input === "function" ? input(new Instance()) : input;
|
|
1212
|
+
assertReturnOfBuilder(result, Instance);
|
|
1213
|
+
options.push(result);
|
|
1214
|
+
return this;
|
|
1215
|
+
}
|
|
1216
|
+
};
|
|
1217
|
+
__name(SharedSlashCommandOptions, "SharedSlashCommandOptions");
|
|
1218
|
+
|
|
1219
|
+
// src/interactions/slashCommands/SlashCommandSubcommands.ts
|
|
1220
|
+
import {
|
|
1221
|
+
ApplicationCommandOptionType as ApplicationCommandOptionType11
|
|
1222
|
+
} from "discord-api-types/v10";
|
|
1223
|
+
import { mix as mix5 } from "ts-mixer";
|
|
1224
|
+
var SlashCommandSubcommandGroupBuilder = class {
|
|
1225
|
+
constructor() {
|
|
1226
|
+
__publicField(this, "name");
|
|
1227
|
+
__publicField(this, "description");
|
|
1228
|
+
__publicField(this, "options", []);
|
|
1229
|
+
}
|
|
1230
|
+
addSubcommand(input) {
|
|
1231
|
+
const { options } = this;
|
|
1232
|
+
validateMaxOptionsLength(options);
|
|
1233
|
+
const result = typeof input === "function" ? input(new SlashCommandSubcommandBuilder()) : input;
|
|
1234
|
+
assertReturnOfBuilder(result, SlashCommandSubcommandBuilder);
|
|
1235
|
+
options.push(result);
|
|
1236
|
+
return this;
|
|
1237
|
+
}
|
|
1238
|
+
toJSON() {
|
|
1239
|
+
validateRequiredParameters3(this.name, this.description, this.options);
|
|
1240
|
+
return {
|
|
1241
|
+
type: ApplicationCommandOptionType11.SubcommandGroup,
|
|
1242
|
+
name: this.name,
|
|
1243
|
+
description: this.description,
|
|
1244
|
+
options: this.options.map((option) => option.toJSON())
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
1247
|
+
};
|
|
1248
|
+
__name(SlashCommandSubcommandGroupBuilder, "SlashCommandSubcommandGroupBuilder");
|
|
1249
|
+
SlashCommandSubcommandGroupBuilder = __decorateClass([
|
|
1250
|
+
mix5(SharedNameAndDescription)
|
|
1251
|
+
], SlashCommandSubcommandGroupBuilder);
|
|
1252
|
+
var SlashCommandSubcommandBuilder = class {
|
|
1253
|
+
constructor() {
|
|
1254
|
+
__publicField(this, "name");
|
|
1255
|
+
__publicField(this, "description");
|
|
1256
|
+
__publicField(this, "options", []);
|
|
1257
|
+
}
|
|
1258
|
+
toJSON() {
|
|
1259
|
+
validateRequiredParameters3(this.name, this.description, this.options);
|
|
1260
|
+
return {
|
|
1261
|
+
type: ApplicationCommandOptionType11.Subcommand,
|
|
1262
|
+
name: this.name,
|
|
1263
|
+
description: this.description,
|
|
1264
|
+
options: this.options.map((option) => option.toJSON())
|
|
1265
|
+
};
|
|
1266
|
+
}
|
|
1267
|
+
};
|
|
1268
|
+
__name(SlashCommandSubcommandBuilder, "SlashCommandSubcommandBuilder");
|
|
1269
|
+
SlashCommandSubcommandBuilder = __decorateClass([
|
|
1270
|
+
mix5(SharedNameAndDescription, SharedSlashCommandOptions)
|
|
1271
|
+
], SlashCommandSubcommandBuilder);
|
|
1272
|
+
|
|
1273
|
+
// src/interactions/slashCommands/SlashCommandBuilder.ts
|
|
1274
|
+
var SlashCommandBuilder = class {
|
|
1275
|
+
constructor() {
|
|
1276
|
+
__publicField(this, "name");
|
|
1277
|
+
__publicField(this, "description");
|
|
1278
|
+
__publicField(this, "options", []);
|
|
1279
|
+
__publicField(this, "defaultPermission");
|
|
1280
|
+
}
|
|
1281
|
+
toJSON() {
|
|
1282
|
+
validateRequiredParameters3(this.name, this.description, this.options);
|
|
1283
|
+
return {
|
|
1284
|
+
name: this.name,
|
|
1285
|
+
description: this.description,
|
|
1286
|
+
options: this.options.map((option) => option.toJSON()),
|
|
1287
|
+
default_permission: this.defaultPermission
|
|
1288
|
+
};
|
|
1289
|
+
}
|
|
1290
|
+
setDefaultPermission(value) {
|
|
1291
|
+
validateDefaultPermission(value);
|
|
1292
|
+
Reflect.set(this, "defaultPermission", value);
|
|
1293
|
+
return this;
|
|
1294
|
+
}
|
|
1295
|
+
addSubcommandGroup(input) {
|
|
1296
|
+
const { options } = this;
|
|
1297
|
+
validateMaxOptionsLength(options);
|
|
1298
|
+
const result = typeof input === "function" ? input(new SlashCommandSubcommandGroupBuilder()) : input;
|
|
1299
|
+
assertReturnOfBuilder(result, SlashCommandSubcommandGroupBuilder);
|
|
1300
|
+
options.push(result);
|
|
1301
|
+
return this;
|
|
1302
|
+
}
|
|
1303
|
+
addSubcommand(input) {
|
|
1304
|
+
const { options } = this;
|
|
1305
|
+
validateMaxOptionsLength(options);
|
|
1306
|
+
const result = typeof input === "function" ? input(new SlashCommandSubcommandBuilder()) : input;
|
|
1307
|
+
assertReturnOfBuilder(result, SlashCommandSubcommandBuilder);
|
|
1308
|
+
options.push(result);
|
|
1309
|
+
return this;
|
|
1310
|
+
}
|
|
1311
|
+
};
|
|
1312
|
+
__name(SlashCommandBuilder, "SlashCommandBuilder");
|
|
1313
|
+
SlashCommandBuilder = __decorateClass([
|
|
1314
|
+
mix6(SharedSlashCommandOptions, SharedNameAndDescription)
|
|
1315
|
+
], SlashCommandBuilder);
|
|
1316
|
+
|
|
1317
|
+
// src/interactions/contextMenuCommands/Assertions.ts
|
|
1318
|
+
var Assertions_exports6 = {};
|
|
1319
|
+
__export(Assertions_exports6, {
|
|
1320
|
+
validateDefaultPermission: () => validateDefaultPermission2,
|
|
1321
|
+
validateName: () => validateName2,
|
|
1322
|
+
validateRequiredParameters: () => validateRequiredParameters4,
|
|
1323
|
+
validateType: () => validateType
|
|
1324
|
+
});
|
|
1325
|
+
import { z as z10 } from "zod";
|
|
1326
|
+
import { ApplicationCommandType } from "discord-api-types/v10";
|
|
1327
|
+
var namePredicate2 = z10.string().min(1).max(32).regex(/^( *[\p{L}\p{N}_-]+ *)+$/u);
|
|
1328
|
+
var typePredicate = z10.union([z10.literal(ApplicationCommandType.User), z10.literal(ApplicationCommandType.Message)]);
|
|
1329
|
+
var booleanPredicate3 = z10.boolean();
|
|
1330
|
+
function validateDefaultPermission2(value) {
|
|
1331
|
+
booleanPredicate3.parse(value);
|
|
1332
|
+
}
|
|
1333
|
+
__name(validateDefaultPermission2, "validateDefaultPermission");
|
|
1334
|
+
function validateName2(name) {
|
|
1335
|
+
namePredicate2.parse(name);
|
|
1336
|
+
}
|
|
1337
|
+
__name(validateName2, "validateName");
|
|
1338
|
+
function validateType(type) {
|
|
1339
|
+
typePredicate.parse(type);
|
|
1340
|
+
}
|
|
1341
|
+
__name(validateType, "validateType");
|
|
1342
|
+
function validateRequiredParameters4(name, type) {
|
|
1343
|
+
validateName2(name);
|
|
1344
|
+
validateType(type);
|
|
1345
|
+
}
|
|
1346
|
+
__name(validateRequiredParameters4, "validateRequiredParameters");
|
|
1347
|
+
|
|
1348
|
+
// src/interactions/contextMenuCommands/ContextMenuCommandBuilder.ts
|
|
1349
|
+
var ContextMenuCommandBuilder = class {
|
|
1350
|
+
constructor() {
|
|
1351
|
+
__publicField(this, "name");
|
|
1352
|
+
__publicField(this, "type");
|
|
1353
|
+
__publicField(this, "defaultPermission");
|
|
1354
|
+
}
|
|
1355
|
+
setName(name) {
|
|
1356
|
+
validateName2(name);
|
|
1357
|
+
Reflect.set(this, "name", name);
|
|
1358
|
+
return this;
|
|
1359
|
+
}
|
|
1360
|
+
setType(type) {
|
|
1361
|
+
validateType(type);
|
|
1362
|
+
Reflect.set(this, "type", type);
|
|
1363
|
+
return this;
|
|
1364
|
+
}
|
|
1365
|
+
setDefaultPermission(value) {
|
|
1366
|
+
validateDefaultPermission2(value);
|
|
1367
|
+
Reflect.set(this, "defaultPermission", value);
|
|
1368
|
+
return this;
|
|
1369
|
+
}
|
|
1370
|
+
toJSON() {
|
|
1371
|
+
validateRequiredParameters4(this.name, this.type);
|
|
1372
|
+
return {
|
|
1373
|
+
name: this.name,
|
|
1374
|
+
type: this.type,
|
|
1375
|
+
default_permission: this.defaultPermission
|
|
1376
|
+
};
|
|
1377
|
+
}
|
|
1378
|
+
};
|
|
1379
|
+
__name(ContextMenuCommandBuilder, "ContextMenuCommandBuilder");
|
|
1380
|
+
|
|
1381
|
+
// src/util/jsonEncodable.ts
|
|
1382
|
+
function isJSONEncodable(maybeEncodable) {
|
|
1383
|
+
return maybeEncodable !== null && typeof maybeEncodable === "object" && "toJSON" in maybeEncodable;
|
|
1384
|
+
}
|
|
1385
|
+
__name(isJSONEncodable, "isJSONEncodable");
|
|
1386
|
+
|
|
1387
|
+
// src/util/equatable.ts
|
|
1388
|
+
function isEquatable(maybeEquatable) {
|
|
1389
|
+
return maybeEquatable !== null && typeof maybeEquatable === "object" && "equals" in maybeEquatable;
|
|
1390
|
+
}
|
|
1391
|
+
__name(isEquatable, "isEquatable");
|
|
1392
|
+
|
|
1393
|
+
// src/util/componentUtil.ts
|
|
1394
|
+
function embedLength(data) {
|
|
1395
|
+
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);
|
|
1396
|
+
}
|
|
1397
|
+
__name(embedLength, "embedLength");
|
|
1398
|
+
export {
|
|
1399
|
+
ActionRowBuilder,
|
|
1400
|
+
ButtonBuilder,
|
|
1401
|
+
Assertions_exports2 as ComponentAssertions,
|
|
1402
|
+
ComponentBuilder,
|
|
1403
|
+
Assertions_exports6 as ContextMenuCommandAssertions,
|
|
1404
|
+
ContextMenuCommandBuilder,
|
|
1405
|
+
Assertions_exports as EmbedAssertions,
|
|
1406
|
+
EmbedBuilder,
|
|
1407
|
+
Faces,
|
|
1408
|
+
Assertions_exports4 as ModalAssertions,
|
|
1409
|
+
ModalBuilder,
|
|
1410
|
+
SelectMenuBuilder,
|
|
1411
|
+
SelectMenuOptionBuilder,
|
|
1412
|
+
Assertions_exports5 as SlashCommandAssertions,
|
|
1413
|
+
SlashCommandAttachmentOption,
|
|
1414
|
+
SlashCommandBooleanOption,
|
|
1415
|
+
SlashCommandBuilder,
|
|
1416
|
+
SlashCommandChannelOption,
|
|
1417
|
+
SlashCommandIntegerOption,
|
|
1418
|
+
SlashCommandMentionableOption,
|
|
1419
|
+
SlashCommandNumberOption,
|
|
1420
|
+
SlashCommandRoleOption,
|
|
1421
|
+
SlashCommandStringOption,
|
|
1422
|
+
SlashCommandSubcommandBuilder,
|
|
1423
|
+
SlashCommandSubcommandGroupBuilder,
|
|
1424
|
+
SlashCommandUserOption,
|
|
1425
|
+
Assertions_exports3 as TextInputAssertions,
|
|
1426
|
+
TextInputBuilder,
|
|
1427
|
+
TimestampStyles,
|
|
1428
|
+
UnsafeButtonBuilder,
|
|
1429
|
+
UnsafeEmbedBuilder,
|
|
1430
|
+
UnsafeModalBuilder,
|
|
1431
|
+
UnsafeSelectMenuBuilder,
|
|
1432
|
+
UnsafeSelectMenuOptionBuilder,
|
|
1433
|
+
UnsafeTextInputBuilder,
|
|
1434
|
+
blockQuote,
|
|
1435
|
+
bold,
|
|
1436
|
+
channelMention,
|
|
1437
|
+
codeBlock,
|
|
1438
|
+
createComponentBuilder,
|
|
1439
|
+
embedLength,
|
|
1440
|
+
formatEmoji,
|
|
1441
|
+
hideLinkEmbed,
|
|
1442
|
+
hyperlink,
|
|
1443
|
+
inlineCode,
|
|
1444
|
+
isEquatable,
|
|
1445
|
+
isJSONEncodable,
|
|
1446
|
+
italic,
|
|
1447
|
+
memberNicknameMention,
|
|
1448
|
+
quote,
|
|
1449
|
+
roleMention,
|
|
1450
|
+
spoiler,
|
|
1451
|
+
strikethrough,
|
|
1452
|
+
time,
|
|
1453
|
+
underscore,
|
|
1454
|
+
userMention
|
|
1455
|
+
};
|
|
4
1456
|
//# sourceMappingURL=index.mjs.map
|