RockPaperScissors/node_modules/@discordjs/builders/dist/index.mjs
2021-11-30 22:03:51 +01:00

5 lines
12 KiB
JavaScript

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