From 338e5b27db9c55698d430276c7a695333479fc0a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 8 Oct 2022 17:22:22 +0000 Subject: [PATCH] deploy: 3842e2dc35097c05f2cf38100e94bd0ace994a5a --- 404.html | 4 ++-- assets/js/{3020eeee.4639977c.js => 3020eeee.38579360.js} | 2 +- assets/js/{6ba1d2c1.e8182645.js => 6ba1d2c1.ae2dcf1f.js} | 2 +- assets/js/b2f554cd.2a754d9f.js | 1 + assets/js/b2f554cd.b71f36d2.js | 1 - .../{runtime~main.345aab81.js => runtime~main.5540c37d.js} | 2 +- blog.html | 6 +++--- blog/1.2.0.html | 6 +++--- blog/archive.html | 4 ++-- blog/atom.xml | 2 +- blog/rss.xml | 2 +- blog/tags.html | 4 ++-- blog/tags/release.html | 6 +++--- docs/api.html | 4 ++-- docs/api/classes/CommandExecutable.html | 4 ++-- docs/api/classes/Context.html | 4 ++-- docs/api/classes/EventExecutable.html | 4 ++-- docs/api/classes/SernEmitter.html | 4 ++-- docs/api/enums/CommandType.html | 4 ++-- docs/api/enums/EventType.html | 4 ++-- docs/api/enums/PayloadType.html | 4 ++-- docs/api/enums/PluginType.html | 4 ++-- docs/api/interfaces/Controller.html | 4 ++-- docs/api/interfaces/Wrapper.html | 4 ++-- docs/api/modules.html | 4 ++-- docs/api/namespaces/Sern.html | 4 ++-- docs/guide.html | 4 ++-- docs/guide/getting-started/choose-ide.html | 4 ++-- docs/guide/getting-started/preparing.html | 4 ++-- docs/guide/walkthrough/cli.html | 4 ++-- docs/guide/walkthrough/conclusion.html | 4 ++-- docs/guide/walkthrough/first-command.html | 4 ++-- docs/guide/walkthrough/first-event.html | 4 ++-- docs/guide/walkthrough/goal.html | 4 ++-- docs/guide/walkthrough/good-to-know.html | 4 ++-- docs/guide/walkthrough/plugins.html | 4 ++-- docs/guide/walkthrough/sern-emitter.html | 4 ++-- docs/intro.html | 4 ++-- fr/404.html | 4 ++-- fr/assets/js/{3020eeee.f05b7e13.js => 3020eeee.b0fe60eb.js} | 2 +- fr/assets/js/{6ba1d2c1.7041a0d3.js => 6ba1d2c1.72a398c7.js} | 2 +- fr/assets/js/cf23ded0.407f98d0.js | 1 - fr/assets/js/cf23ded0.bc4a7762.js | 1 + .../{runtime~main.7ed13804.js => runtime~main.2deb8a4a.js} | 2 +- fr/blog.html | 6 +++--- fr/blog/1.2.0.html | 6 +++--- fr/blog/archive.html | 4 ++-- fr/blog/atom.xml | 2 +- fr/blog/rss.xml | 2 +- fr/blog/tags.html | 4 ++-- fr/blog/tags/release.html | 6 +++--- fr/docs/api.html | 4 ++-- fr/docs/api/classes/CommandExecutable.html | 4 ++-- fr/docs/api/classes/Context.html | 4 ++-- fr/docs/api/classes/EventExecutable.html | 4 ++-- fr/docs/api/classes/SernEmitter.html | 4 ++-- fr/docs/api/enums/CommandType.html | 4 ++-- fr/docs/api/enums/EventType.html | 4 ++-- fr/docs/api/enums/PayloadType.html | 4 ++-- fr/docs/api/enums/PluginType.html | 4 ++-- fr/docs/api/interfaces/Controller.html | 4 ++-- fr/docs/api/interfaces/Wrapper.html | 4 ++-- fr/docs/api/modules.html | 4 ++-- fr/docs/api/namespaces/Sern.html | 4 ++-- fr/docs/guide.html | 4 ++-- fr/docs/guide/getting-started/choose-ide.html | 4 ++-- fr/docs/guide/getting-started/preparing.html | 4 ++-- fr/docs/guide/walkthrough/cli.html | 4 ++-- fr/docs/guide/walkthrough/conclusion.html | 4 ++-- fr/docs/guide/walkthrough/first-command.html | 4 ++-- fr/docs/guide/walkthrough/first-event.html | 4 ++-- fr/docs/guide/walkthrough/goal.html | 4 ++-- fr/docs/guide/walkthrough/good-to-know.html | 4 ++-- fr/docs/guide/walkthrough/plugins.html | 4 ++-- fr/docs/guide/walkthrough/sern-emitter.html | 4 ++-- fr/docs/intro.html | 4 ++-- fr/index.html | 4 ++-- fr/markdown-page.html | 4 ++-- fr/plugins.html | 4 ++-- index.html | 4 ++-- markdown-page.html | 4 ++-- plugins.html | 4 ++-- tr/404.html | 4 ++-- tr/assets/js/{3020eeee.c125a283.js => 3020eeee.79954e26.js} | 2 +- tr/assets/js/{6ba1d2c1.f920bd91.js => 6ba1d2c1.a66bb18b.js} | 2 +- tr/assets/js/c103c7fb.30b3a2fa.js | 1 + tr/assets/js/c103c7fb.8692c87f.js | 1 - .../{runtime~main.9f609f77.js => runtime~main.93354cdc.js} | 2 +- tr/blog.html | 6 +++--- tr/blog/1.2.0.html | 6 +++--- tr/blog/archive.html | 4 ++-- tr/blog/atom.xml | 2 +- tr/blog/rss.xml | 2 +- tr/blog/tags.html | 4 ++-- tr/blog/tags/release.html | 6 +++--- tr/docs/api.html | 4 ++-- tr/docs/api/classes/CommandExecutable.html | 4 ++-- tr/docs/api/classes/Context.html | 4 ++-- tr/docs/api/classes/EventExecutable.html | 4 ++-- tr/docs/api/classes/SernEmitter.html | 4 ++-- tr/docs/api/enums/CommandType.html | 4 ++-- tr/docs/api/enums/EventType.html | 4 ++-- tr/docs/api/enums/PayloadType.html | 4 ++-- tr/docs/api/enums/PluginType.html | 4 ++-- tr/docs/api/interfaces/Controller.html | 4 ++-- tr/docs/api/interfaces/Wrapper.html | 4 ++-- tr/docs/api/modules.html | 4 ++-- tr/docs/api/namespaces/Sern.html | 4 ++-- tr/docs/guide.html | 4 ++-- tr/docs/guide/getting-started/choose-ide.html | 4 ++-- tr/docs/guide/getting-started/preparing.html | 4 ++-- tr/docs/guide/walkthrough/cli.html | 4 ++-- tr/docs/guide/walkthrough/conclusion.html | 4 ++-- tr/docs/guide/walkthrough/first-command.html | 4 ++-- tr/docs/guide/walkthrough/first-event.html | 4 ++-- tr/docs/guide/walkthrough/goal.html | 4 ++-- tr/docs/guide/walkthrough/good-to-know.html | 4 ++-- tr/docs/guide/walkthrough/plugins.html | 4 ++-- tr/docs/guide/walkthrough/sern-emitter.html | 4 ++-- tr/docs/intro.html | 4 ++-- tr/index.html | 4 ++-- tr/markdown-page.html | 4 ++-- tr/plugins.html | 4 ++-- 123 files changed, 231 insertions(+), 231 deletions(-) rename assets/js/{3020eeee.4639977c.js => 3020eeee.38579360.js} (61%) rename assets/js/{6ba1d2c1.e8182645.js => 6ba1d2c1.ae2dcf1f.js} (61%) create mode 100644 assets/js/b2f554cd.2a754d9f.js delete mode 100644 assets/js/b2f554cd.b71f36d2.js rename assets/js/{runtime~main.345aab81.js => runtime~main.5540c37d.js} (96%) rename fr/assets/js/{3020eeee.f05b7e13.js => 3020eeee.b0fe60eb.js} (61%) rename fr/assets/js/{6ba1d2c1.7041a0d3.js => 6ba1d2c1.72a398c7.js} (61%) delete mode 100644 fr/assets/js/cf23ded0.407f98d0.js create mode 100644 fr/assets/js/cf23ded0.bc4a7762.js rename fr/assets/js/{runtime~main.7ed13804.js => runtime~main.2deb8a4a.js} (96%) rename tr/assets/js/{3020eeee.c125a283.js => 3020eeee.79954e26.js} (61%) rename tr/assets/js/{6ba1d2c1.f920bd91.js => 6ba1d2c1.a66bb18b.js} (61%) create mode 100644 tr/assets/js/c103c7fb.30b3a2fa.js delete mode 100644 tr/assets/js/c103c7fb.8692c87f.js rename tr/assets/js/{runtime~main.9f609f77.js => runtime~main.93354cdc.js} (54%) diff --git a/404.html b/404.html index 1adfd8277..b5c5e96f3 100644 --- a/404.html +++ b/404.html @@ -6,13 +6,13 @@ Page Not Found | sern - Handlers. Redefined. - +
Skip to main content

Page Not Found

We could not find what you were looking for.

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

