diff --git a/404.html b/404.html index 015221db5..fd828f2f5 100644 --- a/404.html +++ b/404.html @@ -5,13 +5,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/1ac1bfe9.c3aac910.js b/assets/js/1ac1bfe9.29450634.js similarity index 98% rename from assets/js/1ac1bfe9.c3aac910.js rename to assets/js/1ac1bfe9.29450634.js index 57cbce417..c50b3f4e2 100644 --- a/assets/js/1ac1bfe9.c3aac910.js +++ b/assets/js/1ac1bfe9.29450634.js @@ -1 +1 @@ -"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[5],{3905:(e,n,t)=>{t.d(n,{Zo:()=>p,kt:()=>m});var r=t(7294);function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function a(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function l(e){for(var n=1;n=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var s=r.createContext({}),u=function(e){var n=r.useContext(s),t=n;return e&&(t="function"==typeof e?e(n):l(l({},n),e)),t},p=function(e){var n=u(e.components);return r.createElement(s.Provider,{value:n},e.children)},c={inlineCode:"code",wrapper:function(e){var n=e.children;return r.createElement(r.Fragment,{},n)}},d=r.forwardRef((function(e,n){var t=e.components,o=e.mdxType,a=e.originalType,s=e.parentName,p=i(e,["components","mdxType","originalType","parentName"]),d=u(t),m=o,g=d["".concat(s,".").concat(m)]||d[m]||c[m]||a;return t?r.createElement(g,l(l({ref:n},p),{},{components:t})):r.createElement(g,l({ref:n},p))}));function m(e,n){var t=arguments,o=n&&n.mdxType;if("string"==typeof e||o){var a=t.length,l=new Array(a);l[0]=d;var i={};for(var s in n)hasOwnProperty.call(n,s)&&(i[s]=n[s]);i.originalType=e,i.mdxType="string"==typeof e?e:o,l[1]=i;for(var u=2;u{t.r(n),t.d(n,{assets:()=>s,contentTitle:()=>l,default:()=>c,frontMatter:()=>a,metadata:()=>i,toc:()=>u});var r=t(7462),o=(t(7294),t(3905));const a={sidebar_position:5},l="Plugins",i={unversionedId:"guide/walkthrough/plugins",id:"guide/walkthrough/plugins",title:"Plugins",description:"As of now, modules seem a little underwhelming. It appears that sern doesn't have all the features of a standard handler,",source:"@site/docs/guide/walkthrough/plugins.md",sourceDirName:"guide/walkthrough",slug:"/guide/walkthrough/plugins",permalink:"/docs/guide/walkthrough/plugins",draft:!1,editUrl:"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/guide/walkthrough/plugins.md",tags:[],version:"current",sidebarPosition:5,frontMatter:{sidebar_position:5},sidebar:"tutorialSidebar",previous:{title:"First Event Module",permalink:"/docs/guide/walkthrough/first-event"},next:{title:"The SernEmitter class",permalink:"/docs/guide/walkthrough/sern-emitter"}},s={},u=[{value:"Command Plugins",id:"command-plugins",level:2},{value:"The controller object",id:"the-controller-object",level:3},{value:"Event Plugins",id:"event-plugins",level:2}],p={toc:u};function c(e){let{components:n,...a}=e;return(0,o.kt)("wrapper",(0,r.Z)({},p,a,{components:n,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"plugins"},"Plugins"),(0,o.kt)("p",null,"As of now, modules seem a little underwhelming. It appears that sern doesn't have all the features of a standard handler, which manages permissions, categorizes, cool-downs, publishes application commands, role permissions, etc."),(0,o.kt)("p",null,"Many important parts that manage access and help streamline command creation to make are apparently absent. Below is an example of an event plugin, one of the types of plugins."),(0,o.kt)("p",null,"Typescript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},'export function serenOnly(): EventPlugin {\n return {\n type: PluginType.Event,\n async execute([ctx, args], controller) {\n if (ctx.user.id !== "182326315813306368") {\n await ctx.reply({content: "You cannot use this command"})\n return controller.stop()\n }\n return controller.next();\n }\n }\n}\n')),(0,o.kt)("p",null,"Javascript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},'export function serenOnly() {\n return {\n type: PluginType.Event,\n async execute([ctx, args], controller) {\n if (ctx.user.id !== "182326315813306368") {\n await ctx.reply({content: "You cannot use this command"})\n return controller.stop()\n }\n return controller.next();\n }\n }\n}\n')),(0,o.kt)("br",null)," As part of our extensibility, the plugins feature make sern just as powerful, if not more powerful than standard handlers. Plugins modify and add new behavior to standard modules, extending customizability and implementing automation.",(0,o.kt)("br",null)," At the moment, there are two types of plugins:",(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"Command Plugins"),(0,o.kt)("li",{parentName:"ul"},"Event Plugins")),(0,o.kt)("h2",{id:"command-plugins"},"Command Plugins"),(0,o.kt)("p",null,"All modules are registered into sern's system. With command plugins, you can modify how commands are loaded,\nor do some kind of preprocessing before they are loaded into sern."),(0,o.kt)("h3",{id:"the-controller-object"},"The controller object"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"export interface Controller {\n next: () => Ok;\n stop: () => Err;\n}\n")),(0,o.kt)("p",null,"An instance of the above object is passed into every plugin. ",(0,o.kt)("br",null),"\nThis controls whether a module is stored into sern. ",(0,o.kt)("br",null),"\nTypescript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"export function inDir(dir : string) : CommandPlugin {\n return {\n type: PluginType.Command,\n async execute(wrapper, { absPath, module }, controller) {\n if(path.dirname(absPath) !== dir) {\n console.log(+new Date(), `${module.name} is not in the correct directory!`);\n return controller.stop()\n }\n console.log(+new Date(), `${module.name} is in the correct directory!`);\n return controller.next(); //continue\n }\n }\n}\n")),(0,o.kt)("p",null,"Javascript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},"export function inDir(dir : string) {\n return {\n type: PluginType.Command,\n async execute(wrapper, { absPath, module }, controller) {\n if(path.dirname(absPath) !== dir) {\n console.log(+new Date(), `${module.name} is not in the correct directory!`);\n return controller.stop()\n }\n console.log(+new Date(), `${module.name} is in the correct directory!`);\n return controller.next(); //continue\n }\n }\n}\n")),(0,o.kt)("p",null,"Above, this simple plugin logs that the module has been loaded along with a timestamp. ",(0,o.kt)("br",null),"\nAgain, it is up to ",(0,o.kt)("strong",{parentName:"p"},"you")," to define plugin logic! The possibilities to customize your bots are endless."),(0,o.kt)("admonition",{type:"tip"},(0,o.kt)("p",{parentName:"admonition"},"Command Plugins are good for ensuring the shape, location, and preprocessing of your commands.")),(0,o.kt)("h2",{id:"event-plugins"},"Event Plugins"),(0,o.kt)("p",null,(0,o.kt)("img",{alt:"event-plugins",src:t(1910).Z,width:"542",height:"377"})," ",(0,o.kt)("br",null)),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"An event is emitted by discord.js."),(0,o.kt)("li",{parentName:"ul"},"This event is passed to all plugins (",(0,o.kt)("strong",{parentName:"li"},"in order!!"),"),"),(0,o.kt)("li",{parentName:"ul"},"If all are successful,")),(0,o.kt)("p",null,"The command is executed. Calling ",(0,o.kt)("inlineCode",{parentName:"p"},"controller.stop()")," notifies sern that this command should not be run,\nand this event is ignored."),(0,o.kt)("p",null,"So, what does a command module look like with plugins?"),(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 inDir(\"other\"), \n serenOnly()\n ],\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-typescript"},"const { commandModule, CommandType } = require('@sern/handler');\n\nexports.default = commandModule({\n type: CommandType.Both,\n plugins: [\n inDir(\"other\"), \n serenOnly() //The plugins in this section applied to this module!\n ],\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,"Can you predict the behavior of this command?"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"Before loading into sern, this command module will check if this module is in the correct directory ",(0,o.kt)("inlineCode",{parentName:"li"},"other"),"."),(0,o.kt)("li",{parentName:"ul"},"Before an event occurs, this command module will check if the user has the id ",(0,o.kt)("inlineCode",{parentName:"li"},"182326315813306368"),".")),(0,o.kt)("admonition",{type:"tip"},(0,o.kt)("p",{parentName:"admonition"},"Event Plugins are good for filtering, preconditions, parsing.")),(0,o.kt)("p",null,"If all plugins return ",(0,o.kt)("inlineCode",{parentName:"p"},"controller.next()"),", this command replies ",(0,o.kt)("inlineCode",{parentName:"p"},"Pong \ud83c\udfd3")))}c.isMDXComponent=!0},1910:(e,n,t)=>{t.d(n,{Z:()=>r});const r=t.p+"assets/images/eventplugins.drawio-f22ee78041e60a62a45024f542a2b104.svg"}}]); \ No newline at end of file +"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[5],{3905:(e,n,t)=>{t.d(n,{Zo:()=>p,kt:()=>m});var r=t(7294);function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function a(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function l(e){for(var n=1;n=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var s=r.createContext({}),u=function(e){var n=r.useContext(s),t=n;return e&&(t="function"==typeof e?e(n):l(l({},n),e)),t},p=function(e){var n=u(e.components);return r.createElement(s.Provider,{value:n},e.children)},c={inlineCode:"code",wrapper:function(e){var n=e.children;return r.createElement(r.Fragment,{},n)}},d=r.forwardRef((function(e,n){var t=e.components,o=e.mdxType,a=e.originalType,s=e.parentName,p=i(e,["components","mdxType","originalType","parentName"]),d=u(t),m=o,g=d["".concat(s,".").concat(m)]||d[m]||c[m]||a;return t?r.createElement(g,l(l({ref:n},p),{},{components:t})):r.createElement(g,l({ref:n},p))}));function m(e,n){var t=arguments,o=n&&n.mdxType;if("string"==typeof e||o){var a=t.length,l=new Array(a);l[0]=d;var i={};for(var s in n)hasOwnProperty.call(n,s)&&(i[s]=n[s]);i.originalType=e,i.mdxType="string"==typeof e?e:o,l[1]=i;for(var u=2;u{t.r(n),t.d(n,{assets:()=>s,contentTitle:()=>l,default:()=>c,frontMatter:()=>a,metadata:()=>i,toc:()=>u});var r=t(7462),o=(t(7294),t(3905));const a={sidebar_position:5},l="Plugins",i={unversionedId:"guide/walkthrough/plugins",id:"guide/walkthrough/plugins",title:"Plugins",description:"As of now, modules seem a little underwhelming. It appears that sern doesn't have all the features of a standard handler,",source:"@site/docs/guide/walkthrough/plugins.md",sourceDirName:"guide/walkthrough",slug:"/guide/walkthrough/plugins",permalink:"/docs/guide/walkthrough/plugins",draft:!1,editUrl:"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/guide/walkthrough/plugins.md",tags:[],version:"current",sidebarPosition:5,frontMatter:{sidebar_position:5},sidebar:"tutorialSidebar",previous:{title:"First Event Module",permalink:"/docs/guide/walkthrough/first-event"},next:{title:"The SernEmitter class",permalink:"/docs/guide/walkthrough/sern-emitter"}},s={},u=[{value:"Command Plugins",id:"command-plugins",level:2},{value:"The controller object",id:"the-controller-object",level:3},{value:"Event Plugins",id:"event-plugins",level:2}],p={toc:u};function c(e){let{components:n,...a}=e;return(0,o.kt)("wrapper",(0,r.Z)({},p,a,{components:n,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"plugins"},"Plugins"),(0,o.kt)("p",null,"As of now, modules seem a little underwhelming. It appears that sern doesn't have all the features of a standard handler, which manages permissions, categorizes, cool-downs, publishes application commands, role permissions, etc."),(0,o.kt)("p",null,"Many important parts that manage access and help streamline command creation to make are apparently absent. Below is an example of an event plugin, one of the types of plugins."),(0,o.kt)("p",null,"Typescript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},'export function serenOnly(): EventPlugin {\n return {\n type: PluginType.Event,\n async execute([ctx, args], controller) {\n if (ctx.user.id !== "182326315813306368") {\n await ctx.reply({content: "You cannot use this command"})\n return controller.stop()\n }\n return controller.next();\n }\n }\n}\n')),(0,o.kt)("p",null,"Javascript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},'export function serenOnly() {\n return {\n type: PluginType.Event,\n async execute([ctx, args], controller) {\n if (ctx.user.id !== "182326315813306368") {\n await ctx.reply({content: "You cannot use this command"})\n return controller.stop()\n }\n return controller.next();\n }\n }\n}\n')),(0,o.kt)("br",null)," As part of our extensibility, the plugins feature make sern just as powerful, if not more powerful than standard handlers. Plugins modify and add new behavior to standard modules, extending customizability and implementing automation.",(0,o.kt)("br",null)," At the moment, there are two types of plugins:",(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"Command Plugins"),(0,o.kt)("li",{parentName:"ul"},"Event Plugins")),(0,o.kt)("h2",{id:"command-plugins"},"Command Plugins"),(0,o.kt)("p",null,"All modules are registered into sern's system. With command plugins, you can modify how commands are loaded,\nor do some kind of preprocessing before they are loaded into sern."),(0,o.kt)("h3",{id:"the-controller-object"},"The controller object"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"export interface Controller {\n next: () => Ok;\n stop: () => Err;\n}\n")),(0,o.kt)("p",null,"An instance of the above object is passed into every plugin. ",(0,o.kt)("br",null),"\nThis controls whether a module is stored into sern. ",(0,o.kt)("br",null),"\nTypescript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"export function inDir(dir : string) : CommandPlugin {\n return {\n type: PluginType.Command,\n async execute(wrapper, { absPath, module }, controller) {\n if(path.dirname(absPath) !== dir) {\n console.log(+new Date(), `${module.name} is not in the correct directory!`);\n return controller.stop()\n }\n console.log(+new Date(), `${module.name} is in the correct directory!`);\n return controller.next(); //continue\n }\n }\n}\n")),(0,o.kt)("p",null,"Javascript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},"export function inDir(dir : string) {\n return {\n type: PluginType.Command,\n async execute(wrapper, { absPath, module }, controller) {\n if(path.dirname(absPath) !== dir) {\n console.log(+new Date(), `${module.name} is not in the correct directory!`);\n return controller.stop()\n }\n console.log(+new Date(), `${module.name} is in the correct directory!`);\n return controller.next(); //continue\n }\n }\n}\n")),(0,o.kt)("p",null,"Above, this simple plugin logs that the module has been loaded along with a timestamp. ",(0,o.kt)("br",null),"\nAgain, it is up to ",(0,o.kt)("strong",{parentName:"p"},"you")," to define plugin logic! The possibilities to customize your bots are endless."),(0,o.kt)("admonition",{type:"tip"},(0,o.kt)("p",{parentName:"admonition"},"Command Plugins are good for ensuring the shape, location, and preprocessing of your commands.")),(0,o.kt)("h2",{id:"event-plugins"},"Event Plugins"),(0,o.kt)("p",null,(0,o.kt)("img",{alt:"event-plugins",src:t(6061).Z,width:"542",height:"377"})," ",(0,o.kt)("br",null)),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"An event is emitted by discord.js."),(0,o.kt)("li",{parentName:"ul"},"This event is passed to all plugins (",(0,o.kt)("strong",{parentName:"li"},"in order!!"),"),"),(0,o.kt)("li",{parentName:"ul"},"If all are successful,")),(0,o.kt)("p",null,"The command is executed. Calling ",(0,o.kt)("inlineCode",{parentName:"p"},"controller.stop()")," notifies sern that this command should not be run,\nand this event is ignored."),(0,o.kt)("p",null,"So, what does a command module look like with plugins?"),(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 inDir(\"other\"), \n serenOnly()\n ],\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-typescript"},"const { commandModule, CommandType } = require('@sern/handler');\n\nexports.default = commandModule({\n type: CommandType.Both,\n plugins: [\n inDir(\"other\"), \n serenOnly() //The plugins in this section applied to this module!\n ],\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,"Can you predict the behavior of this command?"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"Before loading into sern, this command module will check if this module is in the correct directory ",(0,o.kt)("inlineCode",{parentName:"li"},"other"),"."),(0,o.kt)("li",{parentName:"ul"},"Before an event occurs, this command module will check if the user has the id ",(0,o.kt)("inlineCode",{parentName:"li"},"182326315813306368"),".")),(0,o.kt)("admonition",{type:"tip"},(0,o.kt)("p",{parentName:"admonition"},"Event Plugins are good for filtering, preconditions, parsing.")),(0,o.kt)("p",null,"If all plugins return ",(0,o.kt)("inlineCode",{parentName:"p"},"controller.next()"),", this command replies ",(0,o.kt)("inlineCode",{parentName:"p"},"Pong \ud83c\udfd3")))}c.isMDXComponent=!0},6061:(e,n,t)=>{t.d(n,{Z:()=>r});const r=t.p+"assets/images/eventplugins.drawio-f22ee78041e60a62a45024f542a2b104.svg"}}]); \ No newline at end of file diff --git a/assets/js/runtime~main.2eafbcd9.js b/assets/js/runtime~main.54351663.js similarity index 98% rename from assets/js/runtime~main.2eafbcd9.js rename to assets/js/runtime~main.54351663.js index e2c6b852f..9661c6fe4 100644 --- a/assets/js/runtime~main.2eafbcd9.js +++ b/assets/js/runtime~main.54351663.js @@ -1 +1 @@ -(()=>{"use strict";var e,t,r,a,f,o={},c={};function n(e){var t=c[e];if(void 0!==t)return t.exports;var r=c[e]={id:e,loaded:!1,exports:{}};return o[e].call(r.exports,r,r.exports,n),r.loaded=!0,r.exports}n.m=o,n.c=c,e=[],n.O=(t,r,a,f)=>{if(!r){var o=1/0;for(i=0;i=f)&&Object.keys(n.O).every((e=>n.O[e](r[d])))?r.splice(d--,1):(c=!1,f0&&e[i-1][2]>f;i--)e[i]=e[i-1];e[i]=[r,a,f]},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,n.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);n.r(f);var o={};t=t||[null,r({}),r([]),r(r)];for(var c=2&a&&e;"object"==typeof c&&!~t.indexOf(c);c=r(c))Object.getOwnPropertyNames(c).forEach((t=>o[t]=()=>e[t]));return o.default=()=>e,n.d(f,o),f},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce(((t,r)=>(n.f[r](e,t),t)),[])),n.u=e=>"assets/js/"+({5:"1ac1bfe9",45:"888566f1",53:"5bc4ccbc",62:"69369ae2",85:"1f391b9e",127:"7e205c4a",137:"1aef51bd",146:"608ca171",195:"c4f5d8e4",197:"935f2afb",226:"707baeff",270:"e4877132",277:"c4348237",306:"f6aebfbf",322:"a5467962",332:"73bd57bd",363:"26f1f3a5",397:"312c2bc5",414:"393be207",429:"eea0bf40",472:"cf183316",514:"1be78505",597:"5e8c322a",640:"a96c96b0",652:"bcd9df7e",671:"0e384e19",703:"981f6151",712:"3dc7c79a",750:"3a2d3092",803:"9201de17",865:"e8e3d8c7",918:"17896441"}[e]||e)+"."+{5:"c3aac910",45:"efdd0a6d",53:"9cf1ed02",62:"1291f58b",85:"d7ab1744",127:"2da4208c",137:"87f8be34",146:"2189cf8e",195:"5e4ab8ce",197:"723ea298",226:"528132fe",270:"e0f6e50e",277:"bbd90c09",306:"98ec2cc1",322:"ad0a4733",332:"261b9526",363:"642e76b9",397:"1f24705a",414:"48b8d064",429:"7176d7bf",472:"bdf11e93",503:"668d49f6",514:"f852ff9f",597:"42a28d05",640:"fea8d1f1",652:"892cfb09",671:"10a24cbf",703:"229dbd75",712:"b1834d5d",750:"e85498fd",803:"5098ec91",865:"c57520fe",918:"15289f85",972:"61be9a41"}[e]+".js",n.miniCssF=e=>{},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a={},f="@sern/website:",n.l=(e,t,r,o)=>{if(a[e])a[e].push(t);else{var c,d;if(void 0!==r)for(var b=document.getElementsByTagName("script"),i=0;i{c.onerror=c.onload=null,clearTimeout(s);var f=a[e];if(delete a[e],c.parentNode&&c.parentNode.removeChild(c),f&&f.forEach((e=>e(r))),t)return t(r)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:c}),12e4);c.onerror=l.bind(null,c.onerror),c.onload=l.bind(null,c.onload),d&&document.head.appendChild(c)}},n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.p="/",n.gca=function(e){return e={17896441:"918","1ac1bfe9":"5","888566f1":"45","5bc4ccbc":"53","69369ae2":"62","1f391b9e":"85","7e205c4a":"127","1aef51bd":"137","608ca171":"146",c4f5d8e4:"195","935f2afb":"197","707baeff":"226",e4877132:"270",c4348237:"277",f6aebfbf:"306",a5467962:"322","73bd57bd":"332","26f1f3a5":"363","312c2bc5":"397","393be207":"414",eea0bf40:"429",cf183316:"472","1be78505":"514","5e8c322a":"597",a96c96b0:"640",bcd9df7e:"652","0e384e19":"671","981f6151":"703","3dc7c79a":"712","3a2d3092":"750","9201de17":"803",e8e3d8c7:"865"}[e]||e,n.p+n.u(e)},(()=>{var e={303:0,532:0};n.f.j=(t,r)=>{var a=n.o(e,t)?e[t]:void 0;if(0!==a)if(a)r.push(a[2]);else if(/^(303|532)$/.test(t))e[t]=0;else{var f=new Promise(((r,f)=>a=e[t]=[r,f]));r.push(a[2]=f);var o=n.p+n.u(t),c=new Error;n.l(o,(r=>{if(n.o(e,t)&&(0!==(a=e[t])&&(e[t]=void 0),a)){var f=r&&("load"===r.type?"missing":r.type),o=r&&r.target&&r.target.src;c.message="Loading chunk "+t+" failed.\n("+f+": "+o+")",c.name="ChunkLoadError",c.type=f,c.request=o,a[1](c)}}),"chunk-"+t,t)}},n.O.j=t=>0===e[t];var t=(t,r)=>{var a,f,o=r[0],c=r[1],d=r[2],b=0;if(o.some((t=>0!==e[t]))){for(a in c)n.o(c,a)&&(n.m[a]=c[a]);if(d)var i=d(n)}for(t&&t(r);b{"use strict";var e,t,r,a,f,o={},c={};function n(e){var t=c[e];if(void 0!==t)return t.exports;var r=c[e]={id:e,loaded:!1,exports:{}};return o[e].call(r.exports,r,r.exports,n),r.loaded=!0,r.exports}n.m=o,n.c=c,e=[],n.O=(t,r,a,f)=>{if(!r){var o=1/0;for(i=0;i=f)&&Object.keys(n.O).every((e=>n.O[e](r[d])))?r.splice(d--,1):(c=!1,f0&&e[i-1][2]>f;i--)e[i]=e[i-1];e[i]=[r,a,f]},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,n.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);n.r(f);var o={};t=t||[null,r({}),r([]),r(r)];for(var c=2&a&&e;"object"==typeof c&&!~t.indexOf(c);c=r(c))Object.getOwnPropertyNames(c).forEach((t=>o[t]=()=>e[t]));return o.default=()=>e,n.d(f,o),f},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce(((t,r)=>(n.f[r](e,t),t)),[])),n.u=e=>"assets/js/"+({5:"1ac1bfe9",45:"888566f1",53:"5bc4ccbc",62:"69369ae2",85:"1f391b9e",127:"7e205c4a",137:"1aef51bd",146:"608ca171",195:"c4f5d8e4",197:"935f2afb",226:"707baeff",270:"e4877132",277:"c4348237",306:"f6aebfbf",322:"a5467962",332:"73bd57bd",363:"26f1f3a5",397:"312c2bc5",414:"393be207",429:"eea0bf40",472:"cf183316",514:"1be78505",597:"5e8c322a",640:"a96c96b0",652:"bcd9df7e",671:"0e384e19",703:"981f6151",712:"3dc7c79a",750:"3a2d3092",803:"9201de17",865:"e8e3d8c7",918:"17896441"}[e]||e)+"."+{5:"29450634",45:"efdd0a6d",53:"9cf1ed02",62:"1291f58b",85:"d7ab1744",127:"2da4208c",137:"87f8be34",146:"2189cf8e",195:"5e4ab8ce",197:"723ea298",226:"528132fe",270:"e0f6e50e",277:"bbd90c09",306:"98ec2cc1",322:"ad0a4733",332:"261b9526",363:"642e76b9",397:"1f24705a",414:"48b8d064",429:"7176d7bf",472:"bdf11e93",503:"668d49f6",514:"f852ff9f",597:"42a28d05",640:"fea8d1f1",652:"892cfb09",671:"10a24cbf",703:"229dbd75",712:"b1834d5d",750:"e85498fd",803:"5098ec91",865:"c57520fe",918:"15289f85",972:"61be9a41"}[e]+".js",n.miniCssF=e=>{},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a={},f="@sern/website:",n.l=(e,t,r,o)=>{if(a[e])a[e].push(t);else{var c,d;if(void 0!==r)for(var b=document.getElementsByTagName("script"),i=0;i{c.onerror=c.onload=null,clearTimeout(s);var f=a[e];if(delete a[e],c.parentNode&&c.parentNode.removeChild(c),f&&f.forEach((e=>e(r))),t)return t(r)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:c}),12e4);c.onerror=l.bind(null,c.onerror),c.onload=l.bind(null,c.onload),d&&document.head.appendChild(c)}},n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.p="/",n.gca=function(e){return e={17896441:"918","1ac1bfe9":"5","888566f1":"45","5bc4ccbc":"53","69369ae2":"62","1f391b9e":"85","7e205c4a":"127","1aef51bd":"137","608ca171":"146",c4f5d8e4:"195","935f2afb":"197","707baeff":"226",e4877132:"270",c4348237:"277",f6aebfbf:"306",a5467962:"322","73bd57bd":"332","26f1f3a5":"363","312c2bc5":"397","393be207":"414",eea0bf40:"429",cf183316:"472","1be78505":"514","5e8c322a":"597",a96c96b0:"640",bcd9df7e:"652","0e384e19":"671","981f6151":"703","3dc7c79a":"712","3a2d3092":"750","9201de17":"803",e8e3d8c7:"865"}[e]||e,n.p+n.u(e)},(()=>{var e={303:0,532:0};n.f.j=(t,r)=>{var a=n.o(e,t)?e[t]:void 0;if(0!==a)if(a)r.push(a[2]);else if(/^(303|532)$/.test(t))e[t]=0;else{var f=new Promise(((r,f)=>a=e[t]=[r,f]));r.push(a[2]=f);var o=n.p+n.u(t),c=new Error;n.l(o,(r=>{if(n.o(e,t)&&(0!==(a=e[t])&&(e[t]=void 0),a)){var f=r&&("load"===r.type?"missing":r.type),o=r&&r.target&&r.target.src;c.message="Loading chunk "+t+" failed.\n("+f+": "+o+")",c.name="ChunkLoadError",c.type=f,c.request=o,a[1](c)}}),"chunk-"+t,t)}},n.O.j=t=>0===e[t];var t=(t,r)=>{var a,f,o=r[0],c=r[1],d=r[2],b=0;if(o.some((t=>0!==e[t]))){for(a in c)n.o(c,a)&&(n.m[a]=c[a]);if(d)var i=d(n)}for(t&&t(r);b @sern/handler | sern - Handlers. Redefined. - +

SernHandler

NPM versionNPM downloads[![License: MIT](https://img.shields.io/badge/License-MIT-blavk.svg)](https://opensource.org/licenses/MIT)

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

Installation

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

Basic Usage

index.js (CommonJS)

const { Client, GatewayIntentBits } = require('discord.js');
const { Sern } = require('@sern/handler');
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 { Sern, CommandType } = require('@sern/handler');

exports.default = {
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/Context.html b/docs/api/classes/Context.html index 1eda0dabf..21c4bdb76 100644 --- a/docs/api/classes/Context.html +++ b/docs/api/classes/Context.html @@ -5,7 +5,7 @@ Class: Context | sern - Handlers. Redefined. - + @@ -16,7 +16,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
contentstring | Omit<InteractionReplyOptions, "fetchReply"> | ReplyMessageOptions

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/SernEmitter.html b/docs/api/classes/SernEmitter.html index 82e72d888..3c6075438 100644 --- a/docs/api/classes/SernEmitter.html +++ b/docs/api/classes/SernEmitter.html @@ -5,7 +5,7 @@ Class: SernEmitter | sern - Handlers. Redefined. - + @@ -49,7 +49,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:194


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 75980497c..8fa493e90 100644 --- a/docs/api/enums/CommandType.html +++ b/docs/api/enums/CommandType.html @@ -5,13 +5,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 c20420017..8eed04456 100644 --- a/docs/api/enums/EventType.html +++ b/docs/api/enums/EventType.html @@ -5,14 +5,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 644ae2e4b..5648ed03d 100644 --- a/docs/api/enums/PayloadType.html +++ b/docs/api/enums/PayloadType.html @@ -5,13 +5,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 7f6eec2ef..68006ea2e 100644 --- a/docs/api/enums/PluginType.html +++ b/docs/api/enums/PluginType.html @@ -5,13 +5,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 eda748ca8..52afa8cf7 100644 --- a/docs/api/interfaces/Controller.html +++ b/docs/api/interfaces/Controller.html @@ -5,13 +5,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 b9db737ad..87579ffb2 100644 --- a/docs/api/interfaces/Wrapper.html +++ b/docs/api/interfaces/Wrapper.html @@ -5,13 +5,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:10


commands

Readonly commands: string

Defined in

src/handler/structures/wrapper.ts:13


defaultPrefix

Optional Readonly defaultPrefix: string

Defined in

src/handler/structures/wrapper.ts:12


events

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

Defined in

src/handler/structures/wrapper.ts:14


sernEmitter

Optional Readonly sernEmitter: SernEmitter

Defined in

src/handler/structures/wrapper.ts:11

- + \ No newline at end of file diff --git a/docs/api/modules.html b/docs/api/modules.html index 416525a27..c17512938 100644 --- a/docs/api/modules.html +++ b/docs/api/modules.html @@ -5,7 +5,7 @@ @sern/handler | sern - Handlers. Redefined. - + @@ -13,7 +13,7 @@

@sern/handler

Namespaces

Enumerations

Classes

Interfaces

Type Aliases

Args

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

Defined in

src/types/handler.ts:11


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:48


DefinedEventModule

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

Defined in

src/types/handler.ts:49


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:47


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:18


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:24


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


IsOptional

Ƭ IsOptional<T>: { [K in keyof T]-?: T[K] extends Required<T>[K] ? false : true }

Type parameters

Name
T

Defined in

src/types/handler.ts:31


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:4


Override

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

Type parameters

Name
T1
T2

Defined in

src/types/handler.ts:16


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:7


Payload

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

Defined in

src/types/handler.ts:50


Reconstruct

Ƭ Reconstruct<T>: T extends Omit<infer O, never> ? O & Reconstruct<O> : T

Type parameters

Name
T

Defined in

src/types/handler.ts:29


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[Error | string]
module.activate[Payload]
module.register[Payload]
warning[string]

Defined in

src/types/handler.ts:53


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:13


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:39


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:86


eventModule

eventModule(mod): EventModule

The wrapper function to define event modules for sern

Parameters

NameType
modInputEventModule

Returns

EventModule

Defined in

src/handler/sern.ts:107

- + \ No newline at end of file diff --git a/docs/api/namespaces/Sern.html b/docs/api/namespaces/Sern.html index e74870bd2..4082bb151 100644 --- a/docs/api/namespaces/Sern.html +++ b/docs/api/namespaces/Sern.html @@ -5,13 +5,13 @@ Namespace: Sern | sern - Handlers. Redefined. - +

Namespace: Sern

References

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:77

Functions

addExternal

addExternal<T>(emitter): void

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:67


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:34

- + \ No newline at end of file diff --git a/docs/guide.html b/docs/guide.html index eea656610..49da6d410 100644 --- a/docs/guide.html +++ b/docs/guide.html @@ -5,13 +5,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 f599c751a..10018c159 100644 --- a/docs/guide/getting-started/choose-ide.html +++ b/docs/guide/getting-started/choose-ide.html @@ -5,14 +5,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 e5dde87e9..2225814ab 100644 --- a/docs/guide/getting-started/preparing.html +++ b/docs/guide/getting-started/preparing.html @@ -5,13 +5,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 f7d7e8e4f..11d8c7da2 100644 --- a/docs/guide/walkthrough/cli.html +++ b/docs/guide/walkthrough/cli.html @@ -5,7 +5,7 @@ CLI | sern - Handlers. Redefined. - + @@ -13,7 +13,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 5b02db802..d08fa7ff5 100644 --- a/docs/guide/walkthrough/conclusion.html +++ b/docs/guide/walkthrough/conclusion.html @@ -5,7 +5,7 @@ Conclusion | sern - Handlers. Redefined. - + @@ -13,7 +13,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 89986059c..5fbda6e16 100644 --- a/docs/guide/walkthrough/first-command.html +++ b/docs/guide/walkthrough/first-command.html @@ -5,7 +5,7 @@ First Command | sern - Handlers. Redefined. - + @@ -14,7 +14,7 @@ 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!
}
});
- + \ No newline at end of file diff --git a/docs/guide/walkthrough/first-event.html b/docs/guide/walkthrough/first-event.html index 07c0d5870..dddf9128e 100644 --- a/docs/guide/walkthrough/first-event.html +++ b/docs/guide/walkthrough/first-event.html @@ -5,7 +5,7 @@ First Event Module | sern - Handlers. Redefined. - + @@ -13,7 +13,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) {
await member.client.channels.fetch('channel-id').send(`Welcome, ${member}`);
}
})

Javascript:


exports.default = eventModule({
type: EventType.Discord,
plugins : [], //NOT SUPPORTED YET!!
name: 'guildMemberAdd', //name of event.
async execute(member) {
await member.client.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 15089a4d2..7a1a6c079 100644 --- a/docs/guide/walkthrough/goal.html +++ b/docs/guide/walkthrough/goal.html @@ -5,7 +5,7 @@ Goal | sern - Handlers. Redefined. - + @@ -13,7 +13,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 6c3041e6e..44af3932a 100644 --- a/docs/guide/walkthrough/good-to-know.html +++ b/docs/guide/walkthrough/good-to-know.html @@ -5,7 +5,7 @@ Good to know | sern - Handlers. Redefined. - + @@ -13,7 +13,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 e5de90a78..139b15ace 100644 --- a/docs/guide/walkthrough/plugins.html +++ b/docs/guide/walkthrough/plugins.html @@ -5,7 +5,7 @@ Plugins | sern - Handlers. Redefined. - + @@ -16,7 +16,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 cd7eb3aa9..ec808542a 100644 --- a/docs/guide/walkthrough/sern-emitter.html +++ b/docs/guide/walkthrough/sern-emitter.html @@ -5,13 +5,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 346d9db61..90744526f 100644 --- a/docs/intro.html +++ b/docs/intro.html @@ -5,13 +5,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.

- + \ No newline at end of file diff --git a/fr/404.html b/fr/404.html index d757521d7..70773f816 100644 --- a/fr/404.html +++ b/fr/404.html @@ -5,13 +5,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/1ac1bfe9.76036e65.js b/fr/assets/js/1ac1bfe9.b0c567c5.js similarity index 98% rename from fr/assets/js/1ac1bfe9.76036e65.js rename to fr/assets/js/1ac1bfe9.b0c567c5.js index f248326c0..ed8218143 100644 --- a/fr/assets/js/1ac1bfe9.76036e65.js +++ b/fr/assets/js/1ac1bfe9.b0c567c5.js @@ -1 +1 @@ -"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[5],{3905:(e,n,t)=>{t.d(n,{Zo:()=>p,kt:()=>m});var r=t(7294);function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function a(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function l(e){for(var n=1;n=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var s=r.createContext({}),u=function(e){var n=r.useContext(s),t=n;return e&&(t="function"==typeof e?e(n):l(l({},n),e)),t},p=function(e){var n=u(e.components);return r.createElement(s.Provider,{value:n},e.children)},c={inlineCode:"code",wrapper:function(e){var n=e.children;return r.createElement(r.Fragment,{},n)}},d=r.forwardRef((function(e,n){var t=e.components,o=e.mdxType,a=e.originalType,s=e.parentName,p=i(e,["components","mdxType","originalType","parentName"]),d=u(t),m=o,g=d["".concat(s,".").concat(m)]||d[m]||c[m]||a;return t?r.createElement(g,l(l({ref:n},p),{},{components:t})):r.createElement(g,l({ref:n},p))}));function m(e,n){var t=arguments,o=n&&n.mdxType;if("string"==typeof e||o){var a=t.length,l=new Array(a);l[0]=d;var i={};for(var s in n)hasOwnProperty.call(n,s)&&(i[s]=n[s]);i.originalType=e,i.mdxType="string"==typeof e?e:o,l[1]=i;for(var u=2;u{t.r(n),t.d(n,{assets:()=>s,contentTitle:()=>l,default:()=>c,frontMatter:()=>a,metadata:()=>i,toc:()=>u});var r=t(7462),o=(t(7294),t(3905));const a={sidebar_position:5},l="Plugins",i={unversionedId:"guide/walkthrough/plugins",id:"guide/walkthrough/plugins",title:"Plugins",description:"As of now, modules seem a little underwhelming. It appears that sern doesn't have all the features of a standard handler,",source:"@site/docs/guide/walkthrough/plugins.md",sourceDirName:"guide/walkthrough",slug:"/guide/walkthrough/plugins",permalink:"/fr/docs/guide/walkthrough/plugins",draft:!1,editUrl:"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/guide/walkthrough/plugins.md",tags:[],version:"current",sidebarPosition:5,frontMatter:{sidebar_position:5},sidebar:"tutorialSidebar",previous:{title:"First Event Module",permalink:"/fr/docs/guide/walkthrough/first-event"},next:{title:"The SernEmitter class",permalink:"/fr/docs/guide/walkthrough/sern-emitter"}},s={},u=[{value:"Command Plugins",id:"command-plugins",level:2},{value:"The controller object",id:"the-controller-object",level:3},{value:"Event Plugins",id:"event-plugins",level:2}],p={toc:u};function c(e){let{components:n,...a}=e;return(0,o.kt)("wrapper",(0,r.Z)({},p,a,{components:n,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"plugins"},"Plugins"),(0,o.kt)("p",null,"As of now, modules seem a little underwhelming. It appears that sern doesn't have all the features of a standard handler, which manages permissions, categorizes, cool-downs, publishes application commands, role permissions, etc."),(0,o.kt)("p",null,"Many important parts that manage access and help streamline command creation to make are apparently absent. Below is an example of an event plugin, one of the types of plugins."),(0,o.kt)("p",null,"Typescript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},'export function serenOnly(): EventPlugin {\n return {\n type: PluginType.Event,\n async execute([ctx, args], controller) {\n if (ctx.user.id !== "182326315813306368") {\n await ctx.reply({content: "You cannot use this command"})\n return controller.stop()\n }\n return controller.next();\n }\n }\n}\n')),(0,o.kt)("p",null,"Javascript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},'export function serenOnly() {\n return {\n type: PluginType.Event,\n async execute([ctx, args], controller) {\n if (ctx.user.id !== "182326315813306368") {\n await ctx.reply({content: "You cannot use this command"})\n return controller.stop()\n }\n return controller.next();\n }\n }\n}\n')),(0,o.kt)("br",null)," As part of our extensibility, the plugins feature make sern just as powerful, if not more powerful than standard handlers. Plugins modify and add new behavior to standard modules, extending customizability and implementing automation.",(0,o.kt)("br",null)," At the moment, there are two types of plugins:",(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"Command Plugins"),(0,o.kt)("li",{parentName:"ul"},"Event Plugins")),(0,o.kt)("h2",{id:"command-plugins"},"Command Plugins"),(0,o.kt)("p",null,"All modules are registered into sern's system. With command plugins, you can modify how commands are loaded,\nor do some kind of preprocessing before they are loaded into sern."),(0,o.kt)("h3",{id:"the-controller-object"},"The controller object"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"export interface Controller {\n next: () => Ok;\n stop: () => Err;\n}\n")),(0,o.kt)("p",null,"An instance of the above object is passed into every plugin. ",(0,o.kt)("br",null),"\nThis controls whether a module is stored into sern. ",(0,o.kt)("br",null),"\nTypescript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"export function inDir(dir : string) : CommandPlugin {\n return {\n type: PluginType.Command,\n async execute(wrapper, { absPath, module }, controller) {\n if(path.dirname(absPath) !== dir) {\n console.log(+new Date(), `${module.name} is not in the correct directory!`);\n return controller.stop()\n }\n console.log(+new Date(), `${module.name} is in the correct directory!`);\n return controller.next(); //continue\n }\n }\n}\n")),(0,o.kt)("p",null,"Javascript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},"export function inDir(dir : string) {\n return {\n type: PluginType.Command,\n async execute(wrapper, { absPath, module }, controller) {\n if(path.dirname(absPath) !== dir) {\n console.log(+new Date(), `${module.name} is not in the correct directory!`);\n return controller.stop()\n }\n console.log(+new Date(), `${module.name} is in the correct directory!`);\n return controller.next(); //continue\n }\n }\n}\n")),(0,o.kt)("p",null,"Above, this simple plugin logs that the module has been loaded along with a timestamp. ",(0,o.kt)("br",null),"\nAgain, it is up to ",(0,o.kt)("strong",{parentName:"p"},"you")," to define plugin logic! The possibilities to customize your bots are endless."),(0,o.kt)("admonition",{type:"tip"},(0,o.kt)("p",{parentName:"admonition"},"Command Plugins are good for ensuring the shape, location, and preprocessing of your commands.")),(0,o.kt)("h2",{id:"event-plugins"},"Event Plugins"),(0,o.kt)("p",null,(0,o.kt)("img",{alt:"event-plugins",src:t(1910).Z,width:"542",height:"377"})," ",(0,o.kt)("br",null)),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"An event is emitted by discord.js."),(0,o.kt)("li",{parentName:"ul"},"This event is passed to all plugins (",(0,o.kt)("strong",{parentName:"li"},"in order!!"),"),"),(0,o.kt)("li",{parentName:"ul"},"If all are successful,")),(0,o.kt)("p",null,"The command is executed. Calling ",(0,o.kt)("inlineCode",{parentName:"p"},"controller.stop()")," notifies sern that this command should not be run,\nand this event is ignored."),(0,o.kt)("p",null,"So, what does a command module look like with plugins?"),(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 inDir(\"other\"), \n serenOnly()\n ],\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-typescript"},"const { commandModule, CommandType } = require('@sern/handler');\n\nexports.default = commandModule({\n type: CommandType.Both,\n plugins: [\n inDir(\"other\"), \n serenOnly() //The plugins in this section applied to this module!\n ],\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,"Can you predict the behavior of this command?"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"Before loading into sern, this command module will check if this module is in the correct directory ",(0,o.kt)("inlineCode",{parentName:"li"},"other"),"."),(0,o.kt)("li",{parentName:"ul"},"Before an event occurs, this command module will check if the user has the id ",(0,o.kt)("inlineCode",{parentName:"li"},"182326315813306368"),".")),(0,o.kt)("admonition",{type:"tip"},(0,o.kt)("p",{parentName:"admonition"},"Event Plugins are good for filtering, preconditions, parsing.")),(0,o.kt)("p",null,"If all plugins return ",(0,o.kt)("inlineCode",{parentName:"p"},"controller.next()"),", this command replies ",(0,o.kt)("inlineCode",{parentName:"p"},"Pong \ud83c\udfd3")))}c.isMDXComponent=!0},1910:(e,n,t)=>{t.d(n,{Z:()=>r});const r=t.p+"assets/images/eventplugins.drawio-f22ee78041e60a62a45024f542a2b104.svg"}}]); \ No newline at end of file +"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[5],{3905:(e,n,t)=>{t.d(n,{Zo:()=>p,kt:()=>m});var r=t(7294);function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function a(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function l(e){for(var n=1;n=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var s=r.createContext({}),u=function(e){var n=r.useContext(s),t=n;return e&&(t="function"==typeof e?e(n):l(l({},n),e)),t},p=function(e){var n=u(e.components);return r.createElement(s.Provider,{value:n},e.children)},c={inlineCode:"code",wrapper:function(e){var n=e.children;return r.createElement(r.Fragment,{},n)}},d=r.forwardRef((function(e,n){var t=e.components,o=e.mdxType,a=e.originalType,s=e.parentName,p=i(e,["components","mdxType","originalType","parentName"]),d=u(t),m=o,g=d["".concat(s,".").concat(m)]||d[m]||c[m]||a;return t?r.createElement(g,l(l({ref:n},p),{},{components:t})):r.createElement(g,l({ref:n},p))}));function m(e,n){var t=arguments,o=n&&n.mdxType;if("string"==typeof e||o){var a=t.length,l=new Array(a);l[0]=d;var i={};for(var s in n)hasOwnProperty.call(n,s)&&(i[s]=n[s]);i.originalType=e,i.mdxType="string"==typeof e?e:o,l[1]=i;for(var u=2;u{t.r(n),t.d(n,{assets:()=>s,contentTitle:()=>l,default:()=>c,frontMatter:()=>a,metadata:()=>i,toc:()=>u});var r=t(7462),o=(t(7294),t(3905));const a={sidebar_position:5},l="Plugins",i={unversionedId:"guide/walkthrough/plugins",id:"guide/walkthrough/plugins",title:"Plugins",description:"As of now, modules seem a little underwhelming. It appears that sern doesn't have all the features of a standard handler,",source:"@site/docs/guide/walkthrough/plugins.md",sourceDirName:"guide/walkthrough",slug:"/guide/walkthrough/plugins",permalink:"/fr/docs/guide/walkthrough/plugins",draft:!1,editUrl:"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/guide/walkthrough/plugins.md",tags:[],version:"current",sidebarPosition:5,frontMatter:{sidebar_position:5},sidebar:"tutorialSidebar",previous:{title:"First Event Module",permalink:"/fr/docs/guide/walkthrough/first-event"},next:{title:"The SernEmitter class",permalink:"/fr/docs/guide/walkthrough/sern-emitter"}},s={},u=[{value:"Command Plugins",id:"command-plugins",level:2},{value:"The controller object",id:"the-controller-object",level:3},{value:"Event Plugins",id:"event-plugins",level:2}],p={toc:u};function c(e){let{components:n,...a}=e;return(0,o.kt)("wrapper",(0,r.Z)({},p,a,{components:n,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"plugins"},"Plugins"),(0,o.kt)("p",null,"As of now, modules seem a little underwhelming. It appears that sern doesn't have all the features of a standard handler, which manages permissions, categorizes, cool-downs, publishes application commands, role permissions, etc."),(0,o.kt)("p",null,"Many important parts that manage access and help streamline command creation to make are apparently absent. Below is an example of an event plugin, one of the types of plugins."),(0,o.kt)("p",null,"Typescript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},'export function serenOnly(): EventPlugin {\n return {\n type: PluginType.Event,\n async execute([ctx, args], controller) {\n if (ctx.user.id !== "182326315813306368") {\n await ctx.reply({content: "You cannot use this command"})\n return controller.stop()\n }\n return controller.next();\n }\n }\n}\n')),(0,o.kt)("p",null,"Javascript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},'export function serenOnly() {\n return {\n type: PluginType.Event,\n async execute([ctx, args], controller) {\n if (ctx.user.id !== "182326315813306368") {\n await ctx.reply({content: "You cannot use this command"})\n return controller.stop()\n }\n return controller.next();\n }\n }\n}\n')),(0,o.kt)("br",null)," As part of our extensibility, the plugins feature make sern just as powerful, if not more powerful than standard handlers. Plugins modify and add new behavior to standard modules, extending customizability and implementing automation.",(0,o.kt)("br",null)," At the moment, there are two types of plugins:",(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"Command Plugins"),(0,o.kt)("li",{parentName:"ul"},"Event Plugins")),(0,o.kt)("h2",{id:"command-plugins"},"Command Plugins"),(0,o.kt)("p",null,"All modules are registered into sern's system. With command plugins, you can modify how commands are loaded,\nor do some kind of preprocessing before they are loaded into sern."),(0,o.kt)("h3",{id:"the-controller-object"},"The controller object"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"export interface Controller {\n next: () => Ok;\n stop: () => Err;\n}\n")),(0,o.kt)("p",null,"An instance of the above object is passed into every plugin. ",(0,o.kt)("br",null),"\nThis controls whether a module is stored into sern. ",(0,o.kt)("br",null),"\nTypescript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"export function inDir(dir : string) : CommandPlugin {\n return {\n type: PluginType.Command,\n async execute(wrapper, { absPath, module }, controller) {\n if(path.dirname(absPath) !== dir) {\n console.log(+new Date(), `${module.name} is not in the correct directory!`);\n return controller.stop()\n }\n console.log(+new Date(), `${module.name} is in the correct directory!`);\n return controller.next(); //continue\n }\n }\n}\n")),(0,o.kt)("p",null,"Javascript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},"export function inDir(dir : string) {\n return {\n type: PluginType.Command,\n async execute(wrapper, { absPath, module }, controller) {\n if(path.dirname(absPath) !== dir) {\n console.log(+new Date(), `${module.name} is not in the correct directory!`);\n return controller.stop()\n }\n console.log(+new Date(), `${module.name} is in the correct directory!`);\n return controller.next(); //continue\n }\n }\n}\n")),(0,o.kt)("p",null,"Above, this simple plugin logs that the module has been loaded along with a timestamp. ",(0,o.kt)("br",null),"\nAgain, it is up to ",(0,o.kt)("strong",{parentName:"p"},"you")," to define plugin logic! The possibilities to customize your bots are endless."),(0,o.kt)("admonition",{type:"tip"},(0,o.kt)("p",{parentName:"admonition"},"Command Plugins are good for ensuring the shape, location, and preprocessing of your commands.")),(0,o.kt)("h2",{id:"event-plugins"},"Event Plugins"),(0,o.kt)("p",null,(0,o.kt)("img",{alt:"event-plugins",src:t(6061).Z,width:"542",height:"377"})," ",(0,o.kt)("br",null)),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"An event is emitted by discord.js."),(0,o.kt)("li",{parentName:"ul"},"This event is passed to all plugins (",(0,o.kt)("strong",{parentName:"li"},"in order!!"),"),"),(0,o.kt)("li",{parentName:"ul"},"If all are successful,")),(0,o.kt)("p",null,"The command is executed. Calling ",(0,o.kt)("inlineCode",{parentName:"p"},"controller.stop()")," notifies sern that this command should not be run,\nand this event is ignored."),(0,o.kt)("p",null,"So, what does a command module look like with plugins?"),(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 inDir(\"other\"), \n serenOnly()\n ],\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-typescript"},"const { commandModule, CommandType } = require('@sern/handler');\n\nexports.default = commandModule({\n type: CommandType.Both,\n plugins: [\n inDir(\"other\"), \n serenOnly() //The plugins in this section applied to this module!\n ],\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,"Can you predict the behavior of this command?"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"Before loading into sern, this command module will check if this module is in the correct directory ",(0,o.kt)("inlineCode",{parentName:"li"},"other"),"."),(0,o.kt)("li",{parentName:"ul"},"Before an event occurs, this command module will check if the user has the id ",(0,o.kt)("inlineCode",{parentName:"li"},"182326315813306368"),".")),(0,o.kt)("admonition",{type:"tip"},(0,o.kt)("p",{parentName:"admonition"},"Event Plugins are good for filtering, preconditions, parsing.")),(0,o.kt)("p",null,"If all plugins return ",(0,o.kt)("inlineCode",{parentName:"p"},"controller.next()"),", this command replies ",(0,o.kt)("inlineCode",{parentName:"p"},"Pong \ud83c\udfd3")))}c.isMDXComponent=!0},6061:(e,n,t)=>{t.d(n,{Z:()=>r});const r=t.p+"assets/images/eventplugins.drawio-f22ee78041e60a62a45024f542a2b104.svg"}}]); \ No newline at end of file diff --git a/fr/assets/js/runtime~main.3ca44381.js b/fr/assets/js/runtime~main.5db61f60.js similarity index 98% rename from fr/assets/js/runtime~main.3ca44381.js rename to fr/assets/js/runtime~main.5db61f60.js index 6251f93a4..3dc80ae19 100644 --- a/fr/assets/js/runtime~main.3ca44381.js +++ b/fr/assets/js/runtime~main.5db61f60.js @@ -1 +1 @@ -(()=>{"use strict";var e,t,r,a,f,c={},o={};function d(e){var t=o[e];if(void 0!==t)return t.exports;var r=o[e]={id:e,loaded:!1,exports:{}};return c[e].call(r.exports,r,r.exports,d),r.loaded=!0,r.exports}d.m=c,d.c=o,e=[],d.O=(t,r,a,f)=>{if(!r){var c=1/0;for(i=0;i=f)&&Object.keys(d.O).every((e=>d.O[e](r[n])))?r.splice(n--,1):(o=!1,f0&&e[i-1][2]>f;i--)e[i]=e[i-1];e[i]=[r,a,f]},d.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return d.d(t,{a:t}),t},r=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 c={};t=t||[null,r({}),r([]),r(r)];for(var o=2&a&&e;"object"==typeof o&&!~t.indexOf(o);o=r(o))Object.getOwnPropertyNames(o).forEach((t=>c[t]=()=>e[t]));return c.default=()=>e,d.d(f,c),f},d.d=(e,t)=>{for(var r in t)d.o(t,r)&&!d.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},d.f={},d.e=e=>Promise.all(Object.keys(d.f).reduce(((t,r)=>(d.f[r](e,t),t)),[])),d.u=e=>"assets/js/"+({5:"1ac1bfe9",45:"888566f1",53:"5bc4ccbc",62:"69369ae2",85:"1f391b9e",127:"7e205c4a",137:"1aef51bd",146:"608ca171",195:"c4f5d8e4",197:"935f2afb",226:"707baeff",270:"e4877132",277:"c4348237",306:"f6aebfbf",322:"a5467962",332:"73bd57bd",363:"26f1f3a5",397:"312c2bc5",414:"393be207",429:"eea0bf40",472:"cf183316",514:"1be78505",597:"5e8c322a",640:"a96c96b0",652:"bcd9df7e",671:"0e384e19",703:"981f6151",712:"3dc7c79a",750:"3a2d3092",803:"9201de17",865:"e8e3d8c7",918:"17896441"}[e]||e)+"."+{5:"76036e65",45:"6e075084",53:"51b676b7",62:"1291f58b",85:"d7ab1744",127:"4131c3c4",137:"19a812fc",146:"0d01d94f",195:"5e4ab8ce",197:"3b551e23",226:"00e5aa3b",270:"b7490350",277:"bbd90c09",306:"06105970",322:"7b61a3f2",332:"cde4e056",363:"7d199635",397:"1f24705a",414:"387b15e8",429:"41d2f7a6",472:"eeb9cd73",503:"668d49f6",514:"f852ff9f",597:"47df5c24",640:"42a6d824",652:"d5194af7",671:"3335ebfb",703:"8d323aab",712:"16650433",750:"966c746d",803:"b6d7200c",865:"db18c8a4",918:"15289f85",972:"61be9a41"}[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,t)=>Object.prototype.hasOwnProperty.call(e,t),a={},f="@sern/website:",d.l=(e,t,r,c)=>{if(a[e])a[e].push(t);else{var o,n;if(void 0!==r)for(var b=document.getElementsByTagName("script"),i=0;i{o.onerror=o.onload=null,clearTimeout(s);var f=a[e];if(delete a[e],o.parentNode&&o.parentNode.removeChild(o),f&&f.forEach((e=>e(r))),t)return t(r)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),n&&document.head.appendChild(o)}},d.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},d.p="/fr/",d.gca=function(e){return e={17896441:"918","1ac1bfe9":"5","888566f1":"45","5bc4ccbc":"53","69369ae2":"62","1f391b9e":"85","7e205c4a":"127","1aef51bd":"137","608ca171":"146",c4f5d8e4:"195","935f2afb":"197","707baeff":"226",e4877132:"270",c4348237:"277",f6aebfbf:"306",a5467962:"322","73bd57bd":"332","26f1f3a5":"363","312c2bc5":"397","393be207":"414",eea0bf40:"429",cf183316:"472","1be78505":"514","5e8c322a":"597",a96c96b0:"640",bcd9df7e:"652","0e384e19":"671","981f6151":"703","3dc7c79a":"712","3a2d3092":"750","9201de17":"803",e8e3d8c7:"865"}[e]||e,d.p+d.u(e)},(()=>{var e={303:0,532:0};d.f.j=(t,r)=>{var a=d.o(e,t)?e[t]:void 0;if(0!==a)if(a)r.push(a[2]);else if(/^(303|532)$/.test(t))e[t]=0;else{var f=new Promise(((r,f)=>a=e[t]=[r,f]));r.push(a[2]=f);var c=d.p+d.u(t),o=new Error;d.l(c,(r=>{if(d.o(e,t)&&(0!==(a=e[t])&&(e[t]=void 0),a)){var f=r&&("load"===r.type?"missing":r.type),c=r&&r.target&&r.target.src;o.message="Loading chunk "+t+" failed.\n("+f+": "+c+")",o.name="ChunkLoadError",o.type=f,o.request=c,a[1](o)}}),"chunk-"+t,t)}},d.O.j=t=>0===e[t];var t=(t,r)=>{var a,f,c=r[0],o=r[1],n=r[2],b=0;if(c.some((t=>0!==e[t]))){for(a in o)d.o(o,a)&&(d.m[a]=o[a]);if(n)var i=n(d)}for(t&&t(r);b{"use strict";var e,t,r,a,f,c={},o={};function d(e){var t=o[e];if(void 0!==t)return t.exports;var r=o[e]={id:e,loaded:!1,exports:{}};return c[e].call(r.exports,r,r.exports,d),r.loaded=!0,r.exports}d.m=c,d.c=o,e=[],d.O=(t,r,a,f)=>{if(!r){var c=1/0;for(i=0;i=f)&&Object.keys(d.O).every((e=>d.O[e](r[n])))?r.splice(n--,1):(o=!1,f0&&e[i-1][2]>f;i--)e[i]=e[i-1];e[i]=[r,a,f]},d.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return d.d(t,{a:t}),t},r=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 c={};t=t||[null,r({}),r([]),r(r)];for(var o=2&a&&e;"object"==typeof o&&!~t.indexOf(o);o=r(o))Object.getOwnPropertyNames(o).forEach((t=>c[t]=()=>e[t]));return c.default=()=>e,d.d(f,c),f},d.d=(e,t)=>{for(var r in t)d.o(t,r)&&!d.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},d.f={},d.e=e=>Promise.all(Object.keys(d.f).reduce(((t,r)=>(d.f[r](e,t),t)),[])),d.u=e=>"assets/js/"+({5:"1ac1bfe9",45:"888566f1",53:"5bc4ccbc",62:"69369ae2",85:"1f391b9e",127:"7e205c4a",137:"1aef51bd",146:"608ca171",195:"c4f5d8e4",197:"935f2afb",226:"707baeff",270:"e4877132",277:"c4348237",306:"f6aebfbf",322:"a5467962",332:"73bd57bd",363:"26f1f3a5",397:"312c2bc5",414:"393be207",429:"eea0bf40",472:"cf183316",514:"1be78505",597:"5e8c322a",640:"a96c96b0",652:"bcd9df7e",671:"0e384e19",703:"981f6151",712:"3dc7c79a",750:"3a2d3092",803:"9201de17",865:"e8e3d8c7",918:"17896441"}[e]||e)+"."+{5:"b0c567c5",45:"6e075084",53:"51b676b7",62:"1291f58b",85:"d7ab1744",127:"4131c3c4",137:"19a812fc",146:"0d01d94f",195:"5e4ab8ce",197:"3b551e23",226:"00e5aa3b",270:"b7490350",277:"bbd90c09",306:"06105970",322:"7b61a3f2",332:"cde4e056",363:"7d199635",397:"1f24705a",414:"387b15e8",429:"41d2f7a6",472:"eeb9cd73",503:"668d49f6",514:"f852ff9f",597:"47df5c24",640:"42a6d824",652:"d5194af7",671:"3335ebfb",703:"8d323aab",712:"16650433",750:"966c746d",803:"b6d7200c",865:"db18c8a4",918:"15289f85",972:"61be9a41"}[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,t)=>Object.prototype.hasOwnProperty.call(e,t),a={},f="@sern/website:",d.l=(e,t,r,c)=>{if(a[e])a[e].push(t);else{var o,n;if(void 0!==r)for(var b=document.getElementsByTagName("script"),i=0;i{o.onerror=o.onload=null,clearTimeout(s);var f=a[e];if(delete a[e],o.parentNode&&o.parentNode.removeChild(o),f&&f.forEach((e=>e(r))),t)return t(r)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),n&&document.head.appendChild(o)}},d.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},d.p="/fr/",d.gca=function(e){return e={17896441:"918","1ac1bfe9":"5","888566f1":"45","5bc4ccbc":"53","69369ae2":"62","1f391b9e":"85","7e205c4a":"127","1aef51bd":"137","608ca171":"146",c4f5d8e4:"195","935f2afb":"197","707baeff":"226",e4877132:"270",c4348237:"277",f6aebfbf:"306",a5467962:"322","73bd57bd":"332","26f1f3a5":"363","312c2bc5":"397","393be207":"414",eea0bf40:"429",cf183316:"472","1be78505":"514","5e8c322a":"597",a96c96b0:"640",bcd9df7e:"652","0e384e19":"671","981f6151":"703","3dc7c79a":"712","3a2d3092":"750","9201de17":"803",e8e3d8c7:"865"}[e]||e,d.p+d.u(e)},(()=>{var e={303:0,532:0};d.f.j=(t,r)=>{var a=d.o(e,t)?e[t]:void 0;if(0!==a)if(a)r.push(a[2]);else if(/^(303|532)$/.test(t))e[t]=0;else{var f=new Promise(((r,f)=>a=e[t]=[r,f]));r.push(a[2]=f);var c=d.p+d.u(t),o=new Error;d.l(c,(r=>{if(d.o(e,t)&&(0!==(a=e[t])&&(e[t]=void 0),a)){var f=r&&("load"===r.type?"missing":r.type),c=r&&r.target&&r.target.src;o.message="Loading chunk "+t+" failed.\n("+f+": "+c+")",o.name="ChunkLoadError",o.type=f,o.request=c,a[1](o)}}),"chunk-"+t,t)}},d.O.j=t=>0===e[t];var t=(t,r)=>{var a,f,c=r[0],o=r[1],n=r[2],b=0;if(c.some((t=>0!==e[t]))){for(a in o)d.o(o,a)&&(d.m[a]=o[a]);if(n)var i=n(d)}for(t&&t(r);b @sern/handler | sern - Handlers. Redefined. - +

SernHandler

NPM versionNPM downloads[![License: MIT](https://img.shields.io/badge/License-MIT-blavk.svg)](https://opensource.org/licenses/MIT)

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

Installation

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

Basic Usage

index.js (CommonJS)

const { Client, GatewayIntentBits } = require('discord.js');
const { Sern } = require('@sern/handler');
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 { Sern, CommandType } = require('@sern/handler');

exports.default = {
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/Context.html b/fr/docs/api/classes/Context.html index 3a7dbcb0c..c6c7d74c5 100644 --- a/fr/docs/api/classes/Context.html +++ b/fr/docs/api/classes/Context.html @@ -5,7 +5,7 @@ Class: Context | sern - Handlers. Redefined. - + @@ -16,7 +16,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
contentstring | Omit<InteractionReplyOptions, "fetchReply"> | ReplyMessageOptions

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/SernEmitter.html b/fr/docs/api/classes/SernEmitter.html index f46d57a89..12e728f55 100644 --- a/fr/docs/api/classes/SernEmitter.html +++ b/fr/docs/api/classes/SernEmitter.html @@ -5,7 +5,7 @@ Class: SernEmitter | sern - Handlers. Redefined. - + @@ -49,7 +49,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:194


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 ae521c177..36e00f148 100644 --- a/fr/docs/api/enums/CommandType.html +++ b/fr/docs/api/enums/CommandType.html @@ -5,13 +5,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 2e40f41e2..9daf5f81d 100644 --- a/fr/docs/api/enums/EventType.html +++ b/fr/docs/api/enums/EventType.html @@ -5,14 +5,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 5574f9317..4fd222e8e 100644 --- a/fr/docs/api/enums/PayloadType.html +++ b/fr/docs/api/enums/PayloadType.html @@ -5,13 +5,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 c93a6fa76..6f503881a 100644 --- a/fr/docs/api/enums/PluginType.html +++ b/fr/docs/api/enums/PluginType.html @@ -5,13 +5,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 6c464fedf..4271a3b49 100644 --- a/fr/docs/api/interfaces/Controller.html +++ b/fr/docs/api/interfaces/Controller.html @@ -5,13 +5,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 5579898b6..52d3e8792 100644 --- a/fr/docs/api/interfaces/Wrapper.html +++ b/fr/docs/api/interfaces/Wrapper.html @@ -5,13 +5,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:10


commands

Readonly commands: string

Defined in

src/handler/structures/wrapper.ts:13


defaultPrefix

Optional Readonly defaultPrefix: string

Defined in

src/handler/structures/wrapper.ts:12


events

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

Defined in

src/handler/structures/wrapper.ts:14


sernEmitter

Optional Readonly sernEmitter: SernEmitter

Defined in

src/handler/structures/wrapper.ts:11

- + \ No newline at end of file diff --git a/fr/docs/api/modules.html b/fr/docs/api/modules.html index 58e8d4248..9cb03131c 100644 --- a/fr/docs/api/modules.html +++ b/fr/docs/api/modules.html @@ -5,7 +5,7 @@ @sern/handler | sern - Handlers. Redefined. - + @@ -13,7 +13,7 @@

@sern/handler

Namespaces

Enumerations

Classes

Interfaces

Type Aliases

Args

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

Defined in

src/types/handler.ts:11


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:48


DefinedEventModule

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

Defined in

src/types/handler.ts:49


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:47


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:18


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:24


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


IsOptional

Ƭ IsOptional<T>: { [K in keyof T]-?: T[K] extends Required<T>[K] ? false : true }

Type parameters

Name
T

Defined in

src/types/handler.ts:31


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:4


Override

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

Type parameters

Name
T1
T2

Defined in

src/types/handler.ts:16


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:7


Payload

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

Defined in

src/types/handler.ts:50


Reconstruct

Ƭ Reconstruct<T>: T extends Omit<infer O, never> ? O & Reconstruct<O> : T

Type parameters

Name
T

Defined in

src/types/handler.ts:29


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[Error | string]
module.activate[Payload]
module.register[Payload]
warning[string]

Defined in

src/types/handler.ts:53


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:13


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:39


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:86


eventModule

eventModule(mod): EventModule

The wrapper function to define event modules for sern

Parameters

NameType
modInputEventModule

Returns

EventModule

Defined in

src/handler/sern.ts:107

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

Namespace: Sern

References

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:77

Functions

addExternal

addExternal<T>(emitter): void

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:67


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:34

- + \ No newline at end of file diff --git a/fr/docs/guide.html b/fr/docs/guide.html index f2a0845f7..5dbed0bb4 100644 --- a/fr/docs/guide.html +++ b/fr/docs/guide.html @@ -5,13 +5,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 11d83b775..cd03213f1 100644 --- a/fr/docs/guide/getting-started/choose-ide.html +++ b/fr/docs/guide/getting-started/choose-ide.html @@ -5,14 +5,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 4fc579be8..5c4f79055 100644 --- a/fr/docs/guide/getting-started/preparing.html +++ b/fr/docs/guide/getting-started/preparing.html @@ -5,13 +5,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 81e0b97a9..2b828e9a0 100644 --- a/fr/docs/guide/walkthrough/cli.html +++ b/fr/docs/guide/walkthrough/cli.html @@ -5,7 +5,7 @@ CLI | sern - Handlers. Redefined. - + @@ -13,7 +13,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 a3a37e37a..ce5449240 100644 --- a/fr/docs/guide/walkthrough/conclusion.html +++ b/fr/docs/guide/walkthrough/conclusion.html @@ -5,7 +5,7 @@ Conclusion | sern - Handlers. Redefined. - + @@ -13,7 +13,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 7e09934ad..85f6a5277 100644 --- a/fr/docs/guide/walkthrough/first-command.html +++ b/fr/docs/guide/walkthrough/first-command.html @@ -5,7 +5,7 @@ First Command | sern - Handlers. Redefined. - + @@ -14,7 +14,7 @@ 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!
}
});
- + \ 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 e4fc3fdba..43330a5cd 100644 --- a/fr/docs/guide/walkthrough/first-event.html +++ b/fr/docs/guide/walkthrough/first-event.html @@ -5,7 +5,7 @@ First Event Module | sern - Handlers. Redefined. - + @@ -13,7 +13,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) {
await member.client.channels.fetch('channel-id').send(`Welcome, ${member}`);
}
})

Javascript:


exports.default = eventModule({
type: EventType.Discord,
plugins : [], //NOT SUPPORTED YET!!
name: 'guildMemberAdd', //name of event.
async execute(member) {
await member.client.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 de740e1f8..b11be8a08 100644 --- a/fr/docs/guide/walkthrough/goal.html +++ b/fr/docs/guide/walkthrough/goal.html @@ -5,7 +5,7 @@ Goal | sern - Handlers. Redefined. - + @@ -13,7 +13,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 f68519fd6..2e4da10c2 100644 --- a/fr/docs/guide/walkthrough/good-to-know.html +++ b/fr/docs/guide/walkthrough/good-to-know.html @@ -5,7 +5,7 @@ Good to know | sern - Handlers. Redefined. - + @@ -13,7 +13,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 113f21f22..19a3caee1 100644 --- a/fr/docs/guide/walkthrough/plugins.html +++ b/fr/docs/guide/walkthrough/plugins.html @@ -5,7 +5,7 @@ Plugins | sern - Handlers. Redefined. - + @@ -16,7 +16,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 688339aab..8591358fd 100644 --- a/fr/docs/guide/walkthrough/sern-emitter.html +++ b/fr/docs/guide/walkthrough/sern-emitter.html @@ -5,13 +5,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 bf3a63ba0..81edc94cf 100644 --- a/fr/docs/intro.html +++ b/fr/docs/intro.html @@ -5,13 +5,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.

- + \ No newline at end of file diff --git a/fr/img/R.png b/fr/img/R.png new file mode 100644 index 000000000..ad1a862c5 Binary files /dev/null and b/fr/img/R.png differ diff --git a/fr/img/eventplugins.drawio.svg b/fr/img/eventplugins.drawio.svg new file mode 100644 index 000000000..b97d518a3 --- /dev/null +++ b/fr/img/eventplugins.drawio.svg @@ -0,0 +1,4 @@ + + + +
Event
Event
Plugin 1
Plugin 1
Plugin 2
Plugin 2
Plugin 3
Plugin 3
Is successful
Is successful
Command Executes
Command Executes
Ignore
Ignore
True
True
False
False
Text is not SVG - cannot display
\ No newline at end of file diff --git a/fr/img/icon.png b/fr/img/icon.png new file mode 100644 index 000000000..6859fda10 Binary files /dev/null and b/fr/img/icon.png differ diff --git a/fr/img/logo.png b/fr/img/logo.png new file mode 100644 index 000000000..6cc1a5085 Binary files /dev/null and b/fr/img/logo.png differ diff --git a/fr/img/logo.svg b/fr/img/logo.svg deleted file mode 100644 index 9db6d0d06..000000000 --- a/fr/img/logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/fr/index.html b/fr/index.html index a2d29ec14..4ca67f28e 100644 --- a/fr/index.html +++ b/fr/index.html @@ -5,13 +5,13 @@ sern - Handlers. Redefined. | sern - Handlers. Redefined. - +

Handlers. Redefined.

With the support of the community made plugins and powerful a 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 d6e662553..67d74c991 100644 --- a/fr/markdown-page.html +++ b/fr/markdown-page.html @@ -5,13 +5,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 7d9e983a1..020be2359 100644 --- a/fr/plugins.html +++ b/fr/plugins.html @@ -5,13 +5,13 @@ sern - Handlers. Redefined. - +

Coming soon

- + \ No newline at end of file diff --git a/img/R.png b/img/R.png new file mode 100644 index 000000000..ad1a862c5 Binary files /dev/null and b/img/R.png differ diff --git a/img/eventplugins.drawio.svg b/img/eventplugins.drawio.svg new file mode 100644 index 000000000..b97d518a3 --- /dev/null +++ b/img/eventplugins.drawio.svg @@ -0,0 +1,4 @@ + + + +
Event
Event
Plugin 1
Plugin 1
Plugin 2
Plugin 2
Plugin 3
Plugin 3
Is successful
Is successful
Command Executes
Command Executes
Ignore
Ignore
True
True
False
False
Text is not SVG - cannot display
\ No newline at end of file diff --git a/img/icon.png b/img/icon.png new file mode 100644 index 000000000..6859fda10 Binary files /dev/null and b/img/icon.png differ diff --git a/img/logo.png b/img/logo.png new file mode 100644 index 000000000..6cc1a5085 Binary files /dev/null and b/img/logo.png differ diff --git a/img/logo.svg b/img/logo.svg deleted file mode 100644 index 9db6d0d06..000000000 --- a/img/logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/index.html b/index.html index 713293d4a..224e7d1ec 100644 --- a/index.html +++ b/index.html @@ -5,13 +5,13 @@ sern - Handlers. Redefined. | sern - Handlers. Redefined. - +

Handlers. Redefined.

With the support of the community made plugins and powerful a 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 c8d30bd8d..fddbb3b09 100644 --- a/markdown-page.html +++ b/markdown-page.html @@ -5,13 +5,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 80b38363b..e627e9a5b 100644 --- a/plugins.html +++ b/plugins.html @@ -5,13 +5,13 @@ sern - Handlers. Redefined. - +

Coming soon

- + \ No newline at end of file diff --git a/tr/404.html b/tr/404.html index fb2dfc98f..81acc8fd0 100644 --- a/tr/404.html +++ b/tr/404.html @@ -5,13 +5,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/1ac1bfe9.1dbf1ab5.js b/tr/assets/js/1ac1bfe9.685616df.js similarity index 98% rename from tr/assets/js/1ac1bfe9.1dbf1ab5.js rename to tr/assets/js/1ac1bfe9.685616df.js index 4d14d2812..b36742063 100644 --- a/tr/assets/js/1ac1bfe9.1dbf1ab5.js +++ b/tr/assets/js/1ac1bfe9.685616df.js @@ -1 +1 @@ -"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[5],{3905:(e,n,t)=>{t.d(n,{Zo:()=>p,kt:()=>m});var r=t(7294);function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function a(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function l(e){for(var n=1;n=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var s=r.createContext({}),u=function(e){var n=r.useContext(s),t=n;return e&&(t="function"==typeof e?e(n):l(l({},n),e)),t},p=function(e){var n=u(e.components);return r.createElement(s.Provider,{value:n},e.children)},c={inlineCode:"code",wrapper:function(e){var n=e.children;return r.createElement(r.Fragment,{},n)}},d=r.forwardRef((function(e,n){var t=e.components,o=e.mdxType,a=e.originalType,s=e.parentName,p=i(e,["components","mdxType","originalType","parentName"]),d=u(t),m=o,g=d["".concat(s,".").concat(m)]||d[m]||c[m]||a;return t?r.createElement(g,l(l({ref:n},p),{},{components:t})):r.createElement(g,l({ref:n},p))}));function m(e,n){var t=arguments,o=n&&n.mdxType;if("string"==typeof e||o){var a=t.length,l=new Array(a);l[0]=d;var i={};for(var s in n)hasOwnProperty.call(n,s)&&(i[s]=n[s]);i.originalType=e,i.mdxType="string"==typeof e?e:o,l[1]=i;for(var u=2;u{t.r(n),t.d(n,{assets:()=>s,contentTitle:()=>l,default:()=>c,frontMatter:()=>a,metadata:()=>i,toc:()=>u});var r=t(7462),o=(t(7294),t(3905));const a={sidebar_position:5},l="Plugins",i={unversionedId:"guide/walkthrough/plugins",id:"guide/walkthrough/plugins",title:"Plugins",description:"As of now, modules seem a little underwhelming. It appears that sern doesn't have all the features of a standard handler,",source:"@site/docs/guide/walkthrough/plugins.md",sourceDirName:"guide/walkthrough",slug:"/guide/walkthrough/plugins",permalink:"/tr/docs/guide/walkthrough/plugins",draft:!1,editUrl:"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/guide/walkthrough/plugins.md",tags:[],version:"current",sidebarPosition:5,frontMatter:{sidebar_position:5},sidebar:"tutorialSidebar",previous:{title:"First Event Module",permalink:"/tr/docs/guide/walkthrough/first-event"},next:{title:"The SernEmitter class",permalink:"/tr/docs/guide/walkthrough/sern-emitter"}},s={},u=[{value:"Command Plugins",id:"command-plugins",level:2},{value:"The controller object",id:"the-controller-object",level:3},{value:"Event Plugins",id:"event-plugins",level:2}],p={toc:u};function c(e){let{components:n,...a}=e;return(0,o.kt)("wrapper",(0,r.Z)({},p,a,{components:n,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"plugins"},"Plugins"),(0,o.kt)("p",null,"As of now, modules seem a little underwhelming. It appears that sern doesn't have all the features of a standard handler, which manages permissions, categorizes, cool-downs, publishes application commands, role permissions, etc."),(0,o.kt)("p",null,"Many important parts that manage access and help streamline command creation to make are apparently absent. Below is an example of an event plugin, one of the types of plugins."),(0,o.kt)("p",null,"Typescript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},'export function serenOnly(): EventPlugin {\n return {\n type: PluginType.Event,\n async execute([ctx, args], controller) {\n if (ctx.user.id !== "182326315813306368") {\n await ctx.reply({content: "You cannot use this command"})\n return controller.stop()\n }\n return controller.next();\n }\n }\n}\n')),(0,o.kt)("p",null,"Javascript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},'export function serenOnly() {\n return {\n type: PluginType.Event,\n async execute([ctx, args], controller) {\n if (ctx.user.id !== "182326315813306368") {\n await ctx.reply({content: "You cannot use this command"})\n return controller.stop()\n }\n return controller.next();\n }\n }\n}\n')),(0,o.kt)("br",null)," As part of our extensibility, the plugins feature make sern just as powerful, if not more powerful than standard handlers. Plugins modify and add new behavior to standard modules, extending customizability and implementing automation.",(0,o.kt)("br",null)," At the moment, there are two types of plugins:",(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"Command Plugins"),(0,o.kt)("li",{parentName:"ul"},"Event Plugins")),(0,o.kt)("h2",{id:"command-plugins"},"Command Plugins"),(0,o.kt)("p",null,"All modules are registered into sern's system. With command plugins, you can modify how commands are loaded,\nor do some kind of preprocessing before they are loaded into sern."),(0,o.kt)("h3",{id:"the-controller-object"},"The controller object"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"export interface Controller {\n next: () => Ok;\n stop: () => Err;\n}\n")),(0,o.kt)("p",null,"An instance of the above object is passed into every plugin. ",(0,o.kt)("br",null),"\nThis controls whether a module is stored into sern. ",(0,o.kt)("br",null),"\nTypescript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"export function inDir(dir : string) : CommandPlugin {\n return {\n type: PluginType.Command,\n async execute(wrapper, { absPath, module }, controller) {\n if(path.dirname(absPath) !== dir) {\n console.log(+new Date(), `${module.name} is not in the correct directory!`);\n return controller.stop()\n }\n console.log(+new Date(), `${module.name} is in the correct directory!`);\n return controller.next(); //continue\n }\n }\n}\n")),(0,o.kt)("p",null,"Javascript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},"export function inDir(dir : string) {\n return {\n type: PluginType.Command,\n async execute(wrapper, { absPath, module }, controller) {\n if(path.dirname(absPath) !== dir) {\n console.log(+new Date(), `${module.name} is not in the correct directory!`);\n return controller.stop()\n }\n console.log(+new Date(), `${module.name} is in the correct directory!`);\n return controller.next(); //continue\n }\n }\n}\n")),(0,o.kt)("p",null,"Above, this simple plugin logs that the module has been loaded along with a timestamp. ",(0,o.kt)("br",null),"\nAgain, it is up to ",(0,o.kt)("strong",{parentName:"p"},"you")," to define plugin logic! The possibilities to customize your bots are endless."),(0,o.kt)("admonition",{type:"tip"},(0,o.kt)("p",{parentName:"admonition"},"Command Plugins are good for ensuring the shape, location, and preprocessing of your commands.")),(0,o.kt)("h2",{id:"event-plugins"},"Event Plugins"),(0,o.kt)("p",null,(0,o.kt)("img",{alt:"event-plugins",src:t(1910).Z,width:"542",height:"377"})," ",(0,o.kt)("br",null)),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"An event is emitted by discord.js."),(0,o.kt)("li",{parentName:"ul"},"This event is passed to all plugins (",(0,o.kt)("strong",{parentName:"li"},"in order!!"),"),"),(0,o.kt)("li",{parentName:"ul"},"If all are successful,")),(0,o.kt)("p",null,"The command is executed. Calling ",(0,o.kt)("inlineCode",{parentName:"p"},"controller.stop()")," notifies sern that this command should not be run,\nand this event is ignored."),(0,o.kt)("p",null,"So, what does a command module look like with plugins?"),(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 inDir(\"other\"), \n serenOnly()\n ],\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-typescript"},"const { commandModule, CommandType } = require('@sern/handler');\n\nexports.default = commandModule({\n type: CommandType.Both,\n plugins: [\n inDir(\"other\"), \n serenOnly() //The plugins in this section applied to this module!\n ],\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,"Can you predict the behavior of this command?"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"Before loading into sern, this command module will check if this module is in the correct directory ",(0,o.kt)("inlineCode",{parentName:"li"},"other"),"."),(0,o.kt)("li",{parentName:"ul"},"Before an event occurs, this command module will check if the user has the id ",(0,o.kt)("inlineCode",{parentName:"li"},"182326315813306368"),".")),(0,o.kt)("admonition",{type:"tip"},(0,o.kt)("p",{parentName:"admonition"},"Event Plugins are good for filtering, preconditions, parsing.")),(0,o.kt)("p",null,"If all plugins return ",(0,o.kt)("inlineCode",{parentName:"p"},"controller.next()"),", this command replies ",(0,o.kt)("inlineCode",{parentName:"p"},"Pong \ud83c\udfd3")))}c.isMDXComponent=!0},1910:(e,n,t)=>{t.d(n,{Z:()=>r});const r=t.p+"assets/images/eventplugins.drawio-f22ee78041e60a62a45024f542a2b104.svg"}}]); \ No newline at end of file +"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[5],{3905:(e,n,t)=>{t.d(n,{Zo:()=>p,kt:()=>m});var r=t(7294);function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function a(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function l(e){for(var n=1;n=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var s=r.createContext({}),u=function(e){var n=r.useContext(s),t=n;return e&&(t="function"==typeof e?e(n):l(l({},n),e)),t},p=function(e){var n=u(e.components);return r.createElement(s.Provider,{value:n},e.children)},c={inlineCode:"code",wrapper:function(e){var n=e.children;return r.createElement(r.Fragment,{},n)}},d=r.forwardRef((function(e,n){var t=e.components,o=e.mdxType,a=e.originalType,s=e.parentName,p=i(e,["components","mdxType","originalType","parentName"]),d=u(t),m=o,g=d["".concat(s,".").concat(m)]||d[m]||c[m]||a;return t?r.createElement(g,l(l({ref:n},p),{},{components:t})):r.createElement(g,l({ref:n},p))}));function m(e,n){var t=arguments,o=n&&n.mdxType;if("string"==typeof e||o){var a=t.length,l=new Array(a);l[0]=d;var i={};for(var s in n)hasOwnProperty.call(n,s)&&(i[s]=n[s]);i.originalType=e,i.mdxType="string"==typeof e?e:o,l[1]=i;for(var u=2;u{t.r(n),t.d(n,{assets:()=>s,contentTitle:()=>l,default:()=>c,frontMatter:()=>a,metadata:()=>i,toc:()=>u});var r=t(7462),o=(t(7294),t(3905));const a={sidebar_position:5},l="Plugins",i={unversionedId:"guide/walkthrough/plugins",id:"guide/walkthrough/plugins",title:"Plugins",description:"As of now, modules seem a little underwhelming. It appears that sern doesn't have all the features of a standard handler,",source:"@site/docs/guide/walkthrough/plugins.md",sourceDirName:"guide/walkthrough",slug:"/guide/walkthrough/plugins",permalink:"/tr/docs/guide/walkthrough/plugins",draft:!1,editUrl:"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/guide/walkthrough/plugins.md",tags:[],version:"current",sidebarPosition:5,frontMatter:{sidebar_position:5},sidebar:"tutorialSidebar",previous:{title:"First Event Module",permalink:"/tr/docs/guide/walkthrough/first-event"},next:{title:"The SernEmitter class",permalink:"/tr/docs/guide/walkthrough/sern-emitter"}},s={},u=[{value:"Command Plugins",id:"command-plugins",level:2},{value:"The controller object",id:"the-controller-object",level:3},{value:"Event Plugins",id:"event-plugins",level:2}],p={toc:u};function c(e){let{components:n,...a}=e;return(0,o.kt)("wrapper",(0,r.Z)({},p,a,{components:n,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"plugins"},"Plugins"),(0,o.kt)("p",null,"As of now, modules seem a little underwhelming. It appears that sern doesn't have all the features of a standard handler, which manages permissions, categorizes, cool-downs, publishes application commands, role permissions, etc."),(0,o.kt)("p",null,"Many important parts that manage access and help streamline command creation to make are apparently absent. Below is an example of an event plugin, one of the types of plugins."),(0,o.kt)("p",null,"Typescript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},'export function serenOnly(): EventPlugin {\n return {\n type: PluginType.Event,\n async execute([ctx, args], controller) {\n if (ctx.user.id !== "182326315813306368") {\n await ctx.reply({content: "You cannot use this command"})\n return controller.stop()\n }\n return controller.next();\n }\n }\n}\n')),(0,o.kt)("p",null,"Javascript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},'export function serenOnly() {\n return {\n type: PluginType.Event,\n async execute([ctx, args], controller) {\n if (ctx.user.id !== "182326315813306368") {\n await ctx.reply({content: "You cannot use this command"})\n return controller.stop()\n }\n return controller.next();\n }\n }\n}\n')),(0,o.kt)("br",null)," As part of our extensibility, the plugins feature make sern just as powerful, if not more powerful than standard handlers. Plugins modify and add new behavior to standard modules, extending customizability and implementing automation.",(0,o.kt)("br",null)," At the moment, there are two types of plugins:",(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"Command Plugins"),(0,o.kt)("li",{parentName:"ul"},"Event Plugins")),(0,o.kt)("h2",{id:"command-plugins"},"Command Plugins"),(0,o.kt)("p",null,"All modules are registered into sern's system. With command plugins, you can modify how commands are loaded,\nor do some kind of preprocessing before they are loaded into sern."),(0,o.kt)("h3",{id:"the-controller-object"},"The controller object"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"export interface Controller {\n next: () => Ok;\n stop: () => Err;\n}\n")),(0,o.kt)("p",null,"An instance of the above object is passed into every plugin. ",(0,o.kt)("br",null),"\nThis controls whether a module is stored into sern. ",(0,o.kt)("br",null),"\nTypescript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-typescript"},"export function inDir(dir : string) : CommandPlugin {\n return {\n type: PluginType.Command,\n async execute(wrapper, { absPath, module }, controller) {\n if(path.dirname(absPath) !== dir) {\n console.log(+new Date(), `${module.name} is not in the correct directory!`);\n return controller.stop()\n }\n console.log(+new Date(), `${module.name} is in the correct directory!`);\n return controller.next(); //continue\n }\n }\n}\n")),(0,o.kt)("p",null,"Javascript:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-javascript"},"export function inDir(dir : string) {\n return {\n type: PluginType.Command,\n async execute(wrapper, { absPath, module }, controller) {\n if(path.dirname(absPath) !== dir) {\n console.log(+new Date(), `${module.name} is not in the correct directory!`);\n return controller.stop()\n }\n console.log(+new Date(), `${module.name} is in the correct directory!`);\n return controller.next(); //continue\n }\n }\n}\n")),(0,o.kt)("p",null,"Above, this simple plugin logs that the module has been loaded along with a timestamp. ",(0,o.kt)("br",null),"\nAgain, it is up to ",(0,o.kt)("strong",{parentName:"p"},"you")," to define plugin logic! The possibilities to customize your bots are endless."),(0,o.kt)("admonition",{type:"tip"},(0,o.kt)("p",{parentName:"admonition"},"Command Plugins are good for ensuring the shape, location, and preprocessing of your commands.")),(0,o.kt)("h2",{id:"event-plugins"},"Event Plugins"),(0,o.kt)("p",null,(0,o.kt)("img",{alt:"event-plugins",src:t(6061).Z,width:"542",height:"377"})," ",(0,o.kt)("br",null)),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"An event is emitted by discord.js."),(0,o.kt)("li",{parentName:"ul"},"This event is passed to all plugins (",(0,o.kt)("strong",{parentName:"li"},"in order!!"),"),"),(0,o.kt)("li",{parentName:"ul"},"If all are successful,")),(0,o.kt)("p",null,"The command is executed. Calling ",(0,o.kt)("inlineCode",{parentName:"p"},"controller.stop()")," notifies sern that this command should not be run,\nand this event is ignored."),(0,o.kt)("p",null,"So, what does a command module look like with plugins?"),(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 inDir(\"other\"), \n serenOnly()\n ],\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-typescript"},"const { commandModule, CommandType } = require('@sern/handler');\n\nexports.default = commandModule({\n type: CommandType.Both,\n plugins: [\n inDir(\"other\"), \n serenOnly() //The plugins in this section applied to this module!\n ],\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,"Can you predict the behavior of this command?"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"Before loading into sern, this command module will check if this module is in the correct directory ",(0,o.kt)("inlineCode",{parentName:"li"},"other"),"."),(0,o.kt)("li",{parentName:"ul"},"Before an event occurs, this command module will check if the user has the id ",(0,o.kt)("inlineCode",{parentName:"li"},"182326315813306368"),".")),(0,o.kt)("admonition",{type:"tip"},(0,o.kt)("p",{parentName:"admonition"},"Event Plugins are good for filtering, preconditions, parsing.")),(0,o.kt)("p",null,"If all plugins return ",(0,o.kt)("inlineCode",{parentName:"p"},"controller.next()"),", this command replies ",(0,o.kt)("inlineCode",{parentName:"p"},"Pong \ud83c\udfd3")))}c.isMDXComponent=!0},6061:(e,n,t)=>{t.d(n,{Z:()=>r});const r=t.p+"assets/images/eventplugins.drawio-f22ee78041e60a62a45024f542a2b104.svg"}}]); \ No newline at end of file diff --git a/tr/assets/js/runtime~main.10d5e230.js b/tr/assets/js/runtime~main.eef9e2a1.js similarity index 98% rename from tr/assets/js/runtime~main.10d5e230.js rename to tr/assets/js/runtime~main.eef9e2a1.js index c006feea4..14885bd1a 100644 --- a/tr/assets/js/runtime~main.10d5e230.js +++ b/tr/assets/js/runtime~main.eef9e2a1.js @@ -1 +1 @@ -(()=>{"use strict";var e,t,r,a,f,o={},c={};function n(e){var t=c[e];if(void 0!==t)return t.exports;var r=c[e]={id:e,loaded:!1,exports:{}};return o[e].call(r.exports,r,r.exports,n),r.loaded=!0,r.exports}n.m=o,n.c=c,e=[],n.O=(t,r,a,f)=>{if(!r){var o=1/0;for(i=0;i=f)&&Object.keys(n.O).every((e=>n.O[e](r[d])))?r.splice(d--,1):(c=!1,f0&&e[i-1][2]>f;i--)e[i]=e[i-1];e[i]=[r,a,f]},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,n.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);n.r(f);var o={};t=t||[null,r({}),r([]),r(r)];for(var c=2&a&&e;"object"==typeof c&&!~t.indexOf(c);c=r(c))Object.getOwnPropertyNames(c).forEach((t=>o[t]=()=>e[t]));return o.default=()=>e,n.d(f,o),f},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce(((t,r)=>(n.f[r](e,t),t)),[])),n.u=e=>"assets/js/"+({5:"1ac1bfe9",45:"888566f1",53:"5bc4ccbc",62:"69369ae2",85:"1f391b9e",127:"7e205c4a",137:"1aef51bd",146:"608ca171",195:"c4f5d8e4",197:"935f2afb",226:"707baeff",270:"e4877132",277:"c4348237",306:"f6aebfbf",322:"a5467962",332:"73bd57bd",363:"26f1f3a5",397:"312c2bc5",414:"393be207",429:"eea0bf40",472:"cf183316",514:"1be78505",597:"5e8c322a",640:"a96c96b0",652:"bcd9df7e",671:"0e384e19",703:"981f6151",712:"3dc7c79a",750:"3a2d3092",803:"9201de17",865:"e8e3d8c7",918:"17896441"}[e]||e)+"."+{5:"1dbf1ab5",45:"f5f1dc29",53:"543d4652",62:"1291f58b",85:"d7ab1744",127:"5580539a",137:"375e49c6",146:"34dcba19",195:"5e4ab8ce",197:"21602fd8",226:"ec3c22a7",270:"b1ecf932",277:"bbd90c09",306:"5ba63757",322:"4d983a8a",332:"91bccb31",363:"f89eebba",397:"1f24705a",414:"d0baab28",429:"1da99ada",472:"156f4214",503:"668d49f6",514:"f852ff9f",597:"1768faa6",640:"a0d55f12",652:"0ecd6450",671:"eab1cd86",703:"d14fc527",712:"7e7409ec",750:"dd1d79d2",803:"9ddf3be0",865:"7f14c2ac",918:"15289f85",972:"61be9a41"}[e]+".js",n.miniCssF=e=>{},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a={},f="@sern/website:",n.l=(e,t,r,o)=>{if(a[e])a[e].push(t);else{var c,d;if(void 0!==r)for(var b=document.getElementsByTagName("script"),i=0;i{c.onerror=c.onload=null,clearTimeout(s);var f=a[e];if(delete a[e],c.parentNode&&c.parentNode.removeChild(c),f&&f.forEach((e=>e(r))),t)return t(r)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:c}),12e4);c.onerror=l.bind(null,c.onerror),c.onload=l.bind(null,c.onload),d&&document.head.appendChild(c)}},n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.p="/tr/",n.gca=function(e){return e={17896441:"918","1ac1bfe9":"5","888566f1":"45","5bc4ccbc":"53","69369ae2":"62","1f391b9e":"85","7e205c4a":"127","1aef51bd":"137","608ca171":"146",c4f5d8e4:"195","935f2afb":"197","707baeff":"226",e4877132:"270",c4348237:"277",f6aebfbf:"306",a5467962:"322","73bd57bd":"332","26f1f3a5":"363","312c2bc5":"397","393be207":"414",eea0bf40:"429",cf183316:"472","1be78505":"514","5e8c322a":"597",a96c96b0:"640",bcd9df7e:"652","0e384e19":"671","981f6151":"703","3dc7c79a":"712","3a2d3092":"750","9201de17":"803",e8e3d8c7:"865"}[e]||e,n.p+n.u(e)},(()=>{var e={303:0,532:0};n.f.j=(t,r)=>{var a=n.o(e,t)?e[t]:void 0;if(0!==a)if(a)r.push(a[2]);else if(/^(303|532)$/.test(t))e[t]=0;else{var f=new Promise(((r,f)=>a=e[t]=[r,f]));r.push(a[2]=f);var o=n.p+n.u(t),c=new Error;n.l(o,(r=>{if(n.o(e,t)&&(0!==(a=e[t])&&(e[t]=void 0),a)){var f=r&&("load"===r.type?"missing":r.type),o=r&&r.target&&r.target.src;c.message="Loading chunk "+t+" failed.\n("+f+": "+o+")",c.name="ChunkLoadError",c.type=f,c.request=o,a[1](c)}}),"chunk-"+t,t)}},n.O.j=t=>0===e[t];var t=(t,r)=>{var a,f,o=r[0],c=r[1],d=r[2],b=0;if(o.some((t=>0!==e[t]))){for(a in c)n.o(c,a)&&(n.m[a]=c[a]);if(d)var i=d(n)}for(t&&t(r);b{"use strict";var e,t,r,a,f,o={},c={};function n(e){var t=c[e];if(void 0!==t)return t.exports;var r=c[e]={id:e,loaded:!1,exports:{}};return o[e].call(r.exports,r,r.exports,n),r.loaded=!0,r.exports}n.m=o,n.c=c,e=[],n.O=(t,r,a,f)=>{if(!r){var o=1/0;for(i=0;i=f)&&Object.keys(n.O).every((e=>n.O[e](r[d])))?r.splice(d--,1):(c=!1,f0&&e[i-1][2]>f;i--)e[i]=e[i-1];e[i]=[r,a,f]},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,n.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);n.r(f);var o={};t=t||[null,r({}),r([]),r(r)];for(var c=2&a&&e;"object"==typeof c&&!~t.indexOf(c);c=r(c))Object.getOwnPropertyNames(c).forEach((t=>o[t]=()=>e[t]));return o.default=()=>e,n.d(f,o),f},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce(((t,r)=>(n.f[r](e,t),t)),[])),n.u=e=>"assets/js/"+({5:"1ac1bfe9",45:"888566f1",53:"5bc4ccbc",62:"69369ae2",85:"1f391b9e",127:"7e205c4a",137:"1aef51bd",146:"608ca171",195:"c4f5d8e4",197:"935f2afb",226:"707baeff",270:"e4877132",277:"c4348237",306:"f6aebfbf",322:"a5467962",332:"73bd57bd",363:"26f1f3a5",397:"312c2bc5",414:"393be207",429:"eea0bf40",472:"cf183316",514:"1be78505",597:"5e8c322a",640:"a96c96b0",652:"bcd9df7e",671:"0e384e19",703:"981f6151",712:"3dc7c79a",750:"3a2d3092",803:"9201de17",865:"e8e3d8c7",918:"17896441"}[e]||e)+"."+{5:"685616df",45:"f5f1dc29",53:"543d4652",62:"1291f58b",85:"d7ab1744",127:"5580539a",137:"375e49c6",146:"34dcba19",195:"5e4ab8ce",197:"21602fd8",226:"ec3c22a7",270:"b1ecf932",277:"bbd90c09",306:"5ba63757",322:"4d983a8a",332:"91bccb31",363:"f89eebba",397:"1f24705a",414:"d0baab28",429:"1da99ada",472:"156f4214",503:"668d49f6",514:"f852ff9f",597:"1768faa6",640:"a0d55f12",652:"0ecd6450",671:"eab1cd86",703:"d14fc527",712:"7e7409ec",750:"dd1d79d2",803:"9ddf3be0",865:"7f14c2ac",918:"15289f85",972:"61be9a41"}[e]+".js",n.miniCssF=e=>{},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a={},f="@sern/website:",n.l=(e,t,r,o)=>{if(a[e])a[e].push(t);else{var c,d;if(void 0!==r)for(var b=document.getElementsByTagName("script"),i=0;i{c.onerror=c.onload=null,clearTimeout(s);var f=a[e];if(delete a[e],c.parentNode&&c.parentNode.removeChild(c),f&&f.forEach((e=>e(r))),t)return t(r)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:c}),12e4);c.onerror=l.bind(null,c.onerror),c.onload=l.bind(null,c.onload),d&&document.head.appendChild(c)}},n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.p="/tr/",n.gca=function(e){return e={17896441:"918","1ac1bfe9":"5","888566f1":"45","5bc4ccbc":"53","69369ae2":"62","1f391b9e":"85","7e205c4a":"127","1aef51bd":"137","608ca171":"146",c4f5d8e4:"195","935f2afb":"197","707baeff":"226",e4877132:"270",c4348237:"277",f6aebfbf:"306",a5467962:"322","73bd57bd":"332","26f1f3a5":"363","312c2bc5":"397","393be207":"414",eea0bf40:"429",cf183316:"472","1be78505":"514","5e8c322a":"597",a96c96b0:"640",bcd9df7e:"652","0e384e19":"671","981f6151":"703","3dc7c79a":"712","3a2d3092":"750","9201de17":"803",e8e3d8c7:"865"}[e]||e,n.p+n.u(e)},(()=>{var e={303:0,532:0};n.f.j=(t,r)=>{var a=n.o(e,t)?e[t]:void 0;if(0!==a)if(a)r.push(a[2]);else if(/^(303|532)$/.test(t))e[t]=0;else{var f=new Promise(((r,f)=>a=e[t]=[r,f]));r.push(a[2]=f);var o=n.p+n.u(t),c=new Error;n.l(o,(r=>{if(n.o(e,t)&&(0!==(a=e[t])&&(e[t]=void 0),a)){var f=r&&("load"===r.type?"missing":r.type),o=r&&r.target&&r.target.src;c.message="Loading chunk "+t+" failed.\n("+f+": "+o+")",c.name="ChunkLoadError",c.type=f,c.request=o,a[1](c)}}),"chunk-"+t,t)}},n.O.j=t=>0===e[t];var t=(t,r)=>{var a,f,o=r[0],c=r[1],d=r[2],b=0;if(o.some((t=>0!==e[t]))){for(a in c)n.o(c,a)&&(n.m[a]=c[a]);if(d)var i=d(n)}for(t&&t(r);b @sern/handler | sern - Handlers. Redefined. - +

SernHandler

NPM versionNPM downloads[![License: MIT](https://img.shields.io/badge/License-MIT-blavk.svg)](https://opensource.org/licenses/MIT)

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

Installation

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

Basic Usage

index.js (CommonJS)

const { Client, GatewayIntentBits } = require('discord.js');
const { Sern } = require('@sern/handler');
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 { Sern, CommandType } = require('@sern/handler');

exports.default = {
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/Context.html b/tr/docs/api/classes/Context.html index b971aae72..3be74b5a0 100644 --- a/tr/docs/api/classes/Context.html +++ b/tr/docs/api/classes/Context.html @@ -5,7 +5,7 @@ Class: Context | sern - Handlers. Redefined. - + @@ -16,7 +16,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
contentstring | Omit<InteractionReplyOptions, "fetchReply"> | ReplyMessageOptions

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/SernEmitter.html b/tr/docs/api/classes/SernEmitter.html index 8e836c3ce..a63aa8fe4 100644 --- a/tr/docs/api/classes/SernEmitter.html +++ b/tr/docs/api/classes/SernEmitter.html @@ -5,7 +5,7 @@ Class: SernEmitter | sern - Handlers. Redefined. - + @@ -49,7 +49,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:194


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 154b09ea9..335e8d05b 100644 --- a/tr/docs/api/enums/CommandType.html +++ b/tr/docs/api/enums/CommandType.html @@ -5,13 +5,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 ade082d57..9071ec023 100644 --- a/tr/docs/api/enums/EventType.html +++ b/tr/docs/api/enums/EventType.html @@ -5,14 +5,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 1b88f5082..6e527313b 100644 --- a/tr/docs/api/enums/PayloadType.html +++ b/tr/docs/api/enums/PayloadType.html @@ -5,13 +5,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 d85fbe027..b1ece562a 100644 --- a/tr/docs/api/enums/PluginType.html +++ b/tr/docs/api/enums/PluginType.html @@ -5,13 +5,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 ab1b150c6..8d6e57ed5 100644 --- a/tr/docs/api/interfaces/Controller.html +++ b/tr/docs/api/interfaces/Controller.html @@ -5,13 +5,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 dd95c9eac..37936420f 100644 --- a/tr/docs/api/interfaces/Wrapper.html +++ b/tr/docs/api/interfaces/Wrapper.html @@ -5,13 +5,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:10


commands

Readonly commands: string

Defined in

src/handler/structures/wrapper.ts:13


defaultPrefix

Optional Readonly defaultPrefix: string

Defined in

src/handler/structures/wrapper.ts:12


events

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

Defined in

src/handler/structures/wrapper.ts:14


sernEmitter

Optional Readonly sernEmitter: SernEmitter

Defined in

src/handler/structures/wrapper.ts:11

- + \ No newline at end of file diff --git a/tr/docs/api/modules.html b/tr/docs/api/modules.html index 7247eb9ea..fb29e871c 100644 --- a/tr/docs/api/modules.html +++ b/tr/docs/api/modules.html @@ -5,7 +5,7 @@ @sern/handler | sern - Handlers. Redefined. - + @@ -13,7 +13,7 @@

@sern/handler

Namespaces

Enumerations

Classes

Interfaces

Type Aliases

Args

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

Defined in

src/types/handler.ts:11


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:48


DefinedEventModule

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

Defined in

src/types/handler.ts:49


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:47


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:18


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:24


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


IsOptional

Ƭ IsOptional<T>: { [K in keyof T]-?: T[K] extends Required<T>[K] ? false : true }

Type parameters

Name
T

Defined in

src/types/handler.ts:31


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:4


Override

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

Type parameters

Name
T1
T2

Defined in

src/types/handler.ts:16


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:7


Payload

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

Defined in

src/types/handler.ts:50


Reconstruct

Ƭ Reconstruct<T>: T extends Omit<infer O, never> ? O & Reconstruct<O> : T

Type parameters

Name
T

Defined in

src/types/handler.ts:29


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[Error | string]
module.activate[Payload]
module.register[Payload]
warning[string]

Defined in

src/types/handler.ts:53


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:13


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:39


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:86


eventModule

eventModule(mod): EventModule

The wrapper function to define event modules for sern

Parameters

NameType
modInputEventModule

Returns

EventModule

Defined in

src/handler/sern.ts:107

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

Namespace: Sern

References

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:77

Functions

addExternal

addExternal<T>(emitter): void

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:67


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:34

- + \ No newline at end of file diff --git a/tr/docs/guide.html b/tr/docs/guide.html index 02ed75a84..da04b4da9 100644 --- a/tr/docs/guide.html +++ b/tr/docs/guide.html @@ -5,13 +5,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 8c5030c0b..ca141aa34 100644 --- a/tr/docs/guide/getting-started/choose-ide.html +++ b/tr/docs/guide/getting-started/choose-ide.html @@ -5,14 +5,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 c502bed77..e1c6538f3 100644 --- a/tr/docs/guide/getting-started/preparing.html +++ b/tr/docs/guide/getting-started/preparing.html @@ -5,13 +5,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 fea9cbb99..99370e477 100644 --- a/tr/docs/guide/walkthrough/cli.html +++ b/tr/docs/guide/walkthrough/cli.html @@ -5,7 +5,7 @@ CLI | sern - Handlers. Redefined. - + @@ -13,7 +13,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 6b2a15038..e64fabec1 100644 --- a/tr/docs/guide/walkthrough/conclusion.html +++ b/tr/docs/guide/walkthrough/conclusion.html @@ -5,7 +5,7 @@ Conclusion | sern - Handlers. Redefined. - + @@ -13,7 +13,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 bfc35b8fa..0ae67b2a9 100644 --- a/tr/docs/guide/walkthrough/first-command.html +++ b/tr/docs/guide/walkthrough/first-command.html @@ -5,7 +5,7 @@ First Command | sern - Handlers. Redefined. - + @@ -14,7 +14,7 @@ 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!
}
});
- + \ 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 385894e22..286fe1735 100644 --- a/tr/docs/guide/walkthrough/first-event.html +++ b/tr/docs/guide/walkthrough/first-event.html @@ -5,7 +5,7 @@ First Event Module | sern - Handlers. Redefined. - + @@ -13,7 +13,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) {
await member.client.channels.fetch('channel-id').send(`Welcome, ${member}`);
}
})

Javascript:


exports.default = eventModule({
type: EventType.Discord,
plugins : [], //NOT SUPPORTED YET!!
name: 'guildMemberAdd', //name of event.
async execute(member) {
await member.client.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 9dd0c70c6..01808fc09 100644 --- a/tr/docs/guide/walkthrough/goal.html +++ b/tr/docs/guide/walkthrough/goal.html @@ -5,7 +5,7 @@ Goal | sern - Handlers. Redefined. - + @@ -13,7 +13,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 8e627da91..867751322 100644 --- a/tr/docs/guide/walkthrough/good-to-know.html +++ b/tr/docs/guide/walkthrough/good-to-know.html @@ -5,7 +5,7 @@ Good to know | sern - Handlers. Redefined. - + @@ -13,7 +13,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 2d1229781..5a0a65da0 100644 --- a/tr/docs/guide/walkthrough/plugins.html +++ b/tr/docs/guide/walkthrough/plugins.html @@ -5,7 +5,7 @@ Plugins | sern - Handlers. Redefined. - + @@ -16,7 +16,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 9f64b3d6d..85192dc9d 100644 --- a/tr/docs/guide/walkthrough/sern-emitter.html +++ b/tr/docs/guide/walkthrough/sern-emitter.html @@ -5,13 +5,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 ef68a2697..c856a1fb7 100644 --- a/tr/docs/intro.html +++ b/tr/docs/intro.html @@ -5,13 +5,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.

- + \ No newline at end of file diff --git a/tr/img/R.png b/tr/img/R.png new file mode 100644 index 000000000..ad1a862c5 Binary files /dev/null and b/tr/img/R.png differ diff --git a/tr/img/eventplugins.drawio.svg b/tr/img/eventplugins.drawio.svg new file mode 100644 index 000000000..b97d518a3 --- /dev/null +++ b/tr/img/eventplugins.drawio.svg @@ -0,0 +1,4 @@ + + + +
Event
Event
Plugin 1
Plugin 1
Plugin 2
Plugin 2
Plugin 3
Plugin 3
Is successful
Is successful
Command Executes
Command Executes
Ignore
Ignore
True
True
False
False
Text is not SVG - cannot display
\ No newline at end of file diff --git a/tr/img/icon.png b/tr/img/icon.png new file mode 100644 index 000000000..6859fda10 Binary files /dev/null and b/tr/img/icon.png differ diff --git a/tr/img/logo.png b/tr/img/logo.png new file mode 100644 index 000000000..6cc1a5085 Binary files /dev/null and b/tr/img/logo.png differ diff --git a/tr/img/logo.svg b/tr/img/logo.svg deleted file mode 100644 index 9db6d0d06..000000000 --- a/tr/img/logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/tr/index.html b/tr/index.html index 974e86d98..971900aaa 100644 --- a/tr/index.html +++ b/tr/index.html @@ -5,13 +5,13 @@ sern - Handlers. Redefined. | sern - Handlers. Redefined. - +

Handlers. Redefined.

With the support of the community made plugins and powerful a 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 178c1e489..5f189b1a8 100644 --- a/tr/markdown-page.html +++ b/tr/markdown-page.html @@ -5,13 +5,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 078d4555f..49b0387c4 100644 --- a/tr/plugins.html +++ b/tr/plugins.html @@ -5,13 +5,13 @@ sern - Handlers. Redefined. - +

Coming soon

- + \ No newline at end of file