diff --git a/404.html b/404.html index c94810796..219e18042 100644 --- a/404.html +++ b/404.html @@ -6,13 +6,13 @@ Page Not Found | sern - Handlers. Redefined. - +
Skip to main content

Page Not Found

We could not find what you were looking for.

Please contact the owner of the site that linked you to the original URL and let them know their link is broken.

- + \ No newline at end of file diff --git a/assets/js/981f6151.853bc346.js b/assets/js/981f6151.853bc346.js new file mode 100644 index 000000000..258f4b0c4 --- /dev/null +++ b/assets/js/981f6151.853bc346.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[703],{3905:(e,t,n)=>{n.d(t,{Zo:()=>p,kt:()=>u});var a=n(7294);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function l(e){for(var t=1;t=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var i=a.createContext({}),m=function(e){var t=a.useContext(i),n=t;return e&&(n="function"==typeof e?e(t):l(l({},t),e)),n},p=function(e){var t=m(e.components);return a.createElement(i.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},c=a.forwardRef((function(e,t){var n=e.components,o=e.mdxType,r=e.originalType,i=e.parentName,p=s(e,["components","mdxType","originalType","parentName"]),c=m(n),u=o,y=c["".concat(i,".").concat(u)]||c[u]||d[u]||r;return n?a.createElement(y,l(l({ref:t},p),{},{components:n})):a.createElement(y,l({ref:t},p))}));function u(e,t){var n=arguments,o=t&&t.mdxType;if("string"==typeof e||o){var r=n.length,l=new Array(r);l[0]=c;var s={};for(var i in t)hasOwnProperty.call(t,i)&&(s[i]=t[i]);s.originalType=e,s.mdxType="string"==typeof e?e:o,l[1]=s;for(var m=2;m{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>l,default:()=>d,frontMatter:()=>r,metadata:()=>s,toc:()=>m});var a=n(7462),o=(n(7294),n(3905));const r={sidebar_position:3},l="First Command",s={unversionedId:"guide/walkthrough/first-command",id:"guide/walkthrough/first-command",title:"First Command",description:"We will dissect a basic command.",source:"@site/docs/guide/walkthrough/first-command.md",sourceDirName:"guide/walkthrough",slug:"/guide/walkthrough/first-command",permalink:"/docs/guide/walkthrough/first-command",draft:!1,editUrl:"https://github.com/sern-handler/website/edit/main/docs/guide/walkthrough/first-command.md",tags:[],version:"current",sidebarPosition:3,frontMatter:{sidebar_position:3},sidebar:"tutorialSidebar",previous:{title:"CLI",permalink:"/docs/guide/walkthrough/cli"},next:{title:"First Event Module",permalink:"/docs/guide/walkthrough/first-event"}},i={},m=[{value:"Types of command modules",id:"types-of-command-modules",level:3}],p={toc:m};function d(e){let{components:t,...n}=e;return(0,o.kt)("wrapper",(0,a.Z)({},p,n,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"first-command"},"First Command"),(0,o.kt)("p",null,"We will dissect a basic command.\nIf you installed a new project via the cli, This is the ",(0,o.kt)("inlineCode",{parentName:"p"},"ping")," command located in src/commands folder."),(0,o.kt)("p",null,"Typescript"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"import { commandModule, CommandType } from '@sern/handler';\n\nexport default commandModule({\n type: CommandType.Both,\n plugins: [],\n description: 'A ping command',\n // alias : [],\n execute: async (ctx, args) => {\n await ctx.reply({ content: 'Pong \ud83c\udfd3' });\n },\n});\n")),(0,o.kt)("p",null,"Javascript"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},"const { CommandType, commandModule } = require('@sern/handler');\n\nexports.default = commandModule({\n type: CommandType.Both,\n plugins: [],\n description: 'A ping command',\n // alias : [],\n execute: async (ctx, args) => {\n await ctx.reply('Pong \ud83c\udfd3');\n },\n})\n")),(0,o.kt)("p",null,"To view what each of these properties mean in depth, visit the ",(0,o.kt)("a",{parentName:"p",href:"https://sern-handler.js.org/docs/api/enums/CommandType"},"official documentation"),"."),(0,o.kt)("h3",{id:"types-of-command-modules"},"Types of command modules"),(0,o.kt)("p",null,"Every command module ",(0,o.kt)("inlineCode",{parentName:"p"},"type")," is part of an enum. This field allows type inference for the rest of a module's fields. ",(0,o.kt)("br",null),"\nAll the command types can be found in the ",(0,o.kt)("a",{parentName:"p",href:"https://sern-handler.js.org/docs/api/enums/CommandType"},"official documentation"),"!"),(0,o.kt)("p",null,"So, lets say you want to make a command module that listens to modals. "),(0,o.kt)("p",null,(0,o.kt)("strong",{parentName:"p"},"Note"),": Keep in mind you'll need to send a modal with a custom id ",(0,o.kt)("inlineCode",{parentName:"p"},"dm-me"),". This example below is the response to a modal being sent."),(0,o.kt)("br",null),(0,o.kt)("p",null,"Typescript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"import { commandModule, CommandType } from '@sern/handler';\nexport default commandModule({\n name: 'dm-me',\n type: CommandType.Modal,\n async execute (modal) {\n const value = modal.fields.getTextInputValue('message');\n modal.client.users.fetch('182326315813306368').then( u =>\n u.send(value + ` from ${modal.user}`)\n );\n modal.reply( { ephemeral:true, content: 'Sent' })\n }\n});\n")),(0,o.kt)("p",null,"Javascript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},"const { CommandType, commandModule } = require('@sern/handler');\nexports.default = commandModule({\n name: 'dm-me',\n type: CommandType.Modal,\n async execute (modal) {\n const value = modal.fields.getTextInputValue('message');\n modal.client.users.fetch('182326315813306368').then( u =>\n u.send(value + ` from ${modal.user}`)\n );\n modal.reply( { ephemeral:true, content: 'Sent' })\n }\n});\n")),(0,o.kt)("p",null,"Commands are straight forward. Keep in mind, every other property on the commandModule object is\noptional ",(0,o.kt)("strong",{parentName:"p"},"except")," the type and execute function."),(0,o.kt)("h1",{id:"context-class"},"Context class"),(0,o.kt)("p",null,"The provided Context class helps with modules of ",(0,o.kt)("inlineCode",{parentName:"p"},"CommandType.Both")," (A mixture of slash / legacy commands)."),(0,o.kt)("p",null,"The Context class is passed into modules with type:"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"CommandType.Both")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"CommandType.Slash")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"CommandType.Text"))),(0,o.kt)("p",null,"This data structure helps interop between legacy commands and slash commands with ease."),(0,o.kt)("admonition",{type:"note"},(0,o.kt)("p",{parentName:"admonition"},"View the ",(0,o.kt)("a",{parentName:"p",href:"/docs/api/classes/Context"},"docs"))),(0,o.kt)("p",null,"Typescript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"export default commandModule({\n name: 'ping',\n type: CommandType.Both,\n async execute(ctx: Context) {\n await ctx.reply(`pong ${ctx.user}`) \n // .reply is shared between both message and interaction!\n // So is an User object!\n }\n});\n")),(0,o.kt)("p",null,"Javascript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},"exports.default = commandModule({\n name: 'ping',\n type: CommandType.Both,\n async execute(ctx) { //ctx is a Context instance\n await ctx.reply(`pong ${ctx.user}`) \n // .reply is shared between both message and interaction!\n // So is an User object!\n }\n});\n")))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/981f6151.acf5ae36.js b/assets/js/981f6151.acf5ae36.js deleted file mode 100644 index 373404c52..000000000 --- a/assets/js/981f6151.acf5ae36.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[703],{3905:(e,t,n)=>{n.d(t,{Zo:()=>p,kt:()=>u});var a=n(7294);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function l(e){for(var t=1;t=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var i=a.createContext({}),m=function(e){var t=a.useContext(i),n=t;return e&&(n="function"==typeof e?e(t):l(l({},t),e)),n},p=function(e){var t=m(e.components);return a.createElement(i.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},c=a.forwardRef((function(e,t){var n=e.components,o=e.mdxType,r=e.originalType,i=e.parentName,p=s(e,["components","mdxType","originalType","parentName"]),c=m(n),u=o,y=c["".concat(i,".").concat(u)]||c[u]||d[u]||r;return n?a.createElement(y,l(l({ref:t},p),{},{components:n})):a.createElement(y,l({ref:t},p))}));function u(e,t){var n=arguments,o=t&&t.mdxType;if("string"==typeof e||o){var r=n.length,l=new Array(r);l[0]=c;var s={};for(var i in t)hasOwnProperty.call(t,i)&&(s[i]=t[i]);s.originalType=e,s.mdxType="string"==typeof e?e:o,l[1]=s;for(var m=2;m{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>l,default:()=>d,frontMatter:()=>r,metadata:()=>s,toc:()=>m});var a=n(7462),o=(n(7294),n(3905));const r={sidebar_position:3},l="First Command",s={unversionedId:"guide/walkthrough/first-command",id:"guide/walkthrough/first-command",title:"First Command",description:"We will dissect a basic command.",source:"@site/docs/guide/walkthrough/first-command.md",sourceDirName:"guide/walkthrough",slug:"/guide/walkthrough/first-command",permalink:"/docs/guide/walkthrough/first-command",draft:!1,editUrl:"https://github.com/sern-handler/website/edit/main/docs/guide/walkthrough/first-command.md",tags:[],version:"current",sidebarPosition:3,frontMatter:{sidebar_position:3},sidebar:"tutorialSidebar",previous:{title:"CLI",permalink:"/docs/guide/walkthrough/cli"},next:{title:"First Event Module",permalink:"/docs/guide/walkthrough/first-event"}},i={},m=[{value:"Types of command modules",id:"types-of-command-modules",level:3}],p={toc:m};function d(e){let{components:t,...n}=e;return(0,o.kt)("wrapper",(0,a.Z)({},p,n,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"first-command"},"First Command"),(0,o.kt)("p",null,"We will dissect a basic command.\nIf you installed a new project via the cli, This is the ",(0,o.kt)("inlineCode",{parentName:"p"},"ping")," command located in src/commands folder."),(0,o.kt)("p",null,"Typescript"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"import { commandModule, CommandType } from '@sern/handler';\n\nexport default commandModule({\n type: CommandType.Both,\n plugins: [],\n description: 'A ping command',\n //alias : [],\n execute: async (ctx, args) => {\n await ctx.reply({ content: 'Pong \ud83c\udfd3' });\n },\n});\n")),(0,o.kt)("p",null,"Javascript"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},"const { CommandType, commandModule } = require('@sern/handler');\n\nexports.default = commandModule({\n type: CommandType.Both,\n plugins: [],\n description: 'A ping command',\n //alias : [],\n execute: async (ctx, args) => {\n await ctx.reply('Pong \ud83c\udfd3');\n },\n})\n")),(0,o.kt)("p",null,"To view what each of these properties mean in depth, visit the ",(0,o.kt)("a",{parentName:"p",href:"https://sern-handler.js.org/docs/api/enums/CommandType"},"official documentation"),"."),(0,o.kt)("h3",{id:"types-of-command-modules"},"Types of command modules"),(0,o.kt)("p",null,"Every command module ",(0,o.kt)("inlineCode",{parentName:"p"},"type")," is part of an enum. This field allows type inference for the rest of a module's fields. ",(0,o.kt)("br",null),"\nAll the command types can be found in the ",(0,o.kt)("a",{parentName:"p",href:"https://sern-handler.js.org/docs/api/enums/CommandType"},"official documentation"),"!"),(0,o.kt)("p",null,"So, lets say you want to make a command module that listens to modals. "),(0,o.kt)("p",null,(0,o.kt)("strong",{parentName:"p"},"Note"),": Keep in mind you'll need to send a modal with a custom id ",(0,o.kt)("inlineCode",{parentName:"p"},"dm-me"),". This example below is the response to a modal being sent."),(0,o.kt)("br",null),(0,o.kt)("p",null,"Typescript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"import { commandModule, CommandType } from '@sern/handler';\nexport default commandModule({\n name: 'dm-me',\n type: CommandType.Modal,\n async execute (modal) {\n const value = modal.fields.getTextInputValue('message');\n modal.client.users.fetch('182326315813306368').then( u =>\n u.send(value + ` from ${modal.user}`)\n );\n modal.reply( { ephemeral:true, content: 'Sent' })\n }\n});\n")),(0,o.kt)("p",null,"Javascript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},"const { CommandType, commandModule } = require('@sern/handler');\nexports.default = commandModule({\n name: 'dm-me',\n type: CommandType.Modal,\n async execute (modal) {\n const value = modal.fields.getTextInputValue('message');\n modal.client.users.fetch('182326315813306368').then( u =>\n u.send(value + ` from ${modal.user}`)\n );\n modal.reply( { ephemeral:true, content: 'Sent' })\n }\n});\n")),(0,o.kt)("p",null,"Commands are straight forward. Keep in mind, every other property on the commandModule object is\noptional ",(0,o.kt)("strong",{parentName:"p"},"except")," the type and execute function."),(0,o.kt)("h1",{id:"context-class"},"Context class"),(0,o.kt)("p",null,"The provided Context class helps with modules of ",(0,o.kt)("inlineCode",{parentName:"p"},"CommandType.Both")," (A mixture of slash / legacy commands)."),(0,o.kt)("p",null,"The Context class is passed into modules with type :"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"CommandType.Both")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"CommandType.Slash")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"CommandType.Text"))),(0,o.kt)("p",null,"This data structure helps interop between legacy commands and slash commands with ease."),(0,o.kt)("admonition",{type:"note"},(0,o.kt)("p",{parentName:"admonition"},"View the ",(0,o.kt)("a",{parentName:"p",href:"/docs/api/classes/Context"},"docs"))),(0,o.kt)("p",null,"Typescript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"export default commandModule({\n name: 'ping',\n type: CommandType.Both,\n async execute(ctx: Context) {\n await ctx.reply(`pong ${ctx.user}`) \n // .reply is shared between both message and interaction!\n // So is an User object!\n }\n});\n")),(0,o.kt)("p",null,"Javascript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},"exports.default = commandModule({\n name: 'ping',\n type: CommandType.Both,\n async execute(ctx) { //ctx is a Context instance\n await ctx.reply(`pong ${ctx.user}`) \n // .reply is shared between both message and interaction!\n // So is an User object!\n }\n});\n")))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/runtime~main.cf82e2f0.js b/assets/js/runtime~main.39967979.js similarity index 56% rename from assets/js/runtime~main.cf82e2f0.js rename to assets/js/runtime~main.39967979.js index 611980a90..e5ea91702 100644 --- a/assets/js/runtime~main.cf82e2f0.js +++ b/assets/js/runtime~main.39967979.js @@ -1 +1 @@ -(()=>{"use strict";var e,c,t,a,f,r={},b={};function d(e){var c=b[e];if(void 0!==c)return c.exports;var t=b[e]={id:e,loaded:!1,exports:{}};return r[e].call(t.exports,t,t.exports,d),t.loaded=!0,t.exports}d.m=r,d.c=b,e=[],d.O=(c,t,a,f)=>{if(!t){var r=1/0;for(i=0;i=f)&&Object.keys(d.O).every((e=>d.O[e](t[o])))?t.splice(o--,1):(b=!1,f0&&e[i-1][2]>f;i--)e[i]=e[i-1];e[i]=[t,a,f]},d.n=e=>{var c=e&&e.__esModule?()=>e.default:()=>e;return d.d(c,{a:c}),c},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,d.t=function(e,a){if(1&a&&(e=this(e)),8&a)return e;if("object"==typeof e&&e){if(4&a&&e.__esModule)return e;if(16&a&&"function"==typeof e.then)return e}var f=Object.create(null);d.r(f);var r={};c=c||[null,t({}),t([]),t(t)];for(var b=2&a&&e;"object"==typeof b&&!~c.indexOf(b);b=t(b))Object.getOwnPropertyNames(b).forEach((c=>r[c]=()=>e[c]));return r.default=()=>e,d.d(f,r),f},d.d=(e,c)=>{for(var t in c)d.o(c,t)&&!d.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:c[t]})},d.f={},d.e=e=>Promise.all(Object.keys(d.f).reduce(((c,t)=>(d.f[t](e,c),c)),[])),d.u=e=>"assets/js/"+({53:"5bc4ccbc",65:"2f13d849",205:"83d480e9",277:"c4348237",332:"73bd57bd",496:"6cfc4513",533:"b2b675dd",703:"981f6151",1036:"c0846785",1472:"cf183316",1477:"b2f554cd",1505:"7c2ff145",1713:"a7023ddc",2005:"1ac1bfe9",2197:"935f2afb",2535:"814f3328",2640:"a96c96b0",3045:"888566f1",3085:"1f391b9e",3089:"a6aa9e1f",3608:"9e4087bc",4013:"01a85c17",4137:"1aef51bd",4195:"c4f5d8e4",4332:"6c624b4c",4429:"eea0bf40",4685:"cfb1619e",4803:"9201de17",4865:"e8e3d8c7",5062:"69369ae2",5397:"312c2bc5",6103:"ccc49370",6146:"608ca171",6270:"e4877132",6322:"a5467962",7127:"7e205c4a",7223:"3020eeee",7306:"f6aebfbf",7363:"26f1f3a5",7374:"6ba1d2c1",7414:"393be207",7438:"9c021584",7597:"5e8c322a",7750:"3a2d3092",7918:"17896441",8610:"6875c492",8652:"bcd9df7e",9226:"707baeff",9514:"1be78505",9671:"0e384e19",9712:"3dc7c79a",9881:"f7831d67"}[e]||e)+"."+{53:"92cc6d18",65:"2347eba1",205:"eab2a9ae",277:"bbd90c09",332:"383ce150",496:"0511b22e",533:"51de8158",703:"acf5ae36",1036:"91a9ca08",1472:"eb995599",1477:"cc8fb7a5",1505:"ac336ebd",1713:"80224c93",2005:"0d668acf",2197:"47826bb0",2529:"824aaa15",2535:"d83b577a",2640:"adb9b5b6",3045:"b736b053",3085:"8c38cce5",3089:"41e3be1f",3608:"66639242",4013:"e1f6e46d",4137:"6b77f2f4",4195:"e4059570",4332:"4d15c544",4429:"6eea27e0",4685:"afbd870d",4803:"5d152ee5",4865:"589397c6",4972:"8f7e7193",5062:"40f3e7eb",5397:"1cae9e75",6103:"7974c41a",6146:"16600ea2",6270:"c7d96e55",6322:"89fc49a2",7127:"41cd04ca",7223:"5ec7ce89",7306:"daff3f4e",7363:"9a6faf84",7374:"e34036ab",7414:"93c2e119",7438:"79afbc4d",7540:"0456e07a",7597:"d36b9afa",7750:"ba775b44",7918:"3625818f",8610:"d7a7cd5d",8652:"fd236fd7",9226:"367c3cac",9514:"b1e810d5",9671:"4425eaf5",9712:"346d9fd5",9881:"abedf207"}[e]+".js",d.miniCssF=e=>{},d.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),d.o=(e,c)=>Object.prototype.hasOwnProperty.call(e,c),a={},f="@sern/website:",d.l=(e,c,t,r)=>{if(a[e])a[e].push(c);else{var b,o;if(void 0!==t)for(var n=document.getElementsByTagName("script"),i=0;i{b.onerror=b.onload=null,clearTimeout(s);var f=a[e];if(delete a[e],b.parentNode&&b.parentNode.removeChild(b),f&&f.forEach((e=>e(t))),c)return c(t)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:b}),12e4);b.onerror=l.bind(null,b.onerror),b.onload=l.bind(null,b.onload),o&&document.head.appendChild(b)}},d.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},d.p="/",d.gca=function(e){return e={17896441:"7918","5bc4ccbc":"53","2f13d849":"65","83d480e9":"205",c4348237:"277","73bd57bd":"332","6cfc4513":"496",b2b675dd:"533","981f6151":"703",c0846785:"1036",cf183316:"1472",b2f554cd:"1477","7c2ff145":"1505",a7023ddc:"1713","1ac1bfe9":"2005","935f2afb":"2197","814f3328":"2535",a96c96b0:"2640","888566f1":"3045","1f391b9e":"3085",a6aa9e1f:"3089","9e4087bc":"3608","01a85c17":"4013","1aef51bd":"4137",c4f5d8e4:"4195","6c624b4c":"4332",eea0bf40:"4429",cfb1619e:"4685","9201de17":"4803",e8e3d8c7:"4865","69369ae2":"5062","312c2bc5":"5397",ccc49370:"6103","608ca171":"6146",e4877132:"6270",a5467962:"6322","7e205c4a":"7127","3020eeee":"7223",f6aebfbf:"7306","26f1f3a5":"7363","6ba1d2c1":"7374","393be207":"7414","9c021584":"7438","5e8c322a":"7597","3a2d3092":"7750","6875c492":"8610",bcd9df7e:"8652","707baeff":"9226","1be78505":"9514","0e384e19":"9671","3dc7c79a":"9712",f7831d67:"9881"}[e]||e,d.p+d.u(e)},(()=>{var e={1303:0,532:0};d.f.j=(c,t)=>{var a=d.o(e,c)?e[c]:void 0;if(0!==a)if(a)t.push(a[2]);else if(/^(1303|532)$/.test(c))e[c]=0;else{var f=new Promise(((t,f)=>a=e[c]=[t,f]));t.push(a[2]=f);var r=d.p+d.u(c),b=new Error;d.l(r,(t=>{if(d.o(e,c)&&(0!==(a=e[c])&&(e[c]=void 0),a)){var f=t&&("load"===t.type?"missing":t.type),r=t&&t.target&&t.target.src;b.message="Loading chunk "+c+" failed.\n("+f+": "+r+")",b.name="ChunkLoadError",b.type=f,b.request=r,a[1](b)}}),"chunk-"+c,c)}},d.O.j=c=>0===e[c];var c=(c,t)=>{var a,f,r=t[0],b=t[1],o=t[2],n=0;if(r.some((c=>0!==e[c]))){for(a in b)d.o(b,a)&&(d.m[a]=b[a]);if(o)var i=o(d)}for(c&&c(t);n{"use strict";var e,c,t,a,f,r={},d={};function b(e){var c=d[e];if(void 0!==c)return c.exports;var t=d[e]={id:e,loaded:!1,exports:{}};return r[e].call(t.exports,t,t.exports,b),t.loaded=!0,t.exports}b.m=r,b.c=d,e=[],b.O=(c,t,a,f)=>{if(!t){var r=1/0;for(i=0;i=f)&&Object.keys(b.O).every((e=>b.O[e](t[o])))?t.splice(o--,1):(d=!1,f0&&e[i-1][2]>f;i--)e[i]=e[i-1];e[i]=[t,a,f]},b.n=e=>{var c=e&&e.__esModule?()=>e.default:()=>e;return b.d(c,{a:c}),c},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,b.t=function(e,a){if(1&a&&(e=this(e)),8&a)return e;if("object"==typeof e&&e){if(4&a&&e.__esModule)return e;if(16&a&&"function"==typeof e.then)return e}var f=Object.create(null);b.r(f);var r={};c=c||[null,t({}),t([]),t(t)];for(var d=2&a&&e;"object"==typeof d&&!~c.indexOf(d);d=t(d))Object.getOwnPropertyNames(d).forEach((c=>r[c]=()=>e[c]));return r.default=()=>e,b.d(f,r),f},b.d=(e,c)=>{for(var t in c)b.o(c,t)&&!b.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:c[t]})},b.f={},b.e=e=>Promise.all(Object.keys(b.f).reduce(((c,t)=>(b.f[t](e,c),c)),[])),b.u=e=>"assets/js/"+({53:"5bc4ccbc",65:"2f13d849",205:"83d480e9",277:"c4348237",332:"73bd57bd",496:"6cfc4513",533:"b2b675dd",703:"981f6151",1036:"c0846785",1472:"cf183316",1477:"b2f554cd",1505:"7c2ff145",1713:"a7023ddc",2005:"1ac1bfe9",2197:"935f2afb",2535:"814f3328",2640:"a96c96b0",3045:"888566f1",3085:"1f391b9e",3089:"a6aa9e1f",3608:"9e4087bc",4013:"01a85c17",4137:"1aef51bd",4195:"c4f5d8e4",4332:"6c624b4c",4429:"eea0bf40",4685:"cfb1619e",4803:"9201de17",4865:"e8e3d8c7",5062:"69369ae2",5397:"312c2bc5",6103:"ccc49370",6146:"608ca171",6270:"e4877132",6322:"a5467962",7127:"7e205c4a",7223:"3020eeee",7306:"f6aebfbf",7363:"26f1f3a5",7374:"6ba1d2c1",7414:"393be207",7438:"9c021584",7597:"5e8c322a",7750:"3a2d3092",7918:"17896441",8610:"6875c492",8652:"bcd9df7e",9226:"707baeff",9514:"1be78505",9671:"0e384e19",9712:"3dc7c79a",9881:"f7831d67"}[e]||e)+"."+{53:"92cc6d18",65:"2347eba1",205:"eab2a9ae",277:"bbd90c09",332:"383ce150",496:"0511b22e",533:"51de8158",703:"853bc346",1036:"91a9ca08",1472:"eb995599",1477:"cc8fb7a5",1505:"ac336ebd",1713:"80224c93",2005:"0d668acf",2197:"47826bb0",2529:"824aaa15",2535:"d83b577a",2640:"adb9b5b6",3045:"b736b053",3085:"8c38cce5",3089:"41e3be1f",3608:"66639242",4013:"e1f6e46d",4137:"6b77f2f4",4195:"e4059570",4332:"4d15c544",4429:"6eea27e0",4685:"afbd870d",4803:"5d152ee5",4865:"589397c6",4972:"8f7e7193",5062:"40f3e7eb",5397:"1cae9e75",6103:"7974c41a",6146:"16600ea2",6270:"c7d96e55",6322:"89fc49a2",7127:"41cd04ca",7223:"5ec7ce89",7306:"daff3f4e",7363:"9a6faf84",7374:"e34036ab",7414:"93c2e119",7438:"79afbc4d",7540:"0456e07a",7597:"d36b9afa",7750:"ba775b44",7918:"3625818f",8610:"d7a7cd5d",8652:"fd236fd7",9226:"367c3cac",9514:"b1e810d5",9671:"4425eaf5",9712:"346d9fd5",9881:"abedf207"}[e]+".js",b.miniCssF=e=>{},b.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),b.o=(e,c)=>Object.prototype.hasOwnProperty.call(e,c),a={},f="@sern/website:",b.l=(e,c,t,r)=>{if(a[e])a[e].push(c);else{var d,o;if(void 0!==t)for(var n=document.getElementsByTagName("script"),i=0;i{d.onerror=d.onload=null,clearTimeout(s);var f=a[e];if(delete a[e],d.parentNode&&d.parentNode.removeChild(d),f&&f.forEach((e=>e(t))),c)return c(t)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:d}),12e4);d.onerror=l.bind(null,d.onerror),d.onload=l.bind(null,d.onload),o&&document.head.appendChild(d)}},b.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},b.p="/",b.gca=function(e){return e={17896441:"7918","5bc4ccbc":"53","2f13d849":"65","83d480e9":"205",c4348237:"277","73bd57bd":"332","6cfc4513":"496",b2b675dd:"533","981f6151":"703",c0846785:"1036",cf183316:"1472",b2f554cd:"1477","7c2ff145":"1505",a7023ddc:"1713","1ac1bfe9":"2005","935f2afb":"2197","814f3328":"2535",a96c96b0:"2640","888566f1":"3045","1f391b9e":"3085",a6aa9e1f:"3089","9e4087bc":"3608","01a85c17":"4013","1aef51bd":"4137",c4f5d8e4:"4195","6c624b4c":"4332",eea0bf40:"4429",cfb1619e:"4685","9201de17":"4803",e8e3d8c7:"4865","69369ae2":"5062","312c2bc5":"5397",ccc49370:"6103","608ca171":"6146",e4877132:"6270",a5467962:"6322","7e205c4a":"7127","3020eeee":"7223",f6aebfbf:"7306","26f1f3a5":"7363","6ba1d2c1":"7374","393be207":"7414","9c021584":"7438","5e8c322a":"7597","3a2d3092":"7750","6875c492":"8610",bcd9df7e:"8652","707baeff":"9226","1be78505":"9514","0e384e19":"9671","3dc7c79a":"9712",f7831d67:"9881"}[e]||e,b.p+b.u(e)},(()=>{var e={1303:0,532:0};b.f.j=(c,t)=>{var a=b.o(e,c)?e[c]:void 0;if(0!==a)if(a)t.push(a[2]);else if(/^(1303|532)$/.test(c))e[c]=0;else{var f=new Promise(((t,f)=>a=e[c]=[t,f]));t.push(a[2]=f);var r=b.p+b.u(c),d=new Error;b.l(r,(t=>{if(b.o(e,c)&&(0!==(a=e[c])&&(e[c]=void 0),a)){var f=t&&("load"===t.type?"missing":t.type),r=t&&t.target&&t.target.src;d.message="Loading chunk "+c+" failed.\n("+f+": "+r+")",d.name="ChunkLoadError",d.type=f,d.request=r,a[1](d)}}),"chunk-"+c,c)}},b.O.j=c=>0===e[c];var c=(c,t)=>{var a,f,r=t[0],d=t[1],o=t[2],n=0;if(r.some((c=>0!==e[c]))){for(a in d)b.o(d,a)&&(b.m[a]=d[a]);if(o)var i=o(b)}for(c&&c(t);n Blog | sern - Handlers. Redefined. - + @@ -20,7 +20,7 @@ Extend the new CommandExecutabledecorators now unofficially work with modules! Feel free to use TypeScript experimental decorators to augment and customize your classes.

Deprecation Warnings

The next update will bring sern v2 with some important features. Here are some things to watch out for.

Dependencies Update

  • TypeScript has been updated to 4.8.3
  • Discord.js has been upgraded to 14.5
- + \ No newline at end of file diff --git a/blog/1.2.0.html b/blog/1.2.0.html index 47c0e961b..86444a8a9 100644 --- a/blog/1.2.0.html +++ b/blog/1.2.0.html @@ -6,7 +6,7 @@ Release 1.2.0 | sern - Handlers. Redefined. - + @@ -17,7 +17,7 @@ Extend the new CommandExecuta I believe that you should build your own structures however you might like and customize to your liking. In addition, decorators now unofficially work with modules! Feel free to use TypeScript experimental decorators to augment and customize your classes.

Deprecation Warnings

The next update will bring sern v2 with some important features. Here are some things to watch out for.

Dependencies Update

  • TypeScript has been updated to 4.8.3
  • Discord.js has been upgraded to 14.5
- + \ No newline at end of file diff --git a/blog/archive.html b/blog/archive.html index d48894a5c..9dd2f1357 100644 --- a/blog/archive.html +++ b/blog/archive.html @@ -6,13 +6,13 @@ Archive | sern - Handlers. Redefined. - + - + \ No newline at end of file diff --git a/blog/getting-started.html b/blog/getting-started.html index 03e098ba8..88f1f182e 100644 --- a/blog/getting-started.html +++ b/blog/getting-started.html @@ -6,7 +6,7 @@ How to get started with sern! | sern - Handlers. Redefined. - + @@ -15,7 +15,7 @@ A: Install the publish extension. Little video:

Q: Any snippet VSCode extension?
A: Yeah, just search sern Snippets made by a verified publisher called Sr Izan (haha yeah me funny!)

Q: HEEEELLLPPPP!!!!
A: Hey, don't panic! We're here to help so, join the Discord. We're trying to get to 100 members!

- + \ No newline at end of file diff --git a/blog/tags.html b/blog/tags.html index 5af2667ac..50606c6ad 100644 --- a/blog/tags.html +++ b/blog/tags.html @@ -6,13 +6,13 @@ Tags | sern - Handlers. Redefined. - + - + \ No newline at end of file diff --git a/blog/tags/guides.html b/blog/tags/guides.html index 86a57fefd..e2f495b1a 100644 --- a/blog/tags/guides.html +++ b/blog/tags/guides.html @@ -6,7 +6,7 @@ One post tagged with "guides" | sern - Handlers. Redefined. - + @@ -15,7 +15,7 @@ A: Install the publish extension. Little video:

Q: Any snippet VSCode extension?
A: Yeah, just search sern Snippets made by a verified publisher called Sr Izan (haha yeah me funny!)

Q: HEEEELLLPPPP!!!!
A: Hey, don't panic! We're here to help so, join the Discord. We're trying to get to 100 members!

- + \ No newline at end of file diff --git a/blog/tags/release.html b/blog/tags/release.html index 1e21a9b89..0c88ce6b2 100644 --- a/blog/tags/release.html +++ b/blog/tags/release.html @@ -6,7 +6,7 @@ One post tagged with "release" | sern - Handlers. Redefined. - + @@ -17,7 +17,7 @@ Extend the new CommandEx I believe that you should build your own structures however you might like and customize to your liking. In addition, decorators now unofficially work with modules! Feel free to use TypeScript experimental decorators to augment and customize your classes.

Deprecation Warnings

The next update will bring sern v2 with some important features. Here are some things to watch out for.

Dependencies Update

  • TypeScript has been updated to 4.8.3
  • Discord.js has been upgraded to 14.5
- + \ No newline at end of file diff --git a/docs/api.html b/docs/api.html index a78faa763..e7aed524f 100644 --- a/docs/api.html +++ b/docs/api.html @@ -6,13 +6,13 @@ @sern/handler | sern - Handlers. Redefined. - +

@sern/handler

Handlers. Redefined.

A customizable, batteries-included, powerful discord.js framework to streamline bot development.

NPM versionNPM downloadsLicense MITdocs.rsLines of code

📜 Installation

npm install @sern/handler
yarn add @sern/handler
pnpm add @sern/handler

👀 Quick Look

  • Support for discord.js v14 and all interactions
  • Hybrid commands
  • lightweight and customizable
  • ESM, CommonJS and TypeScript support
  • A powerful cli and awesome community-made plugins

👶 Basic Usage

index.js (CommonJS)

// Import the discord.js Client and GatewayIntentBits
const { Client, GatewayIntentBits } = require('discord.js');

// Import Sern namespace
const { Sern } = require('@sern/handler');

// Our configuration file
const { defaultPrefix, token } = require('./config.json');

const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages
]
});

Sern.init({
client,
defaultPrefix,
commands : 'src/commands',
});

client.login(token);

ping.js (CommonJS)

const { CommandType, commandModule } = require('@sern/handler');

exports.default = commandModule({
name: 'ping',
description: 'A ping pong command',
type: CommandType.Slash,
execute(ctx) {
ctx.reply('pong!');
}
});

See our templates for TypeScript examples and more

💻 CLI

It is highly encouraged to use the command line interface for your project. Don't forget to view it.

👋 Contribute

  • Read our contribution guidelines carefully
  • Pull up on issues and report bugs
  • All kinds of contributions are welcomed.

🚈 Roadmap

You can check our roadmap to see what's going to be added or patched in the future.

- + \ No newline at end of file diff --git a/docs/api/classes/CommandExecutable.html b/docs/api/classes/CommandExecutable.html index 9fda576c5..dbfae4f7c 100644 --- a/docs/api/classes/CommandExecutable.html +++ b/docs/api/classes/CommandExecutable.html @@ -6,13 +6,13 @@ Class: CommandExecutable<Type> | sern - Handlers. Redefined. - +

Class: CommandExecutable<Type>

Type parameters

NameType
Typeextends CommandType

Constructors

constructor

new CommandExecutable<Type>()

Type parameters

NameType
Typeextends CommandType

Properties

execute

Abstract execute: CommandModuleDefs[Type][``"execute"``]

Defined in

src/handler/sern.ts:132


onEvent

onEvent: EventPlugin<Type>[] = []

Defined in

src/handler/sern.ts:131


plugins

plugins: CommandPlugin<Type>[] = []

Defined in

src/handler/sern.ts:130


type

Abstract type: Type

Defined in

src/handler/sern.ts:129

- + \ No newline at end of file diff --git a/docs/api/classes/Context.html b/docs/api/classes/Context.html index 4797c7f28..6384ab4b8 100644 --- a/docs/api/classes/Context.html +++ b/docs/api/classes/Context.html @@ -6,7 +6,7 @@ Class: Context | sern - Handlers. Redefined. - + @@ -17,7 +17,7 @@ CommandType.Text or the event fired in a Both command was Message

Returns

ChatInputCommandInteraction<CacheType>

Defined in

src/handler/structures/context.ts:52


member

get member(): Nullish<GuildMember | APIGuildMember>

Returns

Nullish<GuildMember | APIGuildMember>

Defined in

src/handler/structures/context.ts:101


message

get message(): Message<boolean>

Getting the Message object. Crashes if module type is CommandType.Slash or the event fired in a Both command was ChatInputCommandInteraction

Returns

Message<boolean>

Defined in

src/handler/structures/context.ts:44


user

get user(): User

Returns

User

Defined in

src/handler/structures/context.ts:70

Methods

isEmpty

isEmpty(): boolean

Returns

boolean

Defined in

src/handler/structures/context.ts:129


reply

reply(content): Promise<Message<boolean>>

Parameters

NameType
contentReplyOptions

Returns

Promise<Message<boolean>>

Defined in

src/handler/structures/context.ts:133


wrap

Static wrap(wrappable): Context

Parameters

NameType
wrappableMessage<boolean> | ChatInputCommandInteraction<CacheType>

Returns

Context

Defined in

src/handler/structures/context.ts:122

- + \ No newline at end of file diff --git a/docs/api/classes/EventExecutable.html b/docs/api/classes/EventExecutable.html index 73f58f852..50c7a15e5 100644 --- a/docs/api/classes/EventExecutable.html +++ b/docs/api/classes/EventExecutable.html @@ -6,13 +6,13 @@ Class: EventExecutable<Type> | sern - Handlers. Redefined. - +

Class: EventExecutable<Type>

Type parameters

NameType
Typeextends EventType

Constructors

constructor

new EventExecutable<Type>()

Type parameters

NameType
Typeextends EventType

Properties

execute

Abstract execute: EventModuleDefs[Type][``"execute"``]

Defined in

src/handler/sern.ts:139


onEvent

onEvent: EventModuleEventPluginDefs[Type][] = []

Defined in

src/handler/sern.ts:138


plugins

plugins: EventModuleCommandPluginDefs[Type][] = []

Defined in

src/handler/sern.ts:137


type

Abstract type: Type

Defined in

src/handler/sern.ts:136

- + \ No newline at end of file diff --git a/docs/api/classes/SernEmitter.html b/docs/api/classes/SernEmitter.html index 01a19dcd4..7643f37f4 100644 --- a/docs/api/classes/SernEmitter.html +++ b/docs/api/classes/SernEmitter.html @@ -6,7 +6,7 @@ Class: SernEmitter | sern - Handlers. Redefined. - + @@ -50,7 +50,7 @@ given event.

This method is intentionally generic and works with the web p semantics and does not listen to the 'error' event.

const { once, EventEmitter } = require('events');

async function run() {
const ee = new EventEmitter();

process.nextTick(() => {
ee.emit('myevent', 42);
});

const [value] = await once(ee, 'myevent');
console.log(value);

const err = new Error('kaboom');
process.nextTick(() => {
ee.emit('error', err);
});

try {
await once(ee, 'myevent');
} catch (err) {
console.log('error happened', err);
}
}

run();

The special handling of the 'error' event is only used when events.once()is used to wait for another event. If events.once() is used to wait for the 'error' event itself, then it is treated as any other kind of event without special handling:

const { EventEmitter, once } = require('events');

const ee = new EventEmitter();

once(ee, 'error')
.then(([err]) => console.log('ok', err.message))
.catch((err) => console.log('error', err.message));

ee.emit('error', new Error('boom'));

// Prints: ok boom

An AbortSignal can be used to cancel waiting for the event:

const { EventEmitter, once } = require('events');

const ee = new EventEmitter();
const ac = new AbortController();

async function foo(emitter, event, signal) {
try {
await once(emitter, event, { signal });
console.log('event emitted!');
} catch (error) {
if (error.name === 'AbortError') {
console.error('Waiting for the event was canceled!');
} else {
console.error('There was an error', error.message);
}
}
}

foo(ee, 'foo', ac.signal);
ac.abort(); // Abort waiting for the event
ee.emit('foo'); // Prints: Waiting for the event was canceled!

Since

v11.13.0, v10.16.0

Parameters

NameType
emitterNodeEventTarget
eventNamestring | symbol
options?StaticEventEmitterOptions

Returns

Promise<any[]>

Inherited from

EventEmitter.once

Defined in

node_modules/@types/node/events.d.ts:157

Static once(emitter, eventName, options?): Promise<any[]>

Parameters

NameType
emitterDOMEventTarget
eventNamestring
options?StaticEventEmitterOptions

Returns

Promise<any[]>

Inherited from

EventEmitter.once

Defined in

node_modules/@types/node/events.d.ts:158

Static once<K>(eventEmitter, eventName): Promise<ClientEvents[K]>

Type parameters

NameType
Kextends keyof ClientEvents

Parameters

NameType
eventEmitterClient<boolean>
eventNameK

Returns

Promise<ClientEvents[K]>

Inherited from

EventEmitter.once

Defined in

node_modules/discord.js/typings/index.d.ts:196


setMaxListeners

Static setMaxListeners(n?, ...eventTargets): void

const {
setMaxListeners,
EventEmitter
} = require('events');

const target = new EventTarget();
const emitter = new EventEmitter();

setMaxListeners(5, target, emitter);

Since

v15.4.0

Parameters

NameTypeDescription
n?numberA non-negative number. The maximum number of listeners per EventTarget event.
...eventTargets(EventEmitter | DOMEventTarget)[]-

Returns

void

Inherited from

EventEmitter.setMaxListeners

Defined in

node_modules/@types/node/events.d.ts:280

- + \ No newline at end of file diff --git a/docs/api/enums/CommandType.html b/docs/api/enums/CommandType.html index 583a556f6..4f2d9eaa6 100644 --- a/docs/api/enums/CommandType.html +++ b/docs/api/enums/CommandType.html @@ -6,13 +6,13 @@ Enumeration: CommandType | sern - Handlers. Redefined. - +

Enumeration: CommandType

Example

export default commandModule({
type : CommandType.Text,
name : 'a text command'
execute(message) {
console.log(message.content)
}
})

Enumeration Members

Both

Both = 3

The CommandType for hybrid commands, text and slash

Defined in

src/handler/structures/enums.ts:27


Button

Button = 16

The CommandType for ButtonInteraction commands

Defined in

src/handler/structures/enums.ts:39


MenuMsg = 8

The CommandType for MessageContextMenuInteraction commands

Defined in

src/handler/structures/enums.ts:35


MenuSelect = 32

The CommandType for SelectMenuInteraction commands

Defined in

src/handler/structures/enums.ts:43


MenuUser = 4

The CommandType for UserContextMenuInteraction commands

Defined in

src/handler/structures/enums.ts:31


Modal = 64

The CommandType for ModalSubmitInteraction commands

Defined in

src/handler/structures/enums.ts:47


Slash

Slash = 2

The CommandType for slash commands

Defined in

src/handler/structures/enums.ts:23


Text

Text = 1

The CommandType for text commands

Defined in

src/handler/structures/enums.ts:19

- + \ No newline at end of file diff --git a/docs/api/enums/EventType.html b/docs/api/enums/EventType.html index c6ae97d75..276a8beef 100644 --- a/docs/api/enums/EventType.html +++ b/docs/api/enums/EventType.html @@ -6,14 +6,14 @@ Enumeration: EventType | sern - Handlers. Redefined. - +

Enumeration: EventType

Example

export default eventModule({
type : EventType.Discord,
name : 'guildMemberAdd'
execute(member : GuildMember) {
console.log(member)
}
})

Enumeration Members

Discord

Discord = 1

The EventType for handling discord events

Defined in

src/handler/structures/enums.ts:68


External

External = 3

The EventType for handling external events. Could be for example, process events, database events

Defined in

src/handler/structures/enums.ts:77


Sern

Sern = 2

The EventType for handling sern events

Defined in

src/handler/structures/enums.ts:72

- + \ No newline at end of file diff --git a/docs/api/enums/PayloadType.html b/docs/api/enums/PayloadType.html index 2e63f8c95..13115d192 100644 --- a/docs/api/enums/PayloadType.html +++ b/docs/api/enums/PayloadType.html @@ -6,13 +6,13 @@ Enumeration: PayloadType | sern - Handlers. Redefined. - +
- + \ No newline at end of file diff --git a/docs/api/enums/PluginType.html b/docs/api/enums/PluginType.html index 4bf6077db..c83e2116d 100644 --- a/docs/api/enums/PluginType.html +++ b/docs/api/enums/PluginType.html @@ -6,13 +6,13 @@ Enumeration: PluginType | sern - Handlers. Redefined. - +

Enumeration: PluginType

Example

export default function myPlugin() : EventPlugin<CommandType.Text> {
type : PluginType.Event,
execute([ctx, args], controller) {
return controller.next();
}
}

Enumeration Members

Command

Command = 1

The PluginType for CommandPlugins

Defined in

src/handler/structures/enums.ts:97


Event

Event = 2

The PluginType for EventPlugins

Defined in

src/handler/structures/enums.ts:101

- + \ No newline at end of file diff --git a/docs/api/interfaces/Controller.html b/docs/api/interfaces/Controller.html index 7e38647d4..fe149f00b 100644 --- a/docs/api/interfaces/Controller.html +++ b/docs/api/interfaces/Controller.html @@ -6,13 +6,13 @@ Interface: Controller | sern - Handlers. Redefined. - +
- + \ No newline at end of file diff --git a/docs/api/interfaces/Wrapper.html b/docs/api/interfaces/Wrapper.html index 778aa780b..66c3505cd 100644 --- a/docs/api/interfaces/Wrapper.html +++ b/docs/api/interfaces/Wrapper.html @@ -6,13 +6,13 @@ Interface: Wrapper | sern - Handlers. Redefined. - +

Interface: Wrapper

An object to be passed into Sern#init() function.

Properties

client

Readonly client: Client<boolean>

Defined in

src/handler/structures/wrapper.ts:11


commands

Readonly commands: string

Defined in

src/handler/structures/wrapper.ts:15


defaultPrefix

Optional Readonly defaultPrefix: string

Defined in

src/handler/structures/wrapper.ts:14


events

Optional Readonly events: string | { absPath: string ; mod: EventModule }[] | () => { absPath: string ; mod: EventModule }[]

Defined in

src/handler/structures/wrapper.ts:16


sernEmitter

Optional Readonly sernEmitter: SernEmitter

Defined in

src/handler/structures/wrapper.ts:13

- + \ No newline at end of file diff --git a/docs/api/modules.html b/docs/api/modules.html index 9916ab964..c0af895b3 100644 --- a/docs/api/modules.html +++ b/docs/api/modules.html @@ -6,7 +6,7 @@ @sern/handler | sern - Handlers. Redefined. - + @@ -14,7 +14,7 @@

@sern/handler

Namespaces

Enumerations

Classes

Interfaces

Type Aliases

Args

Ƭ Args: ParseType<{ slash: SlashOptions ; text: string[] }>

Defined in

src/types/handler.ts:12


AutocompletePlugin

Ƭ AutocompletePlugin: Override<BaseModule, { execute: (autocmp: AutocompleteInteraction, controlller: Controller) => Awaitable<Result<void, void>> ; type: Event }>

Defined in

src/handler/plugins/plugin.ts:92


BaseOptions

Ƭ BaseOptions: ApplicationCommandChoicesData | ApplicationCommandNonOptionsData | ApplicationCommandChannelOptionData | ApplicationCommandNumericOptionData | ApplicationCommandAttachmentOption | SernAutocompleteData

Type that replaces autocomplete with SernAutocompleteData

Defined in

src/handler/structures/module.ts:181


BothCommand

Ƭ BothCommand: Override<BaseModule, { alias?: string[] ; execute: (ctx: Context, args: Args) => Awaitable<void | unknown> ; onEvent: EventPlugin<Both>[] ; options?: SernOptionsData[] ; plugins: CommandPlugin[] ; type: Both }>

Defined in

src/handler/structures/module.ts:55


CommandModuleNoPlugins

Ƭ CommandModuleNoPlugins: { [T in CommandType]: Omit<CommandModuleDefs[T], "plugins" | "onEvent"> }

Defined in

src/handler/plugins/plugin.ts:145


CommandModulePlugin

Ƭ CommandModulePlugin<T>: EventPlugin<T> | CommandPlugin<T>

Type parameters

NameType
Textends CommandType

Defined in

src/handler/plugins/plugin.ts:173


CommandPlugin

Ƭ CommandPlugin<T>: { [K in T]: Override<BasePlugin, Object> }[T]

Type parameters

NameType
Textends keyof CommandModuleDefs = keyof CommandModuleDefs

Defined in

src/handler/plugins/plugin.ts:40


DefinedCommandModule

Ƭ DefinedCommandModule: DefinitelyDefined<CommandModule, "name" | "description">

Defined in

src/types/handler.ts:43


DefinedEventModule

Ƭ DefinedEventModule: DefinitelyDefined<EventModule, "name" | "description">

Defined in

src/types/handler.ts:44


DefinedModule

Ƭ DefinedModule: DefinitelyDefined<Module, "name" | "description">

After modules are transformed, name and description are given default values if none are provided to Module. This type represents that transformation

Defined in

src/types/handler.ts:42


DefinitelyDefined

Ƭ DefinitelyDefined<T, K>: { [L in K]-?: T[L] extends Record<string, unknown> ? DefinitelyDefined<T[L], keyof T[L]> : Required<T>[L] } & T

Type parameters

NameType
TT
Kextends keyof T = keyof T

Defined in

src/types/handler.ts:19


DiscordEmitterPlugin

Ƭ DiscordEmitterPlugin: Override<BasePlugin, { execute: (wrapper: Client, module: DefinitelyDefined<DiscordEventCommand, "name" | "description">, controller: Controller) => Awaitable<Result<void, void>> ; type: Command }>

Defined in

src/handler/plugins/plugin.ts:57


DiscordEventPlugin

Ƭ DiscordEventPlugin<T>: Override<BasePlugin, { execute: (args: ClientEvents[T], controller: Controller) => Awaitable<Result<void, void>> ; name?: T ; type: Event }>

Type parameters

NameType
Textends keyof ClientEvents = keyof ClientEvents

Defined in

src/handler/plugins/plugin.ts:136


EventInput

Ƭ EventInput: string | { absPath: string ; mod: EventModule }[] | () => { absPath: string ; mod: EventModule }[]

Defined in

src/types/handler.ts:25


EventModuleCommandPluginDefs

Ƭ EventModuleCommandPluginDefs: Object

Event Module Command Plugins

Type declaration

NameType
1DiscordEmitterPlugin
2SernEmitterPlugin
3ExternalEmitterPlugin

Defined in

src/handler/plugins/plugin.ts:163


EventModuleEventPluginDefs

Ƭ EventModuleEventPluginDefs: Object

Event Module Event Plugins

Type declaration

NameType
1DiscordEventPlugin
2SernEventPlugin
3ExternalEventPlugin

Defined in

src/handler/plugins/plugin.ts:154


EventModulePlugin

Ƭ EventModulePlugin<T>: EventModuleEventPluginDefs[T] | EventModuleCommandPluginDefs[T]

Type parameters

NameType
Textends EventType

Defined in

src/handler/plugins/plugin.ts:169


EventModulesNoPlugins

Ƭ EventModulesNoPlugins: { [T in EventType]: Omit<EventModuleDefs[T], "plugins" | "onEvent"> }

Defined in

src/handler/plugins/plugin.ts:148


EventPlugin

Ƭ EventPlugin<T>: { [K in T]: Override<BasePlugin, Object> }[T]

Type parameters

NameType
Textends keyof CommandModuleDefs = keyof CommandModuleDefs

Defined in

src/handler/plugins/plugin.ts:103


ExternalEmitterPlugin

Ƭ ExternalEmitterPlugin<T>: Override<BasePlugin, { execute: (wrapper: T, module: DefinitelyDefined<ExternalEventCommand, "name" | "description">, controller: Controller) => Awaitable<Result<void, void>> ; type: Command }>

Type parameters

NameType
Textends EventEmitter = EventEmitter

Defined in

src/handler/plugins/plugin.ts:68


ExternalEventPlugin

Ƭ ExternalEventPlugin: Override<BasePlugin, { execute: (args: unknown[], controller: Controller) => Awaitable<Result<void, void>> ; type: Event }>

Defined in

src/handler/plugins/plugin.ts:128


InputCommandModule

Ƭ InputCommandModule: { [T in CommandType]: CommandModuleNoPlugins[T] & Object }[CommandType]

User inputs this type. Sern processes behind the scenes for better usage

Defined in

src/handler/plugins/plugin.ts:178


InputEventModule

Ƭ InputEventModule: { [T in EventType]: EventModulesNoPlugins[T] & Object }[EventType]

Defined in

src/handler/plugins/plugin.ts:182


Module

Ƭ Module: CommandModule | EventModule

Defined in

src/handler/structures/module.ts:141


Nullish

Ƭ Nullish<T>: T | undefined | null

Type parameters

Name
T

Defined in

src/types/handler.ts:5


Override

Ƭ Override<T1, T2>: Omit<T1, keyof T2> & T2

Type parameters

Name
T1
T2

Defined in

src/types/handler.ts:17


ParseType

Ƭ ParseType<T>: { [K in keyof T]: T[K] extends unknown ? [k: K, args: T[K]] : never }[keyof T]

Type parameters

Name
T

Defined in

src/types/handler.ts:8


Payload

Ƭ Payload: { module: Module ; type: Success } | { module?: Module ; reason: string | Error ; type: Failure }

Defined in

src/types/handler.ts:45


ReplyOptions

Ƭ ReplyOptions: string | Omit<InteractionReplyOptions, "fetchReply"> | MessageReplyOptions

Defined in

src/types/handler.ts:55


SernAutocompleteData

Ƭ SernAutocompleteData: Override<BaseApplicationCommandOptionsData, { autocomplete: true ; command: AutocompleteCommand ; type: ApplicationCommandOptionType.String | ApplicationCommandOptionType.Number | ApplicationCommandOptionType.Integer }>

Defined in

src/handler/structures/module.ts:166


SernEmitterPlugin

Ƭ SernEmitterPlugin: Override<BasePlugin, { execute: (wrapper: SernEmitter, module: DefinitelyDefined<SernEventCommand, "name" | "description">, controller: Controller) => Awaitable<Result<void, void>> ; type: Command }>

Defined in

src/handler/plugins/plugin.ts:80


SernEventPlugin

Ƭ SernEventPlugin<T>: Override<BasePlugin, { execute: (args: SernEventsMapping[T], controller: Controller) => Awaitable<Result<void, void>> ; name?: T ; type: Event }>

Type parameters

NameType
Textends keyof SernEventsMapping = keyof SernEventsMapping

Defined in

src/handler/plugins/plugin.ts:116


SernEventsMapping

Ƭ SernEventsMapping: Object

Type declaration

NameType
error[Payload]
module.activate[Payload]
module.register[Payload]
warning[string]

Defined in

src/types/handler.ts:48


SernOptionsData

Ƭ SernOptionsData<U>: U extends ApplicationCommandSubCommandData ? SernSubCommandData : U extends ApplicationCommandSubGroupData ? SernSubCommandGroupData : BaseOptions

Type parameters

NameType
Uextends ApplicationCommandOptionData = ApplicationCommandOptionData

Defined in

src/handler/structures/module.ts:205


SernSubCommandData

Ƭ SernSubCommandData: Override<Omit<BaseApplicationCommandOptionsData, "required">, { options?: BaseOptions[] ; type: ApplicationCommandOptionType.Subcommand }>

Defined in

src/handler/structures/module.ts:189


SernSubCommandGroupData

Ƭ SernSubCommandGroupData: Override<Omit<BaseApplicationCommandOptionsData, "required">, { options?: SernSubCommandData[] ; type: ApplicationCommandOptionType.SubcommandGroup }>

Defined in

src/handler/structures/module.ts:197


SlashCommand

Ƭ SlashCommand: Override<BaseModule, { execute: (ctx: Context, args: ["slash", SlashOptions]) => Awaitable<void | unknown> ; onEvent: EventPlugin<Slash>[] ; options?: SernOptionsData[] ; plugins: CommandPlugin[] ; type: Slash }>

Defined in

src/handler/structures/module.ts:44


SlashOptions

Ƭ SlashOptions: Omit<CommandInteractionOptionResolver, "getMessage" | "getFocused">

Defined in

src/types/handler.ts:14


SpreadParams

Ƭ SpreadParams<T>: (args: Parameters<T>[number]) => unknown

Type parameters

NameType
Textends (...args: never) => unknown

Type declaration

▸ (args): unknown

Turns a function with a union of array of args into a single union [ T , V , B ] | [ A ] => T | V | B | A

Parameters
NameType
argsParameters<T>[number]
Returns

unknown

Defined in

src/types/handler.ts:34


TextCommand

Ƭ TextCommand: Override<BaseModule, { alias?: string[] ; execute: (ctx: Context, args: ["text", string[]]) => Awaitable<void | unknown> ; onEvent: EventPlugin<Text>[] ; plugins: CommandPlugin[] ; type: Text }>

Defined in

src/handler/structures/module.ts:33

Functions

commandModule

commandModule(mod): CommandModule

The wrapper function to define command modules for sern

Parameters

NameType
modInputCommandModule

Returns

CommandModule

Defined in

src/handler/sern.ts:91


eventModule

eventModule(mod): EventModule

The wrapper function to define event modules for sern

Parameters

NameType
modInputEventModule

Returns

EventModule

Defined in

src/handler/sern.ts:112

- + \ No newline at end of file diff --git a/docs/api/namespaces/Sern.html b/docs/api/namespaces/Sern.html index f9ad83eb5..0cdbfb7e3 100644 --- a/docs/api/namespaces/Sern.html +++ b/docs/api/namespaces/Sern.html @@ -6,13 +6,13 @@ Namespace: Sern | sern - Handlers. Redefined. - +

Namespace: Sern

References

CommandExecutable

Re-exports CommandExecutable


EventExecutable

Re-exports EventExecutable


commandModule

Re-exports commandModule


eventModule

Re-exports eventModule

Variables

controller

Const controller: Object

The object passed into every plugin to control a command's behavior

Type declaration

NameType
next() => OkImpl<void>
stop() => ErrImpl<void>

Defined in

src/handler/sern.ts:82

Functions

addExternal

addExternal<T>(emitter): void

Deprecated

  • use Sern#makeDependencies instead

Example

src/index.ts
//Add this before initiating Sern!
Sern.addExternal(new Level())

Example

events/level.ts
 export default eventModule({
emitter: 'Level',
type : EventType.External,
name: 'error',
execute(args) {
console.log(args)
}
})

Type parameters

NameType
Textends __module

Parameters

NameTypeDescription
emitterTAny external event emitter. The object will be stored in a map, and then fetched by the name of the instance's class. As there are infinite possibilities to adding external event emitters, Most types aren't provided and are as narrow as possibly can.

Returns

void

Defined in

src/handler/sern.ts:72


init

init(wrapper): void

Example

src/index.ts
Sern.init({
client,
defaultPrefix: '!',
commands: 'dist/commands',
})

Parameters

NameTypeDescription
wrapperWrapperOptions to pass into sern. Function to start the handler up

Returns

void

Defined in

src/handler/sern.ts:39

- + \ No newline at end of file diff --git a/docs/guide.html b/docs/guide.html index 4fae2c145..ecc02441c 100644 --- a/docs/guide.html +++ b/docs/guide.html @@ -6,13 +6,13 @@ Introduction | sern - Handlers. Redefined. - +

Introduction

Welcome to our official guide. This guide will go through all the core features of the framework.

  • 💖 Thank you for choosing sern to be your framework!

  • Teaching the discord.js library and / or Javascript / Typescript is out of scope of this project, so the documentation assumes you already know these elements.

  • discord.js v14 is the only supported library at the moment

You will learn

Working with plugins

Events

Good to know

- + \ No newline at end of file diff --git a/docs/guide/getting-started/choose-ide.html b/docs/guide/getting-started/choose-ide.html index e68dac024..bd82587d0 100644 --- a/docs/guide/getting-started/choose-ide.html +++ b/docs/guide/getting-started/choose-ide.html @@ -6,14 +6,14 @@ Choosing an IDE | sern - Handlers. Redefined. - +
- + \ No newline at end of file diff --git a/docs/guide/getting-started/preparing.html b/docs/guide/getting-started/preparing.html index e491b7444..196df43bb 100644 --- a/docs/guide/getting-started/preparing.html +++ b/docs/guide/getting-started/preparing.html @@ -6,13 +6,13 @@ Preparing to Code | sern - Handlers. Redefined. - +

Preparing to Code

After installing and IDE you need to install node.

You can download the LTS version of node right here

- + \ No newline at end of file diff --git a/docs/guide/walkthrough/cli.html b/docs/guide/walkthrough/cli.html index 3158c780b..1f7312b18 100644 --- a/docs/guide/walkthrough/cli.html +++ b/docs/guide/walkthrough/cli.html @@ -6,7 +6,7 @@ CLI | sern - Handlers. Redefined. - + @@ -14,7 +14,7 @@

CLI

Setting up the CLI is easy.

  • To start a brand-new project, run :
sern init (-y)
tip

It creates a directory for you so you don't need to!

Include the -y flag if you want to set up defaults. The default langauge is Typescript

sern plugins
info

Make sure to have a correct sern.config.json

This will display a menu selection of all installable plugins.
Note: You must have a sern.config.json to use this command. If you want to view plugins, visit the repository linked above.

  • To install extra utilities into your project
sern extra
- + \ No newline at end of file diff --git a/docs/guide/walkthrough/conclusion.html b/docs/guide/walkthrough/conclusion.html index 42bac4a16..25038ee9f 100644 --- a/docs/guide/walkthrough/conclusion.html +++ b/docs/guide/walkthrough/conclusion.html @@ -6,7 +6,7 @@ Conclusion | sern - Handlers. Redefined. - + @@ -14,7 +14,7 @@

Conclusion

If you reached this far, thank you for reading! We hope you have learned the necessities you need to create a bot with the sern framework. If you have any other questions, bugs, feature requests, concerns, please join our community server, and we'll be glad to answer your questions.

- + \ No newline at end of file diff --git a/docs/guide/walkthrough/first-command.html b/docs/guide/walkthrough/first-command.html index 71afb2674..2442010f6 100644 --- a/docs/guide/walkthrough/first-command.html +++ b/docs/guide/walkthrough/first-command.html @@ -6,16 +6,16 @@ First Command | sern - Handlers. Redefined. - +

First Command

We will dissect a basic command. -If you installed a new project via the cli, This is the ping command located in src/commands folder.

Typescript

import { commandModule, CommandType } from '@sern/handler';

export default commandModule({
type: CommandType.Both,
plugins: [],
description: 'A ping command',
//alias : [],
execute: async (ctx, args) => {
await ctx.reply({ content: 'Pong 🏓' });
},
});

Javascript

const { CommandType, commandModule } = require('@sern/handler');

exports.default = commandModule({
type: CommandType.Both,
plugins: [],
description: 'A ping command',
//alias : [],
execute: async (ctx, args) => {
await ctx.reply('Pong 🏓');
},
})

To view what each of these properties mean in depth, visit the official documentation.

Types of command modules

Every command module type is part of an enum. This field allows type inference for the rest of a module's fields.
+If you installed a new project via the cli, This is the ping command located in src/commands folder.

Typescript

import { commandModule, CommandType } from '@sern/handler';

export default commandModule({
type: CommandType.Both,
plugins: [],
description: 'A ping command',
// alias : [],
execute: async (ctx, args) => {
await ctx.reply({ content: 'Pong 🏓' });
},
});

Javascript

const { CommandType, commandModule } = require('@sern/handler');

exports.default = commandModule({
type: CommandType.Both,
plugins: [],
description: 'A ping command',
// alias : [],
execute: async (ctx, args) => {
await ctx.reply('Pong 🏓');
},
})

To view what each of these properties mean in depth, visit the official documentation.

Types of command modules

Every command module type is part of an enum. This field allows type inference for the rest of a module's fields.
All the command types can be found in the official documentation!

So, lets say you want to make a command module that listens to modals.

Note: Keep in mind you'll need to send a modal with a custom id dm-me. This example below is the response to a modal being sent.


Typescript:

import { commandModule, CommandType } from '@sern/handler';
export default commandModule({
name: 'dm-me',
type: CommandType.Modal,
async execute (modal) {
const value = modal.fields.getTextInputValue('message');
modal.client.users.fetch('182326315813306368').then( u =>
u.send(value + ` from ${modal.user}`)
);
modal.reply( { ephemeral:true, content: 'Sent' })
}
});

Javascript:

const { CommandType, commandModule } = require('@sern/handler');
exports.default = commandModule({
name: 'dm-me',
type: CommandType.Modal,
async execute (modal) {
const value = modal.fields.getTextInputValue('message');
modal.client.users.fetch('182326315813306368').then( u =>
u.send(value + ` from ${modal.user}`)
);
modal.reply( { ephemeral:true, content: 'Sent' })
}
});

Commands are straight forward. Keep in mind, every other property on the commandModule object is -optional except the type and execute function.

Context class

The provided Context class helps with modules of CommandType.Both (A mixture of slash / legacy commands).

The Context class is passed into modules with type :

  • CommandType.Both
  • CommandType.Slash
  • CommandType.Text

This data structure helps interop between legacy commands and slash commands with ease.

note

View the docs

Typescript:

export default commandModule({
name: 'ping',
type: CommandType.Both,
async execute(ctx: Context) {
await ctx.reply(`pong ${ctx.user}`)
// .reply is shared between both message and interaction!
// So is an User object!
}
});

Javascript:

exports.default = commandModule({
name: 'ping',
type: CommandType.Both,
async execute(ctx) { //ctx is a Context instance
await ctx.reply(`pong ${ctx.user}`)
// .reply is shared between both message and interaction!
// So is an User object!
}
});
- +optional except the type and execute function.

Context class

The provided Context class helps with modules of CommandType.Both (A mixture of slash / legacy commands).

The Context class is passed into modules with type:

  • CommandType.Both
  • CommandType.Slash
  • CommandType.Text

This data structure helps interop between legacy commands and slash commands with ease.

note

View the docs

Typescript:

export default commandModule({
name: 'ping',
type: CommandType.Both,
async execute(ctx: Context) {
await ctx.reply(`pong ${ctx.user}`)
// .reply is shared between both message and interaction!
// So is an User object!
}
});

Javascript:

exports.default = commandModule({
name: 'ping',
type: CommandType.Both,
async execute(ctx) { //ctx is a Context instance
await ctx.reply(`pong ${ctx.user}`)
// .reply is shared between both message and interaction!
// So is an User object!
}
});
+ \ No newline at end of file diff --git a/docs/guide/walkthrough/first-event.html b/docs/guide/walkthrough/first-event.html index 53da02e4d..4000112f5 100644 --- a/docs/guide/walkthrough/first-event.html +++ b/docs/guide/walkthrough/first-event.html @@ -6,7 +6,7 @@ First Event Module | sern - Handlers. Redefined. - + @@ -14,7 +14,7 @@

First Event Module

We will dissect a basic event module.
Typescript:

export default eventModule({
type: EventType.Sern,
plugins : [], //NOT SUPPORTED YET!!
name: 'module.activate', //name of event.
execute(event) {
console.log(event);
}
})

Javascript:

exports.default = eventModule({
type: EventType.Sern,
plugins : [], //NOT SUPPORTED YET!!
name: 'module.activate',
execute(event) {
console.log(event);
}
})

Like command modules, the type property denotes what kind of event it is, which can be found here.

To view what each of these properties mean in depth, visit the official documentation.


Event modules are laid out similarly to command modules. These listen to any and all event you provide. In the current version 1.1.0-beta, plugins are not supported.

Another example of an event module

Typescript:

export default eventModule({
type: EventType.Discord,
plugins : [], //NOT SUPPORTED YET!!
name: 'guildMemberAdd', //name of event.
async execute(member: GuildMember) {
(await member.guild.channels.fetch('channel-id') as TextChannel).send(`Welcome, ${member}`);
}
})

Javascript:


exports.default = eventModule({
type: EventType.Discord,
plugins : [], //NOT SUPPORTED YET!!
name: 'guildMemberAdd', //name of event.
async execute(member) {
(await member.guild.channels.fetch('channel-id')).send(`Welcome, ${member}`);
}
})
- + \ No newline at end of file diff --git a/docs/guide/walkthrough/goal.html b/docs/guide/walkthrough/goal.html index 12a907239..f8645f24b 100644 --- a/docs/guide/walkthrough/goal.html +++ b/docs/guide/walkthrough/goal.html @@ -6,7 +6,7 @@ Goal | sern - Handlers. Redefined. - + @@ -14,7 +14,7 @@

Goal

sern strives to be minimalist, but with all batteries included. Meaning, this framework provides the necessary tools to start up a bot in minutes, and leaves plenty room space to customize your experience and create an amazing project. It should include all the tools for any bot at any scale.

- + \ No newline at end of file diff --git a/docs/guide/walkthrough/good-to-know.html b/docs/guide/walkthrough/good-to-know.html index ac27e533a..4cf799e1d 100644 --- a/docs/guide/walkthrough/good-to-know.html +++ b/docs/guide/walkthrough/good-to-know.html @@ -6,7 +6,7 @@ Good to know | sern - Handlers. Redefined. - + @@ -14,7 +14,7 @@

Good to know

sern.config.json

A sern.config.json, although not necessary, allows your project to communicate with our cli.

For example, when installing typescript plugins, the language property is necessary to install from our open source repository.

Using the cli and running sern init --sync on pre-existing projects should install this json file in the root directory given. Or, if this is a brand-new project, sern init automatically installs it.

{
"language": "typescript",
"paths": {
"base": "src",
"commands": "commands"
}
}
- + \ No newline at end of file diff --git a/docs/guide/walkthrough/plugins.html b/docs/guide/walkthrough/plugins.html index 3eec90385..8202a983e 100644 --- a/docs/guide/walkthrough/plugins.html +++ b/docs/guide/walkthrough/plugins.html @@ -6,7 +6,7 @@ Plugins | sern - Handlers. Redefined. - + @@ -17,7 +17,7 @@ This controls whether a module is stored into sern.
Typescript:

export function inDir(dir : string) : CommandPlugin<CommandType.Both> {
return {
type: PluginType.Command,
async execute(wrapper, { absPath, module }, controller) {
if(path.dirname(absPath) !== dir) {
console.log(+new Date(), `${module.name} is not in the correct directory!`);
return controller.stop()
}
console.log(+new Date(), `${module.name} is in the correct directory!`);
return controller.next(); //continue
}
}
}

Javascript:

export function inDir(dir : string) {
return {
type: PluginType.Command,
async execute(wrapper, { absPath, module }, controller) {
if(path.dirname(absPath) !== dir) {
console.log(+new Date(), `${module.name} is not in the correct directory!`);
return controller.stop()
}
console.log(+new Date(), `${module.name} is in the correct directory!`);
return controller.next(); //continue
}
}
}

Above, this simple plugin logs that the module has been loaded along with a timestamp.
Again, it is up to you to define plugin logic! The possibilities to customize your bots are endless.

tip

Command Plugins are good for ensuring the shape, location, and preprocessing of your commands.

Event Plugins

event-plugins

  • An event is emitted by discord.js.
  • This event is passed to all plugins (in order!!),
  • If all are successful,

The command is executed. Calling controller.stop() notifies sern that this command should not be run, and this event is ignored.

So, what does a command module look like with plugins?

Typescript:

import { commandModule, CommandType } from '@sern/handler';

export default commandModule({
type: CommandType.Both,
plugins: [
inDir("other"),
serenOnly()
],
description: 'A ping command',
//alias : [],
execute: async (ctx, args) => {
await ctx.reply({ content: 'Pong 🏓' });
},
});

Javascript:

const { commandModule, CommandType } = require('@sern/handler');

exports.default = commandModule({
type: CommandType.Both,
plugins: [
inDir("other"),
serenOnly() //The plugins in this section applied to this module!
],
description: 'A ping command',
//alias : [],
execute: async (ctx, args) => {
await ctx.reply({ content: 'Pong 🏓' });
},
});

Can you predict the behavior of this command?

  • Before loading into sern, this command module will check if this module is in the correct directory other.
  • Before an event occurs, this command module will check if the user has the id 182326315813306368.
tip

Event Plugins are good for filtering, preconditions, parsing.

If all plugins return controller.next(), this command replies Pong 🏓

- + \ No newline at end of file diff --git a/docs/guide/walkthrough/sern-emitter.html b/docs/guide/walkthrough/sern-emitter.html index e4f36e6bb..27f380ad1 100644 --- a/docs/guide/walkthrough/sern-emitter.html +++ b/docs/guide/walkthrough/sern-emitter.html @@ -6,13 +6,13 @@ The SernEmitter class | sern - Handlers. Redefined. - +

The SernEmitter class

You're shipped with the SernEmitter. This EventEmitter listens to

  • command modules executing and its status, the module.activate event
  • command modules registered and its status, the module.register event
  • any error that occurs, the error event
  • warn events, where it is possible to throw errors

You can put these and other event listeners into event modules!


View all events
- + \ No newline at end of file diff --git a/docs/intro.html b/docs/intro.html index e403f5b8b..72ce572b6 100644 --- a/docs/intro.html +++ b/docs/intro.html @@ -6,13 +6,13 @@ Welcome! | sern - Handlers. Redefined. - +

Welcome!

Content

  • /docs/api contains autogenerated documentation of our codebase using typedoc
  • /docs/guide contains a basic startup guide and details to get started with sern faster!
tip

This site is open source! Please do contribute if you find any bugs, typos, or sections in need of improvements.

tip

If you have problems, join the discord server here

- + \ No newline at end of file diff --git a/fr/404.html b/fr/404.html index bdf38b052..668f9380f 100644 --- a/fr/404.html +++ b/fr/404.html @@ -6,13 +6,13 @@ Page introuvable | sern - Handlers. Redefined. - +

Page introuvable

Nous n'avons pas trouvé ce que vous recherchez.

Veuillez contacter le propriétaire du site qui vous a lié à l'URL d'origine et leur faire savoir que leur lien est cassé.

- + \ No newline at end of file diff --git a/fr/assets/js/981f6151.9886f16f.js b/fr/assets/js/981f6151.9886f16f.js new file mode 100644 index 000000000..636096de4 --- /dev/null +++ b/fr/assets/js/981f6151.9886f16f.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[703],{3905:(e,t,n)=>{n.d(t,{Zo:()=>p,kt:()=>u});var a=n(7294);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function l(e){for(var t=1;t=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var i=a.createContext({}),m=function(e){var t=a.useContext(i),n=t;return e&&(n="function"==typeof e?e(t):l(l({},t),e)),n},p=function(e){var t=m(e.components);return a.createElement(i.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},c=a.forwardRef((function(e,t){var n=e.components,o=e.mdxType,r=e.originalType,i=e.parentName,p=s(e,["components","mdxType","originalType","parentName"]),c=m(n),u=o,f=c["".concat(i,".").concat(u)]||c[u]||d[u]||r;return n?a.createElement(f,l(l({ref:t},p),{},{components:n})):a.createElement(f,l({ref:t},p))}));function u(e,t){var n=arguments,o=t&&t.mdxType;if("string"==typeof e||o){var r=n.length,l=new Array(r);l[0]=c;var s={};for(var i in t)hasOwnProperty.call(t,i)&&(s[i]=t[i]);s.originalType=e,s.mdxType="string"==typeof e?e:o,l[1]=s;for(var m=2;m{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>l,default:()=>d,frontMatter:()=>r,metadata:()=>s,toc:()=>m});var a=n(7462),o=(n(7294),n(3905));const r={sidebar_position:3},l="First Command",s={unversionedId:"guide/walkthrough/first-command",id:"guide/walkthrough/first-command",title:"First Command",description:"We will dissect a basic command.",source:"@site/docs/guide/walkthrough/first-command.md",sourceDirName:"guide/walkthrough",slug:"/guide/walkthrough/first-command",permalink:"/fr/docs/guide/walkthrough/first-command",draft:!1,editUrl:"https://github.com/sern-handler/website/edit/main/docs/guide/walkthrough/first-command.md",tags:[],version:"current",sidebarPosition:3,frontMatter:{sidebar_position:3},sidebar:"tutorialSidebar",previous:{title:"CLI",permalink:"/fr/docs/guide/walkthrough/cli"},next:{title:"First Event Module",permalink:"/fr/docs/guide/walkthrough/first-event"}},i={},m=[{value:"Types of command modules",id:"types-of-command-modules",level:3}],p={toc:m};function d(e){let{components:t,...n}=e;return(0,o.kt)("wrapper",(0,a.Z)({},p,n,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"first-command"},"First Command"),(0,o.kt)("p",null,"We will dissect a basic command.\nIf you installed a new project via the cli, This is the ",(0,o.kt)("inlineCode",{parentName:"p"},"ping")," command located in src/commands folder."),(0,o.kt)("p",null,"Typescript"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"import { commandModule, CommandType } from '@sern/handler';\n\nexport default commandModule({\n type: CommandType.Both,\n plugins: [],\n description: 'A ping command',\n // alias : [],\n execute: async (ctx, args) => {\n await ctx.reply({ content: 'Pong \ud83c\udfd3' });\n },\n});\n")),(0,o.kt)("p",null,"Javascript"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},"const { CommandType, commandModule } = require('@sern/handler');\n\nexports.default = commandModule({\n type: CommandType.Both,\n plugins: [],\n description: 'A ping command',\n // alias : [],\n execute: async (ctx, args) => {\n await ctx.reply('Pong \ud83c\udfd3');\n },\n})\n")),(0,o.kt)("p",null,"To view what each of these properties mean in depth, visit the ",(0,o.kt)("a",{parentName:"p",href:"https://sern-handler.js.org/docs/api/enums/CommandType"},"official documentation"),"."),(0,o.kt)("h3",{id:"types-of-command-modules"},"Types of command modules"),(0,o.kt)("p",null,"Every command module ",(0,o.kt)("inlineCode",{parentName:"p"},"type")," is part of an enum. This field allows type inference for the rest of a module's fields. ",(0,o.kt)("br",null),"\nAll the command types can be found in the ",(0,o.kt)("a",{parentName:"p",href:"https://sern-handler.js.org/docs/api/enums/CommandType"},"official documentation"),"!"),(0,o.kt)("p",null,"So, lets say you want to make a command module that listens to modals. "),(0,o.kt)("p",null,(0,o.kt)("strong",{parentName:"p"},"Note"),": Keep in mind you'll need to send a modal with a custom id ",(0,o.kt)("inlineCode",{parentName:"p"},"dm-me"),". This example below is the response to a modal being sent."),(0,o.kt)("br",null),(0,o.kt)("p",null,"Typescript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"import { commandModule, CommandType } from '@sern/handler';\nexport default commandModule({\n name: 'dm-me',\n type: CommandType.Modal,\n async execute (modal) {\n const value = modal.fields.getTextInputValue('message');\n modal.client.users.fetch('182326315813306368').then( u =>\n u.send(value + ` from ${modal.user}`)\n );\n modal.reply( { ephemeral:true, content: 'Sent' })\n }\n});\n")),(0,o.kt)("p",null,"Javascript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},"const { CommandType, commandModule } = require('@sern/handler');\nexports.default = commandModule({\n name: 'dm-me',\n type: CommandType.Modal,\n async execute (modal) {\n const value = modal.fields.getTextInputValue('message');\n modal.client.users.fetch('182326315813306368').then( u =>\n u.send(value + ` from ${modal.user}`)\n );\n modal.reply( { ephemeral:true, content: 'Sent' })\n }\n});\n")),(0,o.kt)("p",null,"Commands are straight forward. Keep in mind, every other property on the commandModule object is\noptional ",(0,o.kt)("strong",{parentName:"p"},"except")," the type and execute function."),(0,o.kt)("h1",{id:"context-class"},"Context class"),(0,o.kt)("p",null,"The provided Context class helps with modules of ",(0,o.kt)("inlineCode",{parentName:"p"},"CommandType.Both")," (A mixture of slash / legacy commands)."),(0,o.kt)("p",null,"The Context class is passed into modules with type:"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"CommandType.Both")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"CommandType.Slash")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"CommandType.Text"))),(0,o.kt)("p",null,"This data structure helps interop between legacy commands and slash commands with ease."),(0,o.kt)("admonition",{type:"note"},(0,o.kt)("p",{parentName:"admonition"},"View the ",(0,o.kt)("a",{parentName:"p",href:"/fr/docs/api/classes/Context"},"docs"))),(0,o.kt)("p",null,"Typescript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"export default commandModule({\n name: 'ping',\n type: CommandType.Both,\n async execute(ctx: Context) {\n await ctx.reply(`pong ${ctx.user}`) \n // .reply is shared between both message and interaction!\n // So is an User object!\n }\n});\n")),(0,o.kt)("p",null,"Javascript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},"exports.default = commandModule({\n name: 'ping',\n type: CommandType.Both,\n async execute(ctx) { //ctx is a Context instance\n await ctx.reply(`pong ${ctx.user}`) \n // .reply is shared between both message and interaction!\n // So is an User object!\n }\n});\n")))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/fr/assets/js/981f6151.f0f70d80.js b/fr/assets/js/981f6151.f0f70d80.js deleted file mode 100644 index 28aea4143..000000000 --- a/fr/assets/js/981f6151.f0f70d80.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[703],{3905:(e,t,n)=>{n.d(t,{Zo:()=>p,kt:()=>u});var a=n(7294);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function l(e){for(var t=1;t=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var i=a.createContext({}),m=function(e){var t=a.useContext(i),n=t;return e&&(n="function"==typeof e?e(t):l(l({},t),e)),n},p=function(e){var t=m(e.components);return a.createElement(i.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},c=a.forwardRef((function(e,t){var n=e.components,o=e.mdxType,r=e.originalType,i=e.parentName,p=s(e,["components","mdxType","originalType","parentName"]),c=m(n),u=o,f=c["".concat(i,".").concat(u)]||c[u]||d[u]||r;return n?a.createElement(f,l(l({ref:t},p),{},{components:n})):a.createElement(f,l({ref:t},p))}));function u(e,t){var n=arguments,o=t&&t.mdxType;if("string"==typeof e||o){var r=n.length,l=new Array(r);l[0]=c;var s={};for(var i in t)hasOwnProperty.call(t,i)&&(s[i]=t[i]);s.originalType=e,s.mdxType="string"==typeof e?e:o,l[1]=s;for(var m=2;m{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>l,default:()=>d,frontMatter:()=>r,metadata:()=>s,toc:()=>m});var a=n(7462),o=(n(7294),n(3905));const r={sidebar_position:3},l="First Command",s={unversionedId:"guide/walkthrough/first-command",id:"guide/walkthrough/first-command",title:"First Command",description:"We will dissect a basic command.",source:"@site/docs/guide/walkthrough/first-command.md",sourceDirName:"guide/walkthrough",slug:"/guide/walkthrough/first-command",permalink:"/fr/docs/guide/walkthrough/first-command",draft:!1,editUrl:"https://github.com/sern-handler/website/edit/main/docs/guide/walkthrough/first-command.md",tags:[],version:"current",sidebarPosition:3,frontMatter:{sidebar_position:3},sidebar:"tutorialSidebar",previous:{title:"CLI",permalink:"/fr/docs/guide/walkthrough/cli"},next:{title:"First Event Module",permalink:"/fr/docs/guide/walkthrough/first-event"}},i={},m=[{value:"Types of command modules",id:"types-of-command-modules",level:3}],p={toc:m};function d(e){let{components:t,...n}=e;return(0,o.kt)("wrapper",(0,a.Z)({},p,n,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"first-command"},"First Command"),(0,o.kt)("p",null,"We will dissect a basic command.\nIf you installed a new project via the cli, This is the ",(0,o.kt)("inlineCode",{parentName:"p"},"ping")," command located in src/commands folder."),(0,o.kt)("p",null,"Typescript"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"import { commandModule, CommandType } from '@sern/handler';\n\nexport default commandModule({\n type: CommandType.Both,\n plugins: [],\n description: 'A ping command',\n //alias : [],\n execute: async (ctx, args) => {\n await ctx.reply({ content: 'Pong \ud83c\udfd3' });\n },\n});\n")),(0,o.kt)("p",null,"Javascript"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},"const { CommandType, commandModule } = require('@sern/handler');\n\nexports.default = commandModule({\n type: CommandType.Both,\n plugins: [],\n description: 'A ping command',\n //alias : [],\n execute: async (ctx, args) => {\n await ctx.reply('Pong \ud83c\udfd3');\n },\n})\n")),(0,o.kt)("p",null,"To view what each of these properties mean in depth, visit the ",(0,o.kt)("a",{parentName:"p",href:"https://sern-handler.js.org/docs/api/enums/CommandType"},"official documentation"),"."),(0,o.kt)("h3",{id:"types-of-command-modules"},"Types of command modules"),(0,o.kt)("p",null,"Every command module ",(0,o.kt)("inlineCode",{parentName:"p"},"type")," is part of an enum. This field allows type inference for the rest of a module's fields. ",(0,o.kt)("br",null),"\nAll the command types can be found in the ",(0,o.kt)("a",{parentName:"p",href:"https://sern-handler.js.org/docs/api/enums/CommandType"},"official documentation"),"!"),(0,o.kt)("p",null,"So, lets say you want to make a command module that listens to modals. "),(0,o.kt)("p",null,(0,o.kt)("strong",{parentName:"p"},"Note"),": Keep in mind you'll need to send a modal with a custom id ",(0,o.kt)("inlineCode",{parentName:"p"},"dm-me"),". This example below is the response to a modal being sent."),(0,o.kt)("br",null),(0,o.kt)("p",null,"Typescript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"import { commandModule, CommandType } from '@sern/handler';\nexport default commandModule({\n name: 'dm-me',\n type: CommandType.Modal,\n async execute (modal) {\n const value = modal.fields.getTextInputValue('message');\n modal.client.users.fetch('182326315813306368').then( u =>\n u.send(value + ` from ${modal.user}`)\n );\n modal.reply( { ephemeral:true, content: 'Sent' })\n }\n});\n")),(0,o.kt)("p",null,"Javascript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},"const { CommandType, commandModule } = require('@sern/handler');\nexports.default = commandModule({\n name: 'dm-me',\n type: CommandType.Modal,\n async execute (modal) {\n const value = modal.fields.getTextInputValue('message');\n modal.client.users.fetch('182326315813306368').then( u =>\n u.send(value + ` from ${modal.user}`)\n );\n modal.reply( { ephemeral:true, content: 'Sent' })\n }\n});\n")),(0,o.kt)("p",null,"Commands are straight forward. Keep in mind, every other property on the commandModule object is\noptional ",(0,o.kt)("strong",{parentName:"p"},"except")," the type and execute function."),(0,o.kt)("h1",{id:"context-class"},"Context class"),(0,o.kt)("p",null,"The provided Context class helps with modules of ",(0,o.kt)("inlineCode",{parentName:"p"},"CommandType.Both")," (A mixture of slash / legacy commands)."),(0,o.kt)("p",null,"The Context class is passed into modules with type :"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"CommandType.Both")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"CommandType.Slash")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"CommandType.Text"))),(0,o.kt)("p",null,"This data structure helps interop between legacy commands and slash commands with ease."),(0,o.kt)("admonition",{type:"note"},(0,o.kt)("p",{parentName:"admonition"},"View the ",(0,o.kt)("a",{parentName:"p",href:"/fr/docs/api/classes/Context"},"docs"))),(0,o.kt)("p",null,"Typescript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"export default commandModule({\n name: 'ping',\n type: CommandType.Both,\n async execute(ctx: Context) {\n await ctx.reply(`pong ${ctx.user}`) \n // .reply is shared between both message and interaction!\n // So is an User object!\n }\n});\n")),(0,o.kt)("p",null,"Javascript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},"exports.default = commandModule({\n name: 'ping',\n type: CommandType.Both,\n async execute(ctx) { //ctx is a Context instance\n await ctx.reply(`pong ${ctx.user}`) \n // .reply is shared between both message and interaction!\n // So is an User object!\n }\n});\n")))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/fr/assets/js/runtime~main.10f369a5.js b/fr/assets/js/runtime~main.66f893ff.js similarity index 98% rename from fr/assets/js/runtime~main.10f369a5.js rename to fr/assets/js/runtime~main.66f893ff.js index a4f26aa5d..7aa035a72 100644 --- a/fr/assets/js/runtime~main.10f369a5.js +++ b/fr/assets/js/runtime~main.66f893ff.js @@ -1 +1 @@ -(()=>{"use strict";var e,c,f,a,t,r={},d={};function o(e){var c=d[e];if(void 0!==c)return c.exports;var f=d[e]={id:e,loaded:!1,exports:{}};return r[e].call(f.exports,f,f.exports,o),f.loaded=!0,f.exports}o.m=r,o.c=d,e=[],o.O=(c,f,a,t)=>{if(!f){var r=1/0;for(i=0;i=t)&&Object.keys(o.O).every((e=>o.O[e](f[b])))?f.splice(b--,1):(d=!1,t0&&e[i-1][2]>t;i--)e[i]=e[i-1];e[i]=[f,a,t]},o.n=e=>{var c=e&&e.__esModule?()=>e.default:()=>e;return o.d(c,{a:c}),c},f=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(e,a){if(1&a&&(e=this(e)),8&a)return e;if("object"==typeof e&&e){if(4&a&&e.__esModule)return e;if(16&a&&"function"==typeof e.then)return e}var t=Object.create(null);o.r(t);var r={};c=c||[null,f({}),f([]),f(f)];for(var d=2&a&&e;"object"==typeof d&&!~c.indexOf(d);d=f(d))Object.getOwnPropertyNames(d).forEach((c=>r[c]=()=>e[c]));return r.default=()=>e,o.d(t,r),t},o.d=(e,c)=>{for(var f in c)o.o(c,f)&&!o.o(e,f)&&Object.defineProperty(e,f,{enumerable:!0,get:c[f]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce(((c,f)=>(o.f[f](e,c),c)),[])),o.u=e=>"assets/js/"+({53:"5bc4ccbc",65:"2f13d849",277:"c4348237",332:"73bd57bd",703:"981f6151",1036:"c0846785",1213:"7f673e27",1375:"cf23ded0",1472:"cf183316",1505:"7c2ff145",2005:"1ac1bfe9",2197:"935f2afb",2535:"814f3328",2640:"a96c96b0",3045:"888566f1",3085:"1f391b9e",3089:"a6aa9e1f",3608:"9e4087bc",4013:"01a85c17",4039:"174e7412",4137:"1aef51bd",4195:"c4f5d8e4",4332:"6c624b4c",4429:"eea0bf40",4803:"9201de17",4865:"e8e3d8c7",5062:"69369ae2",5397:"312c2bc5",6103:"ccc49370",6146:"608ca171",6270:"e4877132",6280:"85f3506b",6322:"a5467962",6918:"92293c9c",7127:"7e205c4a",7223:"3020eeee",7306:"f6aebfbf",7363:"26f1f3a5",7374:"6ba1d2c1",7414:"393be207",7597:"5e8c322a",7750:"3a2d3092",7800:"d58f2f6c",7918:"17896441",8069:"2eae8f3a",8610:"6875c492",8652:"bcd9df7e",9226:"707baeff",9514:"1be78505",9671:"0e384e19",9712:"3dc7c79a",9881:"f7831d67"}[e]||e)+"."+{53:"32b47523",65:"87b99c37",277:"bbd90c09",332:"a5f060f5",703:"f0f70d80",1036:"6e6a2e01",1213:"4c8b8cc4",1375:"25ca32fb",1472:"305bb124",1505:"ac336ebd",2005:"4264b86c",2197:"c4a87233",2529:"824aaa15",2535:"d2e7d993",2640:"9625b0b7",3045:"c84be8e6",3085:"8c38cce5",3089:"41e3be1f",3608:"66639242",4013:"e1f6e46d",4039:"632eea85",4137:"1e5fb79d",4195:"e4059570",4332:"89c23cc2",4429:"4b7962b0",4803:"0cd9e16a",4865:"c87a72d8",4972:"8f7e7193",5062:"40f3e7eb",5397:"1cae9e75",6103:"7974c41a",6146:"16383731",6270:"f5606e45",6280:"8dbd18b7",6322:"70de03ff",6918:"f7045e18",7127:"dec4ea49",7223:"529bb797",7306:"2073cc2b",7363:"beb7fb34",7374:"18dbd34f",7414:"ca4670d5",7540:"0456e07a",7597:"f8c69af5",7750:"3b268b53",7800:"f4317188",7918:"3625818f",8069:"41957279",8610:"d7a7cd5d",8652:"909d54fb",9226:"c36a1ca3",9514:"b1e810d5",9671:"ab98e70d",9712:"82727dd4",9881:"8031b99e"}[e]+".js",o.miniCssF=e=>{},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,c)=>Object.prototype.hasOwnProperty.call(e,c),a={},t="@sern/website:",o.l=(e,c,f,r)=>{if(a[e])a[e].push(c);else{var d,b;if(void 0!==f)for(var n=document.getElementsByTagName("script"),i=0;i{d.onerror=d.onload=null,clearTimeout(s);var t=a[e];if(delete a[e],d.parentNode&&d.parentNode.removeChild(d),t&&t.forEach((e=>e(f))),c)return c(f)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:d}),12e4);d.onerror=l.bind(null,d.onerror),d.onload=l.bind(null,d.onload),b&&document.head.appendChild(d)}},o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.p="/fr/",o.gca=function(e){return e={17896441:"7918","5bc4ccbc":"53","2f13d849":"65",c4348237:"277","73bd57bd":"332","981f6151":"703",c0846785:"1036","7f673e27":"1213",cf23ded0:"1375",cf183316:"1472","7c2ff145":"1505","1ac1bfe9":"2005","935f2afb":"2197","814f3328":"2535",a96c96b0:"2640","888566f1":"3045","1f391b9e":"3085",a6aa9e1f:"3089","9e4087bc":"3608","01a85c17":"4013","174e7412":"4039","1aef51bd":"4137",c4f5d8e4:"4195","6c624b4c":"4332",eea0bf40:"4429","9201de17":"4803",e8e3d8c7:"4865","69369ae2":"5062","312c2bc5":"5397",ccc49370:"6103","608ca171":"6146",e4877132:"6270","85f3506b":"6280",a5467962:"6322","92293c9c":"6918","7e205c4a":"7127","3020eeee":"7223",f6aebfbf:"7306","26f1f3a5":"7363","6ba1d2c1":"7374","393be207":"7414","5e8c322a":"7597","3a2d3092":"7750",d58f2f6c:"7800","2eae8f3a":"8069","6875c492":"8610",bcd9df7e:"8652","707baeff":"9226","1be78505":"9514","0e384e19":"9671","3dc7c79a":"9712",f7831d67:"9881"}[e]||e,o.p+o.u(e)},(()=>{var e={1303:0,532:0};o.f.j=(c,f)=>{var a=o.o(e,c)?e[c]:void 0;if(0!==a)if(a)f.push(a[2]);else if(/^(1303|532)$/.test(c))e[c]=0;else{var t=new Promise(((f,t)=>a=e[c]=[f,t]));f.push(a[2]=t);var r=o.p+o.u(c),d=new Error;o.l(r,(f=>{if(o.o(e,c)&&(0!==(a=e[c])&&(e[c]=void 0),a)){var t=f&&("load"===f.type?"missing":f.type),r=f&&f.target&&f.target.src;d.message="Loading chunk "+c+" failed.\n("+t+": "+r+")",d.name="ChunkLoadError",d.type=t,d.request=r,a[1](d)}}),"chunk-"+c,c)}},o.O.j=c=>0===e[c];var c=(c,f)=>{var a,t,r=f[0],d=f[1],b=f[2],n=0;if(r.some((c=>0!==e[c]))){for(a in d)o.o(d,a)&&(o.m[a]=d[a]);if(b)var i=b(o)}for(c&&c(f);n{"use strict";var e,c,f,a,t,r={},d={};function o(e){var c=d[e];if(void 0!==c)return c.exports;var f=d[e]={id:e,loaded:!1,exports:{}};return r[e].call(f.exports,f,f.exports,o),f.loaded=!0,f.exports}o.m=r,o.c=d,e=[],o.O=(c,f,a,t)=>{if(!f){var r=1/0;for(i=0;i=t)&&Object.keys(o.O).every((e=>o.O[e](f[b])))?f.splice(b--,1):(d=!1,t0&&e[i-1][2]>t;i--)e[i]=e[i-1];e[i]=[f,a,t]},o.n=e=>{var c=e&&e.__esModule?()=>e.default:()=>e;return o.d(c,{a:c}),c},f=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(e,a){if(1&a&&(e=this(e)),8&a)return e;if("object"==typeof e&&e){if(4&a&&e.__esModule)return e;if(16&a&&"function"==typeof e.then)return e}var t=Object.create(null);o.r(t);var r={};c=c||[null,f({}),f([]),f(f)];for(var d=2&a&&e;"object"==typeof d&&!~c.indexOf(d);d=f(d))Object.getOwnPropertyNames(d).forEach((c=>r[c]=()=>e[c]));return r.default=()=>e,o.d(t,r),t},o.d=(e,c)=>{for(var f in c)o.o(c,f)&&!o.o(e,f)&&Object.defineProperty(e,f,{enumerable:!0,get:c[f]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce(((c,f)=>(o.f[f](e,c),c)),[])),o.u=e=>"assets/js/"+({53:"5bc4ccbc",65:"2f13d849",277:"c4348237",332:"73bd57bd",703:"981f6151",1036:"c0846785",1213:"7f673e27",1375:"cf23ded0",1472:"cf183316",1505:"7c2ff145",2005:"1ac1bfe9",2197:"935f2afb",2535:"814f3328",2640:"a96c96b0",3045:"888566f1",3085:"1f391b9e",3089:"a6aa9e1f",3608:"9e4087bc",4013:"01a85c17",4039:"174e7412",4137:"1aef51bd",4195:"c4f5d8e4",4332:"6c624b4c",4429:"eea0bf40",4803:"9201de17",4865:"e8e3d8c7",5062:"69369ae2",5397:"312c2bc5",6103:"ccc49370",6146:"608ca171",6270:"e4877132",6280:"85f3506b",6322:"a5467962",6918:"92293c9c",7127:"7e205c4a",7223:"3020eeee",7306:"f6aebfbf",7363:"26f1f3a5",7374:"6ba1d2c1",7414:"393be207",7597:"5e8c322a",7750:"3a2d3092",7800:"d58f2f6c",7918:"17896441",8069:"2eae8f3a",8610:"6875c492",8652:"bcd9df7e",9226:"707baeff",9514:"1be78505",9671:"0e384e19",9712:"3dc7c79a",9881:"f7831d67"}[e]||e)+"."+{53:"32b47523",65:"87b99c37",277:"bbd90c09",332:"a5f060f5",703:"9886f16f",1036:"6e6a2e01",1213:"4c8b8cc4",1375:"25ca32fb",1472:"305bb124",1505:"ac336ebd",2005:"4264b86c",2197:"c4a87233",2529:"824aaa15",2535:"d2e7d993",2640:"9625b0b7",3045:"c84be8e6",3085:"8c38cce5",3089:"41e3be1f",3608:"66639242",4013:"e1f6e46d",4039:"632eea85",4137:"1e5fb79d",4195:"e4059570",4332:"89c23cc2",4429:"4b7962b0",4803:"0cd9e16a",4865:"c87a72d8",4972:"8f7e7193",5062:"40f3e7eb",5397:"1cae9e75",6103:"7974c41a",6146:"16383731",6270:"f5606e45",6280:"8dbd18b7",6322:"70de03ff",6918:"f7045e18",7127:"dec4ea49",7223:"529bb797",7306:"2073cc2b",7363:"beb7fb34",7374:"18dbd34f",7414:"ca4670d5",7540:"0456e07a",7597:"f8c69af5",7750:"3b268b53",7800:"f4317188",7918:"3625818f",8069:"41957279",8610:"d7a7cd5d",8652:"909d54fb",9226:"c36a1ca3",9514:"b1e810d5",9671:"ab98e70d",9712:"82727dd4",9881:"8031b99e"}[e]+".js",o.miniCssF=e=>{},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,c)=>Object.prototype.hasOwnProperty.call(e,c),a={},t="@sern/website:",o.l=(e,c,f,r)=>{if(a[e])a[e].push(c);else{var d,b;if(void 0!==f)for(var n=document.getElementsByTagName("script"),i=0;i{d.onerror=d.onload=null,clearTimeout(s);var t=a[e];if(delete a[e],d.parentNode&&d.parentNode.removeChild(d),t&&t.forEach((e=>e(f))),c)return c(f)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:d}),12e4);d.onerror=l.bind(null,d.onerror),d.onload=l.bind(null,d.onload),b&&document.head.appendChild(d)}},o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.p="/fr/",o.gca=function(e){return e={17896441:"7918","5bc4ccbc":"53","2f13d849":"65",c4348237:"277","73bd57bd":"332","981f6151":"703",c0846785:"1036","7f673e27":"1213",cf23ded0:"1375",cf183316:"1472","7c2ff145":"1505","1ac1bfe9":"2005","935f2afb":"2197","814f3328":"2535",a96c96b0:"2640","888566f1":"3045","1f391b9e":"3085",a6aa9e1f:"3089","9e4087bc":"3608","01a85c17":"4013","174e7412":"4039","1aef51bd":"4137",c4f5d8e4:"4195","6c624b4c":"4332",eea0bf40:"4429","9201de17":"4803",e8e3d8c7:"4865","69369ae2":"5062","312c2bc5":"5397",ccc49370:"6103","608ca171":"6146",e4877132:"6270","85f3506b":"6280",a5467962:"6322","92293c9c":"6918","7e205c4a":"7127","3020eeee":"7223",f6aebfbf:"7306","26f1f3a5":"7363","6ba1d2c1":"7374","393be207":"7414","5e8c322a":"7597","3a2d3092":"7750",d58f2f6c:"7800","2eae8f3a":"8069","6875c492":"8610",bcd9df7e:"8652","707baeff":"9226","1be78505":"9514","0e384e19":"9671","3dc7c79a":"9712",f7831d67:"9881"}[e]||e,o.p+o.u(e)},(()=>{var e={1303:0,532:0};o.f.j=(c,f)=>{var a=o.o(e,c)?e[c]:void 0;if(0!==a)if(a)f.push(a[2]);else if(/^(1303|532)$/.test(c))e[c]=0;else{var t=new Promise(((f,t)=>a=e[c]=[f,t]));f.push(a[2]=t);var r=o.p+o.u(c),d=new Error;o.l(r,(f=>{if(o.o(e,c)&&(0!==(a=e[c])&&(e[c]=void 0),a)){var t=f&&("load"===f.type?"missing":f.type),r=f&&f.target&&f.target.src;d.message="Loading chunk "+c+" failed.\n("+t+": "+r+")",d.name="ChunkLoadError",d.type=t,d.request=r,a[1](d)}}),"chunk-"+c,c)}},o.O.j=c=>0===e[c];var c=(c,f)=>{var a,t,r=f[0],d=f[1],b=f[2],n=0;if(r.some((c=>0!==e[c]))){for(a in d)o.o(d,a)&&(o.m[a]=d[a]);if(b)var i=b(o)}for(c&&c(f);n Blog | sern - Handlers. Redefined. - + @@ -20,7 +20,7 @@ Extend the new CommandExecutabl I believe that you should build your own structures however you might like and customize to your liking. In addition, decorators now unofficially work with modules! Feel free to use TypeScript experimental decorators to augment and customize your classes.

Deprecation Warnings

The next update will bring sern v2 with some important features. Here are some things to watch out for.

Dependencies Update

  • TypeScript has been updated to 4.8.3
  • Discord.js has been upgraded to 14.5
- + \ No newline at end of file diff --git a/fr/blog/1.2.0.html b/fr/blog/1.2.0.html index a6e7cc506..217527690 100644 --- a/fr/blog/1.2.0.html +++ b/fr/blog/1.2.0.html @@ -6,7 +6,7 @@ Release 1.2.0 | sern - Handlers. Redefined. - + @@ -17,7 +17,7 @@ Extend the new CommandExec I believe that you should build your own structures however you might like and customize to your liking. In addition, decorators now unofficially work with modules! Feel free to use TypeScript experimental decorators to augment and customize your classes.

Deprecation Warnings

The next update will bring sern v2 with some important features. Here are some things to watch out for.

Dependencies Update

  • TypeScript has been updated to 4.8.3
  • Discord.js has been upgraded to 14.5
- + \ No newline at end of file diff --git a/fr/blog/archive.html b/fr/blog/archive.html index 2ccd5e0c7..910493518 100644 --- a/fr/blog/archive.html +++ b/fr/blog/archive.html @@ -6,13 +6,13 @@ Archive | sern - Handlers. Redefined. - + - + \ No newline at end of file diff --git a/fr/blog/getting-started.html b/fr/blog/getting-started.html index e6242aefc..df2f75769 100644 --- a/fr/blog/getting-started.html +++ b/fr/blog/getting-started.html @@ -6,7 +6,7 @@ How to get started with sern! | sern - Handlers. Redefined. - + @@ -15,7 +15,7 @@ A: Install the publish extension. Little video:

Q: Any snippet VSCode extension?
A: Yeah, just search sern Snippets made by a verified publisher called Sr Izan (haha yeah me funny!)

Q: HEEEELLLPPPP!!!!
A: Hey, don't panic! We're here to help so, join the Discord. We're trying to get to 100 members!

- + \ No newline at end of file diff --git a/fr/blog/tags.html b/fr/blog/tags.html index 9bfb5392f..fb3ac4159 100644 --- a/fr/blog/tags.html +++ b/fr/blog/tags.html @@ -6,13 +6,13 @@ Tags | sern - Handlers. Redefined. - + - + \ No newline at end of file diff --git a/fr/blog/tags/guides.html b/fr/blog/tags/guides.html index 8a6ab98b6..e55caca5b 100644 --- a/fr/blog/tags/guides.html +++ b/fr/blog/tags/guides.html @@ -6,7 +6,7 @@ Un article tagués avec « guides » | sern - Handlers. Redefined. - + @@ -15,7 +15,7 @@ A: Install the publish extension. Little video:

Q: Any snippet VSCode extension?
A: Yeah, just search sern Snippets made by a verified publisher called Sr Izan (haha yeah me funny!)

Q: HEEEELLLPPPP!!!!
A: Hey, don't panic! We're here to help so, join the Discord. We're trying to get to 100 members!

- + \ No newline at end of file diff --git a/fr/blog/tags/release.html b/fr/blog/tags/release.html index 33aa668df..3df689e67 100644 --- a/fr/blog/tags/release.html +++ b/fr/blog/tags/release.html @@ -6,7 +6,7 @@ Un article tagués avec « release » | sern - Handlers. Redefined. - + @@ -17,7 +17,7 @@ Extend the new Comman I believe that you should build your own structures however you might like and customize to your liking. In addition, decorators now unofficially work with modules! Feel free to use TypeScript experimental decorators to augment and customize your classes.

Deprecation Warnings

The next update will bring sern v2 with some important features. Here are some things to watch out for.

Dependencies Update

  • TypeScript has been updated to 4.8.3
  • Discord.js has been upgraded to 14.5
- + \ No newline at end of file diff --git a/fr/docs/api.html b/fr/docs/api.html index 9ab8ba267..8f181b271 100644 --- a/fr/docs/api.html +++ b/fr/docs/api.html @@ -6,13 +6,13 @@ @sern/handler | sern - Handlers. Redefined. - +

@sern/handler

Handlers. Redefined.

A customizable, batteries-included, powerful discord.js framework to streamline bot development.

NPM versionNPM downloadsLicense MITdocs.rsLines of code

📜 Installation

npm install @sern/handler
yarn add @sern/handler
pnpm add @sern/handler

👀 Quick Look

  • Support for discord.js v14 and all interactions
  • Hybrid commands
  • lightweight and customizable
  • ESM, CommonJS and TypeScript support
  • A powerful cli and awesome community-made plugins

👶 Basic Usage

index.js (CommonJS)

// Import the discord.js Client and GatewayIntentBits
const { Client, GatewayIntentBits } = require('discord.js');

// Import Sern namespace
const { Sern } = require('@sern/handler');

// Our configuration file
const { defaultPrefix, token } = require('./config.json');

const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages
]
});

Sern.init({
client,
defaultPrefix,
commands : 'src/commands',
});

client.login(token);

ping.js (CommonJS)

const { CommandType, commandModule } = require('@sern/handler');

exports.default = commandModule({
name: 'ping',
description: 'A ping pong command',
type: CommandType.Slash,
execute(ctx) {
ctx.reply('pong!');
}
});

See our templates for TypeScript examples and more

💻 CLI

It is highly encouraged to use the command line interface for your project. Don't forget to view it.

👋 Contribute

  • Read our contribution guidelines carefully
  • Pull up on issues and report bugs
  • All kinds of contributions are welcomed.

🚈 Roadmap

You can check our roadmap to see what's going to be added or patched in the future.

- + \ No newline at end of file diff --git a/fr/docs/api/classes/CommandExecutable.html b/fr/docs/api/classes/CommandExecutable.html index dee619245..c86bbb6a4 100644 --- a/fr/docs/api/classes/CommandExecutable.html +++ b/fr/docs/api/classes/CommandExecutable.html @@ -6,13 +6,13 @@ Class: CommandExecutable<Type> | sern - Handlers. Redefined. - +

Class: CommandExecutable<Type>

Type parameters

NameType
Typeextends CommandType

Constructors

constructor

new CommandExecutable<Type>()

Type parameters

NameType
Typeextends CommandType

Properties

execute

Abstract execute: CommandModuleDefs[Type][``"execute"``]

Defined in

src/handler/sern.ts:132


onEvent

onEvent: EventPlugin<Type>[] = []

Defined in

src/handler/sern.ts:131


plugins

plugins: CommandPlugin<Type>[] = []

Defined in

src/handler/sern.ts:130


type

Abstract type: Type

Defined in

src/handler/sern.ts:129

- + \ No newline at end of file diff --git a/fr/docs/api/classes/Context.html b/fr/docs/api/classes/Context.html index 613d2e19e..1161ef79d 100644 --- a/fr/docs/api/classes/Context.html +++ b/fr/docs/api/classes/Context.html @@ -6,7 +6,7 @@ Class: Context | sern - Handlers. Redefined. - + @@ -17,7 +17,7 @@ CommandType.Text or the event fired in a Both command was Message

Returns

ChatInputCommandInteraction<CacheType>

Defined in

src/handler/structures/context.ts:52


member

get member(): Nullish<GuildMember | APIGuildMember>

Returns

Nullish<GuildMember | APIGuildMember>

Defined in

src/handler/structures/context.ts:101


message

get message(): Message<boolean>

Getting the Message object. Crashes if module type is CommandType.Slash or the event fired in a Both command was ChatInputCommandInteraction

Returns

Message<boolean>

Defined in

src/handler/structures/context.ts:44


user

get user(): User

Returns

User

Defined in

src/handler/structures/context.ts:70

Methods

isEmpty

isEmpty(): boolean

Returns

boolean

Defined in

src/handler/structures/context.ts:129


reply

reply(content): Promise<Message<boolean>>

Parameters

NameType
contentReplyOptions

Returns

Promise<Message<boolean>>

Defined in

src/handler/structures/context.ts:133


wrap

Static wrap(wrappable): Context

Parameters

NameType
wrappableMessage<boolean> | ChatInputCommandInteraction<CacheType>

Returns

Context

Defined in

src/handler/structures/context.ts:122

- + \ No newline at end of file diff --git a/fr/docs/api/classes/EventExecutable.html b/fr/docs/api/classes/EventExecutable.html index 6d882548a..ec4396e20 100644 --- a/fr/docs/api/classes/EventExecutable.html +++ b/fr/docs/api/classes/EventExecutable.html @@ -6,13 +6,13 @@ Class: EventExecutable<Type> | sern - Handlers. Redefined. - +

Class: EventExecutable<Type>

Type parameters

NameType
Typeextends EventType

Constructors

constructor

new EventExecutable<Type>()

Type parameters

NameType
Typeextends EventType

Properties

execute

Abstract execute: EventModuleDefs[Type][``"execute"``]

Defined in

src/handler/sern.ts:139


onEvent

onEvent: EventModuleEventPluginDefs[Type][] = []

Defined in

src/handler/sern.ts:138


plugins

plugins: EventModuleCommandPluginDefs[Type][] = []

Defined in

src/handler/sern.ts:137


type

Abstract type: Type

Defined in

src/handler/sern.ts:136

- + \ No newline at end of file diff --git a/fr/docs/api/classes/SernEmitter.html b/fr/docs/api/classes/SernEmitter.html index b4e48063d..d0752ae10 100644 --- a/fr/docs/api/classes/SernEmitter.html +++ b/fr/docs/api/classes/SernEmitter.html @@ -6,7 +6,7 @@ Class: SernEmitter | sern - Handlers. Redefined. - + @@ -50,7 +50,7 @@ given event.

This method is intentionally generic and works with the web p semantics and does not listen to the 'error' event.

const { once, EventEmitter } = require('events');

async function run() {
const ee = new EventEmitter();

process.nextTick(() => {
ee.emit('myevent', 42);
});

const [value] = await once(ee, 'myevent');
console.log(value);

const err = new Error('kaboom');
process.nextTick(() => {
ee.emit('error', err);
});

try {
await once(ee, 'myevent');
} catch (err) {
console.log('error happened', err);
}
}

run();

The special handling of the 'error' event is only used when events.once()is used to wait for another event. If events.once() is used to wait for the 'error' event itself, then it is treated as any other kind of event without special handling:

const { EventEmitter, once } = require('events');

const ee = new EventEmitter();

once(ee, 'error')
.then(([err]) => console.log('ok', err.message))
.catch((err) => console.log('error', err.message));

ee.emit('error', new Error('boom'));

// Prints: ok boom

An AbortSignal can be used to cancel waiting for the event:

const { EventEmitter, once } = require('events');

const ee = new EventEmitter();
const ac = new AbortController();

async function foo(emitter, event, signal) {
try {
await once(emitter, event, { signal });
console.log('event emitted!');
} catch (error) {
if (error.name === 'AbortError') {
console.error('Waiting for the event was canceled!');
} else {
console.error('There was an error', error.message);
}
}
}

foo(ee, 'foo', ac.signal);
ac.abort(); // Abort waiting for the event
ee.emit('foo'); // Prints: Waiting for the event was canceled!

Since

v11.13.0, v10.16.0

Parameters

NameType
emitterNodeEventTarget
eventNamestring | symbol
options?StaticEventEmitterOptions

Returns

Promise<any[]>

Inherited from

EventEmitter.once

Defined in

node_modules/@types/node/events.d.ts:157

Static once(emitter, eventName, options?): Promise<any[]>

Parameters

NameType
emitterDOMEventTarget
eventNamestring
options?StaticEventEmitterOptions

Returns

Promise<any[]>

Inherited from

EventEmitter.once

Defined in

node_modules/@types/node/events.d.ts:158

Static once<K>(eventEmitter, eventName): Promise<ClientEvents[K]>

Type parameters

NameType
Kextends keyof ClientEvents

Parameters

NameType
eventEmitterClient<boolean>
eventNameK

Returns

Promise<ClientEvents[K]>

Inherited from

EventEmitter.once

Defined in

node_modules/discord.js/typings/index.d.ts:196


setMaxListeners

Static setMaxListeners(n?, ...eventTargets): void

const {
setMaxListeners,
EventEmitter
} = require('events');

const target = new EventTarget();
const emitter = new EventEmitter();

setMaxListeners(5, target, emitter);

Since

v15.4.0

Parameters

NameTypeDescription
n?numberA non-negative number. The maximum number of listeners per EventTarget event.
...eventTargets(EventEmitter | DOMEventTarget)[]-

Returns

void

Inherited from

EventEmitter.setMaxListeners

Defined in

node_modules/@types/node/events.d.ts:280

- + \ No newline at end of file diff --git a/fr/docs/api/enums/CommandType.html b/fr/docs/api/enums/CommandType.html index 5636c2670..0f83ca69f 100644 --- a/fr/docs/api/enums/CommandType.html +++ b/fr/docs/api/enums/CommandType.html @@ -6,13 +6,13 @@ Enumeration: CommandType | sern - Handlers. Redefined. - +

Enumeration: CommandType

Example

export default commandModule({
type : CommandType.Text,
name : 'a text command'
execute(message) {
console.log(message.content)
}
})

Enumeration Members

Both

Both = 3

The CommandType for hybrid commands, text and slash

Defined in

src/handler/structures/enums.ts:27


Button

Button = 16

The CommandType for ButtonInteraction commands

Defined in

src/handler/structures/enums.ts:39


MenuMsg = 8

The CommandType for MessageContextMenuInteraction commands

Defined in

src/handler/structures/enums.ts:35


MenuSelect = 32

The CommandType for SelectMenuInteraction commands

Defined in

src/handler/structures/enums.ts:43


MenuUser = 4

The CommandType for UserContextMenuInteraction commands

Defined in

src/handler/structures/enums.ts:31


Modal = 64

The CommandType for ModalSubmitInteraction commands

Defined in

src/handler/structures/enums.ts:47


Slash

Slash = 2

The CommandType for slash commands

Defined in

src/handler/structures/enums.ts:23


Text

Text = 1

The CommandType for text commands

Defined in

src/handler/structures/enums.ts:19

- + \ No newline at end of file diff --git a/fr/docs/api/enums/EventType.html b/fr/docs/api/enums/EventType.html index 4f274fc22..3a2b526dc 100644 --- a/fr/docs/api/enums/EventType.html +++ b/fr/docs/api/enums/EventType.html @@ -6,14 +6,14 @@ Enumeration: EventType | sern - Handlers. Redefined. - +

Enumeration: EventType

Example

export default eventModule({
type : EventType.Discord,
name : 'guildMemberAdd'
execute(member : GuildMember) {
console.log(member)
}
})

Enumeration Members

Discord

Discord = 1

The EventType for handling discord events

Defined in

src/handler/structures/enums.ts:68


External

External = 3

The EventType for handling external events. Could be for example, process events, database events

Defined in

src/handler/structures/enums.ts:77


Sern

Sern = 2

The EventType for handling sern events

Defined in

src/handler/structures/enums.ts:72

- + \ No newline at end of file diff --git a/fr/docs/api/enums/PayloadType.html b/fr/docs/api/enums/PayloadType.html index acb42cac9..83f012680 100644 --- a/fr/docs/api/enums/PayloadType.html +++ b/fr/docs/api/enums/PayloadType.html @@ -6,13 +6,13 @@ Enumeration: PayloadType | sern - Handlers. Redefined. - +
- + \ No newline at end of file diff --git a/fr/docs/api/enums/PluginType.html b/fr/docs/api/enums/PluginType.html index ac10081fa..8ab9ea2c8 100644 --- a/fr/docs/api/enums/PluginType.html +++ b/fr/docs/api/enums/PluginType.html @@ -6,13 +6,13 @@ Enumeration: PluginType | sern - Handlers. Redefined. - +

Enumeration: PluginType

Example

export default function myPlugin() : EventPlugin<CommandType.Text> {
type : PluginType.Event,
execute([ctx, args], controller) {
return controller.next();
}
}

Enumeration Members

Command

Command = 1

The PluginType for CommandPlugins

Defined in

src/handler/structures/enums.ts:97


Event

Event = 2

The PluginType for EventPlugins

Defined in

src/handler/structures/enums.ts:101

- + \ No newline at end of file diff --git a/fr/docs/api/interfaces/Controller.html b/fr/docs/api/interfaces/Controller.html index 05642c6cc..63777a5cc 100644 --- a/fr/docs/api/interfaces/Controller.html +++ b/fr/docs/api/interfaces/Controller.html @@ -6,13 +6,13 @@ Interface: Controller | sern - Handlers. Redefined. - +
- + \ No newline at end of file diff --git a/fr/docs/api/interfaces/Wrapper.html b/fr/docs/api/interfaces/Wrapper.html index d2d1d1758..9f9d5e51c 100644 --- a/fr/docs/api/interfaces/Wrapper.html +++ b/fr/docs/api/interfaces/Wrapper.html @@ -6,13 +6,13 @@ Interface: Wrapper | sern - Handlers. Redefined. - +

Interface: Wrapper

An object to be passed into Sern#init() function.

Properties

client

Readonly client: Client<boolean>

Defined in

src/handler/structures/wrapper.ts:11


commands

Readonly commands: string

Defined in

src/handler/structures/wrapper.ts:15


defaultPrefix

Optional Readonly defaultPrefix: string

Defined in

src/handler/structures/wrapper.ts:14


events

Optional Readonly events: string | { absPath: string ; mod: EventModule }[] | () => { absPath: string ; mod: EventModule }[]

Defined in

src/handler/structures/wrapper.ts:16


sernEmitter

Optional Readonly sernEmitter: SernEmitter

Defined in

src/handler/structures/wrapper.ts:13

- + \ No newline at end of file diff --git a/fr/docs/api/modules.html b/fr/docs/api/modules.html index 3d66b7a2a..834d572cd 100644 --- a/fr/docs/api/modules.html +++ b/fr/docs/api/modules.html @@ -6,7 +6,7 @@ @sern/handler | sern - Handlers. Redefined. - + @@ -14,7 +14,7 @@

@sern/handler

Namespaces

Enumerations

Classes

Interfaces

Type Aliases

Args

Ƭ Args: ParseType<{ slash: SlashOptions ; text: string[] }>

Defined in

src/types/handler.ts:12


AutocompletePlugin

Ƭ AutocompletePlugin: Override<BaseModule, { execute: (autocmp: AutocompleteInteraction, controlller: Controller) => Awaitable<Result<void, void>> ; type: Event }>

Defined in

src/handler/plugins/plugin.ts:92


BaseOptions

Ƭ BaseOptions: ApplicationCommandChoicesData | ApplicationCommandNonOptionsData | ApplicationCommandChannelOptionData | ApplicationCommandNumericOptionData | ApplicationCommandAttachmentOption | SernAutocompleteData

Type that replaces autocomplete with SernAutocompleteData

Defined in

src/handler/structures/module.ts:181


BothCommand

Ƭ BothCommand: Override<BaseModule, { alias?: string[] ; execute: (ctx: Context, args: Args) => Awaitable<void | unknown> ; onEvent: EventPlugin<Both>[] ; options?: SernOptionsData[] ; plugins: CommandPlugin[] ; type: Both }>

Defined in

src/handler/structures/module.ts:55


CommandModuleNoPlugins

Ƭ CommandModuleNoPlugins: { [T in CommandType]: Omit<CommandModuleDefs[T], "plugins" | "onEvent"> }

Defined in

src/handler/plugins/plugin.ts:145


CommandModulePlugin

Ƭ CommandModulePlugin<T>: EventPlugin<T> | CommandPlugin<T>

Type parameters

NameType
Textends CommandType

Defined in

src/handler/plugins/plugin.ts:173


CommandPlugin

Ƭ CommandPlugin<T>: { [K in T]: Override<BasePlugin, Object> }[T]

Type parameters

NameType
Textends keyof CommandModuleDefs = keyof CommandModuleDefs

Defined in

src/handler/plugins/plugin.ts:40


DefinedCommandModule

Ƭ DefinedCommandModule: DefinitelyDefined<CommandModule, "name" | "description">

Defined in

src/types/handler.ts:43


DefinedEventModule

Ƭ DefinedEventModule: DefinitelyDefined<EventModule, "name" | "description">

Defined in

src/types/handler.ts:44


DefinedModule

Ƭ DefinedModule: DefinitelyDefined<Module, "name" | "description">

After modules are transformed, name and description are given default values if none are provided to Module. This type represents that transformation

Defined in

src/types/handler.ts:42


DefinitelyDefined

Ƭ DefinitelyDefined<T, K>: { [L in K]-?: T[L] extends Record<string, unknown> ? DefinitelyDefined<T[L], keyof T[L]> : Required<T>[L] } & T

Type parameters

NameType
TT
Kextends keyof T = keyof T

Defined in

src/types/handler.ts:19


DiscordEmitterPlugin

Ƭ DiscordEmitterPlugin: Override<BasePlugin, { execute: (wrapper: Client, module: DefinitelyDefined<DiscordEventCommand, "name" | "description">, controller: Controller) => Awaitable<Result<void, void>> ; type: Command }>

Defined in

src/handler/plugins/plugin.ts:57


DiscordEventPlugin

Ƭ DiscordEventPlugin<T>: Override<BasePlugin, { execute: (args: ClientEvents[T], controller: Controller) => Awaitable<Result<void, void>> ; name?: T ; type: Event }>

Type parameters

NameType
Textends keyof ClientEvents = keyof ClientEvents

Defined in

src/handler/plugins/plugin.ts:136


EventInput

Ƭ EventInput: string | { absPath: string ; mod: EventModule }[] | () => { absPath: string ; mod: EventModule }[]

Defined in

src/types/handler.ts:25


EventModuleCommandPluginDefs

Ƭ EventModuleCommandPluginDefs: Object

Event Module Command Plugins

Type declaration

NameType
1DiscordEmitterPlugin
2SernEmitterPlugin
3ExternalEmitterPlugin

Defined in

src/handler/plugins/plugin.ts:163


EventModuleEventPluginDefs

Ƭ EventModuleEventPluginDefs: Object

Event Module Event Plugins

Type declaration

NameType
1DiscordEventPlugin
2SernEventPlugin
3ExternalEventPlugin

Defined in

src/handler/plugins/plugin.ts:154


EventModulePlugin

Ƭ EventModulePlugin<T>: EventModuleEventPluginDefs[T] | EventModuleCommandPluginDefs[T]

Type parameters

NameType
Textends EventType

Defined in

src/handler/plugins/plugin.ts:169


EventModulesNoPlugins

Ƭ EventModulesNoPlugins: { [T in EventType]: Omit<EventModuleDefs[T], "plugins" | "onEvent"> }

Defined in

src/handler/plugins/plugin.ts:148


EventPlugin

Ƭ EventPlugin<T>: { [K in T]: Override<BasePlugin, Object> }[T]

Type parameters

NameType
Textends keyof CommandModuleDefs = keyof CommandModuleDefs

Defined in

src/handler/plugins/plugin.ts:103


ExternalEmitterPlugin

Ƭ ExternalEmitterPlugin<T>: Override<BasePlugin, { execute: (wrapper: T, module: DefinitelyDefined<ExternalEventCommand, "name" | "description">, controller: Controller) => Awaitable<Result<void, void>> ; type: Command }>

Type parameters

NameType
Textends EventEmitter = EventEmitter

Defined in

src/handler/plugins/plugin.ts:68


ExternalEventPlugin

Ƭ ExternalEventPlugin: Override<BasePlugin, { execute: (args: unknown[], controller: Controller) => Awaitable<Result<void, void>> ; type: Event }>

Defined in

src/handler/plugins/plugin.ts:128


InputCommandModule

Ƭ InputCommandModule: { [T in CommandType]: CommandModuleNoPlugins[T] & Object }[CommandType]

User inputs this type. Sern processes behind the scenes for better usage

Defined in

src/handler/plugins/plugin.ts:178


InputEventModule

Ƭ InputEventModule: { [T in EventType]: EventModulesNoPlugins[T] & Object }[EventType]

Defined in

src/handler/plugins/plugin.ts:182


Module

Ƭ Module: CommandModule | EventModule

Defined in

src/handler/structures/module.ts:141


Nullish

Ƭ Nullish<T>: T | undefined | null

Type parameters

Name
T

Defined in

src/types/handler.ts:5


Override

Ƭ Override<T1, T2>: Omit<T1, keyof T2> & T2

Type parameters

Name
T1
T2

Defined in

src/types/handler.ts:17


ParseType

Ƭ ParseType<T>: { [K in keyof T]: T[K] extends unknown ? [k: K, args: T[K]] : never }[keyof T]

Type parameters

Name
T

Defined in

src/types/handler.ts:8


Payload

Ƭ Payload: { module: Module ; type: Success } | { module?: Module ; reason: string | Error ; type: Failure }

Defined in

src/types/handler.ts:45


ReplyOptions

Ƭ ReplyOptions: string | Omit<InteractionReplyOptions, "fetchReply"> | MessageReplyOptions

Defined in

src/types/handler.ts:55


SernAutocompleteData

Ƭ SernAutocompleteData: Override<BaseApplicationCommandOptionsData, { autocomplete: true ; command: AutocompleteCommand ; type: ApplicationCommandOptionType.String | ApplicationCommandOptionType.Number | ApplicationCommandOptionType.Integer }>

Defined in

src/handler/structures/module.ts:166


SernEmitterPlugin

Ƭ SernEmitterPlugin: Override<BasePlugin, { execute: (wrapper: SernEmitter, module: DefinitelyDefined<SernEventCommand, "name" | "description">, controller: Controller) => Awaitable<Result<void, void>> ; type: Command }>

Defined in

src/handler/plugins/plugin.ts:80


SernEventPlugin

Ƭ SernEventPlugin<T>: Override<BasePlugin, { execute: (args: SernEventsMapping[T], controller: Controller) => Awaitable<Result<void, void>> ; name?: T ; type: Event }>

Type parameters

NameType
Textends keyof SernEventsMapping = keyof SernEventsMapping

Defined in

src/handler/plugins/plugin.ts:116


SernEventsMapping

Ƭ SernEventsMapping: Object

Type declaration

NameType
error[Payload]
module.activate[Payload]
module.register[Payload]
warning[string]

Defined in

src/types/handler.ts:48


SernOptionsData

Ƭ SernOptionsData<U>: U extends ApplicationCommandSubCommandData ? SernSubCommandData : U extends ApplicationCommandSubGroupData ? SernSubCommandGroupData : BaseOptions

Type parameters

NameType
Uextends ApplicationCommandOptionData = ApplicationCommandOptionData

Defined in

src/handler/structures/module.ts:205


SernSubCommandData

Ƭ SernSubCommandData: Override<Omit<BaseApplicationCommandOptionsData, "required">, { options?: BaseOptions[] ; type: ApplicationCommandOptionType.Subcommand }>

Defined in

src/handler/structures/module.ts:189


SernSubCommandGroupData

Ƭ SernSubCommandGroupData: Override<Omit<BaseApplicationCommandOptionsData, "required">, { options?: SernSubCommandData[] ; type: ApplicationCommandOptionType.SubcommandGroup }>

Defined in

src/handler/structures/module.ts:197


SlashCommand

Ƭ SlashCommand: Override<BaseModule, { execute: (ctx: Context, args: ["slash", SlashOptions]) => Awaitable<void | unknown> ; onEvent: EventPlugin<Slash>[] ; options?: SernOptionsData[] ; plugins: CommandPlugin[] ; type: Slash }>

Defined in

src/handler/structures/module.ts:44


SlashOptions

Ƭ SlashOptions: Omit<CommandInteractionOptionResolver, "getMessage" | "getFocused">

Defined in

src/types/handler.ts:14


SpreadParams

Ƭ SpreadParams<T>: (args: Parameters<T>[number]) => unknown

Type parameters

NameType
Textends (...args: never) => unknown

Type declaration

▸ (args): unknown

Turns a function with a union of array of args into a single union [ T , V , B ] | [ A ] => T | V | B | A

Parameters
NameType
argsParameters<T>[number]
Returns

unknown

Defined in

src/types/handler.ts:34


TextCommand

Ƭ TextCommand: Override<BaseModule, { alias?: string[] ; execute: (ctx: Context, args: ["text", string[]]) => Awaitable<void | unknown> ; onEvent: EventPlugin<Text>[] ; plugins: CommandPlugin[] ; type: Text }>

Defined in

src/handler/structures/module.ts:33

Functions

commandModule

commandModule(mod): CommandModule

The wrapper function to define command modules for sern

Parameters

NameType
modInputCommandModule

Returns

CommandModule

Defined in

src/handler/sern.ts:91


eventModule

eventModule(mod): EventModule

The wrapper function to define event modules for sern

Parameters

NameType
modInputEventModule

Returns

EventModule

Defined in

src/handler/sern.ts:112

- + \ No newline at end of file diff --git a/fr/docs/api/namespaces/Sern.html b/fr/docs/api/namespaces/Sern.html index 7d1b64ba6..f886002b5 100644 --- a/fr/docs/api/namespaces/Sern.html +++ b/fr/docs/api/namespaces/Sern.html @@ -6,13 +6,13 @@ Namespace: Sern | sern - Handlers. Redefined. - +

Namespace: Sern

References

CommandExecutable

Re-exports CommandExecutable


EventExecutable

Re-exports EventExecutable


commandModule

Re-exports commandModule


eventModule

Re-exports eventModule

Variables

controller

Const controller: Object

The object passed into every plugin to control a command's behavior

Type declaration

NameType
next() => OkImpl<void>
stop() => ErrImpl<void>

Defined in

src/handler/sern.ts:82

Functions

addExternal

addExternal<T>(emitter): void

Deprecated

  • use Sern#makeDependencies instead

Example

src/index.ts
//Add this before initiating Sern!
Sern.addExternal(new Level())

Example

events/level.ts
 export default eventModule({
emitter: 'Level',
type : EventType.External,
name: 'error',
execute(args) {
console.log(args)
}
})

Type parameters

NameType
Textends __module

Parameters

NameTypeDescription
emitterTAny external event emitter. The object will be stored in a map, and then fetched by the name of the instance's class. As there are infinite possibilities to adding external event emitters, Most types aren't provided and are as narrow as possibly can.

Returns

void

Defined in

src/handler/sern.ts:72


init

init(wrapper): void

Example

src/index.ts
Sern.init({
client,
defaultPrefix: '!',
commands: 'dist/commands',
})

Parameters

NameTypeDescription
wrapperWrapperOptions to pass into sern. Function to start the handler up

Returns

void

Defined in

src/handler/sern.ts:39

- + \ No newline at end of file diff --git a/fr/docs/guide.html b/fr/docs/guide.html index b33019bba..ca22ddf40 100644 --- a/fr/docs/guide.html +++ b/fr/docs/guide.html @@ -6,13 +6,13 @@ Introduction | sern - Handlers. Redefined. - +

Introduction

Welcome to our official guide. This guide will go through all the core features of the framework.

  • 💖 Thank you for choosing sern to be your framework!

  • Teaching the discord.js library and / or Javascript / Typescript is out of scope of this project, so the documentation assumes you already know these elements.

  • discord.js v14 is the only supported library at the moment

You will learn

Working with plugins

Events

Good to know

- + \ No newline at end of file diff --git a/fr/docs/guide/getting-started/choose-ide.html b/fr/docs/guide/getting-started/choose-ide.html index b94ed6f9e..97f6ad734 100644 --- a/fr/docs/guide/getting-started/choose-ide.html +++ b/fr/docs/guide/getting-started/choose-ide.html @@ -6,14 +6,14 @@ Choosing an IDE | sern - Handlers. Redefined. - +
- + \ No newline at end of file diff --git a/fr/docs/guide/getting-started/preparing.html b/fr/docs/guide/getting-started/preparing.html index 9ed289415..ef0785239 100644 --- a/fr/docs/guide/getting-started/preparing.html +++ b/fr/docs/guide/getting-started/preparing.html @@ -6,13 +6,13 @@ Preparing to Code | sern - Handlers. Redefined. - +

Preparing to Code

After installing and IDE you need to install node.

You can download the LTS version of node right here

- + \ No newline at end of file diff --git a/fr/docs/guide/walkthrough/cli.html b/fr/docs/guide/walkthrough/cli.html index 8bf552db6..280a177df 100644 --- a/fr/docs/guide/walkthrough/cli.html +++ b/fr/docs/guide/walkthrough/cli.html @@ -6,7 +6,7 @@ CLI | sern - Handlers. Redefined. - + @@ -14,7 +14,7 @@

CLI

Setting up the CLI is easy.

  • To start a brand-new project, run :
sern init (-y)
astuce

It creates a directory for you so you don't need to!

Include the -y flag if you want to set up defaults. The default langauge is Typescript

sern plugins
info

Make sure to have a correct sern.config.json

This will display a menu selection of all installable plugins.
Note: You must have a sern.config.json to use this command. If you want to view plugins, visit the repository linked above.

  • To install extra utilities into your project
sern extra
- + \ No newline at end of file diff --git a/fr/docs/guide/walkthrough/conclusion.html b/fr/docs/guide/walkthrough/conclusion.html index 80bfa0e70..bdbbee6a6 100644 --- a/fr/docs/guide/walkthrough/conclusion.html +++ b/fr/docs/guide/walkthrough/conclusion.html @@ -6,7 +6,7 @@ Conclusion | sern - Handlers. Redefined. - + @@ -14,7 +14,7 @@

Conclusion

If you reached this far, thank you for reading! We hope you have learned the necessities you need to create a bot with the sern framework. If you have any other questions, bugs, feature requests, concerns, please join our community server, and we'll be glad to answer your questions.

- + \ No newline at end of file diff --git a/fr/docs/guide/walkthrough/first-command.html b/fr/docs/guide/walkthrough/first-command.html index a16bab245..1fc383b35 100644 --- a/fr/docs/guide/walkthrough/first-command.html +++ b/fr/docs/guide/walkthrough/first-command.html @@ -6,16 +6,16 @@ First Command | sern - Handlers. Redefined. - +

First Command

We will dissect a basic command. -If you installed a new project via the cli, This is the ping command located in src/commands folder.

Typescript

import { commandModule, CommandType } from '@sern/handler';

export default commandModule({
type: CommandType.Both,
plugins: [],
description: 'A ping command',
//alias : [],
execute: async (ctx, args) => {
await ctx.reply({ content: 'Pong 🏓' });
},
});

Javascript

const { CommandType, commandModule } = require('@sern/handler');

exports.default = commandModule({
type: CommandType.Both,
plugins: [],
description: 'A ping command',
//alias : [],
execute: async (ctx, args) => {
await ctx.reply('Pong 🏓');
},
})

To view what each of these properties mean in depth, visit the official documentation.

Types of command modules

Every command module type is part of an enum. This field allows type inference for the rest of a module's fields.
+If you installed a new project via the cli, This is the ping command located in src/commands folder.

Typescript

import { commandModule, CommandType } from '@sern/handler';

export default commandModule({
type: CommandType.Both,
plugins: [],
description: 'A ping command',
// alias : [],
execute: async (ctx, args) => {
await ctx.reply({ content: 'Pong 🏓' });
},
});

Javascript

const { CommandType, commandModule } = require('@sern/handler');

exports.default = commandModule({
type: CommandType.Both,
plugins: [],
description: 'A ping command',
// alias : [],
execute: async (ctx, args) => {
await ctx.reply('Pong 🏓');
},
})

To view what each of these properties mean in depth, visit the official documentation.

Types of command modules

Every command module type is part of an enum. This field allows type inference for the rest of a module's fields.
All the command types can be found in the official documentation!

So, lets say you want to make a command module that listens to modals.

Note: Keep in mind you'll need to send a modal with a custom id dm-me. This example below is the response to a modal being sent.


Typescript:

import { commandModule, CommandType } from '@sern/handler';
export default commandModule({
name: 'dm-me',
type: CommandType.Modal,
async execute (modal) {
const value = modal.fields.getTextInputValue('message');
modal.client.users.fetch('182326315813306368').then( u =>
u.send(value + ` from ${modal.user}`)
);
modal.reply( { ephemeral:true, content: 'Sent' })
}
});

Javascript:

const { CommandType, commandModule } = require('@sern/handler');
exports.default = commandModule({
name: 'dm-me',
type: CommandType.Modal,
async execute (modal) {
const value = modal.fields.getTextInputValue('message');
modal.client.users.fetch('182326315813306368').then( u =>
u.send(value + ` from ${modal.user}`)
);
modal.reply( { ephemeral:true, content: 'Sent' })
}
});

Commands are straight forward. Keep in mind, every other property on the commandModule object is -optional except the type and execute function.

Context class

The provided Context class helps with modules of CommandType.Both (A mixture of slash / legacy commands).

The Context class is passed into modules with type :

  • CommandType.Both
  • CommandType.Slash
  • CommandType.Text

This data structure helps interop between legacy commands and slash commands with ease.

remarque

View the docs

Typescript:

export default commandModule({
name: 'ping',
type: CommandType.Both,
async execute(ctx: Context) {
await ctx.reply(`pong ${ctx.user}`)
// .reply is shared between both message and interaction!
// So is an User object!
}
});

Javascript:

exports.default = commandModule({
name: 'ping',
type: CommandType.Both,
async execute(ctx) { //ctx is a Context instance
await ctx.reply(`pong ${ctx.user}`)
// .reply is shared between both message and interaction!
// So is an User object!
}
});
- +optional except the type and execute function.

Context class

The provided Context class helps with modules of CommandType.Both (A mixture of slash / legacy commands).

The Context class is passed into modules with type:

  • CommandType.Both
  • CommandType.Slash
  • CommandType.Text

This data structure helps interop between legacy commands and slash commands with ease.

remarque

View the docs

Typescript:

export default commandModule({
name: 'ping',
type: CommandType.Both,
async execute(ctx: Context) {
await ctx.reply(`pong ${ctx.user}`)
// .reply is shared between both message and interaction!
// So is an User object!
}
});

Javascript:

exports.default = commandModule({
name: 'ping',
type: CommandType.Both,
async execute(ctx) { //ctx is a Context instance
await ctx.reply(`pong ${ctx.user}`)
// .reply is shared between both message and interaction!
// So is an User object!
}
});
+ \ No newline at end of file diff --git a/fr/docs/guide/walkthrough/first-event.html b/fr/docs/guide/walkthrough/first-event.html index c59b31afe..f32041f5d 100644 --- a/fr/docs/guide/walkthrough/first-event.html +++ b/fr/docs/guide/walkthrough/first-event.html @@ -6,7 +6,7 @@ First Event Module | sern - Handlers. Redefined. - + @@ -14,7 +14,7 @@

First Event Module

We will dissect a basic event module.
Typescript:

export default eventModule({
type: EventType.Sern,
plugins : [], //NOT SUPPORTED YET!!
name: 'module.activate', //name of event.
execute(event) {
console.log(event);
}
})

Javascript:

exports.default = eventModule({
type: EventType.Sern,
plugins : [], //NOT SUPPORTED YET!!
name: 'module.activate',
execute(event) {
console.log(event);
}
})

Like command modules, the type property denotes what kind of event it is, which can be found here.

To view what each of these properties mean in depth, visit the official documentation.


Event modules are laid out similarly to command modules. These listen to any and all event you provide. In the current version 1.1.0-beta, plugins are not supported.

Another example of an event module

Typescript:

export default eventModule({
type: EventType.Discord,
plugins : [], //NOT SUPPORTED YET!!
name: 'guildMemberAdd', //name of event.
async execute(member: GuildMember) {
(await member.guild.channels.fetch('channel-id') as TextChannel).send(`Welcome, ${member}`);
}
})

Javascript:


exports.default = eventModule({
type: EventType.Discord,
plugins : [], //NOT SUPPORTED YET!!
name: 'guildMemberAdd', //name of event.
async execute(member) {
(await member.guild.channels.fetch('channel-id')).send(`Welcome, ${member}`);
}
})
- + \ No newline at end of file diff --git a/fr/docs/guide/walkthrough/goal.html b/fr/docs/guide/walkthrough/goal.html index c6d8dbb1b..3b7c9fab7 100644 --- a/fr/docs/guide/walkthrough/goal.html +++ b/fr/docs/guide/walkthrough/goal.html @@ -6,7 +6,7 @@ Goal | sern - Handlers. Redefined. - + @@ -14,7 +14,7 @@

Goal

sern strives to be minimalist, but with all batteries included. Meaning, this framework provides the necessary tools to start up a bot in minutes, and leaves plenty room space to customize your experience and create an amazing project. It should include all the tools for any bot at any scale.

- + \ No newline at end of file diff --git a/fr/docs/guide/walkthrough/good-to-know.html b/fr/docs/guide/walkthrough/good-to-know.html index 0deedffdb..c2a1a2ea0 100644 --- a/fr/docs/guide/walkthrough/good-to-know.html +++ b/fr/docs/guide/walkthrough/good-to-know.html @@ -6,7 +6,7 @@ Good to know | sern - Handlers. Redefined. - + @@ -14,7 +14,7 @@

Good to know

sern.config.json

A sern.config.json, although not necessary, allows your project to communicate with our cli.

For example, when installing typescript plugins, the language property is necessary to install from our open source repository.

Using the cli and running sern init --sync on pre-existing projects should install this json file in the root directory given. Or, if this is a brand-new project, sern init automatically installs it.

{
"language": "typescript",
"paths": {
"base": "src",
"commands": "commands"
}
}
- + \ No newline at end of file diff --git a/fr/docs/guide/walkthrough/plugins.html b/fr/docs/guide/walkthrough/plugins.html index e3b00cf58..5b734fcd7 100644 --- a/fr/docs/guide/walkthrough/plugins.html +++ b/fr/docs/guide/walkthrough/plugins.html @@ -6,7 +6,7 @@ Plugins | sern - Handlers. Redefined. - + @@ -17,7 +17,7 @@ This controls whether a module is stored into sern.
Typescript:

export function inDir(dir : string) : CommandPlugin<CommandType.Both> {
return {
type: PluginType.Command,
async execute(wrapper, { absPath, module }, controller) {
if(path.dirname(absPath) !== dir) {
console.log(+new Date(), `${module.name} is not in the correct directory!`);
return controller.stop()
}
console.log(+new Date(), `${module.name} is in the correct directory!`);
return controller.next(); //continue
}
}
}

Javascript:

export function inDir(dir : string) {
return {
type: PluginType.Command,
async execute(wrapper, { absPath, module }, controller) {
if(path.dirname(absPath) !== dir) {
console.log(+new Date(), `${module.name} is not in the correct directory!`);
return controller.stop()
}
console.log(+new Date(), `${module.name} is in the correct directory!`);
return controller.next(); //continue
}
}
}

Above, this simple plugin logs that the module has been loaded along with a timestamp.
Again, it is up to you to define plugin logic! The possibilities to customize your bots are endless.

astuce

Command Plugins are good for ensuring the shape, location, and preprocessing of your commands.

Event Plugins

event-plugins

  • An event is emitted by discord.js.
  • This event is passed to all plugins (in order!!),
  • If all are successful,

The command is executed. Calling controller.stop() notifies sern that this command should not be run, and this event is ignored.

So, what does a command module look like with plugins?

Typescript:

import { commandModule, CommandType } from '@sern/handler';

export default commandModule({
type: CommandType.Both,
plugins: [
inDir("other"),
serenOnly()
],
description: 'A ping command',
//alias : [],
execute: async (ctx, args) => {
await ctx.reply({ content: 'Pong 🏓' });
},
});

Javascript:

const { commandModule, CommandType } = require('@sern/handler');

exports.default = commandModule({
type: CommandType.Both,
plugins: [
inDir("other"),
serenOnly() //The plugins in this section applied to this module!
],
description: 'A ping command',
//alias : [],
execute: async (ctx, args) => {
await ctx.reply({ content: 'Pong 🏓' });
},
});

Can you predict the behavior of this command?

  • Before loading into sern, this command module will check if this module is in the correct directory other.
  • Before an event occurs, this command module will check if the user has the id 182326315813306368.
astuce

Event Plugins are good for filtering, preconditions, parsing.

If all plugins return controller.next(), this command replies Pong 🏓

- + \ No newline at end of file diff --git a/fr/docs/guide/walkthrough/sern-emitter.html b/fr/docs/guide/walkthrough/sern-emitter.html index 33c6d0ccc..f26e1b432 100644 --- a/fr/docs/guide/walkthrough/sern-emitter.html +++ b/fr/docs/guide/walkthrough/sern-emitter.html @@ -6,13 +6,13 @@ The SernEmitter class | sern - Handlers. Redefined. - +

The SernEmitter class

You're shipped with the SernEmitter. This EventEmitter listens to

  • command modules executing and its status, the module.activate event
  • command modules registered and its status, the module.register event
  • any error that occurs, the error event
  • warn events, where it is possible to throw errors

You can put these and other event listeners into event modules!


View all events
- + \ No newline at end of file diff --git a/fr/docs/intro.html b/fr/docs/intro.html index abf51204c..d8a201d6c 100644 --- a/fr/docs/intro.html +++ b/fr/docs/intro.html @@ -6,13 +6,13 @@ Welcome! | sern - Handlers. Redefined. - +

Welcome!

Content

  • /docs/api contains autogenerated documentation of our codebase using typedoc
  • /docs/guide contains a basic startup guide and details to get started with sern faster!
astuce

This site is open source! Please do contribute if you find any bugs, typos, or sections in need of improvements.

astuce

If you have problems, join the discord server here

- + \ No newline at end of file diff --git a/fr/index.html b/fr/index.html index d5331c298..f66536a2f 100644 --- a/fr/index.html +++ b/fr/index.html @@ -6,13 +6,13 @@ sern - Handlers. Redefined. | sern - Handlers. Redefined. - +

Handlers. Redefined.

With the support of the community made plugins and a powerful CLI, it's more than just a handler.

sern init
logo

Batteries included

Start or integrate a new project in minutes.

Customizable

Extend or customize with community-based plugins to provide utilities, filters, and more.

Modern

Uses modern and powerful tooling such as swc, tsup, typescript, and rxjs to future-proof and ensure project quality.

- + \ No newline at end of file diff --git a/fr/markdown-page.html b/fr/markdown-page.html index 5d92df7d1..c6a50b259 100644 --- a/fr/markdown-page.html +++ b/fr/markdown-page.html @@ -6,13 +6,13 @@ Markdown page example | sern - Handlers. Redefined. - +

Markdown page example

You don't need React to write simple standalone pages.

- + \ No newline at end of file diff --git a/fr/plugins.html b/fr/plugins.html index 91013c230..e57acd86c 100644 --- a/fr/plugins.html +++ b/fr/plugins.html @@ -6,13 +6,13 @@ sern - Handlers. Redefined. - +

Coming soon

- + \ No newline at end of file diff --git a/index.html b/index.html index 771681fcb..977c87271 100644 --- a/index.html +++ b/index.html @@ -6,13 +6,13 @@ sern - Handlers. Redefined. | sern - Handlers. Redefined. - +

Handlers. Redefined.

With the support of the community made plugins and a powerful CLI, it's more than just a handler.

sern init
logo

Batteries included

Start or integrate a new project in minutes.

Customizable

Extend or customize with community-based plugins to provide utilities, filters, and more.

Modern

Uses modern and powerful tooling such as swc, tsup, typescript, and rxjs to future-proof and ensure project quality.

- + \ No newline at end of file diff --git a/markdown-page.html b/markdown-page.html index 9302b7c70..05d003ed0 100644 --- a/markdown-page.html +++ b/markdown-page.html @@ -6,13 +6,13 @@ Markdown page example | sern - Handlers. Redefined. - +

Markdown page example

You don't need React to write simple standalone pages.

- + \ No newline at end of file diff --git a/plugins.html b/plugins.html index a32d22ed5..a1cb0d2ec 100644 --- a/plugins.html +++ b/plugins.html @@ -6,13 +6,13 @@ sern - Handlers. Redefined. - +

Coming soon

- + \ No newline at end of file diff --git a/tr/404.html b/tr/404.html index 007476653..40d0fb1f9 100644 --- a/tr/404.html +++ b/tr/404.html @@ -6,13 +6,13 @@ Sayfa Bulunamadı | sern - Handlers. Redefined. - +

Sayfa Bulunamadı

Aradığınız şeyi bulamadık.

Lütfen sizi orijinal URL'ye yönlendiren sitenin sahibiyle iletişime geçin ve bağlantısının bozuk olduğunu bildirin.

- + \ No newline at end of file diff --git a/tr/assets/js/981f6151.08a2ac57.js b/tr/assets/js/981f6151.08a2ac57.js new file mode 100644 index 000000000..4246c5909 --- /dev/null +++ b/tr/assets/js/981f6151.08a2ac57.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[703],{3905:(e,t,n)=>{n.d(t,{Zo:()=>p,kt:()=>u});var a=n(7294);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function l(e){for(var t=1;t=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var i=a.createContext({}),m=function(e){var t=a.useContext(i),n=t;return e&&(n="function"==typeof e?e(t):l(l({},t),e)),n},p=function(e){var t=m(e.components);return a.createElement(i.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},c=a.forwardRef((function(e,t){var n=e.components,o=e.mdxType,r=e.originalType,i=e.parentName,p=s(e,["components","mdxType","originalType","parentName"]),c=m(n),u=o,y=c["".concat(i,".").concat(u)]||c[u]||d[u]||r;return n?a.createElement(y,l(l({ref:t},p),{},{components:n})):a.createElement(y,l({ref:t},p))}));function u(e,t){var n=arguments,o=t&&t.mdxType;if("string"==typeof e||o){var r=n.length,l=new Array(r);l[0]=c;var s={};for(var i in t)hasOwnProperty.call(t,i)&&(s[i]=t[i]);s.originalType=e,s.mdxType="string"==typeof e?e:o,l[1]=s;for(var m=2;m{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>l,default:()=>d,frontMatter:()=>r,metadata:()=>s,toc:()=>m});var a=n(7462),o=(n(7294),n(3905));const r={sidebar_position:3},l="First Command",s={unversionedId:"guide/walkthrough/first-command",id:"guide/walkthrough/first-command",title:"First Command",description:"We will dissect a basic command.",source:"@site/docs/guide/walkthrough/first-command.md",sourceDirName:"guide/walkthrough",slug:"/guide/walkthrough/first-command",permalink:"/tr/docs/guide/walkthrough/first-command",draft:!1,editUrl:"https://github.com/sern-handler/website/edit/main/docs/guide/walkthrough/first-command.md",tags:[],version:"current",sidebarPosition:3,frontMatter:{sidebar_position:3},sidebar:"tutorialSidebar",previous:{title:"CLI",permalink:"/tr/docs/guide/walkthrough/cli"},next:{title:"First Event Module",permalink:"/tr/docs/guide/walkthrough/first-event"}},i={},m=[{value:"Types of command modules",id:"types-of-command-modules",level:3}],p={toc:m};function d(e){let{components:t,...n}=e;return(0,o.kt)("wrapper",(0,a.Z)({},p,n,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"first-command"},"First Command"),(0,o.kt)("p",null,"We will dissect a basic command.\nIf you installed a new project via the cli, This is the ",(0,o.kt)("inlineCode",{parentName:"p"},"ping")," command located in src/commands folder."),(0,o.kt)("p",null,"Typescript"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"import { commandModule, CommandType } from '@sern/handler';\n\nexport default commandModule({\n type: CommandType.Both,\n plugins: [],\n description: 'A ping command',\n // alias : [],\n execute: async (ctx, args) => {\n await ctx.reply({ content: 'Pong \ud83c\udfd3' });\n },\n});\n")),(0,o.kt)("p",null,"Javascript"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},"const { CommandType, commandModule } = require('@sern/handler');\n\nexports.default = commandModule({\n type: CommandType.Both,\n plugins: [],\n description: 'A ping command',\n // alias : [],\n execute: async (ctx, args) => {\n await ctx.reply('Pong \ud83c\udfd3');\n },\n})\n")),(0,o.kt)("p",null,"To view what each of these properties mean in depth, visit the ",(0,o.kt)("a",{parentName:"p",href:"https://sern-handler.js.org/docs/api/enums/CommandType"},"official documentation"),"."),(0,o.kt)("h3",{id:"types-of-command-modules"},"Types of command modules"),(0,o.kt)("p",null,"Every command module ",(0,o.kt)("inlineCode",{parentName:"p"},"type")," is part of an enum. This field allows type inference for the rest of a module's fields. ",(0,o.kt)("br",null),"\nAll the command types can be found in the ",(0,o.kt)("a",{parentName:"p",href:"https://sern-handler.js.org/docs/api/enums/CommandType"},"official documentation"),"!"),(0,o.kt)("p",null,"So, lets say you want to make a command module that listens to modals. "),(0,o.kt)("p",null,(0,o.kt)("strong",{parentName:"p"},"Note"),": Keep in mind you'll need to send a modal with a custom id ",(0,o.kt)("inlineCode",{parentName:"p"},"dm-me"),". This example below is the response to a modal being sent."),(0,o.kt)("br",null),(0,o.kt)("p",null,"Typescript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"import { commandModule, CommandType } from '@sern/handler';\nexport default commandModule({\n name: 'dm-me',\n type: CommandType.Modal,\n async execute (modal) {\n const value = modal.fields.getTextInputValue('message');\n modal.client.users.fetch('182326315813306368').then( u =>\n u.send(value + ` from ${modal.user}`)\n );\n modal.reply( { ephemeral:true, content: 'Sent' })\n }\n});\n")),(0,o.kt)("p",null,"Javascript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},"const { CommandType, commandModule } = require('@sern/handler');\nexports.default = commandModule({\n name: 'dm-me',\n type: CommandType.Modal,\n async execute (modal) {\n const value = modal.fields.getTextInputValue('message');\n modal.client.users.fetch('182326315813306368').then( u =>\n u.send(value + ` from ${modal.user}`)\n );\n modal.reply( { ephemeral:true, content: 'Sent' })\n }\n});\n")),(0,o.kt)("p",null,"Commands are straight forward. Keep in mind, every other property on the commandModule object is\noptional ",(0,o.kt)("strong",{parentName:"p"},"except")," the type and execute function."),(0,o.kt)("h1",{id:"context-class"},"Context class"),(0,o.kt)("p",null,"The provided Context class helps with modules of ",(0,o.kt)("inlineCode",{parentName:"p"},"CommandType.Both")," (A mixture of slash / legacy commands)."),(0,o.kt)("p",null,"The Context class is passed into modules with type:"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"CommandType.Both")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"CommandType.Slash")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"CommandType.Text"))),(0,o.kt)("p",null,"This data structure helps interop between legacy commands and slash commands with ease."),(0,o.kt)("admonition",{type:"note"},(0,o.kt)("p",{parentName:"admonition"},"View the ",(0,o.kt)("a",{parentName:"p",href:"/tr/docs/api/classes/Context"},"docs"))),(0,o.kt)("p",null,"Typescript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"export default commandModule({\n name: 'ping',\n type: CommandType.Both,\n async execute(ctx: Context) {\n await ctx.reply(`pong ${ctx.user}`) \n // .reply is shared between both message and interaction!\n // So is an User object!\n }\n});\n")),(0,o.kt)("p",null,"Javascript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},"exports.default = commandModule({\n name: 'ping',\n type: CommandType.Both,\n async execute(ctx) { //ctx is a Context instance\n await ctx.reply(`pong ${ctx.user}`) \n // .reply is shared between both message and interaction!\n // So is an User object!\n }\n});\n")))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/tr/assets/js/981f6151.20818673.js b/tr/assets/js/981f6151.20818673.js deleted file mode 100644 index f113417b5..000000000 --- a/tr/assets/js/981f6151.20818673.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[703],{3905:(e,t,n)=>{n.d(t,{Zo:()=>p,kt:()=>u});var a=n(7294);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function l(e){for(var t=1;t=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var i=a.createContext({}),m=function(e){var t=a.useContext(i),n=t;return e&&(n="function"==typeof e?e(t):l(l({},t),e)),n},p=function(e){var t=m(e.components);return a.createElement(i.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},c=a.forwardRef((function(e,t){var n=e.components,o=e.mdxType,r=e.originalType,i=e.parentName,p=s(e,["components","mdxType","originalType","parentName"]),c=m(n),u=o,y=c["".concat(i,".").concat(u)]||c[u]||d[u]||r;return n?a.createElement(y,l(l({ref:t},p),{},{components:n})):a.createElement(y,l({ref:t},p))}));function u(e,t){var n=arguments,o=t&&t.mdxType;if("string"==typeof e||o){var r=n.length,l=new Array(r);l[0]=c;var s={};for(var i in t)hasOwnProperty.call(t,i)&&(s[i]=t[i]);s.originalType=e,s.mdxType="string"==typeof e?e:o,l[1]=s;for(var m=2;m{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>l,default:()=>d,frontMatter:()=>r,metadata:()=>s,toc:()=>m});var a=n(7462),o=(n(7294),n(3905));const r={sidebar_position:3},l="First Command",s={unversionedId:"guide/walkthrough/first-command",id:"guide/walkthrough/first-command",title:"First Command",description:"We will dissect a basic command.",source:"@site/docs/guide/walkthrough/first-command.md",sourceDirName:"guide/walkthrough",slug:"/guide/walkthrough/first-command",permalink:"/tr/docs/guide/walkthrough/first-command",draft:!1,editUrl:"https://github.com/sern-handler/website/edit/main/docs/guide/walkthrough/first-command.md",tags:[],version:"current",sidebarPosition:3,frontMatter:{sidebar_position:3},sidebar:"tutorialSidebar",previous:{title:"CLI",permalink:"/tr/docs/guide/walkthrough/cli"},next:{title:"First Event Module",permalink:"/tr/docs/guide/walkthrough/first-event"}},i={},m=[{value:"Types of command modules",id:"types-of-command-modules",level:3}],p={toc:m};function d(e){let{components:t,...n}=e;return(0,o.kt)("wrapper",(0,a.Z)({},p,n,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"first-command"},"First Command"),(0,o.kt)("p",null,"We will dissect a basic command.\nIf you installed a new project via the cli, This is the ",(0,o.kt)("inlineCode",{parentName:"p"},"ping")," command located in src/commands folder."),(0,o.kt)("p",null,"Typescript"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"import { commandModule, CommandType } from '@sern/handler';\n\nexport default commandModule({\n type: CommandType.Both,\n plugins: [],\n description: 'A ping command',\n //alias : [],\n execute: async (ctx, args) => {\n await ctx.reply({ content: 'Pong \ud83c\udfd3' });\n },\n});\n")),(0,o.kt)("p",null,"Javascript"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},"const { CommandType, commandModule } = require('@sern/handler');\n\nexports.default = commandModule({\n type: CommandType.Both,\n plugins: [],\n description: 'A ping command',\n //alias : [],\n execute: async (ctx, args) => {\n await ctx.reply('Pong \ud83c\udfd3');\n },\n})\n")),(0,o.kt)("p",null,"To view what each of these properties mean in depth, visit the ",(0,o.kt)("a",{parentName:"p",href:"https://sern-handler.js.org/docs/api/enums/CommandType"},"official documentation"),"."),(0,o.kt)("h3",{id:"types-of-command-modules"},"Types of command modules"),(0,o.kt)("p",null,"Every command module ",(0,o.kt)("inlineCode",{parentName:"p"},"type")," is part of an enum. This field allows type inference for the rest of a module's fields. ",(0,o.kt)("br",null),"\nAll the command types can be found in the ",(0,o.kt)("a",{parentName:"p",href:"https://sern-handler.js.org/docs/api/enums/CommandType"},"official documentation"),"!"),(0,o.kt)("p",null,"So, lets say you want to make a command module that listens to modals. "),(0,o.kt)("p",null,(0,o.kt)("strong",{parentName:"p"},"Note"),": Keep in mind you'll need to send a modal with a custom id ",(0,o.kt)("inlineCode",{parentName:"p"},"dm-me"),". This example below is the response to a modal being sent."),(0,o.kt)("br",null),(0,o.kt)("p",null,"Typescript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"import { commandModule, CommandType } from '@sern/handler';\nexport default commandModule({\n name: 'dm-me',\n type: CommandType.Modal,\n async execute (modal) {\n const value = modal.fields.getTextInputValue('message');\n modal.client.users.fetch('182326315813306368').then( u =>\n u.send(value + ` from ${modal.user}`)\n );\n modal.reply( { ephemeral:true, content: 'Sent' })\n }\n});\n")),(0,o.kt)("p",null,"Javascript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},"const { CommandType, commandModule } = require('@sern/handler');\nexports.default = commandModule({\n name: 'dm-me',\n type: CommandType.Modal,\n async execute (modal) {\n const value = modal.fields.getTextInputValue('message');\n modal.client.users.fetch('182326315813306368').then( u =>\n u.send(value + ` from ${modal.user}`)\n );\n modal.reply( { ephemeral:true, content: 'Sent' })\n }\n});\n")),(0,o.kt)("p",null,"Commands are straight forward. Keep in mind, every other property on the commandModule object is\noptional ",(0,o.kt)("strong",{parentName:"p"},"except")," the type and execute function."),(0,o.kt)("h1",{id:"context-class"},"Context class"),(0,o.kt)("p",null,"The provided Context class helps with modules of ",(0,o.kt)("inlineCode",{parentName:"p"},"CommandType.Both")," (A mixture of slash / legacy commands)."),(0,o.kt)("p",null,"The Context class is passed into modules with type :"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"CommandType.Both")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"CommandType.Slash")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"CommandType.Text"))),(0,o.kt)("p",null,"This data structure helps interop between legacy commands and slash commands with ease."),(0,o.kt)("admonition",{type:"note"},(0,o.kt)("p",{parentName:"admonition"},"View the ",(0,o.kt)("a",{parentName:"p",href:"/tr/docs/api/classes/Context"},"docs"))),(0,o.kt)("p",null,"Typescript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"export default commandModule({\n name: 'ping',\n type: CommandType.Both,\n async execute(ctx: Context) {\n await ctx.reply(`pong ${ctx.user}`) \n // .reply is shared between both message and interaction!\n // So is an User object!\n }\n});\n")),(0,o.kt)("p",null,"Javascript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},"exports.default = commandModule({\n name: 'ping',\n type: CommandType.Both,\n async execute(ctx) { //ctx is a Context instance\n await ctx.reply(`pong ${ctx.user}`) \n // .reply is shared between both message and interaction!\n // So is an User object!\n }\n});\n")))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/tr/assets/js/runtime~main.5d8c9c4c.js b/tr/assets/js/runtime~main.109c6671.js similarity index 98% rename from tr/assets/js/runtime~main.5d8c9c4c.js rename to tr/assets/js/runtime~main.109c6671.js index 568c9fd58..1926b07c1 100644 --- a/tr/assets/js/runtime~main.5d8c9c4c.js +++ b/tr/assets/js/runtime~main.109c6671.js @@ -1 +1 @@ -(()=>{"use strict";var e,a,c,f,t,r={},d={};function b(e){var a=d[e];if(void 0!==a)return a.exports;var c=d[e]={id:e,loaded:!1,exports:{}};return r[e].call(c.exports,c,c.exports,b),c.loaded=!0,c.exports}b.m=r,b.c=d,e=[],b.O=(a,c,f,t)=>{if(!c){var r=1/0;for(i=0;i=t)&&Object.keys(b.O).every((e=>b.O[e](c[o])))?c.splice(o--,1):(d=!1,t0&&e[i-1][2]>t;i--)e[i]=e[i-1];e[i]=[c,f,t]},b.n=e=>{var a=e&&e.__esModule?()=>e.default:()=>e;return b.d(a,{a:a}),a},c=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,b.t=function(e,f){if(1&f&&(e=this(e)),8&f)return e;if("object"==typeof e&&e){if(4&f&&e.__esModule)return e;if(16&f&&"function"==typeof e.then)return e}var t=Object.create(null);b.r(t);var r={};a=a||[null,c({}),c([]),c(c)];for(var d=2&f&&e;"object"==typeof d&&!~a.indexOf(d);d=c(d))Object.getOwnPropertyNames(d).forEach((a=>r[a]=()=>e[a]));return r.default=()=>e,b.d(t,r),t},b.d=(e,a)=>{for(var c in a)b.o(a,c)&&!b.o(e,c)&&Object.defineProperty(e,c,{enumerable:!0,get:a[c]})},b.f={},b.e=e=>Promise.all(Object.keys(b.f).reduce(((a,c)=>(b.f[c](e,a),a)),[])),b.u=e=>"assets/js/"+({53:"5bc4ccbc",65:"2f13d849",277:"c4348237",332:"73bd57bd",703:"981f6151",1036:"c0846785",1472:"cf183316",1505:"7c2ff145",2005:"1ac1bfe9",2165:"26739013",2197:"935f2afb",2535:"814f3328",2640:"a96c96b0",2792:"f50fe504",3045:"888566f1",3085:"1f391b9e",3089:"a6aa9e1f",3608:"9e4087bc",4013:"01a85c17",4137:"1aef51bd",4195:"c4f5d8e4",4332:"6c624b4c",4429:"eea0bf40",4803:"9201de17",4865:"e8e3d8c7",4901:"6e015ab1",4918:"c103c7fb",5062:"69369ae2",5397:"312c2bc5",6103:"ccc49370",6146:"608ca171",6270:"e4877132",6322:"a5467962",7127:"7e205c4a",7223:"3020eeee",7306:"f6aebfbf",7363:"26f1f3a5",7374:"6ba1d2c1",7414:"393be207",7597:"5e8c322a",7705:"b40a3c0d",7750:"3a2d3092",7918:"17896441",8610:"6875c492",8652:"bcd9df7e",8938:"59284627",9226:"707baeff",9232:"afe88353",9514:"1be78505",9671:"0e384e19",9712:"3dc7c79a",9881:"f7831d67"}[e]||e)+"."+{53:"c8c690a8",65:"68beeee7",277:"bbd90c09",332:"19c5dc11",703:"20818673",1036:"4d3fd746",1472:"6c579116",1505:"ac336ebd",2005:"32a59ffe",2165:"40911282",2197:"9d45ee3d",2529:"824aaa15",2535:"42a2e7ce",2640:"6512f1aa",2792:"8f14c30e",3045:"cb4f8a25",3085:"8c38cce5",3089:"41e3be1f",3608:"66639242",4013:"e1f6e46d",4137:"aa912fa6",4195:"e4059570",4332:"1b6a4212",4429:"0dfecd80",4803:"a0a46979",4865:"3dbbffa5",4901:"1d9b673d",4918:"e528839c",4972:"8f7e7193",5062:"40f3e7eb",5397:"1cae9e75",6103:"7974c41a",6146:"cd167ef6",6270:"4977513f",6322:"30bc4b53",7127:"9e935aed",7223:"290935e6",7306:"c5c73bc5",7363:"9ba0381e",7374:"b7f5d35f",7414:"28b43cb8",7540:"0456e07a",7597:"605e80f2",7705:"444c45e5",7750:"339afe92",7918:"3625818f",8610:"d7a7cd5d",8652:"78b2f6c4",8938:"8c214108",9226:"06466012",9232:"ea8113c2",9514:"b1e810d5",9671:"f23753e7",9712:"94c26952",9881:"7d34e5c5"}[e]+".js",b.miniCssF=e=>{},b.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),b.o=(e,a)=>Object.prototype.hasOwnProperty.call(e,a),f={},t="@sern/website:",b.l=(e,a,c,r)=>{if(f[e])f[e].push(a);else{var d,o;if(void 0!==c)for(var n=document.getElementsByTagName("script"),i=0;i{d.onerror=d.onload=null,clearTimeout(s);var t=f[e];if(delete f[e],d.parentNode&&d.parentNode.removeChild(d),t&&t.forEach((e=>e(c))),a)return a(c)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:d}),12e4);d.onerror=l.bind(null,d.onerror),d.onload=l.bind(null,d.onload),o&&document.head.appendChild(d)}},b.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},b.p="/tr/",b.gca=function(e){return e={17896441:"7918",26739013:"2165",59284627:"8938","5bc4ccbc":"53","2f13d849":"65",c4348237:"277","73bd57bd":"332","981f6151":"703",c0846785:"1036",cf183316:"1472","7c2ff145":"1505","1ac1bfe9":"2005","935f2afb":"2197","814f3328":"2535",a96c96b0:"2640",f50fe504:"2792","888566f1":"3045","1f391b9e":"3085",a6aa9e1f:"3089","9e4087bc":"3608","01a85c17":"4013","1aef51bd":"4137",c4f5d8e4:"4195","6c624b4c":"4332",eea0bf40:"4429","9201de17":"4803",e8e3d8c7:"4865","6e015ab1":"4901",c103c7fb:"4918","69369ae2":"5062","312c2bc5":"5397",ccc49370:"6103","608ca171":"6146",e4877132:"6270",a5467962:"6322","7e205c4a":"7127","3020eeee":"7223",f6aebfbf:"7306","26f1f3a5":"7363","6ba1d2c1":"7374","393be207":"7414","5e8c322a":"7597",b40a3c0d:"7705","3a2d3092":"7750","6875c492":"8610",bcd9df7e:"8652","707baeff":"9226",afe88353:"9232","1be78505":"9514","0e384e19":"9671","3dc7c79a":"9712",f7831d67:"9881"}[e]||e,b.p+b.u(e)},(()=>{var e={1303:0,532:0};b.f.j=(a,c)=>{var f=b.o(e,a)?e[a]:void 0;if(0!==f)if(f)c.push(f[2]);else if(/^(1303|532)$/.test(a))e[a]=0;else{var t=new Promise(((c,t)=>f=e[a]=[c,t]));c.push(f[2]=t);var r=b.p+b.u(a),d=new Error;b.l(r,(c=>{if(b.o(e,a)&&(0!==(f=e[a])&&(e[a]=void 0),f)){var t=c&&("load"===c.type?"missing":c.type),r=c&&c.target&&c.target.src;d.message="Loading chunk "+a+" failed.\n("+t+": "+r+")",d.name="ChunkLoadError",d.type=t,d.request=r,f[1](d)}}),"chunk-"+a,a)}},b.O.j=a=>0===e[a];var a=(a,c)=>{var f,t,r=c[0],d=c[1],o=c[2],n=0;if(r.some((a=>0!==e[a]))){for(f in d)b.o(d,f)&&(b.m[f]=d[f]);if(o)var i=o(b)}for(a&&a(c);n{"use strict";var e,a,c,f,t,r={},d={};function b(e){var a=d[e];if(void 0!==a)return a.exports;var c=d[e]={id:e,loaded:!1,exports:{}};return r[e].call(c.exports,c,c.exports,b),c.loaded=!0,c.exports}b.m=r,b.c=d,e=[],b.O=(a,c,f,t)=>{if(!c){var r=1/0;for(i=0;i=t)&&Object.keys(b.O).every((e=>b.O[e](c[o])))?c.splice(o--,1):(d=!1,t0&&e[i-1][2]>t;i--)e[i]=e[i-1];e[i]=[c,f,t]},b.n=e=>{var a=e&&e.__esModule?()=>e.default:()=>e;return b.d(a,{a:a}),a},c=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,b.t=function(e,f){if(1&f&&(e=this(e)),8&f)return e;if("object"==typeof e&&e){if(4&f&&e.__esModule)return e;if(16&f&&"function"==typeof e.then)return e}var t=Object.create(null);b.r(t);var r={};a=a||[null,c({}),c([]),c(c)];for(var d=2&f&&e;"object"==typeof d&&!~a.indexOf(d);d=c(d))Object.getOwnPropertyNames(d).forEach((a=>r[a]=()=>e[a]));return r.default=()=>e,b.d(t,r),t},b.d=(e,a)=>{for(var c in a)b.o(a,c)&&!b.o(e,c)&&Object.defineProperty(e,c,{enumerable:!0,get:a[c]})},b.f={},b.e=e=>Promise.all(Object.keys(b.f).reduce(((a,c)=>(b.f[c](e,a),a)),[])),b.u=e=>"assets/js/"+({53:"5bc4ccbc",65:"2f13d849",277:"c4348237",332:"73bd57bd",703:"981f6151",1036:"c0846785",1472:"cf183316",1505:"7c2ff145",2005:"1ac1bfe9",2165:"26739013",2197:"935f2afb",2535:"814f3328",2640:"a96c96b0",2792:"f50fe504",3045:"888566f1",3085:"1f391b9e",3089:"a6aa9e1f",3608:"9e4087bc",4013:"01a85c17",4137:"1aef51bd",4195:"c4f5d8e4",4332:"6c624b4c",4429:"eea0bf40",4803:"9201de17",4865:"e8e3d8c7",4901:"6e015ab1",4918:"c103c7fb",5062:"69369ae2",5397:"312c2bc5",6103:"ccc49370",6146:"608ca171",6270:"e4877132",6322:"a5467962",7127:"7e205c4a",7223:"3020eeee",7306:"f6aebfbf",7363:"26f1f3a5",7374:"6ba1d2c1",7414:"393be207",7597:"5e8c322a",7705:"b40a3c0d",7750:"3a2d3092",7918:"17896441",8610:"6875c492",8652:"bcd9df7e",8938:"59284627",9226:"707baeff",9232:"afe88353",9514:"1be78505",9671:"0e384e19",9712:"3dc7c79a",9881:"f7831d67"}[e]||e)+"."+{53:"c8c690a8",65:"68beeee7",277:"bbd90c09",332:"19c5dc11",703:"08a2ac57",1036:"4d3fd746",1472:"6c579116",1505:"ac336ebd",2005:"32a59ffe",2165:"40911282",2197:"9d45ee3d",2529:"824aaa15",2535:"42a2e7ce",2640:"6512f1aa",2792:"8f14c30e",3045:"cb4f8a25",3085:"8c38cce5",3089:"41e3be1f",3608:"66639242",4013:"e1f6e46d",4137:"aa912fa6",4195:"e4059570",4332:"1b6a4212",4429:"0dfecd80",4803:"a0a46979",4865:"3dbbffa5",4901:"1d9b673d",4918:"e528839c",4972:"8f7e7193",5062:"40f3e7eb",5397:"1cae9e75",6103:"7974c41a",6146:"cd167ef6",6270:"4977513f",6322:"30bc4b53",7127:"9e935aed",7223:"290935e6",7306:"c5c73bc5",7363:"9ba0381e",7374:"b7f5d35f",7414:"28b43cb8",7540:"0456e07a",7597:"605e80f2",7705:"444c45e5",7750:"339afe92",7918:"3625818f",8610:"d7a7cd5d",8652:"78b2f6c4",8938:"8c214108",9226:"06466012",9232:"ea8113c2",9514:"b1e810d5",9671:"f23753e7",9712:"94c26952",9881:"7d34e5c5"}[e]+".js",b.miniCssF=e=>{},b.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),b.o=(e,a)=>Object.prototype.hasOwnProperty.call(e,a),f={},t="@sern/website:",b.l=(e,a,c,r)=>{if(f[e])f[e].push(a);else{var d,o;if(void 0!==c)for(var n=document.getElementsByTagName("script"),i=0;i{d.onerror=d.onload=null,clearTimeout(s);var t=f[e];if(delete f[e],d.parentNode&&d.parentNode.removeChild(d),t&&t.forEach((e=>e(c))),a)return a(c)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:d}),12e4);d.onerror=l.bind(null,d.onerror),d.onload=l.bind(null,d.onload),o&&document.head.appendChild(d)}},b.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},b.p="/tr/",b.gca=function(e){return e={17896441:"7918",26739013:"2165",59284627:"8938","5bc4ccbc":"53","2f13d849":"65",c4348237:"277","73bd57bd":"332","981f6151":"703",c0846785:"1036",cf183316:"1472","7c2ff145":"1505","1ac1bfe9":"2005","935f2afb":"2197","814f3328":"2535",a96c96b0:"2640",f50fe504:"2792","888566f1":"3045","1f391b9e":"3085",a6aa9e1f:"3089","9e4087bc":"3608","01a85c17":"4013","1aef51bd":"4137",c4f5d8e4:"4195","6c624b4c":"4332",eea0bf40:"4429","9201de17":"4803",e8e3d8c7:"4865","6e015ab1":"4901",c103c7fb:"4918","69369ae2":"5062","312c2bc5":"5397",ccc49370:"6103","608ca171":"6146",e4877132:"6270",a5467962:"6322","7e205c4a":"7127","3020eeee":"7223",f6aebfbf:"7306","26f1f3a5":"7363","6ba1d2c1":"7374","393be207":"7414","5e8c322a":"7597",b40a3c0d:"7705","3a2d3092":"7750","6875c492":"8610",bcd9df7e:"8652","707baeff":"9226",afe88353:"9232","1be78505":"9514","0e384e19":"9671","3dc7c79a":"9712",f7831d67:"9881"}[e]||e,b.p+b.u(e)},(()=>{var e={1303:0,532:0};b.f.j=(a,c)=>{var f=b.o(e,a)?e[a]:void 0;if(0!==f)if(f)c.push(f[2]);else if(/^(1303|532)$/.test(a))e[a]=0;else{var t=new Promise(((c,t)=>f=e[a]=[c,t]));c.push(f[2]=t);var r=b.p+b.u(a),d=new Error;b.l(r,(c=>{if(b.o(e,a)&&(0!==(f=e[a])&&(e[a]=void 0),f)){var t=c&&("load"===c.type?"missing":c.type),r=c&&c.target&&c.target.src;d.message="Loading chunk "+a+" failed.\n("+t+": "+r+")",d.name="ChunkLoadError",d.type=t,d.request=r,f[1](d)}}),"chunk-"+a,a)}},b.O.j=a=>0===e[a];var a=(a,c)=>{var f,t,r=c[0],d=c[1],o=c[2],n=0;if(r.some((a=>0!==e[a]))){for(f in d)b.o(d,f)&&(b.m[f]=d[f]);if(o)var i=o(b)}for(a&&a(c);n Blog | sern - Handlers. Redefined. - + @@ -20,7 +20,7 @@ Extend the new CommandExecutabl I believe that you should build your own structures however you might like and customize to your liking. In addition, decorators now unofficially work with modules! Feel free to use TypeScript experimental decorators to augment and customize your classes.

Deprecation Warnings

The next update will bring sern v2 with some important features. Here are some things to watch out for.

Dependencies Update

  • TypeScript has been updated to 4.8.3
  • Discord.js has been upgraded to 14.5
- + \ No newline at end of file diff --git a/tr/blog/1.2.0.html b/tr/blog/1.2.0.html index 8ce5ef989..ec019bc1a 100644 --- a/tr/blog/1.2.0.html +++ b/tr/blog/1.2.0.html @@ -6,7 +6,7 @@ Release 1.2.0 | sern - Handlers. Redefined. - + @@ -17,7 +17,7 @@ Extend the new CommandExec I believe that you should build your own structures however you might like and customize to your liking. In addition, decorators now unofficially work with modules! Feel free to use TypeScript experimental decorators to augment and customize your classes.

Deprecation Warnings

The next update will bring sern v2 with some important features. Here are some things to watch out for.

Dependencies Update

  • TypeScript has been updated to 4.8.3
  • Discord.js has been upgraded to 14.5
- + \ No newline at end of file diff --git a/tr/blog/archive.html b/tr/blog/archive.html index 52b04b868..43a403678 100644 --- a/tr/blog/archive.html +++ b/tr/blog/archive.html @@ -6,13 +6,13 @@ Arşiv | sern - Handlers. Redefined. - + - + \ No newline at end of file diff --git a/tr/blog/getting-started.html b/tr/blog/getting-started.html index dcac64f01..44d354b3e 100644 --- a/tr/blog/getting-started.html +++ b/tr/blog/getting-started.html @@ -6,7 +6,7 @@ How to get started with sern! | sern - Handlers. Redefined. - + @@ -15,7 +15,7 @@ A: Install the publish extension. Little video:

Q: Any snippet VSCode extension?
A: Yeah, just search sern Snippets made by a verified publisher called Sr Izan (haha yeah me funny!)

Q: HEEEELLLPPPP!!!!
A: Hey, don't panic! We're here to help so, join the Discord. We're trying to get to 100 members!

- + \ No newline at end of file diff --git a/tr/blog/tags.html b/tr/blog/tags.html index 92dae7a0f..fb98a4b19 100644 --- a/tr/blog/tags.html +++ b/tr/blog/tags.html @@ -6,13 +6,13 @@ Etiketler | sern - Handlers. Redefined. - +
- + \ No newline at end of file diff --git a/tr/blog/tags/guides.html b/tr/blog/tags/guides.html index 0519cd703..0e6d0713e 100644 --- a/tr/blog/tags/guides.html +++ b/tr/blog/tags/guides.html @@ -6,7 +6,7 @@ "guides" ile etiketlenmiş Bir gönderi | sern - Handlers. Redefined. - + @@ -15,7 +15,7 @@ A: Install the publish extension. Little video:

Q: Any snippet VSCode extension?
A: Yeah, just search sern Snippets made by a verified publisher called Sr Izan (haha yeah me funny!)

Q: HEEEELLLPPPP!!!!
A: Hey, don't panic! We're here to help so, join the Discord. We're trying to get to 100 members!

- + \ No newline at end of file diff --git a/tr/blog/tags/release.html b/tr/blog/tags/release.html index fe041d666..5658b271b 100644 --- a/tr/blog/tags/release.html +++ b/tr/blog/tags/release.html @@ -6,7 +6,7 @@ "release" ile etiketlenmiş Bir gönderi | sern - Handlers. Redefined. - + @@ -17,7 +17,7 @@ Extend the new Comman I believe that you should build your own structures however you might like and customize to your liking. In addition, decorators now unofficially work with modules! Feel free to use TypeScript experimental decorators to augment and customize your classes.

Deprecation Warnings

The next update will bring sern v2 with some important features. Here are some things to watch out for.

Dependencies Update

  • TypeScript has been updated to 4.8.3
  • Discord.js has been upgraded to 14.5
- + \ No newline at end of file diff --git a/tr/docs/api.html b/tr/docs/api.html index 41f038d8f..387c70ee7 100644 --- a/tr/docs/api.html +++ b/tr/docs/api.html @@ -6,13 +6,13 @@ @sern/handler | sern - Handlers. Redefined. - +

@sern/handler

Handlers. Redefined.

A customizable, batteries-included, powerful discord.js framework to streamline bot development.

NPM versionNPM downloadsLicense MITdocs.rsLines of code

📜 Installation

npm install @sern/handler
yarn add @sern/handler
pnpm add @sern/handler

👀 Quick Look

  • Support for discord.js v14 and all interactions
  • Hybrid commands
  • lightweight and customizable
  • ESM, CommonJS and TypeScript support
  • A powerful cli and awesome community-made plugins

👶 Basic Usage

index.js (CommonJS)

// Import the discord.js Client and GatewayIntentBits
const { Client, GatewayIntentBits } = require('discord.js');

// Import Sern namespace
const { Sern } = require('@sern/handler');

// Our configuration file
const { defaultPrefix, token } = require('./config.json');

const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages
]
});

Sern.init({
client,
defaultPrefix,
commands : 'src/commands',
});

client.login(token);

ping.js (CommonJS)

const { CommandType, commandModule } = require('@sern/handler');

exports.default = commandModule({
name: 'ping',
description: 'A ping pong command',
type: CommandType.Slash,
execute(ctx) {
ctx.reply('pong!');
}
});

See our templates for TypeScript examples and more

💻 CLI

It is highly encouraged to use the command line interface for your project. Don't forget to view it.

👋 Contribute

  • Read our contribution guidelines carefully
  • Pull up on issues and report bugs
  • All kinds of contributions are welcomed.

🚈 Roadmap

You can check our roadmap to see what's going to be added or patched in the future.

- + \ No newline at end of file diff --git a/tr/docs/api/classes/CommandExecutable.html b/tr/docs/api/classes/CommandExecutable.html index 3907aff8e..cf11814e3 100644 --- a/tr/docs/api/classes/CommandExecutable.html +++ b/tr/docs/api/classes/CommandExecutable.html @@ -6,13 +6,13 @@ Class: CommandExecutable<Type> | sern - Handlers. Redefined. - +

Class: CommandExecutable<Type>

Type parameters

NameType
Typeextends CommandType

Constructors

constructor

new CommandExecutable<Type>()

Type parameters

NameType
Typeextends CommandType

Properties

execute

Abstract execute: CommandModuleDefs[Type][``"execute"``]

Defined in

src/handler/sern.ts:132


onEvent

onEvent: EventPlugin<Type>[] = []

Defined in

src/handler/sern.ts:131


plugins

plugins: CommandPlugin<Type>[] = []

Defined in

src/handler/sern.ts:130


type

Abstract type: Type

Defined in

src/handler/sern.ts:129

- + \ No newline at end of file diff --git a/tr/docs/api/classes/Context.html b/tr/docs/api/classes/Context.html index 27116b57c..80a602659 100644 --- a/tr/docs/api/classes/Context.html +++ b/tr/docs/api/classes/Context.html @@ -6,7 +6,7 @@ Class: Context | sern - Handlers. Redefined. - + @@ -17,7 +17,7 @@ CommandType.Text or the event fired in a Both command was Message

Returns

ChatInputCommandInteraction<CacheType>

Defined in

src/handler/structures/context.ts:52


member

get member(): Nullish<GuildMember | APIGuildMember>

Returns

Nullish<GuildMember | APIGuildMember>

Defined in

src/handler/structures/context.ts:101


message

get message(): Message<boolean>

Getting the Message object. Crashes if module type is CommandType.Slash or the event fired in a Both command was ChatInputCommandInteraction

Returns

Message<boolean>

Defined in

src/handler/structures/context.ts:44


user

get user(): User

Returns

User

Defined in

src/handler/structures/context.ts:70

Methods

isEmpty

isEmpty(): boolean

Returns

boolean

Defined in

src/handler/structures/context.ts:129


reply

reply(content): Promise<Message<boolean>>

Parameters

NameType
contentReplyOptions

Returns

Promise<Message<boolean>>

Defined in

src/handler/structures/context.ts:133


wrap

Static wrap(wrappable): Context

Parameters

NameType
wrappableMessage<boolean> | ChatInputCommandInteraction<CacheType>

Returns

Context

Defined in

src/handler/structures/context.ts:122

- + \ No newline at end of file diff --git a/tr/docs/api/classes/EventExecutable.html b/tr/docs/api/classes/EventExecutable.html index b9a86bba3..e6d05471b 100644 --- a/tr/docs/api/classes/EventExecutable.html +++ b/tr/docs/api/classes/EventExecutable.html @@ -6,13 +6,13 @@ Class: EventExecutable<Type> | sern - Handlers. Redefined. - +

Class: EventExecutable<Type>

Type parameters

NameType
Typeextends EventType

Constructors

constructor

new EventExecutable<Type>()

Type parameters

NameType
Typeextends EventType

Properties

execute

Abstract execute: EventModuleDefs[Type][``"execute"``]

Defined in

src/handler/sern.ts:139


onEvent

onEvent: EventModuleEventPluginDefs[Type][] = []

Defined in

src/handler/sern.ts:138


plugins

plugins: EventModuleCommandPluginDefs[Type][] = []

Defined in

src/handler/sern.ts:137


type

Abstract type: Type

Defined in

src/handler/sern.ts:136

- + \ No newline at end of file diff --git a/tr/docs/api/classes/SernEmitter.html b/tr/docs/api/classes/SernEmitter.html index 1e810cea1..fe518a83a 100644 --- a/tr/docs/api/classes/SernEmitter.html +++ b/tr/docs/api/classes/SernEmitter.html @@ -6,7 +6,7 @@ Class: SernEmitter | sern - Handlers. Redefined. - + @@ -50,7 +50,7 @@ given event.

This method is intentionally generic and works with the web p semantics and does not listen to the 'error' event.

const { once, EventEmitter } = require('events');

async function run() {
const ee = new EventEmitter();

process.nextTick(() => {
ee.emit('myevent', 42);
});

const [value] = await once(ee, 'myevent');
console.log(value);

const err = new Error('kaboom');
process.nextTick(() => {
ee.emit('error', err);
});

try {
await once(ee, 'myevent');
} catch (err) {
console.log('error happened', err);
}
}

run();

The special handling of the 'error' event is only used when events.once()is used to wait for another event. If events.once() is used to wait for the 'error' event itself, then it is treated as any other kind of event without special handling:

const { EventEmitter, once } = require('events');

const ee = new EventEmitter();

once(ee, 'error')
.then(([err]) => console.log('ok', err.message))
.catch((err) => console.log('error', err.message));

ee.emit('error', new Error('boom'));

// Prints: ok boom

An AbortSignal can be used to cancel waiting for the event:

const { EventEmitter, once } = require('events');

const ee = new EventEmitter();
const ac = new AbortController();

async function foo(emitter, event, signal) {
try {
await once(emitter, event, { signal });
console.log('event emitted!');
} catch (error) {
if (error.name === 'AbortError') {
console.error('Waiting for the event was canceled!');
} else {
console.error('There was an error', error.message);
}
}
}

foo(ee, 'foo', ac.signal);
ac.abort(); // Abort waiting for the event
ee.emit('foo'); // Prints: Waiting for the event was canceled!

Since

v11.13.0, v10.16.0

Parameters

NameType
emitterNodeEventTarget
eventNamestring | symbol
options?StaticEventEmitterOptions

Returns

Promise<any[]>

Inherited from

EventEmitter.once

Defined in

node_modules/@types/node/events.d.ts:157

Static once(emitter, eventName, options?): Promise<any[]>

Parameters

NameType
emitterDOMEventTarget
eventNamestring
options?StaticEventEmitterOptions

Returns

Promise<any[]>

Inherited from

EventEmitter.once

Defined in

node_modules/@types/node/events.d.ts:158

Static once<K>(eventEmitter, eventName): Promise<ClientEvents[K]>

Type parameters

NameType
Kextends keyof ClientEvents

Parameters

NameType
eventEmitterClient<boolean>
eventNameK

Returns

Promise<ClientEvents[K]>

Inherited from

EventEmitter.once

Defined in

node_modules/discord.js/typings/index.d.ts:196


setMaxListeners

Static setMaxListeners(n?, ...eventTargets): void

const {
setMaxListeners,
EventEmitter
} = require('events');

const target = new EventTarget();
const emitter = new EventEmitter();

setMaxListeners(5, target, emitter);

Since

v15.4.0

Parameters

NameTypeDescription
n?numberA non-negative number. The maximum number of listeners per EventTarget event.
...eventTargets(EventEmitter | DOMEventTarget)[]-

Returns

void

Inherited from

EventEmitter.setMaxListeners

Defined in

node_modules/@types/node/events.d.ts:280

- + \ No newline at end of file diff --git a/tr/docs/api/enums/CommandType.html b/tr/docs/api/enums/CommandType.html index c578d35fc..b9e90fe96 100644 --- a/tr/docs/api/enums/CommandType.html +++ b/tr/docs/api/enums/CommandType.html @@ -6,13 +6,13 @@ Enumeration: CommandType | sern - Handlers. Redefined. - +

Enumeration: CommandType

Example

export default commandModule({
type : CommandType.Text,
name : 'a text command'
execute(message) {
console.log(message.content)
}
})

Enumeration Members

Both

Both = 3

The CommandType for hybrid commands, text and slash

Defined in

src/handler/structures/enums.ts:27


Button

Button = 16

The CommandType for ButtonInteraction commands

Defined in

src/handler/structures/enums.ts:39


MenuMsg = 8

The CommandType for MessageContextMenuInteraction commands

Defined in

src/handler/structures/enums.ts:35


MenuSelect = 32

The CommandType for SelectMenuInteraction commands

Defined in

src/handler/structures/enums.ts:43


MenuUser = 4

The CommandType for UserContextMenuInteraction commands

Defined in

src/handler/structures/enums.ts:31


Modal = 64

The CommandType for ModalSubmitInteraction commands

Defined in

src/handler/structures/enums.ts:47


Slash

Slash = 2

The CommandType for slash commands

Defined in

src/handler/structures/enums.ts:23


Text

Text = 1

The CommandType for text commands

Defined in

src/handler/structures/enums.ts:19

- + \ No newline at end of file diff --git a/tr/docs/api/enums/EventType.html b/tr/docs/api/enums/EventType.html index a02dc2f14..b63b891c1 100644 --- a/tr/docs/api/enums/EventType.html +++ b/tr/docs/api/enums/EventType.html @@ -6,14 +6,14 @@ Enumeration: EventType | sern - Handlers. Redefined. - +

Enumeration: EventType

Example

export default eventModule({
type : EventType.Discord,
name : 'guildMemberAdd'
execute(member : GuildMember) {
console.log(member)
}
})

Enumeration Members

Discord

Discord = 1

The EventType for handling discord events

Defined in

src/handler/structures/enums.ts:68


External

External = 3

The EventType for handling external events. Could be for example, process events, database events

Defined in

src/handler/structures/enums.ts:77


Sern

Sern = 2

The EventType for handling sern events

Defined in

src/handler/structures/enums.ts:72

- + \ No newline at end of file diff --git a/tr/docs/api/enums/PayloadType.html b/tr/docs/api/enums/PayloadType.html index 894cd1cff..aac963c5a 100644 --- a/tr/docs/api/enums/PayloadType.html +++ b/tr/docs/api/enums/PayloadType.html @@ -6,13 +6,13 @@ Enumeration: PayloadType | sern - Handlers. Redefined. - +
- + \ No newline at end of file diff --git a/tr/docs/api/enums/PluginType.html b/tr/docs/api/enums/PluginType.html index 3f6fa8f88..0593643b2 100644 --- a/tr/docs/api/enums/PluginType.html +++ b/tr/docs/api/enums/PluginType.html @@ -6,13 +6,13 @@ Enumeration: PluginType | sern - Handlers. Redefined. - +

Enumeration: PluginType

Example

export default function myPlugin() : EventPlugin<CommandType.Text> {
type : PluginType.Event,
execute([ctx, args], controller) {
return controller.next();
}
}

Enumeration Members

Command

Command = 1

The PluginType for CommandPlugins

Defined in

src/handler/structures/enums.ts:97


Event

Event = 2

The PluginType for EventPlugins

Defined in

src/handler/structures/enums.ts:101

- + \ No newline at end of file diff --git a/tr/docs/api/interfaces/Controller.html b/tr/docs/api/interfaces/Controller.html index 864438f20..aa2f43c52 100644 --- a/tr/docs/api/interfaces/Controller.html +++ b/tr/docs/api/interfaces/Controller.html @@ -6,13 +6,13 @@ Interface: Controller | sern - Handlers. Redefined. - +
- + \ No newline at end of file diff --git a/tr/docs/api/interfaces/Wrapper.html b/tr/docs/api/interfaces/Wrapper.html index 7e608db4e..d9c79f083 100644 --- a/tr/docs/api/interfaces/Wrapper.html +++ b/tr/docs/api/interfaces/Wrapper.html @@ -6,13 +6,13 @@ Interface: Wrapper | sern - Handlers. Redefined. - +

Interface: Wrapper

An object to be passed into Sern#init() function.

Properties

client

Readonly client: Client<boolean>

Defined in

src/handler/structures/wrapper.ts:11


commands

Readonly commands: string

Defined in

src/handler/structures/wrapper.ts:15


defaultPrefix

Optional Readonly defaultPrefix: string

Defined in

src/handler/structures/wrapper.ts:14


events

Optional Readonly events: string | { absPath: string ; mod: EventModule }[] | () => { absPath: string ; mod: EventModule }[]

Defined in

src/handler/structures/wrapper.ts:16


sernEmitter

Optional Readonly sernEmitter: SernEmitter

Defined in

src/handler/structures/wrapper.ts:13

- + \ No newline at end of file diff --git a/tr/docs/api/modules.html b/tr/docs/api/modules.html index 094ea9627..31f1eebc9 100644 --- a/tr/docs/api/modules.html +++ b/tr/docs/api/modules.html @@ -6,7 +6,7 @@ @sern/handler | sern - Handlers. Redefined. - + @@ -14,7 +14,7 @@

@sern/handler

Namespaces

Enumerations

Classes

Interfaces

Type Aliases

Args

Ƭ Args: ParseType<{ slash: SlashOptions ; text: string[] }>

Defined in

src/types/handler.ts:12


AutocompletePlugin

Ƭ AutocompletePlugin: Override<BaseModule, { execute: (autocmp: AutocompleteInteraction, controlller: Controller) => Awaitable<Result<void, void>> ; type: Event }>

Defined in

src/handler/plugins/plugin.ts:92


BaseOptions

Ƭ BaseOptions: ApplicationCommandChoicesData | ApplicationCommandNonOptionsData | ApplicationCommandChannelOptionData | ApplicationCommandNumericOptionData | ApplicationCommandAttachmentOption | SernAutocompleteData

Type that replaces autocomplete with SernAutocompleteData

Defined in

src/handler/structures/module.ts:181


BothCommand

Ƭ BothCommand: Override<BaseModule, { alias?: string[] ; execute: (ctx: Context, args: Args) => Awaitable<void | unknown> ; onEvent: EventPlugin<Both>[] ; options?: SernOptionsData[] ; plugins: CommandPlugin[] ; type: Both }>

Defined in

src/handler/structures/module.ts:55


CommandModuleNoPlugins

Ƭ CommandModuleNoPlugins: { [T in CommandType]: Omit<CommandModuleDefs[T], "plugins" | "onEvent"> }

Defined in

src/handler/plugins/plugin.ts:145


CommandModulePlugin

Ƭ CommandModulePlugin<T>: EventPlugin<T> | CommandPlugin<T>

Type parameters

NameType
Textends CommandType

Defined in

src/handler/plugins/plugin.ts:173


CommandPlugin

Ƭ CommandPlugin<T>: { [K in T]: Override<BasePlugin, Object> }[T]

Type parameters

NameType
Textends keyof CommandModuleDefs = keyof CommandModuleDefs

Defined in

src/handler/plugins/plugin.ts:40


DefinedCommandModule

Ƭ DefinedCommandModule: DefinitelyDefined<CommandModule, "name" | "description">

Defined in

src/types/handler.ts:43


DefinedEventModule

Ƭ DefinedEventModule: DefinitelyDefined<EventModule, "name" | "description">

Defined in

src/types/handler.ts:44


DefinedModule

Ƭ DefinedModule: DefinitelyDefined<Module, "name" | "description">

After modules are transformed, name and description are given default values if none are provided to Module. This type represents that transformation

Defined in

src/types/handler.ts:42


DefinitelyDefined

Ƭ DefinitelyDefined<T, K>: { [L in K]-?: T[L] extends Record<string, unknown> ? DefinitelyDefined<T[L], keyof T[L]> : Required<T>[L] } & T

Type parameters

NameType
TT
Kextends keyof T = keyof T

Defined in

src/types/handler.ts:19


DiscordEmitterPlugin

Ƭ DiscordEmitterPlugin: Override<BasePlugin, { execute: (wrapper: Client, module: DefinitelyDefined<DiscordEventCommand, "name" | "description">, controller: Controller) => Awaitable<Result<void, void>> ; type: Command }>

Defined in

src/handler/plugins/plugin.ts:57


DiscordEventPlugin

Ƭ DiscordEventPlugin<T>: Override<BasePlugin, { execute: (args: ClientEvents[T], controller: Controller) => Awaitable<Result<void, void>> ; name?: T ; type: Event }>

Type parameters

NameType
Textends keyof ClientEvents = keyof ClientEvents

Defined in

src/handler/plugins/plugin.ts:136


EventInput

Ƭ EventInput: string | { absPath: string ; mod: EventModule }[] | () => { absPath: string ; mod: EventModule }[]

Defined in

src/types/handler.ts:25


EventModuleCommandPluginDefs

Ƭ EventModuleCommandPluginDefs: Object

Event Module Command Plugins

Type declaration

NameType
1DiscordEmitterPlugin
2SernEmitterPlugin
3ExternalEmitterPlugin

Defined in

src/handler/plugins/plugin.ts:163


EventModuleEventPluginDefs

Ƭ EventModuleEventPluginDefs: Object

Event Module Event Plugins

Type declaration

NameType
1DiscordEventPlugin
2SernEventPlugin
3ExternalEventPlugin

Defined in

src/handler/plugins/plugin.ts:154


EventModulePlugin

Ƭ EventModulePlugin<T>: EventModuleEventPluginDefs[T] | EventModuleCommandPluginDefs[T]

Type parameters

NameType
Textends EventType

Defined in

src/handler/plugins/plugin.ts:169


EventModulesNoPlugins

Ƭ EventModulesNoPlugins: { [T in EventType]: Omit<EventModuleDefs[T], "plugins" | "onEvent"> }

Defined in

src/handler/plugins/plugin.ts:148


EventPlugin

Ƭ EventPlugin<T>: { [K in T]: Override<BasePlugin, Object> }[T]

Type parameters

NameType
Textends keyof CommandModuleDefs = keyof CommandModuleDefs

Defined in

src/handler/plugins/plugin.ts:103


ExternalEmitterPlugin

Ƭ ExternalEmitterPlugin<T>: Override<BasePlugin, { execute: (wrapper: T, module: DefinitelyDefined<ExternalEventCommand, "name" | "description">, controller: Controller) => Awaitable<Result<void, void>> ; type: Command }>

Type parameters

NameType
Textends EventEmitter = EventEmitter

Defined in

src/handler/plugins/plugin.ts:68


ExternalEventPlugin

Ƭ ExternalEventPlugin: Override<BasePlugin, { execute: (args: unknown[], controller: Controller) => Awaitable<Result<void, void>> ; type: Event }>

Defined in

src/handler/plugins/plugin.ts:128


InputCommandModule

Ƭ InputCommandModule: { [T in CommandType]: CommandModuleNoPlugins[T] & Object }[CommandType]

User inputs this type. Sern processes behind the scenes for better usage

Defined in

src/handler/plugins/plugin.ts:178


InputEventModule

Ƭ InputEventModule: { [T in EventType]: EventModulesNoPlugins[T] & Object }[EventType]

Defined in

src/handler/plugins/plugin.ts:182


Module

Ƭ Module: CommandModule | EventModule

Defined in

src/handler/structures/module.ts:141


Nullish

Ƭ Nullish<T>: T | undefined | null

Type parameters

Name
T

Defined in

src/types/handler.ts:5


Override

Ƭ Override<T1, T2>: Omit<T1, keyof T2> & T2

Type parameters

Name
T1
T2

Defined in

src/types/handler.ts:17


ParseType

Ƭ ParseType<T>: { [K in keyof T]: T[K] extends unknown ? [k: K, args: T[K]] : never }[keyof T]

Type parameters

Name
T

Defined in

src/types/handler.ts:8


Payload

Ƭ Payload: { module: Module ; type: Success } | { module?: Module ; reason: string | Error ; type: Failure }

Defined in

src/types/handler.ts:45


ReplyOptions

Ƭ ReplyOptions: string | Omit<InteractionReplyOptions, "fetchReply"> | MessageReplyOptions

Defined in

src/types/handler.ts:55


SernAutocompleteData

Ƭ SernAutocompleteData: Override<BaseApplicationCommandOptionsData, { autocomplete: true ; command: AutocompleteCommand ; type: ApplicationCommandOptionType.String | ApplicationCommandOptionType.Number | ApplicationCommandOptionType.Integer }>

Defined in

src/handler/structures/module.ts:166


SernEmitterPlugin

Ƭ SernEmitterPlugin: Override<BasePlugin, { execute: (wrapper: SernEmitter, module: DefinitelyDefined<SernEventCommand, "name" | "description">, controller: Controller) => Awaitable<Result<void, void>> ; type: Command }>

Defined in

src/handler/plugins/plugin.ts:80


SernEventPlugin

Ƭ SernEventPlugin<T>: Override<BasePlugin, { execute: (args: SernEventsMapping[T], controller: Controller) => Awaitable<Result<void, void>> ; name?: T ; type: Event }>

Type parameters

NameType
Textends keyof SernEventsMapping = keyof SernEventsMapping

Defined in

src/handler/plugins/plugin.ts:116


SernEventsMapping

Ƭ SernEventsMapping: Object

Type declaration

NameType
error[Payload]
module.activate[Payload]
module.register[Payload]
warning[string]

Defined in

src/types/handler.ts:48


SernOptionsData

Ƭ SernOptionsData<U>: U extends ApplicationCommandSubCommandData ? SernSubCommandData : U extends ApplicationCommandSubGroupData ? SernSubCommandGroupData : BaseOptions

Type parameters

NameType
Uextends ApplicationCommandOptionData = ApplicationCommandOptionData

Defined in

src/handler/structures/module.ts:205


SernSubCommandData

Ƭ SernSubCommandData: Override<Omit<BaseApplicationCommandOptionsData, "required">, { options?: BaseOptions[] ; type: ApplicationCommandOptionType.Subcommand }>

Defined in

src/handler/structures/module.ts:189


SernSubCommandGroupData

Ƭ SernSubCommandGroupData: Override<Omit<BaseApplicationCommandOptionsData, "required">, { options?: SernSubCommandData[] ; type: ApplicationCommandOptionType.SubcommandGroup }>

Defined in

src/handler/structures/module.ts:197


SlashCommand

Ƭ SlashCommand: Override<BaseModule, { execute: (ctx: Context, args: ["slash", SlashOptions]) => Awaitable<void | unknown> ; onEvent: EventPlugin<Slash>[] ; options?: SernOptionsData[] ; plugins: CommandPlugin[] ; type: Slash }>

Defined in

src/handler/structures/module.ts:44


SlashOptions

Ƭ SlashOptions: Omit<CommandInteractionOptionResolver, "getMessage" | "getFocused">

Defined in

src/types/handler.ts:14


SpreadParams

Ƭ SpreadParams<T>: (args: Parameters<T>[number]) => unknown

Type parameters

NameType
Textends (...args: never) => unknown

Type declaration

▸ (args): unknown

Turns a function with a union of array of args into a single union [ T , V , B ] | [ A ] => T | V | B | A

Parameters
NameType
argsParameters<T>[number]
Returns

unknown

Defined in

src/types/handler.ts:34


TextCommand

Ƭ TextCommand: Override<BaseModule, { alias?: string[] ; execute: (ctx: Context, args: ["text", string[]]) => Awaitable<void | unknown> ; onEvent: EventPlugin<Text>[] ; plugins: CommandPlugin[] ; type: Text }>

Defined in

src/handler/structures/module.ts:33

Functions

commandModule

commandModule(mod): CommandModule

The wrapper function to define command modules for sern

Parameters

NameType
modInputCommandModule

Returns

CommandModule

Defined in

src/handler/sern.ts:91


eventModule

eventModule(mod): EventModule

The wrapper function to define event modules for sern

Parameters

NameType
modInputEventModule

Returns

EventModule

Defined in

src/handler/sern.ts:112

- + \ No newline at end of file diff --git a/tr/docs/api/namespaces/Sern.html b/tr/docs/api/namespaces/Sern.html index 5644226f9..19059c283 100644 --- a/tr/docs/api/namespaces/Sern.html +++ b/tr/docs/api/namespaces/Sern.html @@ -6,13 +6,13 @@ Namespace: Sern | sern - Handlers. Redefined. - +

Namespace: Sern

References

CommandExecutable

Re-exports CommandExecutable


EventExecutable

Re-exports EventExecutable


commandModule

Re-exports commandModule


eventModule

Re-exports eventModule

Variables

controller

Const controller: Object

The object passed into every plugin to control a command's behavior

Type declaration

NameType
next() => OkImpl<void>
stop() => ErrImpl<void>

Defined in

src/handler/sern.ts:82

Functions

addExternal

addExternal<T>(emitter): void

Deprecated

  • use Sern#makeDependencies instead

Example

src/index.ts
//Add this before initiating Sern!
Sern.addExternal(new Level())

Example

events/level.ts
 export default eventModule({
emitter: 'Level',
type : EventType.External,
name: 'error',
execute(args) {
console.log(args)
}
})

Type parameters

NameType
Textends __module

Parameters

NameTypeDescription
emitterTAny external event emitter. The object will be stored in a map, and then fetched by the name of the instance's class. As there are infinite possibilities to adding external event emitters, Most types aren't provided and are as narrow as possibly can.

Returns

void

Defined in

src/handler/sern.ts:72


init

init(wrapper): void

Example

src/index.ts
Sern.init({
client,
defaultPrefix: '!',
commands: 'dist/commands',
})

Parameters

NameTypeDescription
wrapperWrapperOptions to pass into sern. Function to start the handler up

Returns

void

Defined in

src/handler/sern.ts:39

- + \ No newline at end of file diff --git a/tr/docs/guide.html b/tr/docs/guide.html index bac2b9570..c7379d6f7 100644 --- a/tr/docs/guide.html +++ b/tr/docs/guide.html @@ -6,13 +6,13 @@ Introduction | sern - Handlers. Redefined. - +

Introduction

Welcome to our official guide. This guide will go through all the core features of the framework.

  • 💖 Thank you for choosing sern to be your framework!

  • Teaching the discord.js library and / or Javascript / Typescript is out of scope of this project, so the documentation assumes you already know these elements.

  • discord.js v14 is the only supported library at the moment

You will learn

Working with plugins

Events

Good to know

- + \ No newline at end of file diff --git a/tr/docs/guide/getting-started/choose-ide.html b/tr/docs/guide/getting-started/choose-ide.html index 816960fda..89dc14889 100644 --- a/tr/docs/guide/getting-started/choose-ide.html +++ b/tr/docs/guide/getting-started/choose-ide.html @@ -6,14 +6,14 @@ Choosing an IDE | sern - Handlers. Redefined. - +
- + \ No newline at end of file diff --git a/tr/docs/guide/getting-started/preparing.html b/tr/docs/guide/getting-started/preparing.html index 7edd474e7..5e0bcb15f 100644 --- a/tr/docs/guide/getting-started/preparing.html +++ b/tr/docs/guide/getting-started/preparing.html @@ -6,13 +6,13 @@ Preparing to Code | sern - Handlers. Redefined. - +

Preparing to Code

After installing and IDE you need to install node.

You can download the LTS version of node right here

- + \ No newline at end of file diff --git a/tr/docs/guide/walkthrough/cli.html b/tr/docs/guide/walkthrough/cli.html index 642e82cea..396f0cc46 100644 --- a/tr/docs/guide/walkthrough/cli.html +++ b/tr/docs/guide/walkthrough/cli.html @@ -6,7 +6,7 @@ CLI | sern - Handlers. Redefined. - + @@ -14,7 +14,7 @@

CLI

Setting up the CLI is easy.

  • To start a brand-new project, run :
sern init (-y)
tip

It creates a directory for you so you don't need to!

Include the -y flag if you want to set up defaults. The default langauge is Typescript

sern plugins
info

Make sure to have a correct sern.config.json

This will display a menu selection of all installable plugins.
Note: You must have a sern.config.json to use this command. If you want to view plugins, visit the repository linked above.

  • To install extra utilities into your project
sern extra
- + \ No newline at end of file diff --git a/tr/docs/guide/walkthrough/conclusion.html b/tr/docs/guide/walkthrough/conclusion.html index 1ee501fb1..64a3bc634 100644 --- a/tr/docs/guide/walkthrough/conclusion.html +++ b/tr/docs/guide/walkthrough/conclusion.html @@ -6,7 +6,7 @@ Conclusion | sern - Handlers. Redefined. - + @@ -14,7 +14,7 @@

Conclusion

If you reached this far, thank you for reading! We hope you have learned the necessities you need to create a bot with the sern framework. If you have any other questions, bugs, feature requests, concerns, please join our community server, and we'll be glad to answer your questions.

- + \ No newline at end of file diff --git a/tr/docs/guide/walkthrough/first-command.html b/tr/docs/guide/walkthrough/first-command.html index ac6f05b1f..835152f8c 100644 --- a/tr/docs/guide/walkthrough/first-command.html +++ b/tr/docs/guide/walkthrough/first-command.html @@ -6,16 +6,16 @@ First Command | sern - Handlers. Redefined. - +

First Command

We will dissect a basic command. -If you installed a new project via the cli, This is the ping command located in src/commands folder.

Typescript

import { commandModule, CommandType } from '@sern/handler';

export default commandModule({
type: CommandType.Both,
plugins: [],
description: 'A ping command',
//alias : [],
execute: async (ctx, args) => {
await ctx.reply({ content: 'Pong 🏓' });
},
});

Javascript

const { CommandType, commandModule } = require('@sern/handler');

exports.default = commandModule({
type: CommandType.Both,
plugins: [],
description: 'A ping command',
//alias : [],
execute: async (ctx, args) => {
await ctx.reply('Pong 🏓');
},
})

To view what each of these properties mean in depth, visit the official documentation.

Types of command modules

Every command module type is part of an enum. This field allows type inference for the rest of a module's fields.
+If you installed a new project via the cli, This is the ping command located in src/commands folder.

Typescript

import { commandModule, CommandType } from '@sern/handler';

export default commandModule({
type: CommandType.Both,
plugins: [],
description: 'A ping command',
// alias : [],
execute: async (ctx, args) => {
await ctx.reply({ content: 'Pong 🏓' });
},
});

Javascript

const { CommandType, commandModule } = require('@sern/handler');

exports.default = commandModule({
type: CommandType.Both,
plugins: [],
description: 'A ping command',
// alias : [],
execute: async (ctx, args) => {
await ctx.reply('Pong 🏓');
},
})

To view what each of these properties mean in depth, visit the official documentation.

Types of command modules

Every command module type is part of an enum. This field allows type inference for the rest of a module's fields.
All the command types can be found in the official documentation!

So, lets say you want to make a command module that listens to modals.

Note: Keep in mind you'll need to send a modal with a custom id dm-me. This example below is the response to a modal being sent.


Typescript:

import { commandModule, CommandType } from '@sern/handler';
export default commandModule({
name: 'dm-me',
type: CommandType.Modal,
async execute (modal) {
const value = modal.fields.getTextInputValue('message');
modal.client.users.fetch('182326315813306368').then( u =>
u.send(value + ` from ${modal.user}`)
);
modal.reply( { ephemeral:true, content: 'Sent' })
}
});

Javascript:

const { CommandType, commandModule } = require('@sern/handler');
exports.default = commandModule({
name: 'dm-me',
type: CommandType.Modal,
async execute (modal) {
const value = modal.fields.getTextInputValue('message');
modal.client.users.fetch('182326315813306368').then( u =>
u.send(value + ` from ${modal.user}`)
);
modal.reply( { ephemeral:true, content: 'Sent' })
}
});

Commands are straight forward. Keep in mind, every other property on the commandModule object is -optional except the type and execute function.

Context class

The provided Context class helps with modules of CommandType.Both (A mixture of slash / legacy commands).

The Context class is passed into modules with type :

  • CommandType.Both
  • CommandType.Slash
  • CommandType.Text

This data structure helps interop between legacy commands and slash commands with ease.

note

View the docs

Typescript:

export default commandModule({
name: 'ping',
type: CommandType.Both,
async execute(ctx: Context) {
await ctx.reply(`pong ${ctx.user}`)
// .reply is shared between both message and interaction!
// So is an User object!
}
});

Javascript:

exports.default = commandModule({
name: 'ping',
type: CommandType.Both,
async execute(ctx) { //ctx is a Context instance
await ctx.reply(`pong ${ctx.user}`)
// .reply is shared between both message and interaction!
// So is an User object!
}
});
- +optional except the type and execute function.

Context class

The provided Context class helps with modules of CommandType.Both (A mixture of slash / legacy commands).

The Context class is passed into modules with type:

  • CommandType.Both
  • CommandType.Slash
  • CommandType.Text

This data structure helps interop between legacy commands and slash commands with ease.

note

View the docs

Typescript:

export default commandModule({
name: 'ping',
type: CommandType.Both,
async execute(ctx: Context) {
await ctx.reply(`pong ${ctx.user}`)
// .reply is shared between both message and interaction!
// So is an User object!
}
});

Javascript:

exports.default = commandModule({
name: 'ping',
type: CommandType.Both,
async execute(ctx) { //ctx is a Context instance
await ctx.reply(`pong ${ctx.user}`)
// .reply is shared between both message and interaction!
// So is an User object!
}
});
+ \ No newline at end of file diff --git a/tr/docs/guide/walkthrough/first-event.html b/tr/docs/guide/walkthrough/first-event.html index 5669322bc..c60f212c7 100644 --- a/tr/docs/guide/walkthrough/first-event.html +++ b/tr/docs/guide/walkthrough/first-event.html @@ -6,7 +6,7 @@ First Event Module | sern - Handlers. Redefined. - + @@ -14,7 +14,7 @@

First Event Module

We will dissect a basic event module.
Typescript:

export default eventModule({
type: EventType.Sern,
plugins : [], //NOT SUPPORTED YET!!
name: 'module.activate', //name of event.
execute(event) {
console.log(event);
}
})

Javascript:

exports.default = eventModule({
type: EventType.Sern,
plugins : [], //NOT SUPPORTED YET!!
name: 'module.activate',
execute(event) {
console.log(event);
}
})

Like command modules, the type property denotes what kind of event it is, which can be found here.

To view what each of these properties mean in depth, visit the official documentation.


Event modules are laid out similarly to command modules. These listen to any and all event you provide. In the current version 1.1.0-beta, plugins are not supported.

Another example of an event module

Typescript:

export default eventModule({
type: EventType.Discord,
plugins : [], //NOT SUPPORTED YET!!
name: 'guildMemberAdd', //name of event.
async execute(member: GuildMember) {
(await member.guild.channels.fetch('channel-id') as TextChannel).send(`Welcome, ${member}`);
}
})

Javascript:


exports.default = eventModule({
type: EventType.Discord,
plugins : [], //NOT SUPPORTED YET!!
name: 'guildMemberAdd', //name of event.
async execute(member) {
(await member.guild.channels.fetch('channel-id')).send(`Welcome, ${member}`);
}
})
- + \ No newline at end of file diff --git a/tr/docs/guide/walkthrough/goal.html b/tr/docs/guide/walkthrough/goal.html index 89fab8c33..dfb1d5dd7 100644 --- a/tr/docs/guide/walkthrough/goal.html +++ b/tr/docs/guide/walkthrough/goal.html @@ -6,7 +6,7 @@ Goal | sern - Handlers. Redefined. - + @@ -14,7 +14,7 @@

Goal

sern strives to be minimalist, but with all batteries included. Meaning, this framework provides the necessary tools to start up a bot in minutes, and leaves plenty room space to customize your experience and create an amazing project. It should include all the tools for any bot at any scale.

- + \ No newline at end of file diff --git a/tr/docs/guide/walkthrough/good-to-know.html b/tr/docs/guide/walkthrough/good-to-know.html index e169a96c0..5df3e192b 100644 --- a/tr/docs/guide/walkthrough/good-to-know.html +++ b/tr/docs/guide/walkthrough/good-to-know.html @@ -6,7 +6,7 @@ Good to know | sern - Handlers. Redefined. - + @@ -14,7 +14,7 @@

Good to know

sern.config.json

A sern.config.json, although not necessary, allows your project to communicate with our cli.

For example, when installing typescript plugins, the language property is necessary to install from our open source repository.

Using the cli and running sern init --sync on pre-existing projects should install this json file in the root directory given. Or, if this is a brand-new project, sern init automatically installs it.

{
"language": "typescript",
"paths": {
"base": "src",
"commands": "commands"
}
}
- + \ No newline at end of file diff --git a/tr/docs/guide/walkthrough/plugins.html b/tr/docs/guide/walkthrough/plugins.html index ad3ddb65d..43d348817 100644 --- a/tr/docs/guide/walkthrough/plugins.html +++ b/tr/docs/guide/walkthrough/plugins.html @@ -6,7 +6,7 @@ Plugins | sern - Handlers. Redefined. - + @@ -17,7 +17,7 @@ This controls whether a module is stored into sern.
Typescript:

export function inDir(dir : string) : CommandPlugin<CommandType.Both> {
return {
type: PluginType.Command,
async execute(wrapper, { absPath, module }, controller) {
if(path.dirname(absPath) !== dir) {
console.log(+new Date(), `${module.name} is not in the correct directory!`);
return controller.stop()
}
console.log(+new Date(), `${module.name} is in the correct directory!`);
return controller.next(); //continue
}
}
}

Javascript:

export function inDir(dir : string) {
return {
type: PluginType.Command,
async execute(wrapper, { absPath, module }, controller) {
if(path.dirname(absPath) !== dir) {
console.log(+new Date(), `${module.name} is not in the correct directory!`);
return controller.stop()
}
console.log(+new Date(), `${module.name} is in the correct directory!`);
return controller.next(); //continue
}
}
}

Above, this simple plugin logs that the module has been loaded along with a timestamp.
Again, it is up to you to define plugin logic! The possibilities to customize your bots are endless.

tip

Command Plugins are good for ensuring the shape, location, and preprocessing of your commands.

Event Plugins

event-plugins

  • An event is emitted by discord.js.
  • This event is passed to all plugins (in order!!),
  • If all are successful,

The command is executed. Calling controller.stop() notifies sern that this command should not be run, and this event is ignored.

So, what does a command module look like with plugins?

Typescript:

import { commandModule, CommandType } from '@sern/handler';

export default commandModule({
type: CommandType.Both,
plugins: [
inDir("other"),
serenOnly()
],
description: 'A ping command',
//alias : [],
execute: async (ctx, args) => {
await ctx.reply({ content: 'Pong 🏓' });
},
});

Javascript:

const { commandModule, CommandType } = require('@sern/handler');

exports.default = commandModule({
type: CommandType.Both,
plugins: [
inDir("other"),
serenOnly() //The plugins in this section applied to this module!
],
description: 'A ping command',
//alias : [],
execute: async (ctx, args) => {
await ctx.reply({ content: 'Pong 🏓' });
},
});

Can you predict the behavior of this command?

  • Before loading into sern, this command module will check if this module is in the correct directory other.
  • Before an event occurs, this command module will check if the user has the id 182326315813306368.
tip

Event Plugins are good for filtering, preconditions, parsing.

If all plugins return controller.next(), this command replies Pong 🏓

- + \ No newline at end of file diff --git a/tr/docs/guide/walkthrough/sern-emitter.html b/tr/docs/guide/walkthrough/sern-emitter.html index 19016f7ea..284d2c930 100644 --- a/tr/docs/guide/walkthrough/sern-emitter.html +++ b/tr/docs/guide/walkthrough/sern-emitter.html @@ -6,13 +6,13 @@ The SernEmitter class | sern - Handlers. Redefined. - +

The SernEmitter class

You're shipped with the SernEmitter. This EventEmitter listens to

  • command modules executing and its status, the module.activate event
  • command modules registered and its status, the module.register event
  • any error that occurs, the error event
  • warn events, where it is possible to throw errors

You can put these and other event listeners into event modules!


View all events
- + \ No newline at end of file diff --git a/tr/docs/intro.html b/tr/docs/intro.html index 4ba3596f5..866630509 100644 --- a/tr/docs/intro.html +++ b/tr/docs/intro.html @@ -6,13 +6,13 @@ Welcome! | sern - Handlers. Redefined. - +

Welcome!

Content

  • /docs/api contains autogenerated documentation of our codebase using typedoc
  • /docs/guide contains a basic startup guide and details to get started with sern faster!
tip

This site is open source! Please do contribute if you find any bugs, typos, or sections in need of improvements.

tip

If you have problems, join the discord server here

- + \ No newline at end of file diff --git a/tr/index.html b/tr/index.html index c706429d8..9aa5af4dc 100644 --- a/tr/index.html +++ b/tr/index.html @@ -6,13 +6,13 @@ sern - Handlers. Redefined. | sern - Handlers. Redefined. - +

Handlers. Redefined.

With the support of the community made plugins and a powerful CLI, it's more than just a handler.

sern init
logo

Batteries included

Start or integrate a new project in minutes.

Customizable

Extend or customize with community-based plugins to provide utilities, filters, and more.

Modern

Uses modern and powerful tooling such as swc, tsup, typescript, and rxjs to future-proof and ensure project quality.

- + \ No newline at end of file diff --git a/tr/markdown-page.html b/tr/markdown-page.html index 3aeebca5f..b32399446 100644 --- a/tr/markdown-page.html +++ b/tr/markdown-page.html @@ -6,13 +6,13 @@ Markdown page example | sern - Handlers. Redefined. - +

Markdown page example

You don't need React to write simple standalone pages.

- + \ No newline at end of file diff --git a/tr/plugins.html b/tr/plugins.html index 6e19e24b1..fbbb48641 100644 --- a/tr/plugins.html +++ b/tr/plugins.html @@ -6,13 +6,13 @@ sern - Handlers. Redefined. - +

Coming soon

- + \ No newline at end of file diff --git a/zoho-domain-verification.html b/zoho-domain-verification.html new file mode 100644 index 000000000..fa0f7481c --- /dev/null +++ b/zoho-domain-verification.html @@ -0,0 +1 @@ +46738451 \ No newline at end of file