- + \ No newline at end of file diff --git a/assets/js/3020eeee.4639977c.js b/assets/js/3020eeee.38579360.js similarity index 61% rename from assets/js/3020eeee.4639977c.js rename to assets/js/3020eeee.38579360.js index 5661b6291..510a5907b 100644 --- a/assets/js/3020eeee.4639977c.js +++ b/assets/js/3020eeee.38579360.js @@ -1 +1 @@ -"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[7223],{3905:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>m});var a=n(7294);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var i=a.createContext({}),p=function(e){var t=a.useContext(i),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},c=function(e){var t=p(e.components);return a.createElement(i.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},u=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,l=e.originalType,i=e.parentName,c=s(e,["components","mdxType","originalType","parentName"]),u=p(n),m=r,b=u["".concat(i,".").concat(m)]||u[m]||d[m]||l;return n?a.createElement(b,o(o({ref:t},c),{},{components:n})):a.createElement(b,o({ref:t},c))}));function m(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var l=n.length,o=new Array(l);o[0]=u;var s={};for(var i in t)hasOwnProperty.call(t,i)&&(s[i]=t[i]);s.originalType=e,s.mdxType="string"==typeof e?e:r,o[1]=s;for(var p=2;p{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>o,default:()=>d,frontMatter:()=>l,metadata:()=>s,toc:()=>p});var a=n(7462),r=(n(7294),n(3905));const l={slug:"1.2.0",title:"Release 1.2.0",authors:["jacoobes"],tags:["release"]},o=void 0,s={permalink:"/blog/1.2.0",editUrl:"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/blog/2022-09-28-mdx-blog-post.md",source:"@site/blog/2022-09-28-mdx-blog-post.md",title:"Release 1.2.0",description:"Class-based modules",date:"2022-09-28T00:00:00.000Z",formattedDate:"September 28, 2022",tags:[{label:"release",permalink:"/blog/tags/release"}],readingTime:1.71,hasTruncateMarker:!1,authors:[{name:"jacoobes",title:"Head Dev",url:"https://github.com/jacoobes",imageURL:"https://github.com/jacoobes.png",key:"jacoobes"}],frontMatter:{slug:"1.2.0",title:"Release 1.2.0",authors:["jacoobes"],tags:["release"]}},i={authorsImageUrls:[void 0]},p=[{value:"Class-based modules",id:"class-based-modules",level:2},{value:"Class based modules",id:"class-based-modules-1",level:3},{value:"Deprecation Warnings",id:"deprecation-warnings",level:3},{value:"Dependencies Update",id:"dependencies-update",level:3}],c={toc:p};function d(e){let{components:t,...n}=e;return(0,r.kt)("wrapper",(0,a.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("h2",{id:"class-based-modules"},"Class-based modules"),(0,r.kt)("p",null,"Today we're announcing the ability to create class based modules!\nTo get started, install"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre"},"npm install @sern/handler@latest\n")),(0,r.kt)("p",null,"Quick List of changes!"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#class-based-modules"},"Class based modules")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#deprecation-warnings"},"Deprecation Warnings")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#dependencies-update"},"Dependencies update"))),(0,r.kt)("h3",{id:"class-based-modules-1"},"Class based modules"),(0,r.kt)("p",null,"Incorporate class based modules into your project instead of the traditional ",(0,r.kt)("inlineCode",{parentName:"p"},"commandModule")," or ",(0,r.kt)("inlineCode",{parentName:"p"},"eventModule"),"\nExtend the new ",(0,r.kt)("a",{parentName:"p",href:"docs/api/classes/CommandExecutable"},"CommandExecutable")," or ",(0,r.kt)("a",{parentName:"p",href:"docs/api/classes/EventExecutable"},"EventExecutable")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="commands/meaning-of-life.ts"',title:'"commands/meaning-of-life.ts"'},'import { CommandType, CommandExecutable, type Args, type Context } from "@sern/handler";\nimport { publish } from "../plugins/publish.js";\nimport { serendipityOnly } from "../plugins/serendipityOnly.js";\n\nexport default class extends CommandExecutable {\n\n type = CommandType.Both as const;\n description = \'What is the meaning of life?\'\n override onEvent = [\n serendipityOnly()\n ];\n override plugins = [\n publish(),\n ];\n // highlight-next-line\n execute = async (ctx: Context, args: Args) => {\n await ctx.reply(\'42\')\n };\n}\n')),(0,r.kt)("admonition",{type:"caution"},(0,r.kt)("p",{parentName:"admonition"},"execute must not be a method of the class. It should be as above, a property on the class!")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="commands/guildMemberAdd.ts"',title:'"commands/guildMemberAdd.ts"'},"import { CommandType, EventExecutable, type EventType } from \"@sern/handler\";\nimport type { GuildMember } from 'discord.js'\nexport default class extends EventExecutable {\n\n type = EventType.Discord as const;\n // highlight-next-line\n execute = (member: GuildMember) => {\n console.log(member)\n };\n}\n")),(0,r.kt)("p",null,"Now, you might ask ",(0,r.kt)("strong",{parentName:"p"},"why")," this feature was added. ",(0,r.kt)("br",null)," Simply put, to give flexibility to the developers.\nI believe that you should build your own structures however you might like and customize to your liking.\nIn addition, ",(0,r.kt)("strong",{parentName:"p"},"decorators now unofficially work with modules!"),"\nFeel free to use TypeScript experimental decorators to augment and customize your classes. "),(0,r.kt)("h3",{id:"deprecation-warnings"},"Deprecation Warnings"),(0,r.kt)("p",null,"The next update will bring sern v2 with some important features. Here are some things to watch out for."),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#client")," will be deprecated"),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#sernEmitter")," will be deprecated",(0,r.kt)("ul",{parentName:"li"},(0,r.kt)("li",{parentName:"ul"},"a SernEmitter will be automatically created once Sern#init is called"))),(0,r.kt)("li",{parentName:"ul"},"The option to pass in a function or array for ",(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#events")," will be deprecated. Only strings are accepted."),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/classes/SernEmitter"},"Sern#addExternal")," will be deprecated in favor of a better way.")),(0,r.kt)("h3",{id:"dependencies-update"},"Dependencies Update"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},"TypeScript has been updated to 4.8.3"),(0,r.kt)("li",{parentName:"ul"},"Discord.js has been upgraded to 14.5")))}d.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[7223],{3905:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>m});var a=n(7294);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var i=a.createContext({}),p=function(e){var t=a.useContext(i),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},c=function(e){var t=p(e.components);return a.createElement(i.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},u=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,l=e.originalType,i=e.parentName,c=s(e,["components","mdxType","originalType","parentName"]),u=p(n),m=r,b=u["".concat(i,".").concat(m)]||u[m]||d[m]||l;return n?a.createElement(b,o(o({ref:t},c),{},{components:n})):a.createElement(b,o({ref:t},c))}));function m(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var l=n.length,o=new Array(l);o[0]=u;var s={};for(var i in t)hasOwnProperty.call(t,i)&&(s[i]=t[i]);s.originalType=e,s.mdxType="string"==typeof e?e:r,o[1]=s;for(var p=2;p{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>o,default:()=>d,frontMatter:()=>l,metadata:()=>s,toc:()=>p});var a=n(7462),r=(n(7294),n(3905));const l={slug:"1.2.0",title:"Release 1.2.0",authors:["jacoobes"],tags:["release"]},o=void 0,s={permalink:"/blog/1.2.0",editUrl:"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/blog/2022-09-28-mdx-blog-post.md",source:"@site/blog/2022-09-28-mdx-blog-post.md",title:"Release 1.2.0",description:"Class-based modules",date:"2022-09-28T00:00:00.000Z",formattedDate:"September 28, 2022",tags:[{label:"release",permalink:"/blog/tags/release"}],readingTime:1.71,hasTruncateMarker:!1,authors:[{name:"jacoobes",title:"Head Dev",url:"https://github.com/jacoobes",imageURL:"https://github.com/jacoobes.png",key:"jacoobes"}],frontMatter:{slug:"1.2.0",title:"Release 1.2.0",authors:["jacoobes"],tags:["release"]}},i={authorsImageUrls:[void 0]},p=[{value:"Class-based modules",id:"class-based-modules",level:2},{value:"Class based modules",id:"class-based-modules-1",level:3},{value:"Deprecation Warnings",id:"deprecation-warnings",level:3},{value:"Dependencies Update",id:"dependencies-update",level:3}],c={toc:p};function d(e){let{components:t,...n}=e;return(0,r.kt)("wrapper",(0,a.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("h2",{id:"class-based-modules"},"Class-based modules"),(0,r.kt)("p",null,"Today we're announcing the ability to create class based modules!\nTo get started, install"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre"},"npm install @sern/handler@latest\n")),(0,r.kt)("p",null,"Quick List of changes!"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#class-based-modules"},"Class based modules")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#deprecation-warnings"},"Deprecation Warnings")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#dependencies-update"},"Dependencies update"))),(0,r.kt)("h3",{id:"class-based-modules-1"},"Class based modules"),(0,r.kt)("p",null,"Incorporate class based modules into your project instead of the traditional ",(0,r.kt)("inlineCode",{parentName:"p"},"commandModule")," or ",(0,r.kt)("inlineCode",{parentName:"p"},"eventModule"),"\nExtend the new ",(0,r.kt)("a",{parentName:"p",href:"docs/api/classes/CommandExecutable"},"CommandExecutable")," or ",(0,r.kt)("a",{parentName:"p",href:"docs/api/classes/EventExecutable"},"EventExecutable")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="commands/meaning-of-life.ts"',title:'"commands/meaning-of-life.ts"'},"import { CommandType, CommandExecutable, type Args, type Context } from '@sern/handler';\nimport { publish } from '../plugins/publish.js';\nimport { serendipityOnly } from '../plugins/serendipityOnly.js';\n\nexport default class extends CommandExecutable {\n type = CommandType.Both as const;\n description = 'What is the meaning of life?'\n override onEvent = [\n serendipityOnly()\n ];\n override plugins = [\n publish(),\n ];\n // highlight-next-line\n execute = async (ctx: Context, args: Args) => {\n await ctx.reply('42')\n };\n}\n")),(0,r.kt)("admonition",{type:"caution"},(0,r.kt)("p",{parentName:"admonition"},"execute must not be a method of the class. It should be as above, a property on the class!")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="events/guildMemberAdd.ts"',title:'"events/guildMemberAdd.ts"'},"import { CommandType, EventExecutable, type EventType } from '@sern/handler';\nimport type { GuildMember } from 'discord.js'\n\nexport default class extends EventExecutable {\n type = EventType.Discord as const;\n // highlight-next-line\n execute = (member: GuildMember) => {\n console.log(member)\n };\n}\n")),(0,r.kt)("p",null,"Now, you might ask ",(0,r.kt)("strong",{parentName:"p"},"why")," this feature was added. ",(0,r.kt)("br",null)," Simply put, to give flexibility to the developers.\nI believe that you should build your own structures however you might like and customize to your liking.\nIn addition, ",(0,r.kt)("strong",{parentName:"p"},"decorators now unofficially work with modules!"),"\nFeel free to use TypeScript experimental decorators to augment and customize your classes. "),(0,r.kt)("h3",{id:"deprecation-warnings"},"Deprecation Warnings"),(0,r.kt)("p",null,"The next update will bring sern v2 with some important features. Here are some things to watch out for."),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#client")," will be deprecated"),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#sernEmitter")," will be deprecated",(0,r.kt)("ul",{parentName:"li"},(0,r.kt)("li",{parentName:"ul"},"a SernEmitter will be automatically created once Sern#init is called"))),(0,r.kt)("li",{parentName:"ul"},"The option to pass in a function or array for ",(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#events")," will be deprecated. Only strings are accepted."),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/classes/SernEmitter"},"Sern#addExternal")," will be deprecated in favor of a better way.")),(0,r.kt)("h3",{id:"dependencies-update"},"Dependencies Update"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},"TypeScript has been updated to 4.8.3"),(0,r.kt)("li",{parentName:"ul"},"Discord.js has been upgraded to 14.5")))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/6ba1d2c1.e8182645.js b/assets/js/6ba1d2c1.ae2dcf1f.js similarity index 61% rename from assets/js/6ba1d2c1.e8182645.js rename to assets/js/6ba1d2c1.ae2dcf1f.js index 38065ad4d..8d5ae65ae 100644 --- a/assets/js/6ba1d2c1.e8182645.js +++ b/assets/js/6ba1d2c1.ae2dcf1f.js @@ -1 +1 @@ -"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[7374],{3905:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>m});var a=n(7294);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var i=a.createContext({}),p=function(e){var t=a.useContext(i),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},c=function(e){var t=p(e.components);return a.createElement(i.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},u=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,l=e.originalType,i=e.parentName,c=s(e,["components","mdxType","originalType","parentName"]),u=p(n),m=r,b=u["".concat(i,".").concat(m)]||u[m]||d[m]||l;return n?a.createElement(b,o(o({ref:t},c),{},{components:n})):a.createElement(b,o({ref:t},c))}));function m(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var l=n.length,o=new Array(l);o[0]=u;var s={};for(var i in t)hasOwnProperty.call(t,i)&&(s[i]=t[i]);s.originalType=e,s.mdxType="string"==typeof e?e:r,o[1]=s;for(var p=2;p{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>o,default:()=>d,frontMatter:()=>l,metadata:()=>s,toc:()=>p});var a=n(7462),r=(n(7294),n(3905));const l={slug:"1.2.0",title:"Release 1.2.0",authors:["jacoobes"],tags:["release"]},o=void 0,s={permalink:"/blog/1.2.0",editUrl:"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/blog/2022-09-28-mdx-blog-post.md",source:"@site/blog/2022-09-28-mdx-blog-post.md",title:"Release 1.2.0",description:"Class-based modules",date:"2022-09-28T00:00:00.000Z",formattedDate:"September 28, 2022",tags:[{label:"release",permalink:"/blog/tags/release"}],readingTime:1.71,hasTruncateMarker:!1,authors:[{name:"jacoobes",title:"Head Dev",url:"https://github.com/jacoobes",imageURL:"https://github.com/jacoobes.png",key:"jacoobes"}],frontMatter:{slug:"1.2.0",title:"Release 1.2.0",authors:["jacoobes"],tags:["release"]}},i={authorsImageUrls:[void 0]},p=[{value:"Class-based modules",id:"class-based-modules",level:2},{value:"Class based modules",id:"class-based-modules-1",level:3},{value:"Deprecation Warnings",id:"deprecation-warnings",level:3},{value:"Dependencies Update",id:"dependencies-update",level:3}],c={toc:p};function d(e){let{components:t,...n}=e;return(0,r.kt)("wrapper",(0,a.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("h2",{id:"class-based-modules"},"Class-based modules"),(0,r.kt)("p",null,"Today we're announcing the ability to create class based modules!\nTo get started, install"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre"},"npm install @sern/handler@latest\n")),(0,r.kt)("p",null,"Quick List of changes!"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#class-based-modules"},"Class based modules")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#deprecation-warnings"},"Deprecation Warnings")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#dependencies-update"},"Dependencies update"))),(0,r.kt)("h3",{id:"class-based-modules-1"},"Class based modules"),(0,r.kt)("p",null,"Incorporate class based modules into your project instead of the traditional ",(0,r.kt)("inlineCode",{parentName:"p"},"commandModule")," or ",(0,r.kt)("inlineCode",{parentName:"p"},"eventModule"),"\nExtend the new ",(0,r.kt)("a",{parentName:"p",href:"docs/api/classes/CommandExecutable"},"CommandExecutable")," or ",(0,r.kt)("a",{parentName:"p",href:"docs/api/classes/EventExecutable"},"EventExecutable")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="commands/meaning-of-life.ts"',title:'"commands/meaning-of-life.ts"'},'import { CommandType, CommandExecutable, type Args, type Context } from "@sern/handler";\nimport { publish } from "../plugins/publish.js";\nimport { serendipityOnly } from "../plugins/serendipityOnly.js";\n\nexport default class extends CommandExecutable {\n\n type = CommandType.Both as const;\n description = \'What is the meaning of life?\'\n override onEvent = [\n serendipityOnly()\n ];\n override plugins = [\n publish(),\n ];\n // highlight-next-line\n execute = async (ctx: Context, args: Args) => {\n await ctx.reply(\'42\')\n };\n}\n')),(0,r.kt)("admonition",{type:"caution"},(0,r.kt)("p",{parentName:"admonition"},"execute must not be a method of the class. It should be as above, a property on the class!")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="commands/guildMemberAdd.ts"',title:'"commands/guildMemberAdd.ts"'},"import { CommandType, EventExecutable, type EventType } from \"@sern/handler\";\nimport type { GuildMember } from 'discord.js'\nexport default class extends EventExecutable {\n\n type = EventType.Discord as const;\n // highlight-next-line\n execute = (member: GuildMember) => {\n console.log(member)\n };\n}\n")),(0,r.kt)("p",null,"Now, you might ask ",(0,r.kt)("strong",{parentName:"p"},"why")," this feature was added. ",(0,r.kt)("br",null)," Simply put, to give flexibility to the developers.\nI believe that you should build your own structures however you might like and customize to your liking.\nIn addition, ",(0,r.kt)("strong",{parentName:"p"},"decorators now unofficially work with modules!"),"\nFeel free to use TypeScript experimental decorators to augment and customize your classes. "),(0,r.kt)("h3",{id:"deprecation-warnings"},"Deprecation Warnings"),(0,r.kt)("p",null,"The next update will bring sern v2 with some important features. Here are some things to watch out for."),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#client")," will be deprecated"),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#sernEmitter")," will be deprecated",(0,r.kt)("ul",{parentName:"li"},(0,r.kt)("li",{parentName:"ul"},"a SernEmitter will be automatically created once Sern#init is called"))),(0,r.kt)("li",{parentName:"ul"},"The option to pass in a function or array for ",(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#events")," will be deprecated. Only strings are accepted."),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/classes/SernEmitter"},"Sern#addExternal")," will be deprecated in favor of a better way.")),(0,r.kt)("h3",{id:"dependencies-update"},"Dependencies Update"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},"TypeScript has been updated to 4.8.3"),(0,r.kt)("li",{parentName:"ul"},"Discord.js has been upgraded to 14.5")))}d.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[7374],{3905:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>m});var a=n(7294);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var i=a.createContext({}),p=function(e){var t=a.useContext(i),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},c=function(e){var t=p(e.components);return a.createElement(i.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},u=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,l=e.originalType,i=e.parentName,c=s(e,["components","mdxType","originalType","parentName"]),u=p(n),m=r,b=u["".concat(i,".").concat(m)]||u[m]||d[m]||l;return n?a.createElement(b,o(o({ref:t},c),{},{components:n})):a.createElement(b,o({ref:t},c))}));function m(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var l=n.length,o=new Array(l);o[0]=u;var s={};for(var i in t)hasOwnProperty.call(t,i)&&(s[i]=t[i]);s.originalType=e,s.mdxType="string"==typeof e?e:r,o[1]=s;for(var p=2;p{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>o,default:()=>d,frontMatter:()=>l,metadata:()=>s,toc:()=>p});var a=n(7462),r=(n(7294),n(3905));const l={slug:"1.2.0",title:"Release 1.2.0",authors:["jacoobes"],tags:["release"]},o=void 0,s={permalink:"/blog/1.2.0",editUrl:"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/blog/2022-09-28-mdx-blog-post.md",source:"@site/blog/2022-09-28-mdx-blog-post.md",title:"Release 1.2.0",description:"Class-based modules",date:"2022-09-28T00:00:00.000Z",formattedDate:"September 28, 2022",tags:[{label:"release",permalink:"/blog/tags/release"}],readingTime:1.71,hasTruncateMarker:!1,authors:[{name:"jacoobes",title:"Head Dev",url:"https://github.com/jacoobes",imageURL:"https://github.com/jacoobes.png",key:"jacoobes"}],frontMatter:{slug:"1.2.0",title:"Release 1.2.0",authors:["jacoobes"],tags:["release"]}},i={authorsImageUrls:[void 0]},p=[{value:"Class-based modules",id:"class-based-modules",level:2},{value:"Class based modules",id:"class-based-modules-1",level:3},{value:"Deprecation Warnings",id:"deprecation-warnings",level:3},{value:"Dependencies Update",id:"dependencies-update",level:3}],c={toc:p};function d(e){let{components:t,...n}=e;return(0,r.kt)("wrapper",(0,a.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("h2",{id:"class-based-modules"},"Class-based modules"),(0,r.kt)("p",null,"Today we're announcing the ability to create class based modules!\nTo get started, install"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre"},"npm install @sern/handler@latest\n")),(0,r.kt)("p",null,"Quick List of changes!"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#class-based-modules"},"Class based modules")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#deprecation-warnings"},"Deprecation Warnings")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#dependencies-update"},"Dependencies update"))),(0,r.kt)("h3",{id:"class-based-modules-1"},"Class based modules"),(0,r.kt)("p",null,"Incorporate class based modules into your project instead of the traditional ",(0,r.kt)("inlineCode",{parentName:"p"},"commandModule")," or ",(0,r.kt)("inlineCode",{parentName:"p"},"eventModule"),"\nExtend the new ",(0,r.kt)("a",{parentName:"p",href:"docs/api/classes/CommandExecutable"},"CommandExecutable")," or ",(0,r.kt)("a",{parentName:"p",href:"docs/api/classes/EventExecutable"},"EventExecutable")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="commands/meaning-of-life.ts"',title:'"commands/meaning-of-life.ts"'},"import { CommandType, CommandExecutable, type Args, type Context } from '@sern/handler';\nimport { publish } from '../plugins/publish.js';\nimport { serendipityOnly } from '../plugins/serendipityOnly.js';\n\nexport default class extends CommandExecutable {\n type = CommandType.Both as const;\n description = 'What is the meaning of life?'\n override onEvent = [\n serendipityOnly()\n ];\n override plugins = [\n publish(),\n ];\n // highlight-next-line\n execute = async (ctx: Context, args: Args) => {\n await ctx.reply('42')\n };\n}\n")),(0,r.kt)("admonition",{type:"caution"},(0,r.kt)("p",{parentName:"admonition"},"execute must not be a method of the class. It should be as above, a property on the class!")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="events/guildMemberAdd.ts"',title:'"events/guildMemberAdd.ts"'},"import { CommandType, EventExecutable, type EventType } from '@sern/handler';\nimport type { GuildMember } from 'discord.js'\n\nexport default class extends EventExecutable {\n type = EventType.Discord as const;\n // highlight-next-line\n execute = (member: GuildMember) => {\n console.log(member)\n };\n}\n")),(0,r.kt)("p",null,"Now, you might ask ",(0,r.kt)("strong",{parentName:"p"},"why")," this feature was added. ",(0,r.kt)("br",null)," Simply put, to give flexibility to the developers.\nI believe that you should build your own structures however you might like and customize to your liking.\nIn addition, ",(0,r.kt)("strong",{parentName:"p"},"decorators now unofficially work with modules!"),"\nFeel free to use TypeScript experimental decorators to augment and customize your classes. "),(0,r.kt)("h3",{id:"deprecation-warnings"},"Deprecation Warnings"),(0,r.kt)("p",null,"The next update will bring sern v2 with some important features. Here are some things to watch out for."),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#client")," will be deprecated"),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#sernEmitter")," will be deprecated",(0,r.kt)("ul",{parentName:"li"},(0,r.kt)("li",{parentName:"ul"},"a SernEmitter will be automatically created once Sern#init is called"))),(0,r.kt)("li",{parentName:"ul"},"The option to pass in a function or array for ",(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#events")," will be deprecated. Only strings are accepted."),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/classes/SernEmitter"},"Sern#addExternal")," will be deprecated in favor of a better way.")),(0,r.kt)("h3",{id:"dependencies-update"},"Dependencies Update"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},"TypeScript has been updated to 4.8.3"),(0,r.kt)("li",{parentName:"ul"},"Discord.js has been upgraded to 14.5")))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/b2f554cd.2a754d9f.js b/assets/js/b2f554cd.2a754d9f.js new file mode 100644 index 000000000..f78477d64 --- /dev/null +++ b/assets/js/b2f554cd.2a754d9f.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[1477],{10:e=>{e.exports=JSON.parse('{"blogPosts":[{"id":"1.2.0","metadata":{"permalink":"/blog/1.2.0","editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/blog/2022-09-28-mdx-blog-post.md","source":"@site/blog/2022-09-28-mdx-blog-post.md","title":"Release 1.2.0","description":"Class-based modules","date":"2022-09-28T00:00:00.000Z","formattedDate":"September 28, 2022","tags":[{"label":"release","permalink":"/blog/tags/release"}],"readingTime":1.71,"hasTruncateMarker":false,"authors":[{"name":"jacoobes","title":"Head Dev","url":"https://github.com/jacoobes","imageURL":"https://github.com/jacoobes.png","key":"jacoobes"}],"frontMatter":{"slug":"1.2.0","title":"Release 1.2.0","authors":["jacoobes"],"tags":["release"]}},"content":"## Class-based modules\\n\\nToday we\'re announcing the ability to create class based modules!\\nTo get started, install\\n```\\nnpm install @sern/handler@latest\\n```\\n\\nQuick List of changes!\\n- [Class based modules](#class-based-modules)\\n- [Deprecation Warnings](#deprecation-warnings)\\n- [Dependencies update](#dependencies-update)\\n\\n\\n### Class based modules\\nIncorporate class based modules into your project instead of the traditional `commandModule` or `eventModule`\\nExtend the new [CommandExecutable](docs/api/classes/CommandExecutable) or [EventExecutable](docs/api/classes/EventExecutable)\\n```ts title=\\"commands/meaning-of-life.ts\\"\\nimport { CommandType, CommandExecutable, type Args, type Context } from \'@sern/handler\';\\nimport { publish } from \'../plugins/publish.js\';\\nimport { serendipityOnly } from \'../plugins/serendipityOnly.js\';\\n\\nexport default class extends CommandExecutable {\\n type = CommandType.Both as const;\\n description = \'What is the meaning of life?\'\\n override onEvent = [\\n serendipityOnly()\\n ];\\n override plugins = [\\n publish(),\\n ];\\n // highlight-next-line\\n execute = async (ctx: Context, args: Args) => {\\n await ctx.reply(\'42\')\\n };\\n}\\n```\\n:::caution\\n\\nexecute must not be a method of the class. It should be as above, a property on the class!\\n\\n:::\\n\\n```ts title=\\"events/guildMemberAdd.ts\\"\\nimport { CommandType, EventExecutable, type EventType } from \'@sern/handler\';\\nimport type { GuildMember } from \'discord.js\'\\n\\nexport default class extends EventExecutable {\\n type = EventType.Discord as const;\\n // highlight-next-line\\n execute = (member: GuildMember) => {\\n console.log(member)\\n };\\n}\\n```\\nNow, you might ask **why** this feature was added.
Simply put, to give flexibility to the developers.\\nI believe that you should build your own structures however you might like and customize to your liking.\\nIn addition, **decorators now unofficially work with modules!**\\nFeel free to use TypeScript experimental decorators to augment and customize your classes. \\n\\n### Deprecation Warnings\\nThe next update will bring sern v2 with some important features. Here are some things to watch out for.\\n\\n- [Wrapper#client](docs/api/interfaces/Wrapper) will be deprecated\\n- [Wrapper#sernEmitter](docs/api/interfaces/Wrapper) will be deprecated\\n - a SernEmitter will be automatically created once Sern#init is called\\n- The option to pass in a function or array for [Wrapper#events](docs/api/interfaces/Wrapper) will be deprecated. Only strings are accepted.\\n- [Sern#addExternal](docs/api/classes/SernEmitter) will be deprecated in favor of a better way.\\n\\n### Dependencies Update\\n- TypeScript has been updated to 4.8.3\\n- Discord.js has been upgraded to 14.5"}]}')}}]); \ No newline at end of file diff --git a/assets/js/b2f554cd.b71f36d2.js b/assets/js/b2f554cd.b71f36d2.js deleted file mode 100644 index d8d23f815..000000000 --- a/assets/js/b2f554cd.b71f36d2.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[1477],{10:e=>{e.exports=JSON.parse('{"blogPosts":[{"id":"1.2.0","metadata":{"permalink":"/blog/1.2.0","editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/blog/2022-09-28-mdx-blog-post.md","source":"@site/blog/2022-09-28-mdx-blog-post.md","title":"Release 1.2.0","description":"Class-based modules","date":"2022-09-28T00:00:00.000Z","formattedDate":"September 28, 2022","tags":[{"label":"release","permalink":"/blog/tags/release"}],"readingTime":1.71,"hasTruncateMarker":false,"authors":[{"name":"jacoobes","title":"Head Dev","url":"https://github.com/jacoobes","imageURL":"https://github.com/jacoobes.png","key":"jacoobes"}],"frontMatter":{"slug":"1.2.0","title":"Release 1.2.0","authors":["jacoobes"],"tags":["release"]}},"content":"## Class-based modules\\n\\nToday we\'re announcing the ability to create class based modules!\\nTo get started, install\\n```\\nnpm install @sern/handler@latest\\n```\\n\\nQuick List of changes!\\n- [Class based modules](#class-based-modules)\\n- [Deprecation Warnings](#deprecation-warnings)\\n- [Dependencies update](#dependencies-update)\\n\\n\\n\\n### Class based modules\\nIncorporate class based modules into your project instead of the traditional `commandModule` or `eventModule`\\nExtend the new [CommandExecutable](docs/api/classes/CommandExecutable) or [EventExecutable](docs/api/classes/EventExecutable)\\n```ts title=\\"commands/meaning-of-life.ts\\"\\nimport { CommandType, CommandExecutable, type Args, type Context } from \\"@sern/handler\\";\\nimport { publish } from \\"../plugins/publish.js\\";\\nimport { serendipityOnly } from \\"../plugins/serendipityOnly.js\\";\\n\\nexport default class extends CommandExecutable {\\n\\n type = CommandType.Both as const;\\n description = \'What is the meaning of life?\'\\n override onEvent = [\\n serendipityOnly()\\n ];\\n override plugins = [\\n publish(),\\n ];\\n // highlight-next-line\\n execute = async (ctx: Context, args: Args) => {\\n await ctx.reply(\'42\')\\n };\\n}\\n```\\n:::caution\\n\\nexecute must not be a method of the class. It should be as above, a property on the class!\\n\\n:::\\n\\n```ts title=\\"commands/guildMemberAdd.ts\\"\\nimport { CommandType, EventExecutable, type EventType } from \\"@sern/handler\\";\\nimport type { GuildMember } from \'discord.js\'\\nexport default class extends EventExecutable {\\n\\n type = EventType.Discord as const;\\n // highlight-next-line\\n execute = (member: GuildMember) => {\\n console.log(member)\\n };\\n}\\n```\\nNow, you might ask **why** this feature was added.
Simply put, to give flexibility to the developers.\\nI believe that you should build your own structures however you might like and customize to your liking.\\nIn addition, **decorators now unofficially work with modules!**\\nFeel free to use TypeScript experimental decorators to augment and customize your classes. \\n\\n### Deprecation Warnings\\nThe next update will bring sern v2 with some important features. Here are some things to watch out for.\\n\\n- [Wrapper#client](docs/api/interfaces/Wrapper) will be deprecated\\n- [Wrapper#sernEmitter](docs/api/interfaces/Wrapper) will be deprecated\\n - a SernEmitter will be automatically created once Sern#init is called\\n- The option to pass in a function or array for [Wrapper#events](docs/api/interfaces/Wrapper) will be deprecated. Only strings are accepted.\\n- [Sern#addExternal](docs/api/classes/SernEmitter) will be deprecated in favor of a better way.\\n\\n### Dependencies Update\\n- TypeScript has been updated to 4.8.3\\n- Discord.js has been upgraded to 14.5"}]}')}}]); \ No newline at end of file diff --git a/assets/js/runtime~main.345aab81.js b/assets/js/runtime~main.5540c37d.js similarity index 96% rename from assets/js/runtime~main.345aab81.js rename to assets/js/runtime~main.5540c37d.js index 84ecfdd58..48c102c9f 100644 --- a/assets/js/runtime~main.345aab81.js +++ b/assets/js/runtime~main.5540c37d.js @@ -1 +1 @@ -(()=>{"use strict";var e,c,t,r,a,f={},b={};function d(e){var c=b[e];if(void 0!==c)return c.exports;var t=b[e]={id:e,loaded:!1,exports:{}};return f[e].call(t.exports,t,t.exports,d),t.loaded=!0,t.exports}d.m=f,d.c=b,e=[],d.O=(c,t,r,a)=>{if(!t){var f=1/0;for(i=0;i=a)&&Object.keys(d.O).every((e=>d.O[e](t[o])))?t.splice(o--,1):(b=!1,a0&&e[i-1][2]>a;i--)e[i]=e[i-1];e[i]=[t,r,a]},d.n=e=>{var c=e&&e.__esModule?()=>e.default:()=>e;return d.d(c,{a:c}),c},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,d.t=function(e,r){if(1&r&&(e=this(e)),8&r)return e;if("object"==typeof e&&e){if(4&r&&e.__esModule)return e;if(16&r&&"function"==typeof e.then)return e}var a=Object.create(null);d.r(a);var f={};c=c||[null,t({}),t([]),t(t)];for(var b=2&r&&e;"object"==typeof b&&!~c.indexOf(b);b=t(b))Object.getOwnPropertyNames(b).forEach((c=>f[c]=()=>e[c]));return f.default=()=>e,d.d(a,f),a},d.d=(e,c)=>{for(var t in c)d.o(c,t)&&!d.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:c[t]})},d.f={},d.e=e=>Promise.all(Object.keys(d.f).reduce(((c,t)=>(d.f[t](e,c),c)),[])),d.u=e=>"assets/js/"+({53:"5bc4ccbc",205:"83d480e9",277:"c4348237",332:"73bd57bd",533:"b2b675dd",703:"981f6151",1036:"c0846785",1472:"cf183316",1477:"b2f554cd",1505:"7c2ff145",1713:"a7023ddc",2005:"1ac1bfe9",2197:"935f2afb",2535:"814f3328",2640:"a96c96b0",3045:"888566f1",3085:"1f391b9e",3089:"a6aa9e1f",3608:"9e4087bc",4013:"01a85c17",4137:"1aef51bd",4195:"c4f5d8e4",4332:"6c624b4c",4429:"eea0bf40",4803:"9201de17",4865:"e8e3d8c7",5062:"69369ae2",5397:"312c2bc5",6103:"ccc49370",6146:"608ca171",6270:"e4877132",6322:"a5467962",7127:"7e205c4a",7223:"3020eeee",7306:"f6aebfbf",7363:"26f1f3a5",7374:"6ba1d2c1",7414:"393be207",7438:"9c021584",7597:"5e8c322a",7750:"3a2d3092",7918:"17896441",8610:"6875c492",8652:"bcd9df7e",9226:"707baeff",9514:"1be78505",9671:"0e384e19",9712:"3dc7c79a"}[e]||e)+"."+{53:"92cc6d18",205:"eab2a9ae",277:"bbd90c09",332:"383ce150",533:"7881b09d",703:"acf5ae36",1036:"91a9ca08",1472:"eb995599",1477:"b71f36d2",1505:"ac336ebd",1713:"931ff84d",2005:"0d668acf",2197:"47826bb0",2529:"824aaa15",2535:"c1c87a03",2640:"adb9b5b6",3045:"b736b053",3085:"8c38cce5",3089:"41e3be1f",3608:"66639242",4013:"e1f6e46d",4137:"6b77f2f4",4195:"e4059570",4332:"4d15c544",4429:"6eea27e0",4803:"5d152ee5",4865:"589397c6",4972:"8f7e7193",5062:"40f3e7eb",5397:"1cae9e75",6103:"7974c41a",6146:"16600ea2",6270:"c7d96e55",6322:"89fc49a2",7127:"41cd04ca",7223:"4639977c",7306:"daff3f4e",7363:"9a6faf84",7374:"e8182645",7414:"93c2e119",7438:"79afbc4d",7540:"0456e07a",7597:"d36b9afa",7750:"ba775b44",7918:"3625818f",8610:"d7a7cd5d",8652:"fd236fd7",9226:"367c3cac",9514:"b1e810d5",9671:"4425eaf5",9712:"346d9fd5"}[e]+".js",d.miniCssF=e=>{},d.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),d.o=(e,c)=>Object.prototype.hasOwnProperty.call(e,c),r={},a="@sern/website:",d.l=(e,c,t,f)=>{if(r[e])r[e].push(c);else{var b,o;if(void 0!==t)for(var n=document.getElementsByTagName("script"),i=0;i{b.onerror=b.onload=null,clearTimeout(s);var a=r[e];if(delete r[e],b.parentNode&&b.parentNode.removeChild(b),a&&a.forEach((e=>e(t))),c)return c(t)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:b}),12e4);b.onerror=l.bind(null,b.onerror),b.onload=l.bind(null,b.onload),o&&document.head.appendChild(b)}},d.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},d.p="/",d.gca=function(e){return e={17896441:"7918","5bc4ccbc":"53","83d480e9":"205",c4348237:"277","73bd57bd":"332",b2b675dd:"533","981f6151":"703",c0846785:"1036",cf183316:"1472",b2f554cd:"1477","7c2ff145":"1505",a7023ddc:"1713","1ac1bfe9":"2005","935f2afb":"2197","814f3328":"2535",a96c96b0:"2640","888566f1":"3045","1f391b9e":"3085",a6aa9e1f:"3089","9e4087bc":"3608","01a85c17":"4013","1aef51bd":"4137",c4f5d8e4:"4195","6c624b4c":"4332",eea0bf40:"4429","9201de17":"4803",e8e3d8c7:"4865","69369ae2":"5062","312c2bc5":"5397",ccc49370:"6103","608ca171":"6146",e4877132:"6270",a5467962:"6322","7e205c4a":"7127","3020eeee":"7223",f6aebfbf:"7306","26f1f3a5":"7363","6ba1d2c1":"7374","393be207":"7414","9c021584":"7438","5e8c322a":"7597","3a2d3092":"7750","6875c492":"8610",bcd9df7e:"8652","707baeff":"9226","1be78505":"9514","0e384e19":"9671","3dc7c79a":"9712"}[e]||e,d.p+d.u(e)},(()=>{var e={1303:0,532:0};d.f.j=(c,t)=>{var r=d.o(e,c)?e[c]:void 0;if(0!==r)if(r)t.push(r[2]);else if(/^(1303|532)$/.test(c))e[c]=0;else{var a=new Promise(((t,a)=>r=e[c]=[t,a]));t.push(r[2]=a);var f=d.p+d.u(c),b=new Error;d.l(f,(t=>{if(d.o(e,c)&&(0!==(r=e[c])&&(e[c]=void 0),r)){var a=t&&("load"===t.type?"missing":t.type),f=t&&t.target&&t.target.src;b.message="Loading chunk "+c+" failed.\n("+a+": "+f+")",b.name="ChunkLoadError",b.type=a,b.request=f,r[1](b)}}),"chunk-"+c,c)}},d.O.j=c=>0===e[c];var c=(c,t)=>{var r,a,f=t[0],b=t[1],o=t[2],n=0;if(f.some((c=>0!==e[c]))){for(r in b)d.o(b,r)&&(d.m[r]=b[r]);if(o)var i=o(d)}for(c&&c(t);n{"use strict";var e,c,t,r,a,f={},b={};function d(e){var c=b[e];if(void 0!==c)return c.exports;var t=b[e]={id:e,loaded:!1,exports:{}};return f[e].call(t.exports,t,t.exports,d),t.loaded=!0,t.exports}d.m=f,d.c=b,e=[],d.O=(c,t,r,a)=>{if(!t){var f=1/0;for(i=0;i=a)&&Object.keys(d.O).every((e=>d.O[e](t[o])))?t.splice(o--,1):(b=!1,a0&&e[i-1][2]>a;i--)e[i]=e[i-1];e[i]=[t,r,a]},d.n=e=>{var c=e&&e.__esModule?()=>e.default:()=>e;return d.d(c,{a:c}),c},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,d.t=function(e,r){if(1&r&&(e=this(e)),8&r)return e;if("object"==typeof e&&e){if(4&r&&e.__esModule)return e;if(16&r&&"function"==typeof e.then)return e}var a=Object.create(null);d.r(a);var f={};c=c||[null,t({}),t([]),t(t)];for(var b=2&r&&e;"object"==typeof b&&!~c.indexOf(b);b=t(b))Object.getOwnPropertyNames(b).forEach((c=>f[c]=()=>e[c]));return f.default=()=>e,d.d(a,f),a},d.d=(e,c)=>{for(var t in c)d.o(c,t)&&!d.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:c[t]})},d.f={},d.e=e=>Promise.all(Object.keys(d.f).reduce(((c,t)=>(d.f[t](e,c),c)),[])),d.u=e=>"assets/js/"+({53:"5bc4ccbc",205:"83d480e9",277:"c4348237",332:"73bd57bd",533:"b2b675dd",703:"981f6151",1036:"c0846785",1472:"cf183316",1477:"b2f554cd",1505:"7c2ff145",1713:"a7023ddc",2005:"1ac1bfe9",2197:"935f2afb",2535:"814f3328",2640:"a96c96b0",3045:"888566f1",3085:"1f391b9e",3089:"a6aa9e1f",3608:"9e4087bc",4013:"01a85c17",4137:"1aef51bd",4195:"c4f5d8e4",4332:"6c624b4c",4429:"eea0bf40",4803:"9201de17",4865:"e8e3d8c7",5062:"69369ae2",5397:"312c2bc5",6103:"ccc49370",6146:"608ca171",6270:"e4877132",6322:"a5467962",7127:"7e205c4a",7223:"3020eeee",7306:"f6aebfbf",7363:"26f1f3a5",7374:"6ba1d2c1",7414:"393be207",7438:"9c021584",7597:"5e8c322a",7750:"3a2d3092",7918:"17896441",8610:"6875c492",8652:"bcd9df7e",9226:"707baeff",9514:"1be78505",9671:"0e384e19",9712:"3dc7c79a"}[e]||e)+"."+{53:"92cc6d18",205:"eab2a9ae",277:"bbd90c09",332:"383ce150",533:"7881b09d",703:"acf5ae36",1036:"91a9ca08",1472:"eb995599",1477:"2a754d9f",1505:"ac336ebd",1713:"931ff84d",2005:"0d668acf",2197:"47826bb0",2529:"824aaa15",2535:"c1c87a03",2640:"adb9b5b6",3045:"b736b053",3085:"8c38cce5",3089:"41e3be1f",3608:"66639242",4013:"e1f6e46d",4137:"6b77f2f4",4195:"e4059570",4332:"4d15c544",4429:"6eea27e0",4803:"5d152ee5",4865:"589397c6",4972:"8f7e7193",5062:"40f3e7eb",5397:"1cae9e75",6103:"7974c41a",6146:"16600ea2",6270:"c7d96e55",6322:"89fc49a2",7127:"41cd04ca",7223:"38579360",7306:"daff3f4e",7363:"9a6faf84",7374:"ae2dcf1f",7414:"93c2e119",7438:"79afbc4d",7540:"0456e07a",7597:"d36b9afa",7750:"ba775b44",7918:"3625818f",8610:"d7a7cd5d",8652:"fd236fd7",9226:"367c3cac",9514:"b1e810d5",9671:"4425eaf5",9712:"346d9fd5"}[e]+".js",d.miniCssF=e=>{},d.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),d.o=(e,c)=>Object.prototype.hasOwnProperty.call(e,c),r={},a="@sern/website:",d.l=(e,c,t,f)=>{if(r[e])r[e].push(c);else{var b,o;if(void 0!==t)for(var n=document.getElementsByTagName("script"),i=0;i{b.onerror=b.onload=null,clearTimeout(s);var a=r[e];if(delete r[e],b.parentNode&&b.parentNode.removeChild(b),a&&a.forEach((e=>e(t))),c)return c(t)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:b}),12e4);b.onerror=l.bind(null,b.onerror),b.onload=l.bind(null,b.onload),o&&document.head.appendChild(b)}},d.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},d.p="/",d.gca=function(e){return e={17896441:"7918","5bc4ccbc":"53","83d480e9":"205",c4348237:"277","73bd57bd":"332",b2b675dd:"533","981f6151":"703",c0846785:"1036",cf183316:"1472",b2f554cd:"1477","7c2ff145":"1505",a7023ddc:"1713","1ac1bfe9":"2005","935f2afb":"2197","814f3328":"2535",a96c96b0:"2640","888566f1":"3045","1f391b9e":"3085",a6aa9e1f:"3089","9e4087bc":"3608","01a85c17":"4013","1aef51bd":"4137",c4f5d8e4:"4195","6c624b4c":"4332",eea0bf40:"4429","9201de17":"4803",e8e3d8c7:"4865","69369ae2":"5062","312c2bc5":"5397",ccc49370:"6103","608ca171":"6146",e4877132:"6270",a5467962:"6322","7e205c4a":"7127","3020eeee":"7223",f6aebfbf:"7306","26f1f3a5":"7363","6ba1d2c1":"7374","393be207":"7414","9c021584":"7438","5e8c322a":"7597","3a2d3092":"7750","6875c492":"8610",bcd9df7e:"8652","707baeff":"9226","1be78505":"9514","0e384e19":"9671","3dc7c79a":"9712"}[e]||e,d.p+d.u(e)},(()=>{var e={1303:0,532:0};d.f.j=(c,t)=>{var r=d.o(e,c)?e[c]:void 0;if(0!==r)if(r)t.push(r[2]);else if(/^(1303|532)$/.test(c))e[c]=0;else{var a=new Promise(((t,a)=>r=e[c]=[t,a]));t.push(r[2]=a);var f=d.p+d.u(c),b=new Error;d.l(f,(t=>{if(d.o(e,c)&&(0!==(r=e[c])&&(e[c]=void 0),r)){var a=t&&("load"===t.type?"missing":t.type),f=t&&t.target&&t.target.src;b.message="Loading chunk "+c+" failed.\n("+a+": "+f+")",b.name="ChunkLoadError",b.type=a,b.request=f,r[1](b)}}),"chunk-"+c,c)}},d.O.j=c=>0===e[c];var c=(c,t)=>{var r,a,f=t[0],b=t[1],o=t[2],n=0;if(f.some((c=>0!==e[c]))){for(r in b)d.o(b,r)&&(d.m[r]=b[r]);if(o)var i=o(d)}for(c&&c(t);n Blog | sern - Handlers. Redefined. - +

