@discordjs/builders 0.13.0-dev.1648123730.b520c3d → 0.13.0-dev.1648515278-ac4bc3a
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 +90 -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(lo,"codeBlock");function uo(e){return`\`${e}\``}o(uo,"inlineCode");function co(e){return`_${e}_`}o(co,"italic");function ho(e){return`**${e}**`}o(ho,"bold");function Co(e){return`__${e}__`}o(Co,"underscore");function bo(e){return`~~${e}~~`}o(bo,"strikethrough");function fo(e){return`> ${e}`}o(fo,"quote");function Ao(e){return`>>> ${e}`}o(Ao,"blockQuote");function xo(e){return`<${e}>`}o(xo,"hideLinkEmbed");function yo(e,t,n){return n?`[${e}](${t} "${n}")`:`[${e}](${t})`}o(yo,"hyperlink");function go(e){return`||${e}||`}o(go,"spoiler");function Oo(e){return`<@${e}>`}o(Oo,"userMention");function So(e){return`<@!${e}>`}o(So,"memberNicknameMention");function Po(e){return`<#${e}>`}o(Po,"channelMention");function Io(e){return`<@&${e}>`}o(Io,"roleMention");function Mo(e,t=!1){return`<${t?"a":""}:_:${e}>`}o(Mo,"formatEmoji");function To(e,t){return typeof e!="number"&&(e=Math.floor((e?.getTime()??Date.now())/1e3)),typeof t=="string"?`<t:${e}:${t}>`:`<t:${e}>`}o(To,"time");var Ro={ShortTime:"t",LongTime:"T",ShortDate:"d",LongDate:"D",ShortDateTime:"f",LongDateTime:"F",RelativeTime:"R"},Oe=(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))(Oe||{});var te={};R(te,{buttonLabelValidator:()=>Pt,buttonStyleValidator:()=>It,customIdValidator:()=>c,defaultValidator:()=>Rt,disabledValidator:()=>_,emojiValidator:()=>D,labelValueValidator:()=>J,minMaxValidator:()=>K,optionsValidator:()=>Yt,placeholderValidator:()=>Mt,urlValidator:()=>wt,validateRequiredButtonParameters:()=>vt,validateRequiredSelectMenuOptionParameters:()=>Bt,validateRequiredSelectMenuParameters:()=>Tt});import{ButtonStyle as St}from"discord-api-types/v10";import{z as d}from"zod";var c=d.string().min(1).max(100),D=d.object({id:d.string(),name:d.string(),animated:d.boolean()}).partial().strict(),_=d.boolean(),Pt=d.string().nonempty().max(80),It=d.number().int().min(St.Primary).max(St.Link),Mt=d.string().max(150),K=d.number().int().min(0).max(25),Yt=d.object({}).array().nonempty();function Tt(e,t){c.parse(t),Yt.parse(e)}o(Tt,"validateRequiredSelectMenuParameters");var J=d.string().min(1).max(100),Rt=d.boolean();function Bt(e,t){J.parse(e),J.parse(t)}o(Bt,"validateRequiredSelectMenuOptionParameters");var wt=d.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===St.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 Se}from"discord-api-types/v10";var h=class{constructor(t){i(this,"data");this.data=t}};o(h,"ComponentBuilder");import{ComponentType as Q}from"discord-api-types/v10";function H(e){if(e instanceof h)return e;switch(e.type){case Q.ActionRow:return new b(e);case Q.Button:return new X(e);case Q.SelectMenu:return new tt(e);case Q.TextInput:return new Y(e);default:throw new Error(`Cannot properly serialize component type: ${e.type}`)}}o(H,"createComponentBuilder");var b=class extends h{constructor({components:t,...n}={}){super({type:Se.ActionRow,...n});i(this,"components");this.components=t?.map(r=>H(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");import{ComponentType as Pe}from"discord-api-types/v10";var et=class extends h{constructor(t){super({type:Pe.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(et,"UnsafeButtonBuilder");var X=class extends et{setStyle(t){return super.setStyle(It.parse(t))}setURL(t){return super.setURL(wt.parse(t))}setCustomId(t){return super.setCustomId(c.parse(t))}setEmoji(t){return super.setEmoji(D.parse(t))}setDisabled(t=!0){return super.setDisabled(_.parse(t))}setLabel(t){return super.setLabel(Pt.parse(t))}toJSON(){return vt(this.data.style,this.data.label,this.data.emoji,this.data.custom_id,this.data.url),super.toJSON()}};o(X,"ButtonBuilder");var ne={};R(ne,{labelValidator:()=>oe,maxLengthValidator:()=>Et,minLengthValidator:()=>Nt,placeholderValidator:()=>Lt,requiredValidator:()=>Vt,textInputStyleValidator:()=>ee,validateRequiredParameters:()=>Dt,valueValidator:()=>$t});import{TextInputStyle as Ie}from"discord-api-types/v10";import{z as I}from"zod";var ee=I.nativeEnum(Ie),Nt=I.number().int().min(0).max(4e3),Et=I.number().int().min(1).max(4e3),Vt=I.boolean(),$t=I.string().max(4e3),Lt=I.string().max(100),oe=I.string().min(1).max(45);function Dt(e,t,n){c.parse(e),ee.parse(t),oe.parse(n)}o(Dt,"validateRequiredParameters");import{ComponentType as Me}from"discord-api-types/v10";import ie from"fast-deep-equal";var B=class extends h{constructor(t){super({type:Me.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 B?ie(t.data,this.data):ie(t,this.data)}};o(B,"UnsafeTextInputBuilder");var Y=class extends B{setMinLength(t){return super.setMinLength(Nt.parse(t))}setMaxLength(t){return super.setMaxLength(Et.parse(t))}setRequired(t=!0){return super.setRequired(Vt.parse(t))}setValue(t){return super.setValue($t.parse(t))}setPlaceholder(t){return super.setPlaceholder(Lt.parse(t))}toJSON(){return Dt(this.data.custom_id,this.data.style,this.data.label),super.toJSON()}};o(Y,"TextInputBuilder");var ot=class{constructor({components:t,...n}={}){i(this,"data");i(this,"components",[]);this.data={...n},this.components=t?.map(r=>H(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(ot,"UnsafeModalBuilder");var ae={};R(ae,{componentsValidator:()=>re,titleValidator:()=>nt,validateRequiredParameters:()=>Jt});import{z as _t}from"zod";var nt=_t.string().min(1).max(45),re=_t.array(_t.instanceof(b)).min(1);function Jt(e,t,n){c.parse(e),nt.parse(t),re.parse(n)}o(Jt,"validateRequiredParameters");var se=class extends ot{setCustomId(t){return super.setCustomId(c.parse(t))}setTitle(t){return super.setTitle(nt.parse(t))}toJSON(){return Jt(this.data.custom_id,this.data.title,this.components),super.toJSON()}};o(se,"ModalBuilder");import{ComponentType as Te}from"discord-api-types/v10";var C=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(C,"UnsafeSelectMenuOptionBuilder");var it=class extends h{constructor(t){let{options:n,...r}=t??{};super({type:Te.SelectMenu,...r});i(this,"options");this.options=n?.map(p=>new C(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 C?n:new C(n))),this}setOptions(...t){return this.options.splice(0,this.options.length,...t.map(n=>n instanceof C?n:new C(n))),this}toJSON(){return{...this.data,options:this.options.map(t=>t.toJSON())}}};o(it,"UnsafeSelectMenuBuilder");var tt=class extends it{setPlaceholder(t){return super.setPlaceholder(Mt.parse(t))}setMinValues(t){return super.setMinValues(K.parse(t))}setMaxValues(t){return super.setMaxValues(K.parse(t))}setCustomId(t){return super.setCustomId(c.parse(t))}setDisabled(t=!0){return super.setDisabled(_.parse(t))}toJSON(){return Tt(this.options,this.data.custom_id),super.toJSON()}};o(tt,"SelectMenuBuilder");var pe=class extends C{setDescription(t){return super.setDescription(J.parse(t))}setDefault(t=!0){return super.setDefault(Rt.parse(t))}setEmoji(t){return super.setEmoji(D.parse(t))}toJSON(){return Bt(this.data.label,this.data.value),super.toJSON()}};o(pe,"SelectMenuOptionBuilder");var le={};R(le,{assertReturnOfBuilder:()=>S,validateChoicesLength:()=>qt,validateDefaultPermission:()=>Ut,validateDescription:()=>at,validateMaxOptionsLength:()=>f,validateName:()=>rt,validateRequired:()=>st,validateRequiredParameters:()=>O});import kt from"@sindresorhus/is";import{z as k}from"zod";var Re=k.string().min(1).max(32).regex(/^[\P{Lu}\p{N}_-]+$/u);function rt(e){Re.parse(e)}o(rt,"validateName");var Be=k.string().min(1).max(100);function at(e){Be.parse(e)}o(at,"validateDescription");var we=k.unknown().array().max(25);function f(e){we.parse(e)}o(f,"validateMaxOptionsLength");function O(e,t,n){rt(e),at(t),f(n)}o(O,"validateRequiredParameters");var me=k.boolean();function Ut(e){me.parse(e)}o(Ut,"validateDefaultPermission");function st(e){me.parse(e)}o(st,"validateRequired");var ve=k.number().lte(25);function qt(e,t){ve.parse((t?.length??0)+e)}o(qt,"validateChoicesLength");function S(e,t){let n=t.name;if(kt.nullOrUndefined(e))throw new TypeError(`Expected to receive a ${n} builder, got ${e===null?"null":"undefined"} instead.`);if(kt.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=kt.function_(e)?e.name:r.constructor.name,T=Reflect.get(r,Symbol.toStringTag),L=T?`${p} [${T}]`:p;throw new TypeError(`Expected to receive a ${n} builder, got ${L} instead.`)}}o(S,"assertReturnOfBuilder");import{mix as He}from"ts-mixer";import{ApplicationCommandOptionType as Ne}from"discord-api-types/v10";var A=class{constructor(){i(this,"name");i(this,"description")}setName(t){return rt(t),Reflect.set(this,"name",t),this}setDescription(t){return at(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 st(t),Reflect.set(this,"required",t),this}runRequiredValidations(){O(this.name,this.description,[]),st(this.required)}};o(m,"ApplicationCommandOptionBase");var pt=class extends m{constructor(){super(...arguments);i(this,"type",Ne.Boolean)}toJSON(){return this.runRequiredValidations(),{...this}}};o(pt,"SlashCommandBooleanOption");import{ApplicationCommandOptionType as $e}from"discord-api-types/v10";import{mix as Le}from"ts-mixer";import{ChannelType as x}from"discord-api-types/v10";import{z as jt}from"zod";var Ee=[x.GuildText,x.GuildVoice,x.GuildCategory,x.GuildNews,x.GuildStore,x.GuildNewsThread,x.GuildPublicThread,x.GuildPrivateThread,x.GuildStageVoice],Ve=jt.array(jt.union(Ee.map(e=>jt.literal(e)))),mt=class{constructor(){i(this,"channel_types")}addChannelTypes(...t){return this.channel_types===void 0&&Reflect.set(this,"channel_types",[]),Ve.parse(t),this.channel_types.push(...t),this}};o(mt,"ApplicationCommandOptionChannelTypesMixin");var w=class extends m{constructor(){super(...arguments);i(this,"type",$e.Channel)}toJSON(){return this.runRequiredValidations(),{...this}}};o(w,"SlashCommandChannelOption"),w=u([Le(mt)],w);import{ApplicationCommandOptionType as Je}from"discord-api-types/v10";import{mix as ke}from"ts-mixer";import{z as Ue}from"zod";var v=class{constructor(){i(this,"max_value");i(this,"min_value")}};o(v,"ApplicationCommandNumericOptionMinMaxValueMixin");import{ApplicationCommandOptionType as De}from"discord-api-types/v10";import{z as U}from"zod";var Ft=U.string().min(1).max(100),de=U.number().gt(-1/0).lt(1/0),ue=U.object({name:Ft,value:U.union([Ft,de])}).array(),_e=U.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.");ue.parse(t),this.choices===void 0&&Reflect.set(this,"choices",[]),qt(t.length,this.choices);for(let{name:n,value:r}of t)this.type===De.String?Ft.parse(r):de.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 ue.parse(t),Reflect.set(this,"choices",[]),this.addChoices(...t),this}setAutocomplete(t){if(_e.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=Ue.number().int(),N=class extends m{constructor(){super(...arguments);i(this,"type",Je.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(N,"SlashCommandIntegerOption"),N=u([ke(v,P)],N);import{ApplicationCommandOptionType as qe}from"discord-api-types/v10";var lt=class extends m{constructor(){super(...arguments);i(this,"type",qe.Mentionable)}toJSON(){return this.runRequiredValidations(),{...this}}};o(lt,"SlashCommandMentionableOption");import{ApplicationCommandOptionType as je}from"discord-api-types/v10";import{mix as Fe}from"ts-mixer";import{z as Ge}from"zod";var he=Ge.number(),E=class extends m{constructor(){super(...arguments);i(this,"type",je.Number)}setMaxValue(t){return he.parse(t),Reflect.set(this,"max_value",t),this}setMinValue(t){return he.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,"SlashCommandNumberOption"),E=u([Fe(v,P)],E);import{ApplicationCommandOptionType as We}from"discord-api-types/v10";var dt=class extends m{constructor(){super(...arguments);i(this,"type",We.Role)}toJSON(){return this.runRequiredValidations(),{...this}}};o(dt,"SlashCommandRoleOption");import{ApplicationCommandOptionType as ze}from"discord-api-types/v10";var ut=class extends m{constructor(){super(...arguments);i(this,"type",ze.Attachment)}toJSON(){return this.runRequiredValidations(),{...this}}};o(ut,"SlashCommandAttachmentOption");import{ApplicationCommandOptionType as Ze}from"discord-api-types/v10";import{mix as Ke}from"ts-mixer";var V=class extends m{constructor(){super(...arguments);i(this,"type",Ze.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(V,"SlashCommandStringOption"),V=u([Ke(P)],V);import{ApplicationCommandOptionType as Qe}from"discord-api-types/v10";var ct=class extends m{constructor(){super(...arguments);i(this,"type",Qe.User)}toJSON(){return this.runRequiredValidations(),{...this}}};o(ct,"SlashCommandUserOption");var $=class{constructor(){i(this,"options")}addBooleanOption(t){return this._sharedAddOptionMethod(t,pt)}addUserOption(t){return this._sharedAddOptionMethod(t,ct)}addChannelOption(t){return this._sharedAddOptionMethod(t,w)}addRoleOption(t){return this._sharedAddOptionMethod(t,dt)}addAttachmentOption(t){return this._sharedAddOptionMethod(t,ut)}addMentionableOption(t){return this._sharedAddOptionMethod(t,lt)}addStringOption(t){return this._sharedAddOptionMethod(t,V)}addIntegerOption(t){return this._sharedAddOptionMethod(t,N)}addNumberOption(t){return this._sharedAddOptionMethod(t,E)}_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 Ce}from"discord-api-types/v10";import{mix as be}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 O(this.name,this.description,this.options),{type:Ce.SubcommandGroup,name:this.name,description:this.description,options:this.options.map(t=>t.toJSON())}}};o(M,"SlashCommandSubcommandGroupBuilder"),M=u([be(A)],M);var y=class{constructor(){i(this,"name");i(this,"description");i(this,"options",[])}toJSON(){return O(this.name,this.description,this.options),{type:Ce.Subcommand,name:this.name,description:this.description,options:this.options.map(t=>t.toJSON())}}};o(y,"SlashCommandSubcommandBuilder"),y=u([be(A,$)],y);var ht=class{constructor(){i(this,"name");i(this,"description");i(this,"options",[]);i(this,"defaultPermission")}toJSON(){return O(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 Ut(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(ht,"SlashCommandBuilder"),ht=u([He($,A)],ht);var Ae={};R(Ae,{validateDefaultPermission:()=>Gt,validateName:()=>Ct,validateRequiredParameters:()=>Wt,validateType:()=>bt});import{z as q}from"zod";import{ApplicationCommandType as fe}from"discord-api-types/v10";var Xe=q.string().min(1).max(32).regex(/^( *[\p{L}\p{N}_-]+ *)+$/u),Ye=q.union([q.literal(fe.User),q.literal(fe.Message)]),to=q.boolean();function Gt(e){to.parse(e)}o(Gt,"validateDefaultPermission");function Ct(e){Xe.parse(e)}o(Ct,"validateName");function bt(e){Ye.parse(e)}o(bt,"validateType");function Wt(e,t){Ct(e),bt(t)}o(Wt,"validateRequiredParameters");var xe=class{constructor(){i(this,"name");i(this,"type");i(this,"defaultPermission")}setName(t){return Ct(t),Reflect.set(this,"name",t),this}setType(t){return bt(t),Reflect.set(this,"type",t),this}setDefaultPermission(t){return Gt(t),Reflect.set(this,"defaultPermission",t),this}toJSON(){return Wt(this.name,this.type),{name:this.name,type:this.type,default_permission:this.defaultPermission}}};o(xe,"ContextMenuCommandBuilder");function Ar(e){return e!==null&&typeof e=="object"&&"toJSON"in e}o(Ar,"isJSONEncodable");function yr(e){return e!==null&&typeof e=="object"&&"equals"in e}o(yr,"isEquatable");function Or(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(Or,"embedLength");export{b as ActionRowBuilder,X as ButtonBuilder,te as ComponentAssertions,h as ComponentBuilder,Ae as ContextMenuCommandAssertions,xe as ContextMenuCommandBuilder,Ht as EmbedAssertions,Xt as EmbedBuilder,Oe as Faces,ae as ModalAssertions,se as ModalBuilder,tt as SelectMenuBuilder,pe as SelectMenuOptionBuilder,le as SlashCommandAssertions,ut as SlashCommandAttachmentOption,pt as SlashCommandBooleanOption,ht as SlashCommandBuilder,w as SlashCommandChannelOption,N as SlashCommandIntegerOption,lt as SlashCommandMentionableOption,E as SlashCommandNumberOption,dt as SlashCommandRoleOption,V as SlashCommandStringOption,y as SlashCommandSubcommandBuilder,M as SlashCommandSubcommandGroupBuilder,ct as SlashCommandUserOption,ne as TextInputAssertions,Y as TextInputBuilder,Ro as TimestampStyles,et as UnsafeButtonBuilder,Z as UnsafeEmbedBuilder,ot as UnsafeModalBuilder,it as UnsafeSelectMenuBuilder,C as UnsafeSelectMenuOptionBuilder,B as UnsafeTextInputBuilder,Ao as blockQuote,ho as bold,Po as channelMention,lo as codeBlock,H as createComponentBuilder,Or as embedLength,Mo as formatEmoji,xo as hideLinkEmbed,yo as hyperlink,uo as inlineCode,yr as isEquatable,Ar as isJSONEncodable,co as italic,So as memberNicknameMention,fo as quote,Io as roleMention,go as spoiler,bo as strikethrough,To as time,Co as underscore,Oo 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
|