· 2 min read
jacoobes

Class-based modules

Today we're announcing the ability to create class based modules! To get started, install

npm install @sern/handler@latest

Quick List of changes!

Class based modules

Incorporate class based modules into your project instead of the traditional commandModule or eventModule -Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from "@sern/handler";
import { publish } from "../plugins/publish.js";
import { serendipityOnly } from "../plugins/serendipityOnly.js";

export default class extends CommandExecutable<CommandType.Both> {

type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
caution

execute must not be a method of the class. It should be as above, a property on the class!

commands/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from "@sern/handler";
import type { GuildMember } from 'discord.js'
export default class extends EventExecutable<EventType.Discord> {

type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. +Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from '@sern/handler';
import { publish } from '../plugins/publish.js';
import { serendipityOnly } from '../plugins/serendipityOnly.js';

export default class extends CommandExecutable<CommandType.Both> {
type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
caution

execute must not be a method of the class. It should be as above, a property on the class!

events/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from '@sern/handler';
import type { GuildMember } from 'discord.js'

export default class extends EventExecutable<EventType.Discord> {
type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. I believe that you should build your own structures however you might like and customize to your liking. In addition, decorators now unofficially work with modules! Feel free to use TypeScript experimental decorators to augment and customize your classes.

Deprecation Warnings

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

Dependencies Update

  • TypeScript has been updated to 4.8.3
  • Discord.js has been upgraded to 14.5
- + \ No newline at end of file diff --git a/blog/1.2.0.html b/blog/1.2.0.html index 548040da8..30fadc90a 100644 --- a/blog/1.2.0.html +++ b/blog/1.2.0.html @@ -6,18 +6,18 @@ Release 1.2.0 | sern - Handlers. Redefined. - +

Release 1.2.0

· 2 min read
jacoobes

Class-based modules

Today we're announcing the ability to create class based modules! To get started, install

npm install @sern/handler@latest

Quick List of changes!

Class based modules

Incorporate class based modules into your project instead of the traditional commandModule or eventModule -Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from "@sern/handler";
import { publish } from "../plugins/publish.js";
import { serendipityOnly } from "../plugins/serendipityOnly.js";

export default class extends CommandExecutable<CommandType.Both> {

type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
caution

execute must not be a method of the class. It should be as above, a property on the class!

commands/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from "@sern/handler";
import type { GuildMember } from 'discord.js'
export default class extends EventExecutable<EventType.Discord> {

type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. +Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from '@sern/handler';
import { publish } from '../plugins/publish.js';
import { serendipityOnly } from '../plugins/serendipityOnly.js';

export default class extends CommandExecutable<CommandType.Both> {
type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
caution

execute must not be a method of the class. It should be as above, a property on the class!

events/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from '@sern/handler';
import type { GuildMember } from 'discord.js'

export default class extends EventExecutable<EventType.Discord> {
type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. I believe that you should build your own structures however you might like and customize to your liking. In addition, decorators now unofficially work with modules! Feel free to use TypeScript experimental decorators to augment and customize your classes.

Deprecation Warnings

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

Dependencies Update

  • TypeScript has been updated to 4.8.3
  • Discord.js has been upgraded to 14.5
- + \ No newline at end of file diff --git a/blog/archive.html b/blog/archive.html index feeda8372..aadc63e85 100644 --- a/blog/archive.html +++ b/blog/archive.html @@ -6,13 +6,13 @@ Archive | sern - Handlers. Redefined. - +
- + \ No newline at end of file diff --git a/blog/atom.xml b/blog/atom.xml index b3853ec7d..e202cfd92 100644 --- a/blog/atom.xml +++ b/blog/atom.xml @@ -15,7 +15,7 @@ Class-based modules

Today we're announcing the ability to create class based modules! To get started, install

npm install @sern/handler@latest

Quick List of changes!

Class based modules

Incorporate class based modules into your project instead of the traditional commandModule or eventModule -Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from "@sern/handler";
import { publish } from "../plugins/publish.js";
import { serendipityOnly } from "../plugins/serendipityOnly.js";

export default class extends CommandExecutable<CommandType.Both> {

type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
caution

execute must not be a method of the class. It should be as above, a property on the class!

commands/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from "@sern/handler";
import type { GuildMember } from 'discord.js'
export default class extends EventExecutable<EventType.Discord> {

type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. +Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from '@sern/handler';
import { publish } from '../plugins/publish.js';
import { serendipityOnly } from '../plugins/serendipityOnly.js';

export default class extends CommandExecutable<CommandType.Both> {
type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
caution

execute must not be a method of the class. It should be as above, a property on the class!

events/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from '@sern/handler';
import type { GuildMember } from 'discord.js'

export default class extends EventExecutable<EventType.Discord> {
type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. I believe that you should build your own structures however you might like and customize to your liking. In addition, decorators now unofficially work with modules! Feel free to use TypeScript experimental decorators to augment and customize your classes.

Deprecation Warnings

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

Dependencies Update

  • TypeScript has been updated to 4.8.3
  • Discord.js has been upgraded to 14.5
]]>
diff --git a/blog/rss.xml b/blog/rss.xml index 27eb1ee4a..925f3591c 100644 --- a/blog/rss.xml +++ b/blog/rss.xml @@ -16,7 +16,7 @@ Class-based modules

Today we're announcing the ability to create class based modules! To get started, install

npm install @sern/handler@latest

Quick List of changes!

Class based modules

Incorporate class based modules into your project instead of the traditional commandModule or eventModule -Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from "@sern/handler";
import { publish } from "../plugins/publish.js";
import { serendipityOnly } from "../plugins/serendipityOnly.js";

export default class extends CommandExecutable<CommandType.Both> {

type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
caution

execute must not be a method of the class. It should be as above, a property on the class!

commands/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from "@sern/handler";
import type { GuildMember } from 'discord.js'
export default class extends EventExecutable<EventType.Discord> {

type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. +Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from '@sern/handler';
import { publish } from '../plugins/publish.js';
import { serendipityOnly } from '../plugins/serendipityOnly.js';

export default class extends CommandExecutable<CommandType.Both> {
type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
caution

execute must not be a method of the class. It should be as above, a property on the class!

events/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from '@sern/handler';
import type { GuildMember } from 'discord.js'

export default class extends EventExecutable<EventType.Discord> {
type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. I believe that you should build your own structures however you might like and customize to your liking. In addition, decorators now unofficially work with modules! Feel free to use TypeScript experimental decorators to augment and customize your classes.

Deprecation Warnings

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

Dependencies Update

  • TypeScript has been updated to 4.8.3
  • Discord.js has been upgraded to 14.5
]]>
diff --git a/blog/tags.html b/blog/tags.html index 6ad917340..ac63997e9 100644 --- a/blog/tags.html +++ b/blog/tags.html @@ -6,13 +6,13 @@ Tags | sern - Handlers. Redefined. - +

Tags

- + \ No newline at end of file diff --git a/blog/tags/release.html b/blog/tags/release.html index 03db1d4e0..7b58dfe14 100644 --- a/blog/tags/release.html +++ b/blog/tags/release.html @@ -6,18 +6,18 @@ One post tagged with "release" | sern - Handlers. Redefined. - +

One post tagged with "release"

View All Tags

· 2 min read
jacoobes

Class-based modules

Today we're announcing the ability to create class based modules! To get started, install

npm install @sern/handler@latest

Quick List of changes!

Class based modules

Incorporate class based modules into your project instead of the traditional commandModule or eventModule -Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from "@sern/handler";
import { publish } from "../plugins/publish.js";
import { serendipityOnly } from "../plugins/serendipityOnly.js";

export default class extends CommandExecutable<CommandType.Both> {

type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
caution

execute must not be a method of the class. It should be as above, a property on the class!

commands/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from "@sern/handler";
import type { GuildMember } from 'discord.js'
export default class extends EventExecutable<EventType.Discord> {

type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. +Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from '@sern/handler';
import { publish } from '../plugins/publish.js';
import { serendipityOnly } from '../plugins/serendipityOnly.js';

export default class extends CommandExecutable<CommandType.Both> {
type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
caution

execute must not be a method of the class. It should be as above, a property on the class!

events/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from '@sern/handler';
import type { GuildMember } from 'discord.js'

export default class extends EventExecutable<EventType.Discord> {
type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. I believe that you should build your own structures however you might like and customize to your liking. In addition, decorators now unofficially work with modules! Feel free to use TypeScript experimental decorators to augment and customize your classes.

Deprecation Warnings

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

Dependencies Update

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

@sern/handler

Handlers. Redefined.

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

NPM versionNPM downloadsLicense MITdocs.rsLines of code

📜 Installation

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

👀 Quick Look

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

👶 Basic Usage

index.js (CommonJS)

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

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

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

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

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

client.login(token);

ping.js (CommonJS)

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

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

See our templates for TypeScript examples and more

💻 CLI

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

👋 Contribute

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

🚈 Roadmap

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

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

Class: CommandExecutable<Type>

Type parameters

NameType
Typeextends CommandType

Constructors

constructor

new CommandExecutable<Type>()

Type parameters

NameType
Typeextends CommandType

Properties

execute

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

Defined in

src/handler/sern.ts:132


onEvent

onEvent: EventPlugin<Type>[] = []

Defined in

src/handler/sern.ts:131


plugins

plugins: CommandPlugin<Type>[] = []

Defined in

src/handler/sern.ts:130


type

Abstract type: Type

Defined in

src/handler/sern.ts:129

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

Returns

ChatInputCommandInteraction<CacheType>

Defined in

src/handler/structures/context.ts:52


member

get member(): Nullish<GuildMember | APIGuildMember>

Returns

Nullish<GuildMember | APIGuildMember>

Defined in

src/handler/structures/context.ts:101


message

get message(): Message<boolean>

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

Returns

Message<boolean>

Defined in

src/handler/structures/context.ts:44


user

get user(): User

Returns

User

Defined in

src/handler/structures/context.ts:70

Methods

isEmpty

isEmpty(): boolean

Returns

boolean

Defined in

src/handler/structures/context.ts:129


reply

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

Parameters

NameType
contentReplyOptions

Returns

Promise<Message<boolean>>

Defined in

src/handler/structures/context.ts:133


wrap

Static wrap(wrappable): Context

Parameters

NameType
wrappableMessage<boolean> | ChatInputCommandInteraction<CacheType>

Returns

Context

Defined in

src/handler/structures/context.ts:122

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

Class: EventExecutable<Type>

Type parameters

NameType
Typeextends EventType

Constructors

constructor

new EventExecutable<Type>()

Type parameters

NameType
Typeextends EventType

Properties

execute

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

Defined in

src/handler/sern.ts:139


onEvent

onEvent: EventModuleEventPluginDefs[Type][] = []

Defined in

src/handler/sern.ts:138


plugins

plugins: EventModuleCommandPluginDefs[Type][] = []

Defined in

src/handler/sern.ts:137


type

Abstract type: Type

Defined in

src/handler/sern.ts:136

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

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

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

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

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

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

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

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

run();

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

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

const ee = new EventEmitter();

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

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

// Prints: ok boom

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

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

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

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

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

Since

v11.13.0, v10.16.0

Parameters

NameType
emitterNodeEventTarget
eventNamestring | symbol
options?StaticEventEmitterOptions

Returns

Promise<any[]>

Inherited from

EventEmitter.once

Defined in

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

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

Parameters

NameType
emitterDOMEventTarget
eventNamestring
options?StaticEventEmitterOptions

Returns

Promise<any[]>

Inherited from

EventEmitter.once

Defined in

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

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

Type parameters

NameType
Kextends keyof ClientEvents

Parameters

NameType
eventEmitterClient<boolean>
eventNameK

Returns

Promise<ClientEvents[K]>

Inherited from

EventEmitter.once

Defined in

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


setMaxListeners

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

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

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

setMaxListeners(5, target, emitter);

Since

v15.4.0

Parameters

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

Returns

void

Inherited from

EventEmitter.setMaxListeners

Defined in

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

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

Enumeration: CommandType

Example

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

Enumeration Members

Both

Both = 3

The CommandType for hybrid commands, text and slash

Defined in

src/handler/structures/enums.ts:27


Button

Button = 16

The CommandType for ButtonInteraction commands

Defined in

src/handler/structures/enums.ts:39


MenuMsg = 8

The CommandType for MessageContextMenuInteraction commands

Defined in

src/handler/structures/enums.ts:35


MenuSelect = 32

The CommandType for SelectMenuInteraction commands

Defined in

src/handler/structures/enums.ts:43


MenuUser = 4

The CommandType for UserContextMenuInteraction commands

Defined in

src/handler/structures/enums.ts:31


Modal = 64

The CommandType for ModalSubmitInteraction commands

Defined in

src/handler/structures/enums.ts:47


Slash

Slash = 2

The CommandType for slash commands

Defined in

src/handler/structures/enums.ts:23


Text

Text = 1

The CommandType for text commands

Defined in

src/handler/structures/enums.ts:19

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

Enumeration: EventType

Example

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

Enumeration Members

Discord

Discord = 1

The EventType for handling discord events

Defined in

src/handler/structures/enums.ts:68


External

External = 3

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

Defined in

src/handler/structures/enums.ts:77


Sern

Sern = 2

The EventType for handling sern events

Defined in

src/handler/structures/enums.ts:72

- + \ No newline at end of file diff --git a/docs/api/enums/PayloadType.html b/docs/api/enums/PayloadType.html index f7bf66540..925551a0b 100644 --- a/docs/api/enums/PayloadType.html +++ b/docs/api/enums/PayloadType.html @@ -6,13 +6,13 @@ Enumeration: PayloadType | sern - Handlers. Redefined. - +
- + \ No newline at end of file diff --git a/docs/api/enums/PluginType.html b/docs/api/enums/PluginType.html index 7a21d4b0a..6c764d50a 100644 --- a/docs/api/enums/PluginType.html +++ b/docs/api/enums/PluginType.html @@ -6,13 +6,13 @@ Enumeration: PluginType | sern - Handlers. Redefined. - +

Enumeration: PluginType

Example

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

Enumeration Members

Command

Command = 1

The PluginType for CommandPlugins

Defined in

src/handler/structures/enums.ts:97


Event

Event = 2

The PluginType for EventPlugins

Defined in

src/handler/structures/enums.ts:101

- + \ No newline at end of file diff --git a/docs/api/interfaces/Controller.html b/docs/api/interfaces/Controller.html index caace5b9d..19ca7bbfd 100644 --- a/docs/api/interfaces/Controller.html +++ b/docs/api/interfaces/Controller.html @@ -6,13 +6,13 @@ Interface: Controller | sern - Handlers. Redefined. - +
- + \ No newline at end of file diff --git a/docs/api/interfaces/Wrapper.html b/docs/api/interfaces/Wrapper.html index 78b8ae474..830cd7e60 100644 --- a/docs/api/interfaces/Wrapper.html +++ b/docs/api/interfaces/Wrapper.html @@ -6,13 +6,13 @@ Interface: Wrapper | sern - Handlers. Redefined. - +

Interface: Wrapper

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

Properties

client

Readonly client: Client<boolean>

Defined in

src/handler/structures/wrapper.ts:11


commands

Readonly commands: string

Defined in

src/handler/structures/wrapper.ts:15


defaultPrefix

Optional Readonly defaultPrefix: string

Defined in

src/handler/structures/wrapper.ts:14


events

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

Defined in

src/handler/structures/wrapper.ts:16


sernEmitter

Optional Readonly sernEmitter: SernEmitter

Defined in

src/handler/structures/wrapper.ts:13

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

@sern/handler

Namespaces

Enumerations

Classes

Interfaces

Type Aliases

Args

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

Defined in

src/types/handler.ts:12


AutocompletePlugin

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

Defined in

src/handler/plugins/plugin.ts:92


BaseOptions

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

Type that replaces autocomplete with SernAutocompleteData

Defined in

src/handler/structures/module.ts:181


BothCommand

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

Defined in

src/handler/structures/module.ts:55


CommandModuleNoPlugins

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

Defined in

src/handler/plugins/plugin.ts:145


CommandModulePlugin

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

Type parameters

NameType
Textends CommandType

Defined in

src/handler/plugins/plugin.ts:173


CommandPlugin

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

Type parameters

NameType
Textends keyof CommandModuleDefs = keyof CommandModuleDefs

Defined in

src/handler/plugins/plugin.ts:40


DefinedCommandModule

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

Defined in

src/types/handler.ts:43


DefinedEventModule

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

Defined in

src/types/handler.ts:44


DefinedModule

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

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

Defined in

src/types/handler.ts:42


DefinitelyDefined

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

Type parameters

NameType
TT
Kextends keyof T = keyof T

Defined in

src/types/handler.ts:19


DiscordEmitterPlugin

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

Defined in

src/handler/plugins/plugin.ts:57


DiscordEventPlugin

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

Type parameters

NameType
Textends keyof ClientEvents = keyof ClientEvents

Defined in

src/handler/plugins/plugin.ts:136


EventInput

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

Defined in

src/types/handler.ts:25


EventModuleCommandPluginDefs

Ƭ EventModuleCommandPluginDefs: Object

Event Module Command Plugins

Type declaration

NameType
1DiscordEmitterPlugin
2SernEmitterPlugin
3ExternalEmitterPlugin

Defined in

src/handler/plugins/plugin.ts:163


EventModuleEventPluginDefs

Ƭ EventModuleEventPluginDefs: Object

Event Module Event Plugins

Type declaration

NameType
1DiscordEventPlugin
2SernEventPlugin
3ExternalEventPlugin

Defined in

src/handler/plugins/plugin.ts:154


EventModulePlugin

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

Type parameters

NameType
Textends EventType

Defined in

src/handler/plugins/plugin.ts:169


EventModulesNoPlugins

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

Defined in

src/handler/plugins/plugin.ts:148


EventPlugin

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

Type parameters

NameType
Textends keyof CommandModuleDefs = keyof CommandModuleDefs

Defined in

src/handler/plugins/plugin.ts:103


ExternalEmitterPlugin

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

Type parameters

NameType
Textends EventEmitter = EventEmitter

Defined in

src/handler/plugins/plugin.ts:68


ExternalEventPlugin

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

Defined in

src/handler/plugins/plugin.ts:128


InputCommandModule

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

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

Defined in

src/handler/plugins/plugin.ts:178


InputEventModule

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

Defined in

src/handler/plugins/plugin.ts:182


Module

Ƭ Module: CommandModule | EventModule

Defined in

src/handler/structures/module.ts:141


Nullish

Ƭ Nullish<T>: T | undefined | null

Type parameters

Name
T

Defined in

src/types/handler.ts:5


Override

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

Type parameters

Name
T1
T2

Defined in

src/types/handler.ts:17


ParseType

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

Type parameters

Name
T

Defined in

src/types/handler.ts:8


Payload

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

Defined in

src/types/handler.ts:45


ReplyOptions

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

Defined in

src/types/handler.ts:55


SernAutocompleteData

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

Defined in

src/handler/structures/module.ts:166


SernEmitterPlugin

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

Defined in

src/handler/plugins/plugin.ts:80


SernEventPlugin

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

Type parameters

NameType
Textends keyof SernEventsMapping = keyof SernEventsMapping

Defined in

src/handler/plugins/plugin.ts:116


SernEventsMapping

Ƭ SernEventsMapping: Object

Type declaration

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

Defined in

src/types/handler.ts:48


SernOptionsData

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

Type parameters

NameType
Uextends ApplicationCommandOptionData = ApplicationCommandOptionData

Defined in

src/handler/structures/module.ts:205


SernSubCommandData

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

Defined in

src/handler/structures/module.ts:189


SernSubCommandGroupData

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

Defined in

src/handler/structures/module.ts:197


SlashCommand

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

Defined in

src/handler/structures/module.ts:44


SlashOptions

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

Defined in

src/types/handler.ts:14


SpreadParams

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

Type parameters

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

Type declaration

▸ (args): unknown

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

Parameters
NameType
argsParameters<T>[number]
Returns

unknown

Defined in

src/types/handler.ts:34


TextCommand

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

Defined in

src/handler/structures/module.ts:33

Functions

commandModule

commandModule(mod): CommandModule

The wrapper function to define command modules for sern

Parameters

NameType
modInputCommandModule

Returns

CommandModule

Defined in

src/handler/sern.ts:91


eventModule

eventModule(mod): EventModule

The wrapper function to define event modules for sern

Parameters

NameType
modInputEventModule

Returns

EventModule

Defined in

src/handler/sern.ts:112

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

Namespace: Sern

References

CommandExecutable

Re-exports CommandExecutable


EventExecutable

Re-exports EventExecutable


commandModule

Re-exports commandModule


eventModule

Re-exports eventModule

Variables

controller

Const controller: Object

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

Type declaration

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

Defined in

src/handler/sern.ts:82

Functions

addExternal

addExternal<T>(emitter): void

Deprecated

  • use Sern#makeDependencies instead

Example

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

Example

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

Type parameters

NameType
Textends __module

Parameters

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

Returns

void

Defined in

src/handler/sern.ts:72


init

init(wrapper): void

Example

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

Parameters

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

Returns

void

Defined in

src/handler/sern.ts:39

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

Introduction

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

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

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

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

You will learn

Working with plugins

Events

Good to know

- + \ No newline at end of file diff --git a/docs/guide/getting-started/choose-ide.html b/docs/guide/getting-started/choose-ide.html index 1b68444ca..0a6cc2cc7 100644 --- a/docs/guide/getting-started/choose-ide.html +++ b/docs/guide/getting-started/choose-ide.html @@ -6,14 +6,14 @@ Choosing an IDE | sern - Handlers. Redefined. - +
- + \ No newline at end of file diff --git a/docs/guide/getting-started/preparing.html b/docs/guide/getting-started/preparing.html index 0a9ca4161..3b1b670cc 100644 --- a/docs/guide/getting-started/preparing.html +++ b/docs/guide/getting-started/preparing.html @@ -6,13 +6,13 @@ Preparing to Code | sern - Handlers. Redefined. - +

Preparing to Code

After installing and IDE you need to install node.

You can download the LTS version of node right here

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

CLI

Setting up the CLI is easy.

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

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

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

sern plugins
info

Make sure to have a correct sern.config.json

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

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

Conclusion

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

- + \ No newline at end of file diff --git a/docs/guide/walkthrough/first-command.html b/docs/guide/walkthrough/first-command.html index 67a754be6..8e9d2617f 100644 --- a/docs/guide/walkthrough/first-command.html +++ b/docs/guide/walkthrough/first-command.html @@ -6,7 +6,7 @@ First Command | sern - Handlers. Redefined. - + @@ -15,7 +15,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 517802ef2..2881f2643 100644 --- a/docs/guide/walkthrough/first-event.html +++ b/docs/guide/walkthrough/first-event.html @@ -6,7 +6,7 @@ First Event Module | sern - Handlers. Redefined. - + @@ -14,7 +14,7 @@

First Event Module

We will dissect a basic event module.
Typescript:

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

Javascript:

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

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

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


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

Another example of an event module

Typescript:

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

Javascript:


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

Goal

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

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

Good to know

sern.config.json

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

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

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

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

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

Javascript:

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

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

tip

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

Event Plugins

event-plugins

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

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

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

Typescript:

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

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

Javascript:

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

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

Can you predict the behavior of this command?

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

Event Plugins are good for filtering, preconditions, parsing.

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

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

The SernEmitter class

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

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

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


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

Welcome!

Content

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

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

tip

If you have problems, join the discord server here

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

Page introuvable

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

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

- + \ No newline at end of file diff --git a/fr/assets/js/3020eeee.f05b7e13.js b/fr/assets/js/3020eeee.b0fe60eb.js similarity index 61% rename from fr/assets/js/3020eeee.f05b7e13.js rename to fr/assets/js/3020eeee.b0fe60eb.js index 86543d9ac..f9fc40be9 100644 --- a/fr/assets/js/3020eeee.f05b7e13.js +++ b/fr/assets/js/3020eeee.b0fe60eb.js @@ -1 +1 @@ -"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[7223],{3905:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>m});var a=n(7294);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var i=a.createContext({}),p=function(e){var t=a.useContext(i),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},c=function(e){var t=p(e.components);return a.createElement(i.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},u=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,l=e.originalType,i=e.parentName,c=s(e,["components","mdxType","originalType","parentName"]),u=p(n),m=r,b=u["".concat(i,".").concat(m)]||u[m]||d[m]||l;return n?a.createElement(b,o(o({ref:t},c),{},{components:n})):a.createElement(b,o({ref:t},c))}));function m(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var l=n.length,o=new Array(l);o[0]=u;var s={};for(var i in t)hasOwnProperty.call(t,i)&&(s[i]=t[i]);s.originalType=e,s.mdxType="string"==typeof e?e:r,o[1]=s;for(var p=2;p{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>o,default:()=>d,frontMatter:()=>l,metadata:()=>s,toc:()=>p});var a=n(7462),r=(n(7294),n(3905));const l={slug:"1.2.0",title:"Release 1.2.0",authors:["jacoobes"],tags:["release"]},o=void 0,s={permalink:"/fr/blog/1.2.0",editUrl:"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/blog/2022-09-28-mdx-blog-post.md",source:"@site/blog/2022-09-28-mdx-blog-post.md",title:"Release 1.2.0",description:"Class-based modules",date:"2022-09-28T00:00:00.000Z",formattedDate:"28 septembre 2022",tags:[{label:"release",permalink:"/fr/blog/tags/release"}],readingTime:1.71,hasTruncateMarker:!1,authors:[{name:"jacoobes",title:"Head Dev",url:"https://github.com/jacoobes",imageURL:"https://github.com/jacoobes.png",key:"jacoobes"}],frontMatter:{slug:"1.2.0",title:"Release 1.2.0",authors:["jacoobes"],tags:["release"]}},i={authorsImageUrls:[void 0]},p=[{value:"Class-based modules",id:"class-based-modules",level:2},{value:"Class based modules",id:"class-based-modules-1",level:3},{value:"Deprecation Warnings",id:"deprecation-warnings",level:3},{value:"Dependencies Update",id:"dependencies-update",level:3}],c={toc:p};function d(e){let{components:t,...n}=e;return(0,r.kt)("wrapper",(0,a.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("h2",{id:"class-based-modules"},"Class-based modules"),(0,r.kt)("p",null,"Today we're announcing the ability to create class based modules!\nTo get started, install"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre"},"npm install @sern/handler@latest\n")),(0,r.kt)("p",null,"Quick List of changes!"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#class-based-modules"},"Class based modules")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#deprecation-warnings"},"Deprecation Warnings")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#dependencies-update"},"Dependencies update"))),(0,r.kt)("h3",{id:"class-based-modules-1"},"Class based modules"),(0,r.kt)("p",null,"Incorporate class based modules into your project instead of the traditional ",(0,r.kt)("inlineCode",{parentName:"p"},"commandModule")," or ",(0,r.kt)("inlineCode",{parentName:"p"},"eventModule"),"\nExtend the new ",(0,r.kt)("a",{parentName:"p",href:"docs/api/classes/CommandExecutable"},"CommandExecutable")," or ",(0,r.kt)("a",{parentName:"p",href:"docs/api/classes/EventExecutable"},"EventExecutable")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="commands/meaning-of-life.ts"',title:'"commands/meaning-of-life.ts"'},'import { CommandType, CommandExecutable, type Args, type Context } from "@sern/handler";\nimport { publish } from "../plugins/publish.js";\nimport { serendipityOnly } from "../plugins/serendipityOnly.js";\n\nexport default class extends CommandExecutable {\n\n type = CommandType.Both as const;\n description = \'What is the meaning of life?\'\n override onEvent = [\n serendipityOnly()\n ];\n override plugins = [\n publish(),\n ];\n // highlight-next-line\n execute = async (ctx: Context, args: Args) => {\n await ctx.reply(\'42\')\n };\n}\n')),(0,r.kt)("admonition",{type:"caution"},(0,r.kt)("p",{parentName:"admonition"},"execute must not be a method of the class. It should be as above, a property on the class!")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="commands/guildMemberAdd.ts"',title:'"commands/guildMemberAdd.ts"'},"import { CommandType, EventExecutable, type EventType } from \"@sern/handler\";\nimport type { GuildMember } from 'discord.js'\nexport default class extends EventExecutable {\n\n type = EventType.Discord as const;\n // highlight-next-line\n execute = (member: GuildMember) => {\n console.log(member)\n };\n}\n")),(0,r.kt)("p",null,"Now, you might ask ",(0,r.kt)("strong",{parentName:"p"},"why")," this feature was added. ",(0,r.kt)("br",null)," Simply put, to give flexibility to the developers.\nI believe that you should build your own structures however you might like and customize to your liking.\nIn addition, ",(0,r.kt)("strong",{parentName:"p"},"decorators now unofficially work with modules!"),"\nFeel free to use TypeScript experimental decorators to augment and customize your classes. "),(0,r.kt)("h3",{id:"deprecation-warnings"},"Deprecation Warnings"),(0,r.kt)("p",null,"The next update will bring sern v2 with some important features. Here are some things to watch out for."),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#client")," will be deprecated"),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#sernEmitter")," will be deprecated",(0,r.kt)("ul",{parentName:"li"},(0,r.kt)("li",{parentName:"ul"},"a SernEmitter will be automatically created once Sern#init is called"))),(0,r.kt)("li",{parentName:"ul"},"The option to pass in a function or array for ",(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#events")," will be deprecated. Only strings are accepted."),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/classes/SernEmitter"},"Sern#addExternal")," will be deprecated in favor of a better way.")),(0,r.kt)("h3",{id:"dependencies-update"},"Dependencies Update"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},"TypeScript has been updated to 4.8.3"),(0,r.kt)("li",{parentName:"ul"},"Discord.js has been upgraded to 14.5")))}d.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[7223],{3905:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>m});var a=n(7294);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var i=a.createContext({}),p=function(e){var t=a.useContext(i),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},c=function(e){var t=p(e.components);return a.createElement(i.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},u=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,l=e.originalType,i=e.parentName,c=s(e,["components","mdxType","originalType","parentName"]),u=p(n),m=r,b=u["".concat(i,".").concat(m)]||u[m]||d[m]||l;return n?a.createElement(b,o(o({ref:t},c),{},{components:n})):a.createElement(b,o({ref:t},c))}));function m(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var l=n.length,o=new Array(l);o[0]=u;var s={};for(var i in t)hasOwnProperty.call(t,i)&&(s[i]=t[i]);s.originalType=e,s.mdxType="string"==typeof e?e:r,o[1]=s;for(var p=2;p{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>o,default:()=>d,frontMatter:()=>l,metadata:()=>s,toc:()=>p});var a=n(7462),r=(n(7294),n(3905));const l={slug:"1.2.0",title:"Release 1.2.0",authors:["jacoobes"],tags:["release"]},o=void 0,s={permalink:"/fr/blog/1.2.0",editUrl:"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/blog/2022-09-28-mdx-blog-post.md",source:"@site/blog/2022-09-28-mdx-blog-post.md",title:"Release 1.2.0",description:"Class-based modules",date:"2022-09-28T00:00:00.000Z",formattedDate:"28 septembre 2022",tags:[{label:"release",permalink:"/fr/blog/tags/release"}],readingTime:1.71,hasTruncateMarker:!1,authors:[{name:"jacoobes",title:"Head Dev",url:"https://github.com/jacoobes",imageURL:"https://github.com/jacoobes.png",key:"jacoobes"}],frontMatter:{slug:"1.2.0",title:"Release 1.2.0",authors:["jacoobes"],tags:["release"]}},i={authorsImageUrls:[void 0]},p=[{value:"Class-based modules",id:"class-based-modules",level:2},{value:"Class based modules",id:"class-based-modules-1",level:3},{value:"Deprecation Warnings",id:"deprecation-warnings",level:3},{value:"Dependencies Update",id:"dependencies-update",level:3}],c={toc:p};function d(e){let{components:t,...n}=e;return(0,r.kt)("wrapper",(0,a.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("h2",{id:"class-based-modules"},"Class-based modules"),(0,r.kt)("p",null,"Today we're announcing the ability to create class based modules!\nTo get started, install"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre"},"npm install @sern/handler@latest\n")),(0,r.kt)("p",null,"Quick List of changes!"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#class-based-modules"},"Class based modules")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#deprecation-warnings"},"Deprecation Warnings")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#dependencies-update"},"Dependencies update"))),(0,r.kt)("h3",{id:"class-based-modules-1"},"Class based modules"),(0,r.kt)("p",null,"Incorporate class based modules into your project instead of the traditional ",(0,r.kt)("inlineCode",{parentName:"p"},"commandModule")," or ",(0,r.kt)("inlineCode",{parentName:"p"},"eventModule"),"\nExtend the new ",(0,r.kt)("a",{parentName:"p",href:"docs/api/classes/CommandExecutable"},"CommandExecutable")," or ",(0,r.kt)("a",{parentName:"p",href:"docs/api/classes/EventExecutable"},"EventExecutable")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="commands/meaning-of-life.ts"',title:'"commands/meaning-of-life.ts"'},"import { CommandType, CommandExecutable, type Args, type Context } from '@sern/handler';\nimport { publish } from '../plugins/publish.js';\nimport { serendipityOnly } from '../plugins/serendipityOnly.js';\n\nexport default class extends CommandExecutable {\n type = CommandType.Both as const;\n description = 'What is the meaning of life?'\n override onEvent = [\n serendipityOnly()\n ];\n override plugins = [\n publish(),\n ];\n // highlight-next-line\n execute = async (ctx: Context, args: Args) => {\n await ctx.reply('42')\n };\n}\n")),(0,r.kt)("admonition",{type:"caution"},(0,r.kt)("p",{parentName:"admonition"},"execute must not be a method of the class. It should be as above, a property on the class!")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="events/guildMemberAdd.ts"',title:'"events/guildMemberAdd.ts"'},"import { CommandType, EventExecutable, type EventType } from '@sern/handler';\nimport type { GuildMember } from 'discord.js'\n\nexport default class extends EventExecutable {\n type = EventType.Discord as const;\n // highlight-next-line\n execute = (member: GuildMember) => {\n console.log(member)\n };\n}\n")),(0,r.kt)("p",null,"Now, you might ask ",(0,r.kt)("strong",{parentName:"p"},"why")," this feature was added. ",(0,r.kt)("br",null)," Simply put, to give flexibility to the developers.\nI believe that you should build your own structures however you might like and customize to your liking.\nIn addition, ",(0,r.kt)("strong",{parentName:"p"},"decorators now unofficially work with modules!"),"\nFeel free to use TypeScript experimental decorators to augment and customize your classes. "),(0,r.kt)("h3",{id:"deprecation-warnings"},"Deprecation Warnings"),(0,r.kt)("p",null,"The next update will bring sern v2 with some important features. Here are some things to watch out for."),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#client")," will be deprecated"),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#sernEmitter")," will be deprecated",(0,r.kt)("ul",{parentName:"li"},(0,r.kt)("li",{parentName:"ul"},"a SernEmitter will be automatically created once Sern#init is called"))),(0,r.kt)("li",{parentName:"ul"},"The option to pass in a function or array for ",(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#events")," will be deprecated. Only strings are accepted."),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/classes/SernEmitter"},"Sern#addExternal")," will be deprecated in favor of a better way.")),(0,r.kt)("h3",{id:"dependencies-update"},"Dependencies Update"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},"TypeScript has been updated to 4.8.3"),(0,r.kt)("li",{parentName:"ul"},"Discord.js has been upgraded to 14.5")))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/fr/assets/js/6ba1d2c1.7041a0d3.js b/fr/assets/js/6ba1d2c1.72a398c7.js similarity index 61% rename from fr/assets/js/6ba1d2c1.7041a0d3.js rename to fr/assets/js/6ba1d2c1.72a398c7.js index b10b73dbf..9d58b0298 100644 --- a/fr/assets/js/6ba1d2c1.7041a0d3.js +++ b/fr/assets/js/6ba1d2c1.72a398c7.js @@ -1 +1 @@ -"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[7374],{3905:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>m});var a=n(7294);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var i=a.createContext({}),p=function(e){var t=a.useContext(i),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},c=function(e){var t=p(e.components);return a.createElement(i.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},u=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,l=e.originalType,i=e.parentName,c=s(e,["components","mdxType","originalType","parentName"]),u=p(n),m=r,b=u["".concat(i,".").concat(m)]||u[m]||d[m]||l;return n?a.createElement(b,o(o({ref:t},c),{},{components:n})):a.createElement(b,o({ref:t},c))}));function m(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var l=n.length,o=new Array(l);o[0]=u;var s={};for(var i in t)hasOwnProperty.call(t,i)&&(s[i]=t[i]);s.originalType=e,s.mdxType="string"==typeof e?e:r,o[1]=s;for(var p=2;p{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>o,default:()=>d,frontMatter:()=>l,metadata:()=>s,toc:()=>p});var a=n(7462),r=(n(7294),n(3905));const l={slug:"1.2.0",title:"Release 1.2.0",authors:["jacoobes"],tags:["release"]},o=void 0,s={permalink:"/fr/blog/1.2.0",editUrl:"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/blog/2022-09-28-mdx-blog-post.md",source:"@site/blog/2022-09-28-mdx-blog-post.md",title:"Release 1.2.0",description:"Class-based modules",date:"2022-09-28T00:00:00.000Z",formattedDate:"28 septembre 2022",tags:[{label:"release",permalink:"/fr/blog/tags/release"}],readingTime:1.71,hasTruncateMarker:!1,authors:[{name:"jacoobes",title:"Head Dev",url:"https://github.com/jacoobes",imageURL:"https://github.com/jacoobes.png",key:"jacoobes"}],frontMatter:{slug:"1.2.0",title:"Release 1.2.0",authors:["jacoobes"],tags:["release"]}},i={authorsImageUrls:[void 0]},p=[{value:"Class-based modules",id:"class-based-modules",level:2},{value:"Class based modules",id:"class-based-modules-1",level:3},{value:"Deprecation Warnings",id:"deprecation-warnings",level:3},{value:"Dependencies Update",id:"dependencies-update",level:3}],c={toc:p};function d(e){let{components:t,...n}=e;return(0,r.kt)("wrapper",(0,a.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("h2",{id:"class-based-modules"},"Class-based modules"),(0,r.kt)("p",null,"Today we're announcing the ability to create class based modules!\nTo get started, install"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre"},"npm install @sern/handler@latest\n")),(0,r.kt)("p",null,"Quick List of changes!"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#class-based-modules"},"Class based modules")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#deprecation-warnings"},"Deprecation Warnings")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#dependencies-update"},"Dependencies update"))),(0,r.kt)("h3",{id:"class-based-modules-1"},"Class based modules"),(0,r.kt)("p",null,"Incorporate class based modules into your project instead of the traditional ",(0,r.kt)("inlineCode",{parentName:"p"},"commandModule")," or ",(0,r.kt)("inlineCode",{parentName:"p"},"eventModule"),"\nExtend the new ",(0,r.kt)("a",{parentName:"p",href:"docs/api/classes/CommandExecutable"},"CommandExecutable")," or ",(0,r.kt)("a",{parentName:"p",href:"docs/api/classes/EventExecutable"},"EventExecutable")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="commands/meaning-of-life.ts"',title:'"commands/meaning-of-life.ts"'},'import { CommandType, CommandExecutable, type Args, type Context } from "@sern/handler";\nimport { publish } from "../plugins/publish.js";\nimport { serendipityOnly } from "../plugins/serendipityOnly.js";\n\nexport default class extends CommandExecutable {\n\n type = CommandType.Both as const;\n description = \'What is the meaning of life?\'\n override onEvent = [\n serendipityOnly()\n ];\n override plugins = [\n publish(),\n ];\n // highlight-next-line\n execute = async (ctx: Context, args: Args) => {\n await ctx.reply(\'42\')\n };\n}\n')),(0,r.kt)("admonition",{type:"caution"},(0,r.kt)("p",{parentName:"admonition"},"execute must not be a method of the class. It should be as above, a property on the class!")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="commands/guildMemberAdd.ts"',title:'"commands/guildMemberAdd.ts"'},"import { CommandType, EventExecutable, type EventType } from \"@sern/handler\";\nimport type { GuildMember } from 'discord.js'\nexport default class extends EventExecutable {\n\n type = EventType.Discord as const;\n // highlight-next-line\n execute = (member: GuildMember) => {\n console.log(member)\n };\n}\n")),(0,r.kt)("p",null,"Now, you might ask ",(0,r.kt)("strong",{parentName:"p"},"why")," this feature was added. ",(0,r.kt)("br",null)," Simply put, to give flexibility to the developers.\nI believe that you should build your own structures however you might like and customize to your liking.\nIn addition, ",(0,r.kt)("strong",{parentName:"p"},"decorators now unofficially work with modules!"),"\nFeel free to use TypeScript experimental decorators to augment and customize your classes. "),(0,r.kt)("h3",{id:"deprecation-warnings"},"Deprecation Warnings"),(0,r.kt)("p",null,"The next update will bring sern v2 with some important features. Here are some things to watch out for."),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#client")," will be deprecated"),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#sernEmitter")," will be deprecated",(0,r.kt)("ul",{parentName:"li"},(0,r.kt)("li",{parentName:"ul"},"a SernEmitter will be automatically created once Sern#init is called"))),(0,r.kt)("li",{parentName:"ul"},"The option to pass in a function or array for ",(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#events")," will be deprecated. Only strings are accepted."),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/classes/SernEmitter"},"Sern#addExternal")," will be deprecated in favor of a better way.")),(0,r.kt)("h3",{id:"dependencies-update"},"Dependencies Update"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},"TypeScript has been updated to 4.8.3"),(0,r.kt)("li",{parentName:"ul"},"Discord.js has been upgraded to 14.5")))}d.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[7374],{3905:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>m});var a=n(7294);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var i=a.createContext({}),p=function(e){var t=a.useContext(i),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},c=function(e){var t=p(e.components);return a.createElement(i.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},u=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,l=e.originalType,i=e.parentName,c=s(e,["components","mdxType","originalType","parentName"]),u=p(n),m=r,b=u["".concat(i,".").concat(m)]||u[m]||d[m]||l;return n?a.createElement(b,o(o({ref:t},c),{},{components:n})):a.createElement(b,o({ref:t},c))}));function m(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var l=n.length,o=new Array(l);o[0]=u;var s={};for(var i in t)hasOwnProperty.call(t,i)&&(s[i]=t[i]);s.originalType=e,s.mdxType="string"==typeof e?e:r,o[1]=s;for(var p=2;p{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>o,default:()=>d,frontMatter:()=>l,metadata:()=>s,toc:()=>p});var a=n(7462),r=(n(7294),n(3905));const l={slug:"1.2.0",title:"Release 1.2.0",authors:["jacoobes"],tags:["release"]},o=void 0,s={permalink:"/fr/blog/1.2.0",editUrl:"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/blog/2022-09-28-mdx-blog-post.md",source:"@site/blog/2022-09-28-mdx-blog-post.md",title:"Release 1.2.0",description:"Class-based modules",date:"2022-09-28T00:00:00.000Z",formattedDate:"28 septembre 2022",tags:[{label:"release",permalink:"/fr/blog/tags/release"}],readingTime:1.71,hasTruncateMarker:!1,authors:[{name:"jacoobes",title:"Head Dev",url:"https://github.com/jacoobes",imageURL:"https://github.com/jacoobes.png",key:"jacoobes"}],frontMatter:{slug:"1.2.0",title:"Release 1.2.0",authors:["jacoobes"],tags:["release"]}},i={authorsImageUrls:[void 0]},p=[{value:"Class-based modules",id:"class-based-modules",level:2},{value:"Class based modules",id:"class-based-modules-1",level:3},{value:"Deprecation Warnings",id:"deprecation-warnings",level:3},{value:"Dependencies Update",id:"dependencies-update",level:3}],c={toc:p};function d(e){let{components:t,...n}=e;return(0,r.kt)("wrapper",(0,a.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("h2",{id:"class-based-modules"},"Class-based modules"),(0,r.kt)("p",null,"Today we're announcing the ability to create class based modules!\nTo get started, install"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre"},"npm install @sern/handler@latest\n")),(0,r.kt)("p",null,"Quick List of changes!"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#class-based-modules"},"Class based modules")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#deprecation-warnings"},"Deprecation Warnings")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#dependencies-update"},"Dependencies update"))),(0,r.kt)("h3",{id:"class-based-modules-1"},"Class based modules"),(0,r.kt)("p",null,"Incorporate class based modules into your project instead of the traditional ",(0,r.kt)("inlineCode",{parentName:"p"},"commandModule")," or ",(0,r.kt)("inlineCode",{parentName:"p"},"eventModule"),"\nExtend the new ",(0,r.kt)("a",{parentName:"p",href:"docs/api/classes/CommandExecutable"},"CommandExecutable")," or ",(0,r.kt)("a",{parentName:"p",href:"docs/api/classes/EventExecutable"},"EventExecutable")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="commands/meaning-of-life.ts"',title:'"commands/meaning-of-life.ts"'},"import { CommandType, CommandExecutable, type Args, type Context } from '@sern/handler';\nimport { publish } from '../plugins/publish.js';\nimport { serendipityOnly } from '../plugins/serendipityOnly.js';\n\nexport default class extends CommandExecutable {\n type = CommandType.Both as const;\n description = 'What is the meaning of life?'\n override onEvent = [\n serendipityOnly()\n ];\n override plugins = [\n publish(),\n ];\n // highlight-next-line\n execute = async (ctx: Context, args: Args) => {\n await ctx.reply('42')\n };\n}\n")),(0,r.kt)("admonition",{type:"caution"},(0,r.kt)("p",{parentName:"admonition"},"execute must not be a method of the class. It should be as above, a property on the class!")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="events/guildMemberAdd.ts"',title:'"events/guildMemberAdd.ts"'},"import { CommandType, EventExecutable, type EventType } from '@sern/handler';\nimport type { GuildMember } from 'discord.js'\n\nexport default class extends EventExecutable {\n type = EventType.Discord as const;\n // highlight-next-line\n execute = (member: GuildMember) => {\n console.log(member)\n };\n}\n")),(0,r.kt)("p",null,"Now, you might ask ",(0,r.kt)("strong",{parentName:"p"},"why")," this feature was added. ",(0,r.kt)("br",null)," Simply put, to give flexibility to the developers.\nI believe that you should build your own structures however you might like and customize to your liking.\nIn addition, ",(0,r.kt)("strong",{parentName:"p"},"decorators now unofficially work with modules!"),"\nFeel free to use TypeScript experimental decorators to augment and customize your classes. "),(0,r.kt)("h3",{id:"deprecation-warnings"},"Deprecation Warnings"),(0,r.kt)("p",null,"The next update will bring sern v2 with some important features. Here are some things to watch out for."),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#client")," will be deprecated"),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#sernEmitter")," will be deprecated",(0,r.kt)("ul",{parentName:"li"},(0,r.kt)("li",{parentName:"ul"},"a SernEmitter will be automatically created once Sern#init is called"))),(0,r.kt)("li",{parentName:"ul"},"The option to pass in a function or array for ",(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#events")," will be deprecated. Only strings are accepted."),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/classes/SernEmitter"},"Sern#addExternal")," will be deprecated in favor of a better way.")),(0,r.kt)("h3",{id:"dependencies-update"},"Dependencies Update"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},"TypeScript has been updated to 4.8.3"),(0,r.kt)("li",{parentName:"ul"},"Discord.js has been upgraded to 14.5")))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/fr/assets/js/cf23ded0.407f98d0.js b/fr/assets/js/cf23ded0.407f98d0.js deleted file mode 100644 index e1350bc0d..000000000 --- a/fr/assets/js/cf23ded0.407f98d0.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[1375],{441:e=>{e.exports=JSON.parse('{"blogPosts":[{"id":"1.2.0","metadata":{"permalink":"/fr/blog/1.2.0","editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/blog/2022-09-28-mdx-blog-post.md","source":"@site/blog/2022-09-28-mdx-blog-post.md","title":"Release 1.2.0","description":"Class-based modules","date":"2022-09-28T00:00:00.000Z","formattedDate":"28 septembre 2022","tags":[{"label":"release","permalink":"/fr/blog/tags/release"}],"readingTime":1.71,"hasTruncateMarker":false,"authors":[{"name":"jacoobes","title":"Head Dev","url":"https://github.com/jacoobes","imageURL":"https://github.com/jacoobes.png","key":"jacoobes"}],"frontMatter":{"slug":"1.2.0","title":"Release 1.2.0","authors":["jacoobes"],"tags":["release"]}},"content":"## Class-based modules\\n\\nToday we\'re announcing the ability to create class based modules!\\nTo get started, install\\n```\\nnpm install @sern/handler@latest\\n```\\n\\nQuick List of changes!\\n- [Class based modules](#class-based-modules)\\n- [Deprecation Warnings](#deprecation-warnings)\\n- [Dependencies update](#dependencies-update)\\n\\n\\n\\n### Class based modules\\nIncorporate class based modules into your project instead of the traditional `commandModule` or `eventModule`\\nExtend the new [CommandExecutable](docs/api/classes/CommandExecutable) or [EventExecutable](docs/api/classes/EventExecutable)\\n```ts title=\\"commands/meaning-of-life.ts\\"\\nimport { CommandType, CommandExecutable, type Args, type Context } from \\"@sern/handler\\";\\nimport { publish } from \\"../plugins/publish.js\\";\\nimport { serendipityOnly } from \\"../plugins/serendipityOnly.js\\";\\n\\nexport default class extends CommandExecutable {\\n\\n type = CommandType.Both as const;\\n description = \'What is the meaning of life?\'\\n override onEvent = [\\n serendipityOnly()\\n ];\\n override plugins = [\\n publish(),\\n ];\\n // highlight-next-line\\n execute = async (ctx: Context, args: Args) => {\\n await ctx.reply(\'42\')\\n };\\n}\\n```\\n:::caution\\n\\nexecute must not be a method of the class. It should be as above, a property on the class!\\n\\n:::\\n\\n```ts title=\\"commands/guildMemberAdd.ts\\"\\nimport { CommandType, EventExecutable, type EventType } from \\"@sern/handler\\";\\nimport type { GuildMember } from \'discord.js\'\\nexport default class extends EventExecutable {\\n\\n type = EventType.Discord as const;\\n // highlight-next-line\\n execute = (member: GuildMember) => {\\n console.log(member)\\n };\\n}\\n```\\nNow, you might ask **why** this feature was added.
Simply put, to give flexibility to the developers.\\nI believe that you should build your own structures however you might like and customize to your liking.\\nIn addition, **decorators now unofficially work with modules!**\\nFeel free to use TypeScript experimental decorators to augment and customize your classes. \\n\\n### Deprecation Warnings\\nThe next update will bring sern v2 with some important features. Here are some things to watch out for.\\n\\n- [Wrapper#client](docs/api/interfaces/Wrapper) will be deprecated\\n- [Wrapper#sernEmitter](docs/api/interfaces/Wrapper) will be deprecated\\n - a SernEmitter will be automatically created once Sern#init is called\\n- The option to pass in a function or array for [Wrapper#events](docs/api/interfaces/Wrapper) will be deprecated. Only strings are accepted.\\n- [Sern#addExternal](docs/api/classes/SernEmitter) will be deprecated in favor of a better way.\\n\\n### Dependencies Update\\n- TypeScript has been updated to 4.8.3\\n- Discord.js has been upgraded to 14.5"}]}')}}]); \ No newline at end of file diff --git a/fr/assets/js/cf23ded0.bc4a7762.js b/fr/assets/js/cf23ded0.bc4a7762.js new file mode 100644 index 000000000..270519bd7 --- /dev/null +++ b/fr/assets/js/cf23ded0.bc4a7762.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[1375],{441:e=>{e.exports=JSON.parse('{"blogPosts":[{"id":"1.2.0","metadata":{"permalink":"/fr/blog/1.2.0","editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/blog/2022-09-28-mdx-blog-post.md","source":"@site/blog/2022-09-28-mdx-blog-post.md","title":"Release 1.2.0","description":"Class-based modules","date":"2022-09-28T00:00:00.000Z","formattedDate":"28 septembre 2022","tags":[{"label":"release","permalink":"/fr/blog/tags/release"}],"readingTime":1.71,"hasTruncateMarker":false,"authors":[{"name":"jacoobes","title":"Head Dev","url":"https://github.com/jacoobes","imageURL":"https://github.com/jacoobes.png","key":"jacoobes"}],"frontMatter":{"slug":"1.2.0","title":"Release 1.2.0","authors":["jacoobes"],"tags":["release"]}},"content":"## Class-based modules\\n\\nToday we\'re announcing the ability to create class based modules!\\nTo get started, install\\n```\\nnpm install @sern/handler@latest\\n```\\n\\nQuick List of changes!\\n- [Class based modules](#class-based-modules)\\n- [Deprecation Warnings](#deprecation-warnings)\\n- [Dependencies update](#dependencies-update)\\n\\n\\n### Class based modules\\nIncorporate class based modules into your project instead of the traditional `commandModule` or `eventModule`\\nExtend the new [CommandExecutable](docs/api/classes/CommandExecutable) or [EventExecutable](docs/api/classes/EventExecutable)\\n```ts title=\\"commands/meaning-of-life.ts\\"\\nimport { CommandType, CommandExecutable, type Args, type Context } from \'@sern/handler\';\\nimport { publish } from \'../plugins/publish.js\';\\nimport { serendipityOnly } from \'../plugins/serendipityOnly.js\';\\n\\nexport default class extends CommandExecutable {\\n type = CommandType.Both as const;\\n description = \'What is the meaning of life?\'\\n override onEvent = [\\n serendipityOnly()\\n ];\\n override plugins = [\\n publish(),\\n ];\\n // highlight-next-line\\n execute = async (ctx: Context, args: Args) => {\\n await ctx.reply(\'42\')\\n };\\n}\\n```\\n:::caution\\n\\nexecute must not be a method of the class. It should be as above, a property on the class!\\n\\n:::\\n\\n```ts title=\\"events/guildMemberAdd.ts\\"\\nimport { CommandType, EventExecutable, type EventType } from \'@sern/handler\';\\nimport type { GuildMember } from \'discord.js\'\\n\\nexport default class extends EventExecutable {\\n type = EventType.Discord as const;\\n // highlight-next-line\\n execute = (member: GuildMember) => {\\n console.log(member)\\n };\\n}\\n```\\nNow, you might ask **why** this feature was added.
Simply put, to give flexibility to the developers.\\nI believe that you should build your own structures however you might like and customize to your liking.\\nIn addition, **decorators now unofficially work with modules!**\\nFeel free to use TypeScript experimental decorators to augment and customize your classes. \\n\\n### Deprecation Warnings\\nThe next update will bring sern v2 with some important features. Here are some things to watch out for.\\n\\n- [Wrapper#client](docs/api/interfaces/Wrapper) will be deprecated\\n- [Wrapper#sernEmitter](docs/api/interfaces/Wrapper) will be deprecated\\n - a SernEmitter will be automatically created once Sern#init is called\\n- The option to pass in a function or array for [Wrapper#events](docs/api/interfaces/Wrapper) will be deprecated. Only strings are accepted.\\n- [Sern#addExternal](docs/api/classes/SernEmitter) will be deprecated in favor of a better way.\\n\\n### Dependencies Update\\n- TypeScript has been updated to 4.8.3\\n- Discord.js has been upgraded to 14.5"}]}')}}]); \ No newline at end of file diff --git a/fr/assets/js/runtime~main.7ed13804.js b/fr/assets/js/runtime~main.2deb8a4a.js similarity index 96% rename from fr/assets/js/runtime~main.7ed13804.js rename to fr/assets/js/runtime~main.2deb8a4a.js index 22ef1c491..4c07dc50d 100644 --- a/fr/assets/js/runtime~main.7ed13804.js +++ b/fr/assets/js/runtime~main.2deb8a4a.js @@ -1 +1 @@ -(()=>{"use strict";var e,c,a,t,f,r={},d={};function o(e){var c=d[e];if(void 0!==c)return c.exports;var a=d[e]={id:e,loaded:!1,exports:{}};return r[e].call(a.exports,a,a.exports,o),a.loaded=!0,a.exports}o.m=r,o.c=d,e=[],o.O=(c,a,t,f)=>{if(!a){var r=1/0;for(i=0;i=f)&&Object.keys(o.O).every((e=>o.O[e](a[b])))?a.splice(b--,1):(d=!1,f0&&e[i-1][2]>f;i--)e[i]=e[i-1];e[i]=[a,t,f]},o.n=e=>{var c=e&&e.__esModule?()=>e.default:()=>e;return o.d(c,{a:c}),c},a=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(e,t){if(1&t&&(e=this(e)),8&t)return e;if("object"==typeof e&&e){if(4&t&&e.__esModule)return e;if(16&t&&"function"==typeof e.then)return e}var f=Object.create(null);o.r(f);var r={};c=c||[null,a({}),a([]),a(a)];for(var d=2&t&&e;"object"==typeof d&&!~c.indexOf(d);d=a(d))Object.getOwnPropertyNames(d).forEach((c=>r[c]=()=>e[c]));return r.default=()=>e,o.d(f,r),f},o.d=(e,c)=>{for(var a in c)o.o(c,a)&&!o.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:c[a]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce(((c,a)=>(o.f[a](e,c),c)),[])),o.u=e=>"assets/js/"+({53:"5bc4ccbc",277:"c4348237",332:"73bd57bd",703:"981f6151",1036:"c0846785",1375:"cf23ded0",1472:"cf183316",1505:"7c2ff145",2005:"1ac1bfe9",2197:"935f2afb",2535:"814f3328",2640:"a96c96b0",3045:"888566f1",3085:"1f391b9e",3089:"a6aa9e1f",3608:"9e4087bc",4013:"01a85c17",4039:"174e7412",4137:"1aef51bd",4195:"c4f5d8e4",4332:"6c624b4c",4429:"eea0bf40",4803:"9201de17",4865:"e8e3d8c7",5062:"69369ae2",5397:"312c2bc5",6103:"ccc49370",6146:"608ca171",6270:"e4877132",6322:"a5467962",6918:"92293c9c",7127:"7e205c4a",7223:"3020eeee",7306:"f6aebfbf",7363:"26f1f3a5",7374:"6ba1d2c1",7414:"393be207",7597:"5e8c322a",7750:"3a2d3092",7800:"d58f2f6c",7918:"17896441",8069:"2eae8f3a",8610:"6875c492",8652:"bcd9df7e",9226:"707baeff",9514:"1be78505",9671:"0e384e19",9712:"3dc7c79a"}[e]||e)+"."+{53:"32b47523",277:"bbd90c09",332:"a5f060f5",703:"f0f70d80",1036:"6e6a2e01",1375:"407f98d0",1472:"305bb124",1505:"ac336ebd",2005:"4264b86c",2197:"c4a87233",2529:"824aaa15",2535:"609d1d08",2640:"9625b0b7",3045:"c84be8e6",3085:"8c38cce5",3089:"41e3be1f",3608:"66639242",4013:"e1f6e46d",4039:"632eea85",4137:"1e5fb79d",4195:"e4059570",4332:"89c23cc2",4429:"4b7962b0",4803:"0cd9e16a",4865:"c87a72d8",4972:"8f7e7193",5062:"40f3e7eb",5397:"1cae9e75",6103:"7974c41a",6146:"16383731",6270:"f5606e45",6322:"70de03ff",6918:"be6d9053",7127:"dec4ea49",7223:"f05b7e13",7306:"2073cc2b",7363:"beb7fb34",7374:"7041a0d3",7414:"ca4670d5",7540:"0456e07a",7597:"f8c69af5",7750:"3b268b53",7800:"072e21e3",7918:"3625818f",8069:"41957279",8610:"d7a7cd5d",8652:"909d54fb",9226:"c36a1ca3",9514:"b1e810d5",9671:"ab98e70d",9712:"82727dd4"}[e]+".js",o.miniCssF=e=>{},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,c)=>Object.prototype.hasOwnProperty.call(e,c),t={},f="@sern/website:",o.l=(e,c,a,r)=>{if(t[e])t[e].push(c);else{var d,b;if(void 0!==a)for(var n=document.getElementsByTagName("script"),i=0;i{d.onerror=d.onload=null,clearTimeout(s);var f=t[e];if(delete t[e],d.parentNode&&d.parentNode.removeChild(d),f&&f.forEach((e=>e(a))),c)return c(a)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:d}),12e4);d.onerror=l.bind(null,d.onerror),d.onload=l.bind(null,d.onload),b&&document.head.appendChild(d)}},o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.p="/fr/",o.gca=function(e){return e={17896441:"7918","5bc4ccbc":"53",c4348237:"277","73bd57bd":"332","981f6151":"703",c0846785:"1036",cf23ded0:"1375",cf183316:"1472","7c2ff145":"1505","1ac1bfe9":"2005","935f2afb":"2197","814f3328":"2535",a96c96b0:"2640","888566f1":"3045","1f391b9e":"3085",a6aa9e1f:"3089","9e4087bc":"3608","01a85c17":"4013","174e7412":"4039","1aef51bd":"4137",c4f5d8e4:"4195","6c624b4c":"4332",eea0bf40:"4429","9201de17":"4803",e8e3d8c7:"4865","69369ae2":"5062","312c2bc5":"5397",ccc49370:"6103","608ca171":"6146",e4877132:"6270",a5467962:"6322","92293c9c":"6918","7e205c4a":"7127","3020eeee":"7223",f6aebfbf:"7306","26f1f3a5":"7363","6ba1d2c1":"7374","393be207":"7414","5e8c322a":"7597","3a2d3092":"7750",d58f2f6c:"7800","2eae8f3a":"8069","6875c492":"8610",bcd9df7e:"8652","707baeff":"9226","1be78505":"9514","0e384e19":"9671","3dc7c79a":"9712"}[e]||e,o.p+o.u(e)},(()=>{var e={1303:0,532:0};o.f.j=(c,a)=>{var t=o.o(e,c)?e[c]:void 0;if(0!==t)if(t)a.push(t[2]);else if(/^(1303|532)$/.test(c))e[c]=0;else{var f=new Promise(((a,f)=>t=e[c]=[a,f]));a.push(t[2]=f);var r=o.p+o.u(c),d=new Error;o.l(r,(a=>{if(o.o(e,c)&&(0!==(t=e[c])&&(e[c]=void 0),t)){var f=a&&("load"===a.type?"missing":a.type),r=a&&a.target&&a.target.src;d.message="Loading chunk "+c+" failed.\n("+f+": "+r+")",d.name="ChunkLoadError",d.type=f,d.request=r,t[1](d)}}),"chunk-"+c,c)}},o.O.j=c=>0===e[c];var c=(c,a)=>{var t,f,r=a[0],d=a[1],b=a[2],n=0;if(r.some((c=>0!==e[c]))){for(t in d)o.o(d,t)&&(o.m[t]=d[t]);if(b)var i=b(o)}for(c&&c(a);n{"use strict";var e,c,a,t,f,r={},d={};function o(e){var c=d[e];if(void 0!==c)return c.exports;var a=d[e]={id:e,loaded:!1,exports:{}};return r[e].call(a.exports,a,a.exports,o),a.loaded=!0,a.exports}o.m=r,o.c=d,e=[],o.O=(c,a,t,f)=>{if(!a){var r=1/0;for(i=0;i=f)&&Object.keys(o.O).every((e=>o.O[e](a[b])))?a.splice(b--,1):(d=!1,f0&&e[i-1][2]>f;i--)e[i]=e[i-1];e[i]=[a,t,f]},o.n=e=>{var c=e&&e.__esModule?()=>e.default:()=>e;return o.d(c,{a:c}),c},a=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(e,t){if(1&t&&(e=this(e)),8&t)return e;if("object"==typeof e&&e){if(4&t&&e.__esModule)return e;if(16&t&&"function"==typeof e.then)return e}var f=Object.create(null);o.r(f);var r={};c=c||[null,a({}),a([]),a(a)];for(var d=2&t&&e;"object"==typeof d&&!~c.indexOf(d);d=a(d))Object.getOwnPropertyNames(d).forEach((c=>r[c]=()=>e[c]));return r.default=()=>e,o.d(f,r),f},o.d=(e,c)=>{for(var a in c)o.o(c,a)&&!o.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:c[a]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce(((c,a)=>(o.f[a](e,c),c)),[])),o.u=e=>"assets/js/"+({53:"5bc4ccbc",277:"c4348237",332:"73bd57bd",703:"981f6151",1036:"c0846785",1375:"cf23ded0",1472:"cf183316",1505:"7c2ff145",2005:"1ac1bfe9",2197:"935f2afb",2535:"814f3328",2640:"a96c96b0",3045:"888566f1",3085:"1f391b9e",3089:"a6aa9e1f",3608:"9e4087bc",4013:"01a85c17",4039:"174e7412",4137:"1aef51bd",4195:"c4f5d8e4",4332:"6c624b4c",4429:"eea0bf40",4803:"9201de17",4865:"e8e3d8c7",5062:"69369ae2",5397:"312c2bc5",6103:"ccc49370",6146:"608ca171",6270:"e4877132",6322:"a5467962",6918:"92293c9c",7127:"7e205c4a",7223:"3020eeee",7306:"f6aebfbf",7363:"26f1f3a5",7374:"6ba1d2c1",7414:"393be207",7597:"5e8c322a",7750:"3a2d3092",7800:"d58f2f6c",7918:"17896441",8069:"2eae8f3a",8610:"6875c492",8652:"bcd9df7e",9226:"707baeff",9514:"1be78505",9671:"0e384e19",9712:"3dc7c79a"}[e]||e)+"."+{53:"32b47523",277:"bbd90c09",332:"a5f060f5",703:"f0f70d80",1036:"6e6a2e01",1375:"bc4a7762",1472:"305bb124",1505:"ac336ebd",2005:"4264b86c",2197:"c4a87233",2529:"824aaa15",2535:"609d1d08",2640:"9625b0b7",3045:"c84be8e6",3085:"8c38cce5",3089:"41e3be1f",3608:"66639242",4013:"e1f6e46d",4039:"632eea85",4137:"1e5fb79d",4195:"e4059570",4332:"89c23cc2",4429:"4b7962b0",4803:"0cd9e16a",4865:"c87a72d8",4972:"8f7e7193",5062:"40f3e7eb",5397:"1cae9e75",6103:"7974c41a",6146:"16383731",6270:"f5606e45",6322:"70de03ff",6918:"be6d9053",7127:"dec4ea49",7223:"b0fe60eb",7306:"2073cc2b",7363:"beb7fb34",7374:"72a398c7",7414:"ca4670d5",7540:"0456e07a",7597:"f8c69af5",7750:"3b268b53",7800:"072e21e3",7918:"3625818f",8069:"41957279",8610:"d7a7cd5d",8652:"909d54fb",9226:"c36a1ca3",9514:"b1e810d5",9671:"ab98e70d",9712:"82727dd4"}[e]+".js",o.miniCssF=e=>{},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,c)=>Object.prototype.hasOwnProperty.call(e,c),t={},f="@sern/website:",o.l=(e,c,a,r)=>{if(t[e])t[e].push(c);else{var d,b;if(void 0!==a)for(var n=document.getElementsByTagName("script"),i=0;i{d.onerror=d.onload=null,clearTimeout(s);var f=t[e];if(delete t[e],d.parentNode&&d.parentNode.removeChild(d),f&&f.forEach((e=>e(a))),c)return c(a)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:d}),12e4);d.onerror=l.bind(null,d.onerror),d.onload=l.bind(null,d.onload),b&&document.head.appendChild(d)}},o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.p="/fr/",o.gca=function(e){return e={17896441:"7918","5bc4ccbc":"53",c4348237:"277","73bd57bd":"332","981f6151":"703",c0846785:"1036",cf23ded0:"1375",cf183316:"1472","7c2ff145":"1505","1ac1bfe9":"2005","935f2afb":"2197","814f3328":"2535",a96c96b0:"2640","888566f1":"3045","1f391b9e":"3085",a6aa9e1f:"3089","9e4087bc":"3608","01a85c17":"4013","174e7412":"4039","1aef51bd":"4137",c4f5d8e4:"4195","6c624b4c":"4332",eea0bf40:"4429","9201de17":"4803",e8e3d8c7:"4865","69369ae2":"5062","312c2bc5":"5397",ccc49370:"6103","608ca171":"6146",e4877132:"6270",a5467962:"6322","92293c9c":"6918","7e205c4a":"7127","3020eeee":"7223",f6aebfbf:"7306","26f1f3a5":"7363","6ba1d2c1":"7374","393be207":"7414","5e8c322a":"7597","3a2d3092":"7750",d58f2f6c:"7800","2eae8f3a":"8069","6875c492":"8610",bcd9df7e:"8652","707baeff":"9226","1be78505":"9514","0e384e19":"9671","3dc7c79a":"9712"}[e]||e,o.p+o.u(e)},(()=>{var e={1303:0,532:0};o.f.j=(c,a)=>{var t=o.o(e,c)?e[c]:void 0;if(0!==t)if(t)a.push(t[2]);else if(/^(1303|532)$/.test(c))e[c]=0;else{var f=new Promise(((a,f)=>t=e[c]=[a,f]));a.push(t[2]=f);var r=o.p+o.u(c),d=new Error;o.l(r,(a=>{if(o.o(e,c)&&(0!==(t=e[c])&&(e[c]=void 0),t)){var f=a&&("load"===a.type?"missing":a.type),r=a&&a.target&&a.target.src;d.message="Loading chunk "+c+" failed.\n("+f+": "+r+")",d.name="ChunkLoadError",d.type=f,d.request=r,t[1](d)}}),"chunk-"+c,c)}},o.O.j=c=>0===e[c];var c=(c,a)=>{var t,f,r=a[0],d=a[1],b=a[2],n=0;if(r.some((c=>0!==e[c]))){for(t in d)o.o(d,t)&&(o.m[t]=d[t]);if(b)var i=b(o)}for(c&&c(a);n Blog | sern - Handlers. Redefined. - +

· 2 minutes de lecture
jacoobes

Class-based modules

Today we're announcing the ability to create class based modules! To get started, install

npm install @sern/handler@latest

Quick List of changes!

Class based modules

Incorporate class based modules into your project instead of the traditional commandModule or eventModule -Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from "@sern/handler";
import { publish } from "../plugins/publish.js";
import { serendipityOnly } from "../plugins/serendipityOnly.js";

export default class extends CommandExecutable<CommandType.Both> {

type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
attention

execute must not be a method of the class. It should be as above, a property on the class!

commands/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from "@sern/handler";
import type { GuildMember } from 'discord.js'
export default class extends EventExecutable<EventType.Discord> {

type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. +Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from '@sern/handler';
import { publish } from '../plugins/publish.js';
import { serendipityOnly } from '../plugins/serendipityOnly.js';

export default class extends CommandExecutable<CommandType.Both> {
type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
attention

execute must not be a method of the class. It should be as above, a property on the class!

events/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from '@sern/handler';
import type { GuildMember } from 'discord.js'

export default class extends EventExecutable<EventType.Discord> {
type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. I believe that you should build your own structures however you might like and customize to your liking. In addition, decorators now unofficially work with modules! Feel free to use TypeScript experimental decorators to augment and customize your classes.

Deprecation Warnings

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

Dependencies Update

  • TypeScript has been updated to 4.8.3
  • Discord.js has been upgraded to 14.5
- + \ No newline at end of file diff --git a/fr/blog/1.2.0.html b/fr/blog/1.2.0.html index 65600f81b..e8767f134 100644 --- a/fr/blog/1.2.0.html +++ b/fr/blog/1.2.0.html @@ -6,18 +6,18 @@ Release 1.2.0 | sern - Handlers. Redefined. - +

Release 1.2.0

· 2 minutes de lecture
jacoobes

Class-based modules

Today we're announcing the ability to create class based modules! To get started, install

npm install @sern/handler@latest

Quick List of changes!

Class based modules

Incorporate class based modules into your project instead of the traditional commandModule or eventModule -Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from "@sern/handler";
import { publish } from "../plugins/publish.js";
import { serendipityOnly } from "../plugins/serendipityOnly.js";

export default class extends CommandExecutable<CommandType.Both> {

type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
attention

execute must not be a method of the class. It should be as above, a property on the class!

commands/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from "@sern/handler";
import type { GuildMember } from 'discord.js'
export default class extends EventExecutable<EventType.Discord> {

type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. +Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from '@sern/handler';
import { publish } from '../plugins/publish.js';
import { serendipityOnly } from '../plugins/serendipityOnly.js';

export default class extends CommandExecutable<CommandType.Both> {
type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
attention

execute must not be a method of the class. It should be as above, a property on the class!

events/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from '@sern/handler';
import type { GuildMember } from 'discord.js'

export default class extends EventExecutable<EventType.Discord> {
type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. I believe that you should build your own structures however you might like and customize to your liking. In addition, decorators now unofficially work with modules! Feel free to use TypeScript experimental decorators to augment and customize your classes.

Deprecation Warnings

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

Dependencies Update

  • TypeScript has been updated to 4.8.3
  • Discord.js has been upgraded to 14.5
- + \ No newline at end of file diff --git a/fr/blog/archive.html b/fr/blog/archive.html index a374397a2..574581e2a 100644 --- a/fr/blog/archive.html +++ b/fr/blog/archive.html @@ -6,13 +6,13 @@ Archive | sern - Handlers. Redefined. - +
- + \ No newline at end of file diff --git a/fr/blog/atom.xml b/fr/blog/atom.xml index 137b90e44..f3416c543 100644 --- a/fr/blog/atom.xml +++ b/fr/blog/atom.xml @@ -15,7 +15,7 @@ Class-based modules

Today we're announcing the ability to create class based modules! To get started, install

npm install @sern/handler@latest

Quick List of changes!

Class based modules

Incorporate class based modules into your project instead of the traditional commandModule or eventModule -Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from "@sern/handler";
import { publish } from "../plugins/publish.js";
import { serendipityOnly } from "../plugins/serendipityOnly.js";

export default class extends CommandExecutable<CommandType.Both> {

type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
attention

execute must not be a method of the class. It should be as above, a property on the class!

commands/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from "@sern/handler";
import type { GuildMember } from 'discord.js'
export default class extends EventExecutable<EventType.Discord> {

type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. +Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from '@sern/handler';
import { publish } from '../plugins/publish.js';
import { serendipityOnly } from '../plugins/serendipityOnly.js';

export default class extends CommandExecutable<CommandType.Both> {
type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
attention

execute must not be a method of the class. It should be as above, a property on the class!

events/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from '@sern/handler';
import type { GuildMember } from 'discord.js'

export default class extends EventExecutable<EventType.Discord> {
type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. I believe that you should build your own structures however you might like and customize to your liking. In addition, decorators now unofficially work with modules! Feel free to use TypeScript experimental decorators to augment and customize your classes.

Deprecation Warnings

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

Dependencies Update

  • TypeScript has been updated to 4.8.3
  • Discord.js has been upgraded to 14.5
]]>
diff --git a/fr/blog/rss.xml b/fr/blog/rss.xml index 0d271e8b4..3484bcc9b 100644 --- a/fr/blog/rss.xml +++ b/fr/blog/rss.xml @@ -16,7 +16,7 @@ Class-based modules

Today we're announcing the ability to create class based modules! To get started, install

npm install @sern/handler@latest

Quick List of changes!

Class based modules

Incorporate class based modules into your project instead of the traditional commandModule or eventModule -Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from "@sern/handler";
import { publish } from "../plugins/publish.js";
import { serendipityOnly } from "../plugins/serendipityOnly.js";

export default class extends CommandExecutable<CommandType.Both> {

type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
attention

execute must not be a method of the class. It should be as above, a property on the class!

commands/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from "@sern/handler";
import type { GuildMember } from 'discord.js'
export default class extends EventExecutable<EventType.Discord> {

type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. +Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from '@sern/handler';
import { publish } from '../plugins/publish.js';
import { serendipityOnly } from '../plugins/serendipityOnly.js';

export default class extends CommandExecutable<CommandType.Both> {
type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
attention

execute must not be a method of the class. It should be as above, a property on the class!

events/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from '@sern/handler';
import type { GuildMember } from 'discord.js'

export default class extends EventExecutable<EventType.Discord> {
type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. I believe that you should build your own structures however you might like and customize to your liking. In addition, decorators now unofficially work with modules! Feel free to use TypeScript experimental decorators to augment and customize your classes.

Deprecation Warnings

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

Dependencies Update

  • TypeScript has been updated to 4.8.3
  • Discord.js has been upgraded to 14.5
]]>
diff --git a/fr/blog/tags.html b/fr/blog/tags.html index e071523e9..def8744aa 100644 --- a/fr/blog/tags.html +++ b/fr/blog/tags.html @@ -6,13 +6,13 @@ Tags | sern - Handlers. Redefined. - +

Tags

- + \ No newline at end of file diff --git a/fr/blog/tags/release.html b/fr/blog/tags/release.html index 6463ee702..498f45e40 100644 --- a/fr/blog/tags/release.html +++ b/fr/blog/tags/release.html @@ -6,18 +6,18 @@ Un article tagués avec « release » | sern - Handlers. Redefined. - +

Un article tagués avec « release »

Voir tous les tags

· 2 minutes de lecture
jacoobes

Class-based modules

Today we're announcing the ability to create class based modules! To get started, install

npm install @sern/handler@latest

Quick List of changes!

Class based modules

Incorporate class based modules into your project instead of the traditional commandModule or eventModule -Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from "@sern/handler";
import { publish } from "../plugins/publish.js";
import { serendipityOnly } from "../plugins/serendipityOnly.js";

export default class extends CommandExecutable<CommandType.Both> {

type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
attention

execute must not be a method of the class. It should be as above, a property on the class!

commands/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from "@sern/handler";
import type { GuildMember } from 'discord.js'
export default class extends EventExecutable<EventType.Discord> {

type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. +Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from '@sern/handler';
import { publish } from '../plugins/publish.js';
import { serendipityOnly } from '../plugins/serendipityOnly.js';

export default class extends CommandExecutable<CommandType.Both> {
type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
attention

execute must not be a method of the class. It should be as above, a property on the class!

events/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from '@sern/handler';
import type { GuildMember } from 'discord.js'

export default class extends EventExecutable<EventType.Discord> {
type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. I believe that you should build your own structures however you might like and customize to your liking. In addition, decorators now unofficially work with modules! Feel free to use TypeScript experimental decorators to augment and customize your classes.

Deprecation Warnings

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

Dependencies Update

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

@sern/handler

Handlers. Redefined.

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

NPM versionNPM downloadsLicense MITdocs.rsLines of code

📜 Installation

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

👀 Quick Look

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

👶 Basic Usage

index.js (CommonJS)

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

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

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

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

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

client.login(token);

ping.js (CommonJS)

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

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

See our templates for TypeScript examples and more

💻 CLI

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

👋 Contribute

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

🚈 Roadmap

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

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

Class: CommandExecutable<Type>

Type parameters

NameType
Typeextends CommandType

Constructors

constructor

new CommandExecutable<Type>()

Type parameters

NameType
Typeextends CommandType

Properties

execute

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

Defined in

src/handler/sern.ts:132


onEvent

onEvent: EventPlugin<Type>[] = []

Defined in

src/handler/sern.ts:131


plugins

plugins: CommandPlugin<Type>[] = []

Defined in

src/handler/sern.ts:130


type

Abstract type: Type

Defined in

src/handler/sern.ts:129

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

Returns

ChatInputCommandInteraction<CacheType>

Defined in

src/handler/structures/context.ts:52


member

get member(): Nullish<GuildMember | APIGuildMember>

Returns

Nullish<GuildMember | APIGuildMember>

Defined in

src/handler/structures/context.ts:101


message

get message(): Message<boolean>

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

Returns

Message<boolean>

Defined in

src/handler/structures/context.ts:44


user

get user(): User

Returns

User

Defined in

src/handler/structures/context.ts:70

Methods

isEmpty

isEmpty(): boolean

Returns

boolean

Defined in

src/handler/structures/context.ts:129


reply

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

Parameters

NameType
contentReplyOptions

Returns

Promise<Message<boolean>>

Defined in

src/handler/structures/context.ts:133


wrap

Static wrap(wrappable): Context

Parameters

NameType
wrappableMessage<boolean> | ChatInputCommandInteraction<CacheType>

Returns

Context

Defined in

src/handler/structures/context.ts:122

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

Class: EventExecutable<Type>

Type parameters

NameType
Typeextends EventType

Constructors

constructor

new EventExecutable<Type>()

Type parameters

NameType
Typeextends EventType

Properties

execute

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

Defined in

src/handler/sern.ts:139


onEvent

onEvent: EventModuleEventPluginDefs[Type][] = []

Defined in

src/handler/sern.ts:138


plugins

plugins: EventModuleCommandPluginDefs[Type][] = []

Defined in

src/handler/sern.ts:137


type

Abstract type: Type

Defined in

src/handler/sern.ts:136

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

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

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

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

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

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

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

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

run();

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

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

const ee = new EventEmitter();

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

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

// Prints: ok boom

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

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

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

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

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

Since

v11.13.0, v10.16.0

Parameters

NameType
emitterNodeEventTarget
eventNamestring | symbol
options?StaticEventEmitterOptions

Returns

Promise<any[]>

Inherited from

EventEmitter.once

Defined in

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

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

Parameters

NameType
emitterDOMEventTarget
eventNamestring
options?StaticEventEmitterOptions

Returns

Promise<any[]>

Inherited from

EventEmitter.once

Defined in

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

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

Type parameters

NameType
Kextends keyof ClientEvents

Parameters

NameType
eventEmitterClient<boolean>
eventNameK

Returns

Promise<ClientEvents[K]>

Inherited from

EventEmitter.once

Defined in

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


setMaxListeners

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

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

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

setMaxListeners(5, target, emitter);

Since

v15.4.0

Parameters

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

Returns

void

Inherited from

EventEmitter.setMaxListeners

Defined in

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

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

Enumeration: CommandType

Example

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

Enumeration Members

Both

Both = 3

The CommandType for hybrid commands, text and slash

Defined in

src/handler/structures/enums.ts:27


Button

Button = 16

The CommandType for ButtonInteraction commands

Defined in

src/handler/structures/enums.ts:39


MenuMsg = 8

The CommandType for MessageContextMenuInteraction commands

Defined in

src/handler/structures/enums.ts:35


MenuSelect = 32

The CommandType for SelectMenuInteraction commands

Defined in

src/handler/structures/enums.ts:43


MenuUser = 4

The CommandType for UserContextMenuInteraction commands

Defined in

src/handler/structures/enums.ts:31


Modal = 64

The CommandType for ModalSubmitInteraction commands

Defined in

src/handler/structures/enums.ts:47


Slash

Slash = 2

The CommandType for slash commands

Defined in

src/handler/structures/enums.ts:23


Text

Text = 1

The CommandType for text commands

Defined in

src/handler/structures/enums.ts:19

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

Enumeration: EventType

Example

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

Enumeration Members

Discord

Discord = 1

The EventType for handling discord events

Defined in

src/handler/structures/enums.ts:68


External

External = 3

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

Defined in

src/handler/structures/enums.ts:77


Sern

Sern = 2

The EventType for handling sern events

Defined in

src/handler/structures/enums.ts:72

- + \ No newline at end of file diff --git a/fr/docs/api/enums/PayloadType.html b/fr/docs/api/enums/PayloadType.html index 6912b61e4..82bf2d5d3 100644 --- a/fr/docs/api/enums/PayloadType.html +++ b/fr/docs/api/enums/PayloadType.html @@ -6,13 +6,13 @@ Enumeration: PayloadType | sern - Handlers. Redefined. - +
- + \ No newline at end of file diff --git a/fr/docs/api/enums/PluginType.html b/fr/docs/api/enums/PluginType.html index dac323468..263a8af41 100644 --- a/fr/docs/api/enums/PluginType.html +++ b/fr/docs/api/enums/PluginType.html @@ -6,13 +6,13 @@ Enumeration: PluginType | sern - Handlers. Redefined. - +

Enumeration: PluginType

Example

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

Enumeration Members

Command

Command = 1

The PluginType for CommandPlugins

Defined in

src/handler/structures/enums.ts:97


Event

Event = 2

The PluginType for EventPlugins

Defined in

src/handler/structures/enums.ts:101

- + \ No newline at end of file diff --git a/fr/docs/api/interfaces/Controller.html b/fr/docs/api/interfaces/Controller.html index 8fd9c7f40..eccbda9ed 100644 --- a/fr/docs/api/interfaces/Controller.html +++ b/fr/docs/api/interfaces/Controller.html @@ -6,13 +6,13 @@ Interface: Controller | sern - Handlers. Redefined. - +
- + \ No newline at end of file diff --git a/fr/docs/api/interfaces/Wrapper.html b/fr/docs/api/interfaces/Wrapper.html index 2317b6bbc..17b17f56b 100644 --- a/fr/docs/api/interfaces/Wrapper.html +++ b/fr/docs/api/interfaces/Wrapper.html @@ -6,13 +6,13 @@ Interface: Wrapper | sern - Handlers. Redefined. - +

Interface: Wrapper

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

Properties

client

Readonly client: Client<boolean>

Defined in

src/handler/structures/wrapper.ts:11


commands

Readonly commands: string

Defined in

src/handler/structures/wrapper.ts:15


defaultPrefix

Optional Readonly defaultPrefix: string

Defined in

src/handler/structures/wrapper.ts:14


events

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

Defined in

src/handler/structures/wrapper.ts:16


sernEmitter

Optional Readonly sernEmitter: SernEmitter

Defined in

src/handler/structures/wrapper.ts:13

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

@sern/handler

Namespaces

Enumerations

Classes

Interfaces

Type Aliases

Args

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

Defined in

src/types/handler.ts:12


AutocompletePlugin

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

Defined in

src/handler/plugins/plugin.ts:92


BaseOptions

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

Type that replaces autocomplete with SernAutocompleteData

Defined in

src/handler/structures/module.ts:181


BothCommand

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

Defined in

src/handler/structures/module.ts:55


CommandModuleNoPlugins

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

Defined in

src/handler/plugins/plugin.ts:145


CommandModulePlugin

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

Type parameters

NameType
Textends CommandType

Defined in

src/handler/plugins/plugin.ts:173


CommandPlugin

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

Type parameters

NameType
Textends keyof CommandModuleDefs = keyof CommandModuleDefs

Defined in

src/handler/plugins/plugin.ts:40


DefinedCommandModule

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

Defined in

src/types/handler.ts:43


DefinedEventModule

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

Defined in

src/types/handler.ts:44


DefinedModule

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

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

Defined in

src/types/handler.ts:42


DefinitelyDefined

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

Type parameters

NameType
TT
Kextends keyof T = keyof T

Defined in

src/types/handler.ts:19


DiscordEmitterPlugin

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

Defined in

src/handler/plugins/plugin.ts:57


DiscordEventPlugin

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

Type parameters

NameType
Textends keyof ClientEvents = keyof ClientEvents

Defined in

src/handler/plugins/plugin.ts:136


EventInput

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

Defined in

src/types/handler.ts:25


EventModuleCommandPluginDefs

Ƭ EventModuleCommandPluginDefs: Object

Event Module Command Plugins

Type declaration

NameType
1DiscordEmitterPlugin
2SernEmitterPlugin
3ExternalEmitterPlugin

Defined in

src/handler/plugins/plugin.ts:163


EventModuleEventPluginDefs

Ƭ EventModuleEventPluginDefs: Object

Event Module Event Plugins

Type declaration

NameType
1DiscordEventPlugin
2SernEventPlugin
3ExternalEventPlugin

Defined in

src/handler/plugins/plugin.ts:154


EventModulePlugin

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

Type parameters

NameType
Textends EventType

Defined in

src/handler/plugins/plugin.ts:169


EventModulesNoPlugins

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

Defined in

src/handler/plugins/plugin.ts:148


EventPlugin

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

Type parameters

NameType
Textends keyof CommandModuleDefs = keyof CommandModuleDefs

Defined in

src/handler/plugins/plugin.ts:103


ExternalEmitterPlugin

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

Type parameters

NameType
Textends EventEmitter = EventEmitter

Defined in

src/handler/plugins/plugin.ts:68


ExternalEventPlugin

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

Defined in

src/handler/plugins/plugin.ts:128


InputCommandModule

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

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

Defined in

src/handler/plugins/plugin.ts:178


InputEventModule

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

Defined in

src/handler/plugins/plugin.ts:182


Module

Ƭ Module: CommandModule | EventModule

Defined in

src/handler/structures/module.ts:141


Nullish

Ƭ Nullish<T>: T | undefined | null

Type parameters

Name
T

Defined in

src/types/handler.ts:5


Override

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

Type parameters

Name
T1
T2

Defined in

src/types/handler.ts:17


ParseType

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

Type parameters

Name
T

Defined in

src/types/handler.ts:8


Payload

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

Defined in

src/types/handler.ts:45


ReplyOptions

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

Defined in

src/types/handler.ts:55


SernAutocompleteData

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

Defined in

src/handler/structures/module.ts:166


SernEmitterPlugin

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

Defined in

src/handler/plugins/plugin.ts:80


SernEventPlugin

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

Type parameters

NameType
Textends keyof SernEventsMapping = keyof SernEventsMapping

Defined in

src/handler/plugins/plugin.ts:116


SernEventsMapping

Ƭ SernEventsMapping: Object

Type declaration

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

Defined in

src/types/handler.ts:48


SernOptionsData

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

Type parameters

NameType
Uextends ApplicationCommandOptionData = ApplicationCommandOptionData

Defined in

src/handler/structures/module.ts:205


SernSubCommandData

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

Defined in

src/handler/structures/module.ts:189


SernSubCommandGroupData

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

Defined in

src/handler/structures/module.ts:197


SlashCommand

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

Defined in

src/handler/structures/module.ts:44


SlashOptions

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

Defined in

src/types/handler.ts:14


SpreadParams

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

Type parameters

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

Type declaration

▸ (args): unknown

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

Parameters
NameType
argsParameters<T>[number]
Returns

unknown

Defined in

src/types/handler.ts:34


TextCommand

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

Defined in

src/handler/structures/module.ts:33

Functions

commandModule

commandModule(mod): CommandModule

The wrapper function to define command modules for sern

Parameters

NameType
modInputCommandModule

Returns

CommandModule

Defined in

src/handler/sern.ts:91


eventModule

eventModule(mod): EventModule

The wrapper function to define event modules for sern

Parameters

NameType
modInputEventModule

Returns

EventModule

Defined in

src/handler/sern.ts:112

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

Namespace: Sern

References

CommandExecutable

Re-exports CommandExecutable


EventExecutable

Re-exports EventExecutable


commandModule

Re-exports commandModule


eventModule

Re-exports eventModule

Variables

controller

Const controller: Object

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

Type declaration

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

Defined in

src/handler/sern.ts:82

Functions

addExternal

addExternal<T>(emitter): void

Deprecated

  • use Sern#makeDependencies instead

Example

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

Example

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

Type parameters

NameType
Textends __module

Parameters

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

Returns

void

Defined in

src/handler/sern.ts:72


init

init(wrapper): void

Example

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

Parameters

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

Returns

void

Defined in

src/handler/sern.ts:39

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

Introduction

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

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

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

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

You will learn

Working with plugins

Events

Good to know

- + \ No newline at end of file diff --git a/fr/docs/guide/getting-started/choose-ide.html b/fr/docs/guide/getting-started/choose-ide.html index 84b31966f..8dda62b28 100644 --- a/fr/docs/guide/getting-started/choose-ide.html +++ b/fr/docs/guide/getting-started/choose-ide.html @@ -6,14 +6,14 @@ Choosing an IDE | sern - Handlers. Redefined. - +
- + \ No newline at end of file diff --git a/fr/docs/guide/getting-started/preparing.html b/fr/docs/guide/getting-started/preparing.html index e4ff238ae..7155377f7 100644 --- a/fr/docs/guide/getting-started/preparing.html +++ b/fr/docs/guide/getting-started/preparing.html @@ -6,13 +6,13 @@ Preparing to Code | sern - Handlers. Redefined. - +

Preparing to Code

After installing and IDE you need to install node.

You can download the LTS version of node right here

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

CLI

Setting up the CLI is easy.

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

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

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

sern plugins
info

Make sure to have a correct sern.config.json

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

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

Conclusion

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

- + \ No newline at end of file diff --git a/fr/docs/guide/walkthrough/first-command.html b/fr/docs/guide/walkthrough/first-command.html index 74cd45b19..13d1ed4e7 100644 --- a/fr/docs/guide/walkthrough/first-command.html +++ b/fr/docs/guide/walkthrough/first-command.html @@ -6,7 +6,7 @@ First Command | sern - Handlers. Redefined. - + @@ -15,7 +15,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 8ddf704c5..fd0664f24 100644 --- a/fr/docs/guide/walkthrough/first-event.html +++ b/fr/docs/guide/walkthrough/first-event.html @@ -6,7 +6,7 @@ First Event Module | sern - Handlers. Redefined. - + @@ -14,7 +14,7 @@

First Event Module

We will dissect a basic event module.
Typescript:

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

Javascript:

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

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

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


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

Another example of an event module

Typescript:

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

Javascript:


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

Goal

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

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

Good to know

sern.config.json

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

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

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

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

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

Javascript:

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

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

astuce

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

Event Plugins

event-plugins

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

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

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

Typescript:

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

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

Javascript:

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

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

Can you predict the behavior of this command?

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

Event Plugins are good for filtering, preconditions, parsing.

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

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

The SernEmitter class

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

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

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


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

Welcome!

Content

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

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

astuce

If you have problems, join the discord server here

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

Handlers. Redefined.

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

sern init
logo

Batteries included

Start or integrate a new project in minutes.

Customizable

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

Modern

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

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

Markdown page example

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

- + \ No newline at end of file diff --git a/fr/plugins.html b/fr/plugins.html index 9708cf7fd..210a96357 100644 --- a/fr/plugins.html +++ b/fr/plugins.html @@ -6,13 +6,13 @@ sern - Handlers. Redefined. - +

Coming soon

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

Handlers. Redefined.

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

sern init
logo

Batteries included

Start or integrate a new project in minutes.

Customizable

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

Modern

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

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

Markdown page example

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

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

Coming soon

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

Sayfa Bulunamadı

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

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

- + \ No newline at end of file diff --git a/tr/assets/js/3020eeee.c125a283.js b/tr/assets/js/3020eeee.79954e26.js similarity index 61% rename from tr/assets/js/3020eeee.c125a283.js rename to tr/assets/js/3020eeee.79954e26.js index e150e31e3..a380b3015 100644 --- a/tr/assets/js/3020eeee.c125a283.js +++ b/tr/assets/js/3020eeee.79954e26.js @@ -1 +1 @@ -"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[7223],{3905:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>m});var a=n(7294);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var i=a.createContext({}),p=function(e){var t=a.useContext(i),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},c=function(e){var t=p(e.components);return a.createElement(i.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},u=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,l=e.originalType,i=e.parentName,c=s(e,["components","mdxType","originalType","parentName"]),u=p(n),m=r,b=u["".concat(i,".").concat(m)]||u[m]||d[m]||l;return n?a.createElement(b,o(o({ref:t},c),{},{components:n})):a.createElement(b,o({ref:t},c))}));function m(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var l=n.length,o=new Array(l);o[0]=u;var s={};for(var i in t)hasOwnProperty.call(t,i)&&(s[i]=t[i]);s.originalType=e,s.mdxType="string"==typeof e?e:r,o[1]=s;for(var p=2;p{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>o,default:()=>d,frontMatter:()=>l,metadata:()=>s,toc:()=>p});var a=n(7462),r=(n(7294),n(3905));const l={slug:"1.2.0",title:"Release 1.2.0",authors:["jacoobes"],tags:["release"]},o=void 0,s={permalink:"/tr/blog/1.2.0",editUrl:"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/blog/2022-09-28-mdx-blog-post.md",source:"@site/blog/2022-09-28-mdx-blog-post.md",title:"Release 1.2.0",description:"Class-based modules",date:"2022-09-28T00:00:00.000Z",formattedDate:"28 Eyl\xfcl 2022",tags:[{label:"release",permalink:"/tr/blog/tags/release"}],readingTime:1.71,hasTruncateMarker:!1,authors:[{name:"jacoobes",title:"Head Dev",url:"https://github.com/jacoobes",imageURL:"https://github.com/jacoobes.png",key:"jacoobes"}],frontMatter:{slug:"1.2.0",title:"Release 1.2.0",authors:["jacoobes"],tags:["release"]}},i={authorsImageUrls:[void 0]},p=[{value:"Class-based modules",id:"class-based-modules",level:2},{value:"Class based modules",id:"class-based-modules-1",level:3},{value:"Deprecation Warnings",id:"deprecation-warnings",level:3},{value:"Dependencies Update",id:"dependencies-update",level:3}],c={toc:p};function d(e){let{components:t,...n}=e;return(0,r.kt)("wrapper",(0,a.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("h2",{id:"class-based-modules"},"Class-based modules"),(0,r.kt)("p",null,"Today we're announcing the ability to create class based modules!\nTo get started, install"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre"},"npm install @sern/handler@latest\n")),(0,r.kt)("p",null,"Quick List of changes!"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#class-based-modules"},"Class based modules")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#deprecation-warnings"},"Deprecation Warnings")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#dependencies-update"},"Dependencies update"))),(0,r.kt)("h3",{id:"class-based-modules-1"},"Class based modules"),(0,r.kt)("p",null,"Incorporate class based modules into your project instead of the traditional ",(0,r.kt)("inlineCode",{parentName:"p"},"commandModule")," or ",(0,r.kt)("inlineCode",{parentName:"p"},"eventModule"),"\nExtend the new ",(0,r.kt)("a",{parentName:"p",href:"docs/api/classes/CommandExecutable"},"CommandExecutable")," or ",(0,r.kt)("a",{parentName:"p",href:"docs/api/classes/EventExecutable"},"EventExecutable")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="commands/meaning-of-life.ts"',title:'"commands/meaning-of-life.ts"'},'import { CommandType, CommandExecutable, type Args, type Context } from "@sern/handler";\nimport { publish } from "../plugins/publish.js";\nimport { serendipityOnly } from "../plugins/serendipityOnly.js";\n\nexport default class extends CommandExecutable {\n\n type = CommandType.Both as const;\n description = \'What is the meaning of life?\'\n override onEvent = [\n serendipityOnly()\n ];\n override plugins = [\n publish(),\n ];\n // highlight-next-line\n execute = async (ctx: Context, args: Args) => {\n await ctx.reply(\'42\')\n };\n}\n')),(0,r.kt)("admonition",{type:"caution"},(0,r.kt)("p",{parentName:"admonition"},"execute must not be a method of the class. It should be as above, a property on the class!")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="commands/guildMemberAdd.ts"',title:'"commands/guildMemberAdd.ts"'},"import { CommandType, EventExecutable, type EventType } from \"@sern/handler\";\nimport type { GuildMember } from 'discord.js'\nexport default class extends EventExecutable {\n\n type = EventType.Discord as const;\n // highlight-next-line\n execute = (member: GuildMember) => {\n console.log(member)\n };\n}\n")),(0,r.kt)("p",null,"Now, you might ask ",(0,r.kt)("strong",{parentName:"p"},"why")," this feature was added. ",(0,r.kt)("br",null)," Simply put, to give flexibility to the developers.\nI believe that you should build your own structures however you might like and customize to your liking.\nIn addition, ",(0,r.kt)("strong",{parentName:"p"},"decorators now unofficially work with modules!"),"\nFeel free to use TypeScript experimental decorators to augment and customize your classes. "),(0,r.kt)("h3",{id:"deprecation-warnings"},"Deprecation Warnings"),(0,r.kt)("p",null,"The next update will bring sern v2 with some important features. Here are some things to watch out for."),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#client")," will be deprecated"),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#sernEmitter")," will be deprecated",(0,r.kt)("ul",{parentName:"li"},(0,r.kt)("li",{parentName:"ul"},"a SernEmitter will be automatically created once Sern#init is called"))),(0,r.kt)("li",{parentName:"ul"},"The option to pass in a function or array for ",(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#events")," will be deprecated. Only strings are accepted."),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/classes/SernEmitter"},"Sern#addExternal")," will be deprecated in favor of a better way.")),(0,r.kt)("h3",{id:"dependencies-update"},"Dependencies Update"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},"TypeScript has been updated to 4.8.3"),(0,r.kt)("li",{parentName:"ul"},"Discord.js has been upgraded to 14.5")))}d.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[7223],{3905:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>m});var a=n(7294);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var i=a.createContext({}),p=function(e){var t=a.useContext(i),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},c=function(e){var t=p(e.components);return a.createElement(i.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},u=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,l=e.originalType,i=e.parentName,c=s(e,["components","mdxType","originalType","parentName"]),u=p(n),m=r,b=u["".concat(i,".").concat(m)]||u[m]||d[m]||l;return n?a.createElement(b,o(o({ref:t},c),{},{components:n})):a.createElement(b,o({ref:t},c))}));function m(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var l=n.length,o=new Array(l);o[0]=u;var s={};for(var i in t)hasOwnProperty.call(t,i)&&(s[i]=t[i]);s.originalType=e,s.mdxType="string"==typeof e?e:r,o[1]=s;for(var p=2;p{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>o,default:()=>d,frontMatter:()=>l,metadata:()=>s,toc:()=>p});var a=n(7462),r=(n(7294),n(3905));const l={slug:"1.2.0",title:"Release 1.2.0",authors:["jacoobes"],tags:["release"]},o=void 0,s={permalink:"/tr/blog/1.2.0",editUrl:"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/blog/2022-09-28-mdx-blog-post.md",source:"@site/blog/2022-09-28-mdx-blog-post.md",title:"Release 1.2.0",description:"Class-based modules",date:"2022-09-28T00:00:00.000Z",formattedDate:"28 Eyl\xfcl 2022",tags:[{label:"release",permalink:"/tr/blog/tags/release"}],readingTime:1.71,hasTruncateMarker:!1,authors:[{name:"jacoobes",title:"Head Dev",url:"https://github.com/jacoobes",imageURL:"https://github.com/jacoobes.png",key:"jacoobes"}],frontMatter:{slug:"1.2.0",title:"Release 1.2.0",authors:["jacoobes"],tags:["release"]}},i={authorsImageUrls:[void 0]},p=[{value:"Class-based modules",id:"class-based-modules",level:2},{value:"Class based modules",id:"class-based-modules-1",level:3},{value:"Deprecation Warnings",id:"deprecation-warnings",level:3},{value:"Dependencies Update",id:"dependencies-update",level:3}],c={toc:p};function d(e){let{components:t,...n}=e;return(0,r.kt)("wrapper",(0,a.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("h2",{id:"class-based-modules"},"Class-based modules"),(0,r.kt)("p",null,"Today we're announcing the ability to create class based modules!\nTo get started, install"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre"},"npm install @sern/handler@latest\n")),(0,r.kt)("p",null,"Quick List of changes!"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#class-based-modules"},"Class based modules")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#deprecation-warnings"},"Deprecation Warnings")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#dependencies-update"},"Dependencies update"))),(0,r.kt)("h3",{id:"class-based-modules-1"},"Class based modules"),(0,r.kt)("p",null,"Incorporate class based modules into your project instead of the traditional ",(0,r.kt)("inlineCode",{parentName:"p"},"commandModule")," or ",(0,r.kt)("inlineCode",{parentName:"p"},"eventModule"),"\nExtend the new ",(0,r.kt)("a",{parentName:"p",href:"docs/api/classes/CommandExecutable"},"CommandExecutable")," or ",(0,r.kt)("a",{parentName:"p",href:"docs/api/classes/EventExecutable"},"EventExecutable")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="commands/meaning-of-life.ts"',title:'"commands/meaning-of-life.ts"'},"import { CommandType, CommandExecutable, type Args, type Context } from '@sern/handler';\nimport { publish } from '../plugins/publish.js';\nimport { serendipityOnly } from '../plugins/serendipityOnly.js';\n\nexport default class extends CommandExecutable {\n type = CommandType.Both as const;\n description = 'What is the meaning of life?'\n override onEvent = [\n serendipityOnly()\n ];\n override plugins = [\n publish(),\n ];\n // highlight-next-line\n execute = async (ctx: Context, args: Args) => {\n await ctx.reply('42')\n };\n}\n")),(0,r.kt)("admonition",{type:"caution"},(0,r.kt)("p",{parentName:"admonition"},"execute must not be a method of the class. It should be as above, a property on the class!")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="events/guildMemberAdd.ts"',title:'"events/guildMemberAdd.ts"'},"import { CommandType, EventExecutable, type EventType } from '@sern/handler';\nimport type { GuildMember } from 'discord.js'\n\nexport default class extends EventExecutable {\n type = EventType.Discord as const;\n // highlight-next-line\n execute = (member: GuildMember) => {\n console.log(member)\n };\n}\n")),(0,r.kt)("p",null,"Now, you might ask ",(0,r.kt)("strong",{parentName:"p"},"why")," this feature was added. ",(0,r.kt)("br",null)," Simply put, to give flexibility to the developers.\nI believe that you should build your own structures however you might like and customize to your liking.\nIn addition, ",(0,r.kt)("strong",{parentName:"p"},"decorators now unofficially work with modules!"),"\nFeel free to use TypeScript experimental decorators to augment and customize your classes. "),(0,r.kt)("h3",{id:"deprecation-warnings"},"Deprecation Warnings"),(0,r.kt)("p",null,"The next update will bring sern v2 with some important features. Here are some things to watch out for."),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#client")," will be deprecated"),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#sernEmitter")," will be deprecated",(0,r.kt)("ul",{parentName:"li"},(0,r.kt)("li",{parentName:"ul"},"a SernEmitter will be automatically created once Sern#init is called"))),(0,r.kt)("li",{parentName:"ul"},"The option to pass in a function or array for ",(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#events")," will be deprecated. Only strings are accepted."),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/classes/SernEmitter"},"Sern#addExternal")," will be deprecated in favor of a better way.")),(0,r.kt)("h3",{id:"dependencies-update"},"Dependencies Update"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},"TypeScript has been updated to 4.8.3"),(0,r.kt)("li",{parentName:"ul"},"Discord.js has been upgraded to 14.5")))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/tr/assets/js/6ba1d2c1.f920bd91.js b/tr/assets/js/6ba1d2c1.a66bb18b.js similarity index 61% rename from tr/assets/js/6ba1d2c1.f920bd91.js rename to tr/assets/js/6ba1d2c1.a66bb18b.js index e3b13f475..93d4132e7 100644 --- a/tr/assets/js/6ba1d2c1.f920bd91.js +++ b/tr/assets/js/6ba1d2c1.a66bb18b.js @@ -1 +1 @@ -"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[7374],{3905:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>m});var a=n(7294);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var i=a.createContext({}),p=function(e){var t=a.useContext(i),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},c=function(e){var t=p(e.components);return a.createElement(i.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},u=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,l=e.originalType,i=e.parentName,c=s(e,["components","mdxType","originalType","parentName"]),u=p(n),m=r,b=u["".concat(i,".").concat(m)]||u[m]||d[m]||l;return n?a.createElement(b,o(o({ref:t},c),{},{components:n})):a.createElement(b,o({ref:t},c))}));function m(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var l=n.length,o=new Array(l);o[0]=u;var s={};for(var i in t)hasOwnProperty.call(t,i)&&(s[i]=t[i]);s.originalType=e,s.mdxType="string"==typeof e?e:r,o[1]=s;for(var p=2;p{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>o,default:()=>d,frontMatter:()=>l,metadata:()=>s,toc:()=>p});var a=n(7462),r=(n(7294),n(3905));const l={slug:"1.2.0",title:"Release 1.2.0",authors:["jacoobes"],tags:["release"]},o=void 0,s={permalink:"/tr/blog/1.2.0",editUrl:"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/blog/2022-09-28-mdx-blog-post.md",source:"@site/blog/2022-09-28-mdx-blog-post.md",title:"Release 1.2.0",description:"Class-based modules",date:"2022-09-28T00:00:00.000Z",formattedDate:"28 Eyl\xfcl 2022",tags:[{label:"release",permalink:"/tr/blog/tags/release"}],readingTime:1.71,hasTruncateMarker:!1,authors:[{name:"jacoobes",title:"Head Dev",url:"https://github.com/jacoobes",imageURL:"https://github.com/jacoobes.png",key:"jacoobes"}],frontMatter:{slug:"1.2.0",title:"Release 1.2.0",authors:["jacoobes"],tags:["release"]}},i={authorsImageUrls:[void 0]},p=[{value:"Class-based modules",id:"class-based-modules",level:2},{value:"Class based modules",id:"class-based-modules-1",level:3},{value:"Deprecation Warnings",id:"deprecation-warnings",level:3},{value:"Dependencies Update",id:"dependencies-update",level:3}],c={toc:p};function d(e){let{components:t,...n}=e;return(0,r.kt)("wrapper",(0,a.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("h2",{id:"class-based-modules"},"Class-based modules"),(0,r.kt)("p",null,"Today we're announcing the ability to create class based modules!\nTo get started, install"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre"},"npm install @sern/handler@latest\n")),(0,r.kt)("p",null,"Quick List of changes!"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#class-based-modules"},"Class based modules")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#deprecation-warnings"},"Deprecation Warnings")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#dependencies-update"},"Dependencies update"))),(0,r.kt)("h3",{id:"class-based-modules-1"},"Class based modules"),(0,r.kt)("p",null,"Incorporate class based modules into your project instead of the traditional ",(0,r.kt)("inlineCode",{parentName:"p"},"commandModule")," or ",(0,r.kt)("inlineCode",{parentName:"p"},"eventModule"),"\nExtend the new ",(0,r.kt)("a",{parentName:"p",href:"docs/api/classes/CommandExecutable"},"CommandExecutable")," or ",(0,r.kt)("a",{parentName:"p",href:"docs/api/classes/EventExecutable"},"EventExecutable")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="commands/meaning-of-life.ts"',title:'"commands/meaning-of-life.ts"'},'import { CommandType, CommandExecutable, type Args, type Context } from "@sern/handler";\nimport { publish } from "../plugins/publish.js";\nimport { serendipityOnly } from "../plugins/serendipityOnly.js";\n\nexport default class extends CommandExecutable {\n\n type = CommandType.Both as const;\n description = \'What is the meaning of life?\'\n override onEvent = [\n serendipityOnly()\n ];\n override plugins = [\n publish(),\n ];\n // highlight-next-line\n execute = async (ctx: Context, args: Args) => {\n await ctx.reply(\'42\')\n };\n}\n')),(0,r.kt)("admonition",{type:"caution"},(0,r.kt)("p",{parentName:"admonition"},"execute must not be a method of the class. It should be as above, a property on the class!")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="commands/guildMemberAdd.ts"',title:'"commands/guildMemberAdd.ts"'},"import { CommandType, EventExecutable, type EventType } from \"@sern/handler\";\nimport type { GuildMember } from 'discord.js'\nexport default class extends EventExecutable {\n\n type = EventType.Discord as const;\n // highlight-next-line\n execute = (member: GuildMember) => {\n console.log(member)\n };\n}\n")),(0,r.kt)("p",null,"Now, you might ask ",(0,r.kt)("strong",{parentName:"p"},"why")," this feature was added. ",(0,r.kt)("br",null)," Simply put, to give flexibility to the developers.\nI believe that you should build your own structures however you might like and customize to your liking.\nIn addition, ",(0,r.kt)("strong",{parentName:"p"},"decorators now unofficially work with modules!"),"\nFeel free to use TypeScript experimental decorators to augment and customize your classes. "),(0,r.kt)("h3",{id:"deprecation-warnings"},"Deprecation Warnings"),(0,r.kt)("p",null,"The next update will bring sern v2 with some important features. Here are some things to watch out for."),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#client")," will be deprecated"),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#sernEmitter")," will be deprecated",(0,r.kt)("ul",{parentName:"li"},(0,r.kt)("li",{parentName:"ul"},"a SernEmitter will be automatically created once Sern#init is called"))),(0,r.kt)("li",{parentName:"ul"},"The option to pass in a function or array for ",(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#events")," will be deprecated. Only strings are accepted."),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/classes/SernEmitter"},"Sern#addExternal")," will be deprecated in favor of a better way.")),(0,r.kt)("h3",{id:"dependencies-update"},"Dependencies Update"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},"TypeScript has been updated to 4.8.3"),(0,r.kt)("li",{parentName:"ul"},"Discord.js has been upgraded to 14.5")))}d.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[7374],{3905:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>m});var a=n(7294);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var i=a.createContext({}),p=function(e){var t=a.useContext(i),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},c=function(e){var t=p(e.components);return a.createElement(i.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},u=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,l=e.originalType,i=e.parentName,c=s(e,["components","mdxType","originalType","parentName"]),u=p(n),m=r,b=u["".concat(i,".").concat(m)]||u[m]||d[m]||l;return n?a.createElement(b,o(o({ref:t},c),{},{components:n})):a.createElement(b,o({ref:t},c))}));function m(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var l=n.length,o=new Array(l);o[0]=u;var s={};for(var i in t)hasOwnProperty.call(t,i)&&(s[i]=t[i]);s.originalType=e,s.mdxType="string"==typeof e?e:r,o[1]=s;for(var p=2;p{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>o,default:()=>d,frontMatter:()=>l,metadata:()=>s,toc:()=>p});var a=n(7462),r=(n(7294),n(3905));const l={slug:"1.2.0",title:"Release 1.2.0",authors:["jacoobes"],tags:["release"]},o=void 0,s={permalink:"/tr/blog/1.2.0",editUrl:"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/blog/2022-09-28-mdx-blog-post.md",source:"@site/blog/2022-09-28-mdx-blog-post.md",title:"Release 1.2.0",description:"Class-based modules",date:"2022-09-28T00:00:00.000Z",formattedDate:"28 Eyl\xfcl 2022",tags:[{label:"release",permalink:"/tr/blog/tags/release"}],readingTime:1.71,hasTruncateMarker:!1,authors:[{name:"jacoobes",title:"Head Dev",url:"https://github.com/jacoobes",imageURL:"https://github.com/jacoobes.png",key:"jacoobes"}],frontMatter:{slug:"1.2.0",title:"Release 1.2.0",authors:["jacoobes"],tags:["release"]}},i={authorsImageUrls:[void 0]},p=[{value:"Class-based modules",id:"class-based-modules",level:2},{value:"Class based modules",id:"class-based-modules-1",level:3},{value:"Deprecation Warnings",id:"deprecation-warnings",level:3},{value:"Dependencies Update",id:"dependencies-update",level:3}],c={toc:p};function d(e){let{components:t,...n}=e;return(0,r.kt)("wrapper",(0,a.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("h2",{id:"class-based-modules"},"Class-based modules"),(0,r.kt)("p",null,"Today we're announcing the ability to create class based modules!\nTo get started, install"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre"},"npm install @sern/handler@latest\n")),(0,r.kt)("p",null,"Quick List of changes!"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#class-based-modules"},"Class based modules")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#deprecation-warnings"},"Deprecation Warnings")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"#dependencies-update"},"Dependencies update"))),(0,r.kt)("h3",{id:"class-based-modules-1"},"Class based modules"),(0,r.kt)("p",null,"Incorporate class based modules into your project instead of the traditional ",(0,r.kt)("inlineCode",{parentName:"p"},"commandModule")," or ",(0,r.kt)("inlineCode",{parentName:"p"},"eventModule"),"\nExtend the new ",(0,r.kt)("a",{parentName:"p",href:"docs/api/classes/CommandExecutable"},"CommandExecutable")," or ",(0,r.kt)("a",{parentName:"p",href:"docs/api/classes/EventExecutable"},"EventExecutable")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="commands/meaning-of-life.ts"',title:'"commands/meaning-of-life.ts"'},"import { CommandType, CommandExecutable, type Args, type Context } from '@sern/handler';\nimport { publish } from '../plugins/publish.js';\nimport { serendipityOnly } from '../plugins/serendipityOnly.js';\n\nexport default class extends CommandExecutable {\n type = CommandType.Both as const;\n description = 'What is the meaning of life?'\n override onEvent = [\n serendipityOnly()\n ];\n override plugins = [\n publish(),\n ];\n // highlight-next-line\n execute = async (ctx: Context, args: Args) => {\n await ctx.reply('42')\n };\n}\n")),(0,r.kt)("admonition",{type:"caution"},(0,r.kt)("p",{parentName:"admonition"},"execute must not be a method of the class. It should be as above, a property on the class!")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="events/guildMemberAdd.ts"',title:'"events/guildMemberAdd.ts"'},"import { CommandType, EventExecutable, type EventType } from '@sern/handler';\nimport type { GuildMember } from 'discord.js'\n\nexport default class extends EventExecutable {\n type = EventType.Discord as const;\n // highlight-next-line\n execute = (member: GuildMember) => {\n console.log(member)\n };\n}\n")),(0,r.kt)("p",null,"Now, you might ask ",(0,r.kt)("strong",{parentName:"p"},"why")," this feature was added. ",(0,r.kt)("br",null)," Simply put, to give flexibility to the developers.\nI believe that you should build your own structures however you might like and customize to your liking.\nIn addition, ",(0,r.kt)("strong",{parentName:"p"},"decorators now unofficially work with modules!"),"\nFeel free to use TypeScript experimental decorators to augment and customize your classes. "),(0,r.kt)("h3",{id:"deprecation-warnings"},"Deprecation Warnings"),(0,r.kt)("p",null,"The next update will bring sern v2 with some important features. Here are some things to watch out for."),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#client")," will be deprecated"),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#sernEmitter")," will be deprecated",(0,r.kt)("ul",{parentName:"li"},(0,r.kt)("li",{parentName:"ul"},"a SernEmitter will be automatically created once Sern#init is called"))),(0,r.kt)("li",{parentName:"ul"},"The option to pass in a function or array for ",(0,r.kt)("a",{parentName:"li",href:"docs/api/interfaces/Wrapper"},"Wrapper#events")," will be deprecated. Only strings are accepted."),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"docs/api/classes/SernEmitter"},"Sern#addExternal")," will be deprecated in favor of a better way.")),(0,r.kt)("h3",{id:"dependencies-update"},"Dependencies Update"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},"TypeScript has been updated to 4.8.3"),(0,r.kt)("li",{parentName:"ul"},"Discord.js has been upgraded to 14.5")))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/tr/assets/js/c103c7fb.30b3a2fa.js b/tr/assets/js/c103c7fb.30b3a2fa.js new file mode 100644 index 000000000..875effc0c --- /dev/null +++ b/tr/assets/js/c103c7fb.30b3a2fa.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[4918],{210:e=>{e.exports=JSON.parse('{"blogPosts":[{"id":"1.2.0","metadata":{"permalink":"/tr/blog/1.2.0","editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/blog/2022-09-28-mdx-blog-post.md","source":"@site/blog/2022-09-28-mdx-blog-post.md","title":"Release 1.2.0","description":"Class-based modules","date":"2022-09-28T00:00:00.000Z","formattedDate":"28 Eyl\xfcl 2022","tags":[{"label":"release","permalink":"/tr/blog/tags/release"}],"readingTime":1.71,"hasTruncateMarker":false,"authors":[{"name":"jacoobes","title":"Head Dev","url":"https://github.com/jacoobes","imageURL":"https://github.com/jacoobes.png","key":"jacoobes"}],"frontMatter":{"slug":"1.2.0","title":"Release 1.2.0","authors":["jacoobes"],"tags":["release"]}},"content":"## Class-based modules\\n\\nToday we\'re announcing the ability to create class based modules!\\nTo get started, install\\n```\\nnpm install @sern/handler@latest\\n```\\n\\nQuick List of changes!\\n- [Class based modules](#class-based-modules)\\n- [Deprecation Warnings](#deprecation-warnings)\\n- [Dependencies update](#dependencies-update)\\n\\n\\n### Class based modules\\nIncorporate class based modules into your project instead of the traditional `commandModule` or `eventModule`\\nExtend the new [CommandExecutable](docs/api/classes/CommandExecutable) or [EventExecutable](docs/api/classes/EventExecutable)\\n```ts title=\\"commands/meaning-of-life.ts\\"\\nimport { CommandType, CommandExecutable, type Args, type Context } from \'@sern/handler\';\\nimport { publish } from \'../plugins/publish.js\';\\nimport { serendipityOnly } from \'../plugins/serendipityOnly.js\';\\n\\nexport default class extends CommandExecutable {\\n type = CommandType.Both as const;\\n description = \'What is the meaning of life?\'\\n override onEvent = [\\n serendipityOnly()\\n ];\\n override plugins = [\\n publish(),\\n ];\\n // highlight-next-line\\n execute = async (ctx: Context, args: Args) => {\\n await ctx.reply(\'42\')\\n };\\n}\\n```\\n:::caution\\n\\nexecute must not be a method of the class. It should be as above, a property on the class!\\n\\n:::\\n\\n```ts title=\\"events/guildMemberAdd.ts\\"\\nimport { CommandType, EventExecutable, type EventType } from \'@sern/handler\';\\nimport type { GuildMember } from \'discord.js\'\\n\\nexport default class extends EventExecutable {\\n type = EventType.Discord as const;\\n // highlight-next-line\\n execute = (member: GuildMember) => {\\n console.log(member)\\n };\\n}\\n```\\nNow, you might ask **why** this feature was added.
Simply put, to give flexibility to the developers.\\nI believe that you should build your own structures however you might like and customize to your liking.\\nIn addition, **decorators now unofficially work with modules!**\\nFeel free to use TypeScript experimental decorators to augment and customize your classes. \\n\\n### Deprecation Warnings\\nThe next update will bring sern v2 with some important features. Here are some things to watch out for.\\n\\n- [Wrapper#client](docs/api/interfaces/Wrapper) will be deprecated\\n- [Wrapper#sernEmitter](docs/api/interfaces/Wrapper) will be deprecated\\n - a SernEmitter will be automatically created once Sern#init is called\\n- The option to pass in a function or array for [Wrapper#events](docs/api/interfaces/Wrapper) will be deprecated. Only strings are accepted.\\n- [Sern#addExternal](docs/api/classes/SernEmitter) will be deprecated in favor of a better way.\\n\\n### Dependencies Update\\n- TypeScript has been updated to 4.8.3\\n- Discord.js has been upgraded to 14.5"}]}')}}]); \ No newline at end of file diff --git a/tr/assets/js/c103c7fb.8692c87f.js b/tr/assets/js/c103c7fb.8692c87f.js deleted file mode 100644 index 1e41ae2c9..000000000 --- a/tr/assets/js/c103c7fb.8692c87f.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunk_sern_website=self.webpackChunk_sern_website||[]).push([[4918],{210:e=>{e.exports=JSON.parse('{"blogPosts":[{"id":"1.2.0","metadata":{"permalink":"/tr/blog/1.2.0","editUrl":"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/blog/2022-09-28-mdx-blog-post.md","source":"@site/blog/2022-09-28-mdx-blog-post.md","title":"Release 1.2.0","description":"Class-based modules","date":"2022-09-28T00:00:00.000Z","formattedDate":"28 Eyl\xfcl 2022","tags":[{"label":"release","permalink":"/tr/blog/tags/release"}],"readingTime":1.71,"hasTruncateMarker":false,"authors":[{"name":"jacoobes","title":"Head Dev","url":"https://github.com/jacoobes","imageURL":"https://github.com/jacoobes.png","key":"jacoobes"}],"frontMatter":{"slug":"1.2.0","title":"Release 1.2.0","authors":["jacoobes"],"tags":["release"]}},"content":"## Class-based modules\\n\\nToday we\'re announcing the ability to create class based modules!\\nTo get started, install\\n```\\nnpm install @sern/handler@latest\\n```\\n\\nQuick List of changes!\\n- [Class based modules](#class-based-modules)\\n- [Deprecation Warnings](#deprecation-warnings)\\n- [Dependencies update](#dependencies-update)\\n\\n\\n\\n### Class based modules\\nIncorporate class based modules into your project instead of the traditional `commandModule` or `eventModule`\\nExtend the new [CommandExecutable](docs/api/classes/CommandExecutable) or [EventExecutable](docs/api/classes/EventExecutable)\\n```ts title=\\"commands/meaning-of-life.ts\\"\\nimport { CommandType, CommandExecutable, type Args, type Context } from \\"@sern/handler\\";\\nimport { publish } from \\"../plugins/publish.js\\";\\nimport { serendipityOnly } from \\"../plugins/serendipityOnly.js\\";\\n\\nexport default class extends CommandExecutable {\\n\\n type = CommandType.Both as const;\\n description = \'What is the meaning of life?\'\\n override onEvent = [\\n serendipityOnly()\\n ];\\n override plugins = [\\n publish(),\\n ];\\n // highlight-next-line\\n execute = async (ctx: Context, args: Args) => {\\n await ctx.reply(\'42\')\\n };\\n}\\n```\\n:::caution\\n\\nexecute must not be a method of the class. It should be as above, a property on the class!\\n\\n:::\\n\\n```ts title=\\"commands/guildMemberAdd.ts\\"\\nimport { CommandType, EventExecutable, type EventType } from \\"@sern/handler\\";\\nimport type { GuildMember } from \'discord.js\'\\nexport default class extends EventExecutable {\\n\\n type = EventType.Discord as const;\\n // highlight-next-line\\n execute = (member: GuildMember) => {\\n console.log(member)\\n };\\n}\\n```\\nNow, you might ask **why** this feature was added.
Simply put, to give flexibility to the developers.\\nI believe that you should build your own structures however you might like and customize to your liking.\\nIn addition, **decorators now unofficially work with modules!**\\nFeel free to use TypeScript experimental decorators to augment and customize your classes. \\n\\n### Deprecation Warnings\\nThe next update will bring sern v2 with some important features. Here are some things to watch out for.\\n\\n- [Wrapper#client](docs/api/interfaces/Wrapper) will be deprecated\\n- [Wrapper#sernEmitter](docs/api/interfaces/Wrapper) will be deprecated\\n - a SernEmitter will be automatically created once Sern#init is called\\n- The option to pass in a function or array for [Wrapper#events](docs/api/interfaces/Wrapper) will be deprecated. Only strings are accepted.\\n- [Sern#addExternal](docs/api/classes/SernEmitter) will be deprecated in favor of a better way.\\n\\n### Dependencies Update\\n- TypeScript has been updated to 4.8.3\\n- Discord.js has been upgraded to 14.5"}]}')}}]); \ No newline at end of file diff --git a/tr/assets/js/runtime~main.9f609f77.js b/tr/assets/js/runtime~main.93354cdc.js similarity index 54% rename from tr/assets/js/runtime~main.9f609f77.js rename to tr/assets/js/runtime~main.93354cdc.js index b7a3b3178..5f012665e 100644 --- a/tr/assets/js/runtime~main.9f609f77.js +++ b/tr/assets/js/runtime~main.93354cdc.js @@ -1 +1 @@ -(()=>{"use strict";var e,a,c,t,f,r={},b={};function d(e){var a=b[e];if(void 0!==a)return a.exports;var c=b[e]={id:e,loaded:!1,exports:{}};return r[e].call(c.exports,c,c.exports,d),c.loaded=!0,c.exports}d.m=r,d.c=b,e=[],d.O=(a,c,t,f)=>{if(!c){var r=1/0;for(i=0;i=f)&&Object.keys(d.O).every((e=>d.O[e](c[o])))?c.splice(o--,1):(b=!1,f0&&e[i-1][2]>f;i--)e[i]=e[i-1];e[i]=[c,t,f]},d.n=e=>{var a=e&&e.__esModule?()=>e.default:()=>e;return d.d(a,{a:a}),a},c=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,d.t=function(e,t){if(1&t&&(e=this(e)),8&t)return e;if("object"==typeof e&&e){if(4&t&&e.__esModule)return e;if(16&t&&"function"==typeof e.then)return e}var f=Object.create(null);d.r(f);var r={};a=a||[null,c({}),c([]),c(c)];for(var b=2&t&&e;"object"==typeof b&&!~a.indexOf(b);b=c(b))Object.getOwnPropertyNames(b).forEach((a=>r[a]=()=>e[a]));return r.default=()=>e,d.d(f,r),f},d.d=(e,a)=>{for(var c in a)d.o(a,c)&&!d.o(e,c)&&Object.defineProperty(e,c,{enumerable:!0,get:a[c]})},d.f={},d.e=e=>Promise.all(Object.keys(d.f).reduce(((a,c)=>(d.f[c](e,a),a)),[])),d.u=e=>"assets/js/"+({53:"5bc4ccbc",277:"c4348237",332:"73bd57bd",703:"981f6151",1036:"c0846785",1472:"cf183316",1505:"7c2ff145",2005:"1ac1bfe9",2197:"935f2afb",2535:"814f3328",2640:"a96c96b0",2792:"f50fe504",3045:"888566f1",3085:"1f391b9e",3089:"a6aa9e1f",3608:"9e4087bc",4013:"01a85c17",4137:"1aef51bd",4195:"c4f5d8e4",4332:"6c624b4c",4429:"eea0bf40",4803:"9201de17",4865:"e8e3d8c7",4901:"6e015ab1",4918:"c103c7fb",5062:"69369ae2",5397:"312c2bc5",6103:"ccc49370",6146:"608ca171",6270:"e4877132",6322:"a5467962",7127:"7e205c4a",7223:"3020eeee",7306:"f6aebfbf",7363:"26f1f3a5",7374:"6ba1d2c1",7414:"393be207",7597:"5e8c322a",7705:"b40a3c0d",7750:"3a2d3092",7918:"17896441",8610:"6875c492",8652:"bcd9df7e",9226:"707baeff",9232:"afe88353",9514:"1be78505",9671:"0e384e19",9712:"3dc7c79a"}[e]||e)+"."+{53:"c8c690a8",277:"bbd90c09",332:"19c5dc11",703:"20818673",1036:"4d3fd746",1472:"6c579116",1505:"ac336ebd",2005:"32a59ffe",2197:"9d45ee3d",2529:"824aaa15",2535:"75a1ef51",2640:"6512f1aa",2792:"8f14c30e",3045:"cb4f8a25",3085:"8c38cce5",3089:"41e3be1f",3608:"66639242",4013:"e1f6e46d",4137:"aa912fa6",4195:"e4059570",4332:"1b6a4212",4429:"0dfecd80",4803:"a0a46979",4865:"3dbbffa5",4901:"f4e3c2ac",4918:"8692c87f",4972:"8f7e7193",5062:"40f3e7eb",5397:"1cae9e75",6103:"7974c41a",6146:"cd167ef6",6270:"4977513f",6322:"30bc4b53",7127:"9e935aed",7223:"c125a283",7306:"c5c73bc5",7363:"9ba0381e",7374:"f920bd91",7414:"28b43cb8",7540:"0456e07a",7597:"605e80f2",7705:"444c45e5",7750:"339afe92",7918:"3625818f",8610:"d7a7cd5d",8652:"78b2f6c4",9226:"06466012",9232:"d8cb82df",9514:"b1e810d5",9671:"f23753e7",9712:"94c26952"}[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,a)=>Object.prototype.hasOwnProperty.call(e,a),t={},f="@sern/website:",d.l=(e,a,c,r)=>{if(t[e])t[e].push(a);else{var b,o;if(void 0!==c)for(var n=document.getElementsByTagName("script"),i=0;i{b.onerror=b.onload=null,clearTimeout(s);var f=t[e];if(delete t[e],b.parentNode&&b.parentNode.removeChild(b),f&&f.forEach((e=>e(c))),a)return a(c)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:b}),12e4);b.onerror=l.bind(null,b.onerror),b.onload=l.bind(null,b.onload),o&&document.head.appendChild(b)}},d.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},d.p="/tr/",d.gca=function(e){return e={17896441:"7918","5bc4ccbc":"53",c4348237:"277","73bd57bd":"332","981f6151":"703",c0846785:"1036",cf183316:"1472","7c2ff145":"1505","1ac1bfe9":"2005","935f2afb":"2197","814f3328":"2535",a96c96b0:"2640",f50fe504:"2792","888566f1":"3045","1f391b9e":"3085",a6aa9e1f:"3089","9e4087bc":"3608","01a85c17":"4013","1aef51bd":"4137",c4f5d8e4:"4195","6c624b4c":"4332",eea0bf40:"4429","9201de17":"4803",e8e3d8c7:"4865","6e015ab1":"4901",c103c7fb:"4918","69369ae2":"5062","312c2bc5":"5397",ccc49370:"6103","608ca171":"6146",e4877132:"6270",a5467962:"6322","7e205c4a":"7127","3020eeee":"7223",f6aebfbf:"7306","26f1f3a5":"7363","6ba1d2c1":"7374","393be207":"7414","5e8c322a":"7597",b40a3c0d:"7705","3a2d3092":"7750","6875c492":"8610",bcd9df7e:"8652","707baeff":"9226",afe88353:"9232","1be78505":"9514","0e384e19":"9671","3dc7c79a":"9712"}[e]||e,d.p+d.u(e)},(()=>{var e={1303:0,532:0};d.f.j=(a,c)=>{var t=d.o(e,a)?e[a]:void 0;if(0!==t)if(t)c.push(t[2]);else if(/^(1303|532)$/.test(a))e[a]=0;else{var f=new Promise(((c,f)=>t=e[a]=[c,f]));c.push(t[2]=f);var r=d.p+d.u(a),b=new Error;d.l(r,(c=>{if(d.o(e,a)&&(0!==(t=e[a])&&(e[a]=void 0),t)){var f=c&&("load"===c.type?"missing":c.type),r=c&&c.target&&c.target.src;b.message="Loading chunk "+a+" failed.\n("+f+": "+r+")",b.name="ChunkLoadError",b.type=f,b.request=r,t[1](b)}}),"chunk-"+a,a)}},d.O.j=a=>0===e[a];var a=(a,c)=>{var t,f,r=c[0],b=c[1],o=c[2],n=0;if(r.some((a=>0!==e[a]))){for(t in b)d.o(b,t)&&(d.m[t]=b[t]);if(o)var i=o(d)}for(a&&a(c);n{"use strict";var e,c,a,t,f,r={},b={};function d(e){var c=b[e];if(void 0!==c)return c.exports;var a=b[e]={id:e,loaded:!1,exports:{}};return r[e].call(a.exports,a,a.exports,d),a.loaded=!0,a.exports}d.m=r,d.c=b,e=[],d.O=(c,a,t,f)=>{if(!a){var r=1/0;for(i=0;i=f)&&Object.keys(d.O).every((e=>d.O[e](a[o])))?a.splice(o--,1):(b=!1,f0&&e[i-1][2]>f;i--)e[i]=e[i-1];e[i]=[a,t,f]},d.n=e=>{var c=e&&e.__esModule?()=>e.default:()=>e;return d.d(c,{a:c}),c},a=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,d.t=function(e,t){if(1&t&&(e=this(e)),8&t)return e;if("object"==typeof e&&e){if(4&t&&e.__esModule)return e;if(16&t&&"function"==typeof e.then)return e}var f=Object.create(null);d.r(f);var r={};c=c||[null,a({}),a([]),a(a)];for(var b=2&t&&e;"object"==typeof b&&!~c.indexOf(b);b=a(b))Object.getOwnPropertyNames(b).forEach((c=>r[c]=()=>e[c]));return r.default=()=>e,d.d(f,r),f},d.d=(e,c)=>{for(var a in c)d.o(c,a)&&!d.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:c[a]})},d.f={},d.e=e=>Promise.all(Object.keys(d.f).reduce(((c,a)=>(d.f[a](e,c),c)),[])),d.u=e=>"assets/js/"+({53:"5bc4ccbc",277:"c4348237",332:"73bd57bd",703:"981f6151",1036:"c0846785",1472:"cf183316",1505:"7c2ff145",2005:"1ac1bfe9",2197:"935f2afb",2535:"814f3328",2640:"a96c96b0",2792:"f50fe504",3045:"888566f1",3085:"1f391b9e",3089:"a6aa9e1f",3608:"9e4087bc",4013:"01a85c17",4137:"1aef51bd",4195:"c4f5d8e4",4332:"6c624b4c",4429:"eea0bf40",4803:"9201de17",4865:"e8e3d8c7",4901:"6e015ab1",4918:"c103c7fb",5062:"69369ae2",5397:"312c2bc5",6103:"ccc49370",6146:"608ca171",6270:"e4877132",6322:"a5467962",7127:"7e205c4a",7223:"3020eeee",7306:"f6aebfbf",7363:"26f1f3a5",7374:"6ba1d2c1",7414:"393be207",7597:"5e8c322a",7705:"b40a3c0d",7750:"3a2d3092",7918:"17896441",8610:"6875c492",8652:"bcd9df7e",9226:"707baeff",9232:"afe88353",9514:"1be78505",9671:"0e384e19",9712:"3dc7c79a"}[e]||e)+"."+{53:"c8c690a8",277:"bbd90c09",332:"19c5dc11",703:"20818673",1036:"4d3fd746",1472:"6c579116",1505:"ac336ebd",2005:"32a59ffe",2197:"9d45ee3d",2529:"824aaa15",2535:"75a1ef51",2640:"6512f1aa",2792:"8f14c30e",3045:"cb4f8a25",3085:"8c38cce5",3089:"41e3be1f",3608:"66639242",4013:"e1f6e46d",4137:"aa912fa6",4195:"e4059570",4332:"1b6a4212",4429:"0dfecd80",4803:"a0a46979",4865:"3dbbffa5",4901:"f4e3c2ac",4918:"30b3a2fa",4972:"8f7e7193",5062:"40f3e7eb",5397:"1cae9e75",6103:"7974c41a",6146:"cd167ef6",6270:"4977513f",6322:"30bc4b53",7127:"9e935aed",7223:"79954e26",7306:"c5c73bc5",7363:"9ba0381e",7374:"a66bb18b",7414:"28b43cb8",7540:"0456e07a",7597:"605e80f2",7705:"444c45e5",7750:"339afe92",7918:"3625818f",8610:"d7a7cd5d",8652:"78b2f6c4",9226:"06466012",9232:"d8cb82df",9514:"b1e810d5",9671:"f23753e7",9712:"94c26952"}[e]+".js",d.miniCssF=e=>{},d.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),d.o=(e,c)=>Object.prototype.hasOwnProperty.call(e,c),t={},f="@sern/website:",d.l=(e,c,a,r)=>{if(t[e])t[e].push(c);else{var b,o;if(void 0!==a)for(var n=document.getElementsByTagName("script"),i=0;i{b.onerror=b.onload=null,clearTimeout(s);var f=t[e];if(delete t[e],b.parentNode&&b.parentNode.removeChild(b),f&&f.forEach((e=>e(a))),c)return c(a)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:b}),12e4);b.onerror=l.bind(null,b.onerror),b.onload=l.bind(null,b.onload),o&&document.head.appendChild(b)}},d.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},d.p="/tr/",d.gca=function(e){return e={17896441:"7918","5bc4ccbc":"53",c4348237:"277","73bd57bd":"332","981f6151":"703",c0846785:"1036",cf183316:"1472","7c2ff145":"1505","1ac1bfe9":"2005","935f2afb":"2197","814f3328":"2535",a96c96b0:"2640",f50fe504:"2792","888566f1":"3045","1f391b9e":"3085",a6aa9e1f:"3089","9e4087bc":"3608","01a85c17":"4013","1aef51bd":"4137",c4f5d8e4:"4195","6c624b4c":"4332",eea0bf40:"4429","9201de17":"4803",e8e3d8c7:"4865","6e015ab1":"4901",c103c7fb:"4918","69369ae2":"5062","312c2bc5":"5397",ccc49370:"6103","608ca171":"6146",e4877132:"6270",a5467962:"6322","7e205c4a":"7127","3020eeee":"7223",f6aebfbf:"7306","26f1f3a5":"7363","6ba1d2c1":"7374","393be207":"7414","5e8c322a":"7597",b40a3c0d:"7705","3a2d3092":"7750","6875c492":"8610",bcd9df7e:"8652","707baeff":"9226",afe88353:"9232","1be78505":"9514","0e384e19":"9671","3dc7c79a":"9712"}[e]||e,d.p+d.u(e)},(()=>{var e={1303:0,532:0};d.f.j=(c,a)=>{var t=d.o(e,c)?e[c]:void 0;if(0!==t)if(t)a.push(t[2]);else if(/^(1303|532)$/.test(c))e[c]=0;else{var f=new Promise(((a,f)=>t=e[c]=[a,f]));a.push(t[2]=f);var r=d.p+d.u(c),b=new Error;d.l(r,(a=>{if(d.o(e,c)&&(0!==(t=e[c])&&(e[c]=void 0),t)){var f=a&&("load"===a.type?"missing":a.type),r=a&&a.target&&a.target.src;b.message="Loading chunk "+c+" failed.\n("+f+": "+r+")",b.name="ChunkLoadError",b.type=f,b.request=r,t[1](b)}}),"chunk-"+c,c)}},d.O.j=c=>0===e[c];var c=(c,a)=>{var t,f,r=a[0],b=a[1],o=a[2],n=0;if(r.some((c=>0!==e[c]))){for(t in b)d.o(b,t)&&(d.m[t]=b[t]);if(o)var i=o(d)}for(c&&c(a);n Blog | sern - Handlers. Redefined. - +

· 2 dakikalık okuma
jacoobes

Class-based modules

Today we're announcing the ability to create class based modules! To get started, install

npm install @sern/handler@latest

Quick List of changes!

Class based modules

Incorporate class based modules into your project instead of the traditional commandModule or eventModule -Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from "@sern/handler";
import { publish } from "../plugins/publish.js";
import { serendipityOnly } from "../plugins/serendipityOnly.js";

export default class extends CommandExecutable<CommandType.Both> {

type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
caution

execute must not be a method of the class. It should be as above, a property on the class!

commands/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from "@sern/handler";
import type { GuildMember } from 'discord.js'
export default class extends EventExecutable<EventType.Discord> {

type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. +Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from '@sern/handler';
import { publish } from '../plugins/publish.js';
import { serendipityOnly } from '../plugins/serendipityOnly.js';

export default class extends CommandExecutable<CommandType.Both> {
type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
caution

execute must not be a method of the class. It should be as above, a property on the class!

events/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from '@sern/handler';
import type { GuildMember } from 'discord.js'

export default class extends EventExecutable<EventType.Discord> {
type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. I believe that you should build your own structures however you might like and customize to your liking. In addition, decorators now unofficially work with modules! Feel free to use TypeScript experimental decorators to augment and customize your classes.

Deprecation Warnings

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

Dependencies Update

  • TypeScript has been updated to 4.8.3
  • Discord.js has been upgraded to 14.5
- + \ No newline at end of file diff --git a/tr/blog/1.2.0.html b/tr/blog/1.2.0.html index ced9efa83..1247b58c1 100644 --- a/tr/blog/1.2.0.html +++ b/tr/blog/1.2.0.html @@ -6,18 +6,18 @@ Release 1.2.0 | sern - Handlers. Redefined. - +

Release 1.2.0

· 2 dakikalık okuma
jacoobes

Class-based modules

Today we're announcing the ability to create class based modules! To get started, install

npm install @sern/handler@latest

Quick List of changes!

Class based modules

Incorporate class based modules into your project instead of the traditional commandModule or eventModule -Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from "@sern/handler";
import { publish } from "../plugins/publish.js";
import { serendipityOnly } from "../plugins/serendipityOnly.js";

export default class extends CommandExecutable<CommandType.Both> {

type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
caution

execute must not be a method of the class. It should be as above, a property on the class!

commands/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from "@sern/handler";
import type { GuildMember } from 'discord.js'
export default class extends EventExecutable<EventType.Discord> {

type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. +Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from '@sern/handler';
import { publish } from '../plugins/publish.js';
import { serendipityOnly } from '../plugins/serendipityOnly.js';

export default class extends CommandExecutable<CommandType.Both> {
type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
caution

execute must not be a method of the class. It should be as above, a property on the class!

events/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from '@sern/handler';
import type { GuildMember } from 'discord.js'

export default class extends EventExecutable<EventType.Discord> {
type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. I believe that you should build your own structures however you might like and customize to your liking. In addition, decorators now unofficially work with modules! Feel free to use TypeScript experimental decorators to augment and customize your classes.

Deprecation Warnings

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

Dependencies Update

  • TypeScript has been updated to 4.8.3
  • Discord.js has been upgraded to 14.5
- + \ No newline at end of file diff --git a/tr/blog/archive.html b/tr/blog/archive.html index 2357eabc9..3a19141b0 100644 --- a/tr/blog/archive.html +++ b/tr/blog/archive.html @@ -6,13 +6,13 @@ Arşiv | sern - Handlers. Redefined. - +
- + \ No newline at end of file diff --git a/tr/blog/atom.xml b/tr/blog/atom.xml index d69b3829f..14aea0ed5 100644 --- a/tr/blog/atom.xml +++ b/tr/blog/atom.xml @@ -15,7 +15,7 @@ Class-based modules

Today we're announcing the ability to create class based modules! To get started, install

npm install @sern/handler@latest

Quick List of changes!

Class based modules

Incorporate class based modules into your project instead of the traditional commandModule or eventModule -Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from "@sern/handler";
import { publish } from "../plugins/publish.js";
import { serendipityOnly } from "../plugins/serendipityOnly.js";

export default class extends CommandExecutable<CommandType.Both> {

type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
caution

execute must not be a method of the class. It should be as above, a property on the class!

commands/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from "@sern/handler";
import type { GuildMember } from 'discord.js'
export default class extends EventExecutable<EventType.Discord> {

type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. +Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from '@sern/handler';
import { publish } from '../plugins/publish.js';
import { serendipityOnly } from '../plugins/serendipityOnly.js';

export default class extends CommandExecutable<CommandType.Both> {
type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
caution

execute must not be a method of the class. It should be as above, a property on the class!

events/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from '@sern/handler';
import type { GuildMember } from 'discord.js'

export default class extends EventExecutable<EventType.Discord> {
type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. I believe that you should build your own structures however you might like and customize to your liking. In addition, decorators now unofficially work with modules! Feel free to use TypeScript experimental decorators to augment and customize your classes.

Deprecation Warnings

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

Dependencies Update

  • TypeScript has been updated to 4.8.3
  • Discord.js has been upgraded to 14.5
]]>
diff --git a/tr/blog/rss.xml b/tr/blog/rss.xml index e13d4c173..3d708e28a 100644 --- a/tr/blog/rss.xml +++ b/tr/blog/rss.xml @@ -16,7 +16,7 @@ Class-based modules

Today we're announcing the ability to create class based modules! To get started, install

npm install @sern/handler@latest

Quick List of changes!

Class based modules

Incorporate class based modules into your project instead of the traditional commandModule or eventModule -Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from "@sern/handler";
import { publish } from "../plugins/publish.js";
import { serendipityOnly } from "../plugins/serendipityOnly.js";

export default class extends CommandExecutable<CommandType.Both> {

type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
caution

execute must not be a method of the class. It should be as above, a property on the class!

commands/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from "@sern/handler";
import type { GuildMember } from 'discord.js'
export default class extends EventExecutable<EventType.Discord> {

type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. +Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from '@sern/handler';
import { publish } from '../plugins/publish.js';
import { serendipityOnly } from '../plugins/serendipityOnly.js';

export default class extends CommandExecutable<CommandType.Both> {
type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
caution

execute must not be a method of the class. It should be as above, a property on the class!

events/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from '@sern/handler';
import type { GuildMember } from 'discord.js'

export default class extends EventExecutable<EventType.Discord> {
type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. I believe that you should build your own structures however you might like and customize to your liking. In addition, decorators now unofficially work with modules! Feel free to use TypeScript experimental decorators to augment and customize your classes.

Deprecation Warnings

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

Dependencies Update

  • TypeScript has been updated to 4.8.3
  • Discord.js has been upgraded to 14.5
]]>
diff --git a/tr/blog/tags.html b/tr/blog/tags.html index 46be86055..44512a05b 100644 --- a/tr/blog/tags.html +++ b/tr/blog/tags.html @@ -6,13 +6,13 @@ Etiketler | sern - Handlers. Redefined. - +

Etiketler

- + \ No newline at end of file diff --git a/tr/blog/tags/release.html b/tr/blog/tags/release.html index d0ba31bf4..70a6d0d6f 100644 --- a/tr/blog/tags/release.html +++ b/tr/blog/tags/release.html @@ -6,18 +6,18 @@ "release" ile etiketlenmiş Bir gönderi | sern - Handlers. Redefined. - +

"release" ile etiketlenmiş Bir gönderi

Tüm Etiketleri Görüntüle

· 2 dakikalık okuma
jacoobes

Class-based modules

Today we're announcing the ability to create class based modules! To get started, install

npm install @sern/handler@latest

Quick List of changes!

Class based modules

Incorporate class based modules into your project instead of the traditional commandModule or eventModule -Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from "@sern/handler";
import { publish } from "../plugins/publish.js";
import { serendipityOnly } from "../plugins/serendipityOnly.js";

export default class extends CommandExecutable<CommandType.Both> {

type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
caution

execute must not be a method of the class. It should be as above, a property on the class!

commands/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from "@sern/handler";
import type { GuildMember } from 'discord.js'
export default class extends EventExecutable<EventType.Discord> {

type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. +Extend the new CommandExecutable or EventExecutable

commands/meaning-of-life.ts
import { CommandType, CommandExecutable, type Args, type Context } from '@sern/handler';
import { publish } from '../plugins/publish.js';
import { serendipityOnly } from '../plugins/serendipityOnly.js';

export default class extends CommandExecutable<CommandType.Both> {
type = CommandType.Both as const;
description = 'What is the meaning of life?'
override onEvent = [
serendipityOnly()
];
override plugins = [
publish(),
];
execute = async (ctx: Context, args: Args) => {
await ctx.reply('42')
};
}
caution

execute must not be a method of the class. It should be as above, a property on the class!

events/guildMemberAdd.ts
import { CommandType, EventExecutable, type EventType } from '@sern/handler';
import type { GuildMember } from 'discord.js'

export default class extends EventExecutable<EventType.Discord> {
type = EventType.Discord as const;
execute = (member: GuildMember) => {
console.log(member)
};
}

Now, you might ask why this feature was added.
Simply put, to give flexibility to the developers. I believe that you should build your own structures however you might like and customize to your liking. In addition, decorators now unofficially work with modules! Feel free to use TypeScript experimental decorators to augment and customize your classes.

Deprecation Warnings

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

Dependencies Update

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

@sern/handler

Handlers. Redefined.

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

NPM versionNPM downloadsLicense MITdocs.rsLines of code

📜 Installation

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

👀 Quick Look

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

👶 Basic Usage

index.js (CommonJS)

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

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

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

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

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

client.login(token);

ping.js (CommonJS)

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

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

See our templates for TypeScript examples and more

💻 CLI

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

👋 Contribute

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

🚈 Roadmap

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

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

Class: CommandExecutable<Type>

Type parameters

NameType
Typeextends CommandType

Constructors

constructor

new CommandExecutable<Type>()

Type parameters

NameType
Typeextends CommandType

Properties

execute

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

Defined in

src/handler/sern.ts:132


onEvent

onEvent: EventPlugin<Type>[] = []

Defined in

src/handler/sern.ts:131


plugins

plugins: CommandPlugin<Type>[] = []

Defined in

src/handler/sern.ts:130


type

Abstract type: Type

Defined in

src/handler/sern.ts:129

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

Returns

ChatInputCommandInteraction<CacheType>

Defined in

src/handler/structures/context.ts:52


member

get member(): Nullish<GuildMember | APIGuildMember>

Returns

Nullish<GuildMember | APIGuildMember>

Defined in

src/handler/structures/context.ts:101


message

get message(): Message<boolean>

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

Returns

Message<boolean>

Defined in

src/handler/structures/context.ts:44


user

get user(): User

Returns

User

Defined in

src/handler/structures/context.ts:70

Methods

isEmpty

isEmpty(): boolean

Returns

boolean

Defined in

src/handler/structures/context.ts:129


reply

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

Parameters

NameType
contentReplyOptions

Returns

Promise<Message<boolean>>

Defined in

src/handler/structures/context.ts:133


wrap

Static wrap(wrappable): Context

Parameters

NameType
wrappableMessage<boolean> | ChatInputCommandInteraction<CacheType>

Returns

Context

Defined in

src/handler/structures/context.ts:122

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

Class: EventExecutable<Type>

Type parameters

NameType
Typeextends EventType

Constructors

constructor

new EventExecutable<Type>()

Type parameters

NameType
Typeextends EventType

Properties

execute

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

Defined in

src/handler/sern.ts:139


onEvent

onEvent: EventModuleEventPluginDefs[Type][] = []

Defined in

src/handler/sern.ts:138


plugins

plugins: EventModuleCommandPluginDefs[Type][] = []

Defined in

src/handler/sern.ts:137


type

Abstract type: Type

Defined in

src/handler/sern.ts:136

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

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

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

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

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

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

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

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

run();

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

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

const ee = new EventEmitter();

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

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

// Prints: ok boom

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

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

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

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

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

Since

v11.13.0, v10.16.0

Parameters

NameType
emitterNodeEventTarget
eventNamestring | symbol
options?StaticEventEmitterOptions

Returns

Promise<any[]>

Inherited from

EventEmitter.once

Defined in

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

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

Parameters

NameType
emitterDOMEventTarget
eventNamestring
options?StaticEventEmitterOptions

Returns

Promise<any[]>

Inherited from

EventEmitter.once

Defined in

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

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

Type parameters

NameType
Kextends keyof ClientEvents

Parameters

NameType
eventEmitterClient<boolean>
eventNameK

Returns

Promise<ClientEvents[K]>

Inherited from

EventEmitter.once

Defined in

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


setMaxListeners

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

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

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

setMaxListeners(5, target, emitter);

Since

v15.4.0

Parameters

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

Returns

void

Inherited from

EventEmitter.setMaxListeners

Defined in

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

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

Enumeration: CommandType

Example

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

Enumeration Members

Both

Both = 3

The CommandType for hybrid commands, text and slash

Defined in

src/handler/structures/enums.ts:27


Button

Button = 16

The CommandType for ButtonInteraction commands

Defined in

src/handler/structures/enums.ts:39


MenuMsg = 8

The CommandType for MessageContextMenuInteraction commands

Defined in

src/handler/structures/enums.ts:35


MenuSelect = 32

The CommandType for SelectMenuInteraction commands

Defined in

src/handler/structures/enums.ts:43


MenuUser = 4

The CommandType for UserContextMenuInteraction commands

Defined in

src/handler/structures/enums.ts:31


Modal = 64

The CommandType for ModalSubmitInteraction commands

Defined in

src/handler/structures/enums.ts:47


Slash

Slash = 2

The CommandType for slash commands

Defined in

src/handler/structures/enums.ts:23


Text

Text = 1

The CommandType for text commands

Defined in

src/handler/structures/enums.ts:19

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

Enumeration: EventType

Example

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

Enumeration Members

Discord

Discord = 1

The EventType for handling discord events

Defined in

src/handler/structures/enums.ts:68


External

External = 3

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

Defined in

src/handler/structures/enums.ts:77


Sern

Sern = 2

The EventType for handling sern events

Defined in

src/handler/structures/enums.ts:72

- + \ No newline at end of file diff --git a/tr/docs/api/enums/PayloadType.html b/tr/docs/api/enums/PayloadType.html index 67dd30d3c..49098ba15 100644 --- a/tr/docs/api/enums/PayloadType.html +++ b/tr/docs/api/enums/PayloadType.html @@ -6,13 +6,13 @@ Enumeration: PayloadType | sern - Handlers. Redefined. - +
- + \ No newline at end of file diff --git a/tr/docs/api/enums/PluginType.html b/tr/docs/api/enums/PluginType.html index 5b5e510c8..43fc0120e 100644 --- a/tr/docs/api/enums/PluginType.html +++ b/tr/docs/api/enums/PluginType.html @@ -6,13 +6,13 @@ Enumeration: PluginType | sern - Handlers. Redefined. - +

Enumeration: PluginType

Example

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

Enumeration Members

Command

Command = 1

The PluginType for CommandPlugins

Defined in

src/handler/structures/enums.ts:97


Event

Event = 2

The PluginType for EventPlugins

Defined in

src/handler/structures/enums.ts:101

- + \ No newline at end of file diff --git a/tr/docs/api/interfaces/Controller.html b/tr/docs/api/interfaces/Controller.html index 138e75915..8d4f78239 100644 --- a/tr/docs/api/interfaces/Controller.html +++ b/tr/docs/api/interfaces/Controller.html @@ -6,13 +6,13 @@ Interface: Controller | sern - Handlers. Redefined. - +
- + \ No newline at end of file diff --git a/tr/docs/api/interfaces/Wrapper.html b/tr/docs/api/interfaces/Wrapper.html index fb03bc952..1f9dc0386 100644 --- a/tr/docs/api/interfaces/Wrapper.html +++ b/tr/docs/api/interfaces/Wrapper.html @@ -6,13 +6,13 @@ Interface: Wrapper | sern - Handlers. Redefined. - +

Interface: Wrapper

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

Properties

client

Readonly client: Client<boolean>

Defined in

src/handler/structures/wrapper.ts:11


commands

Readonly commands: string

Defined in

src/handler/structures/wrapper.ts:15


defaultPrefix

Optional Readonly defaultPrefix: string

Defined in

src/handler/structures/wrapper.ts:14


events

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

Defined in

src/handler/structures/wrapper.ts:16


sernEmitter

Optional Readonly sernEmitter: SernEmitter

Defined in

src/handler/structures/wrapper.ts:13

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

@sern/handler

Namespaces

Enumerations

Classes

Interfaces

Type Aliases

Args

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

Defined in

src/types/handler.ts:12


AutocompletePlugin

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

Defined in

src/handler/plugins/plugin.ts:92


BaseOptions

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

Type that replaces autocomplete with SernAutocompleteData

Defined in

src/handler/structures/module.ts:181


BothCommand

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

Defined in

src/handler/structures/module.ts:55


CommandModuleNoPlugins

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

Defined in

src/handler/plugins/plugin.ts:145


CommandModulePlugin

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

Type parameters

NameType
Textends CommandType

Defined in

src/handler/plugins/plugin.ts:173


CommandPlugin

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

Type parameters

NameType
Textends keyof CommandModuleDefs = keyof CommandModuleDefs

Defined in

src/handler/plugins/plugin.ts:40


DefinedCommandModule

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

Defined in

src/types/handler.ts:43


DefinedEventModule

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

Defined in

src/types/handler.ts:44


DefinedModule

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

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

Defined in

src/types/handler.ts:42


DefinitelyDefined

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

Type parameters

NameType
TT
Kextends keyof T = keyof T

Defined in

src/types/handler.ts:19


DiscordEmitterPlugin

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

Defined in

src/handler/plugins/plugin.ts:57


DiscordEventPlugin

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

Type parameters

NameType
Textends keyof ClientEvents = keyof ClientEvents

Defined in

src/handler/plugins/plugin.ts:136


EventInput

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

Defined in

src/types/handler.ts:25


EventModuleCommandPluginDefs

Ƭ EventModuleCommandPluginDefs: Object

Event Module Command Plugins

Type declaration

NameType
1DiscordEmitterPlugin
2SernEmitterPlugin
3ExternalEmitterPlugin

Defined in

src/handler/plugins/plugin.ts:163


EventModuleEventPluginDefs

Ƭ EventModuleEventPluginDefs: Object

Event Module Event Plugins

Type declaration

NameType
1DiscordEventPlugin
2SernEventPlugin
3ExternalEventPlugin

Defined in

src/handler/plugins/plugin.ts:154


EventModulePlugin

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

Type parameters

NameType
Textends EventType

Defined in

src/handler/plugins/plugin.ts:169


EventModulesNoPlugins

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

Defined in

src/handler/plugins/plugin.ts:148


EventPlugin

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

Type parameters

NameType
Textends keyof CommandModuleDefs = keyof CommandModuleDefs

Defined in

src/handler/plugins/plugin.ts:103


ExternalEmitterPlugin

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

Type parameters

NameType
Textends EventEmitter = EventEmitter

Defined in

src/handler/plugins/plugin.ts:68


ExternalEventPlugin

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

Defined in

src/handler/plugins/plugin.ts:128


InputCommandModule

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

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

Defined in

src/handler/plugins/plugin.ts:178


InputEventModule

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

Defined in

src/handler/plugins/plugin.ts:182


Module

Ƭ Module: CommandModule | EventModule

Defined in

src/handler/structures/module.ts:141


Nullish

Ƭ Nullish<T>: T | undefined | null

Type parameters

Name
T

Defined in

src/types/handler.ts:5


Override

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

Type parameters

Name
T1
T2

Defined in

src/types/handler.ts:17


ParseType

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

Type parameters

Name
T

Defined in

src/types/handler.ts:8


Payload

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

Defined in

src/types/handler.ts:45


ReplyOptions

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

Defined in

src/types/handler.ts:55


SernAutocompleteData

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

Defined in

src/handler/structures/module.ts:166


SernEmitterPlugin

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

Defined in

src/handler/plugins/plugin.ts:80


SernEventPlugin

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

Type parameters

NameType
Textends keyof SernEventsMapping = keyof SernEventsMapping

Defined in

src/handler/plugins/plugin.ts:116


SernEventsMapping

Ƭ SernEventsMapping: Object

Type declaration

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

Defined in

src/types/handler.ts:48


SernOptionsData

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

Type parameters

NameType
Uextends ApplicationCommandOptionData = ApplicationCommandOptionData

Defined in

src/handler/structures/module.ts:205


SernSubCommandData

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

Defined in

src/handler/structures/module.ts:189


SernSubCommandGroupData

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

Defined in

src/handler/structures/module.ts:197


SlashCommand

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

Defined in

src/handler/structures/module.ts:44


SlashOptions

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

Defined in

src/types/handler.ts:14


SpreadParams

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

Type parameters

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

Type declaration

▸ (args): unknown

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

Parameters
NameType
argsParameters<T>[number]
Returns

unknown

Defined in

src/types/handler.ts:34


TextCommand

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

Defined in

src/handler/structures/module.ts:33

Functions

commandModule

commandModule(mod): CommandModule

The wrapper function to define command modules for sern

Parameters

NameType
modInputCommandModule

Returns

CommandModule

Defined in

src/handler/sern.ts:91


eventModule

eventModule(mod): EventModule

The wrapper function to define event modules for sern

Parameters

NameType
modInputEventModule

Returns

EventModule

Defined in

src/handler/sern.ts:112

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

Namespace: Sern

References

CommandExecutable

Re-exports CommandExecutable


EventExecutable

Re-exports EventExecutable


commandModule

Re-exports commandModule


eventModule

Re-exports eventModule

Variables

controller

Const controller: Object

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

Type declaration

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

Defined in

src/handler/sern.ts:82

Functions

addExternal

addExternal<T>(emitter): void

Deprecated

  • use Sern#makeDependencies instead

Example

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

Example

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

Type parameters

NameType
Textends __module

Parameters

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

Returns

void

Defined in

src/handler/sern.ts:72


init

init(wrapper): void

Example

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

Parameters

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

Returns

void

Defined in

src/handler/sern.ts:39

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

Introduction

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

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

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

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

You will learn

Working with plugins

Events

Good to know

- + \ No newline at end of file diff --git a/tr/docs/guide/getting-started/choose-ide.html b/tr/docs/guide/getting-started/choose-ide.html index 7d9c1e5e3..8aed413b9 100644 --- a/tr/docs/guide/getting-started/choose-ide.html +++ b/tr/docs/guide/getting-started/choose-ide.html @@ -6,14 +6,14 @@ Choosing an IDE | sern - Handlers. Redefined. - +
- + \ No newline at end of file diff --git a/tr/docs/guide/getting-started/preparing.html b/tr/docs/guide/getting-started/preparing.html index 4f54c0293..3ca17eb62 100644 --- a/tr/docs/guide/getting-started/preparing.html +++ b/tr/docs/guide/getting-started/preparing.html @@ -6,13 +6,13 @@ Preparing to Code | sern - Handlers. Redefined. - +

Preparing to Code

After installing and IDE you need to install node.

You can download the LTS version of node right here

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

CLI

Setting up the CLI is easy.

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

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

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

sern plugins
info

Make sure to have a correct sern.config.json

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

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

Conclusion

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

- + \ No newline at end of file diff --git a/tr/docs/guide/walkthrough/first-command.html b/tr/docs/guide/walkthrough/first-command.html index b0b70bbb0..364ee1b5c 100644 --- a/tr/docs/guide/walkthrough/first-command.html +++ b/tr/docs/guide/walkthrough/first-command.html @@ -6,7 +6,7 @@ First Command | sern - Handlers. Redefined. - + @@ -15,7 +15,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 89fa417ee..301f06fc1 100644 --- a/tr/docs/guide/walkthrough/first-event.html +++ b/tr/docs/guide/walkthrough/first-event.html @@ -6,7 +6,7 @@ First Event Module | sern - Handlers. Redefined. - + @@ -14,7 +14,7 @@

First Event Module

We will dissect a basic event module.
Typescript:

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

Javascript:

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

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

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


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

Another example of an event module

Typescript:

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

Javascript:


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

Goal

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

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

Good to know

sern.config.json

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

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

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

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

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

Javascript:

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

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

tip

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

Event Plugins

event-plugins

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

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

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

Typescript:

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

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

Javascript:

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

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

Can you predict the behavior of this command?

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

Event Plugins are good for filtering, preconditions, parsing.

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

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

The SernEmitter class

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

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

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


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

Welcome!

Content

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

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

tip

If you have problems, join the discord server here

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

Handlers. Redefined.

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

sern init
logo

Batteries included

Start or integrate a new project in minutes.

Customizable

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

Modern

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

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

Markdown page example

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

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

Coming soon

- + \ No newline at end of file