diff --git a/404.html b/404.html index 6f23a2737..8b558deeb 100644 --- a/404.html +++ b/404.html @@ -11,7 +11,7 @@ - +
diff --git a/assets/js/1ac1bfe9.0d260689.js b/assets/js/1ac1bfe9.0d260689.js deleted file mode 100644 index 4c2803c86..000000000 --- a/assets/js/1ac1bfe9.0d260689.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunksern_website=self.webpackChunksern_website||[]).push([[8811],{7348:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>d,contentTitle:()=>o,default:()=>u,frontMatter:()=>t,metadata:()=>l,toc:()=>c});var s=i(4848),r=i(8453);const t={sidebar_position:6},o="Plugins",l={id:"guide/walkthrough/plugins",title:"Plugins",description:"TLDR: Plugins help reduce code repetition and are installable via sern plugins. Put them onto the plugins field of a command/event module.",source:"@site/docs/guide/walkthrough/plugins.md",sourceDirName:"guide/walkthrough",slug:"/guide/walkthrough/plugins",permalink:"/docs/guide/walkthrough/plugins",draft:!1,unlisted:!1,editUrl:"https://github.com/sern-handler/website/edit/main/docs/guide/walkthrough/plugins.md",tags:[],version:"current",sidebarPosition:6,frontMatter:{sidebar_position:6},sidebar:"tutorialSidebar",previous:{title:"First Event Module",permalink:"/docs/guide/walkthrough/first-event"},next:{title:"Services",permalink:"/docs/guide/walkthrough/services"}},d={},c=[{value:"Installing",id:"installing",level:2},{value:"\u2517|\uff40O\u2032|\u251b perfect, your first plugin!",id:"o-perfect-your-first-plugin",level:4},{value:"Creating your own plugins",id:"creating-your-own-plugins",level:2},{value:"The controller object",id:"the-controller-object",level:3},{value:"Init Plugins",id:"init-plugins",level:2},{value:"Event Plugins",id:"event-plugins",level:2}];function a(e){const n={admonition:"admonition",br:"br",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,r.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.h1,{id:"plugins",children:"Plugins"}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["TLDR: Plugins help reduce code repetition and are installable via ",(0,s.jsx)(n.code,{children:"sern plugins"}),". Put them onto the plugins field of a command/event module."]})}),"\n",(0,s.jsx)(n.h2,{id:"installing",children:"Installing"}),"\n",(0,s.jsx)(n.p,{children:"Chances are, you just want your bot to work. Plugins can preprocess and create reusable conditions for modules."}),"\n",(0,s.jsx)(n.p,{children:"run:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-sh",children:"sern plugins\n"})}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["Install your favorite(s) (or the ones that look the coolest). In my imaginary mind, I installed the ownerOnly plugin.\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["This should install in ",(0,s.jsx)(n.code,{children:"plugins"})," directory in ",(0,s.jsx)(n.code,{children:"src"}),"."]}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.li,{children:"Some plugins only work with specific types. Most are targeted towards slash / both modules."}),"\n",(0,s.jsx)(n.li,{children:"Add to your module."}),"\n"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ts",children:"import { commandModule, CommandType } from '@sern/handler'\nimport { ownerOnly } from '../plugins'\n\nexport default commandModule({ \n type: CommandType.Both,\n plugins: [ownerOnly(['182326315813306368')],\n description: 'ping command',\n execute: (ctx) => {\n ctx.reply('hello, owner');\n }\n})\n\n"})}),"\n",(0,s.jsx)(n.h4,{id:"o-perfect-your-first-plugin",children:"\u2517|\uff40O\u2032|\u251b perfect, your first plugin!"}),"\n",(0,s.jsx)(n.h2,{id:"creating-your-own-plugins",children:"Creating your own plugins"}),"\n",(0,s.jsx)(n.p,{children:"The controller determines in plugins whether to continue or fail."}),"\n",(0,s.jsx)(n.h3,{id:"the-controller-object",children:"The controller object"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-typescript",children:"export interface Controller {\n next: () => Okimport { commandModule, CommandType } from '@sern/handler'
import { ownerOnly } from '../plugins'
export default commandModule({
type: CommandType.Both,
plugins: [ownerOnly(['182326315813306368')],
description: 'ping command',
execute: (ctx) => {
ctx.reply('hello, owner');
}
})
import { commandModule, CommandType } from '@sern/handler'
import { ownerOnly } from '../plugins'
export default commandModule({
type: CommandType.Both,
plugins: [ownerOnly(['182326315813306368'])],
description: 'ping command',
execute: (ctx) => {
ctx.reply('hello, owner');
}
})
The controller determines in plugins whether to continue or fail.
diff --git a/docs/guide/walkthrough/sern-emitter.html b/docs/guide/walkthrough/sern-emitter.html index f594e1d6f..535b97934 100644 --- a/docs/guide/walkthrough/sern-emitter.html +++ b/docs/guide/walkthrough/sern-emitter.html @@ -11,7 +11,7 @@ - + diff --git a/docs/guide/walkthrough/services.html b/docs/guide/walkthrough/services.html index dbed7a837..b210d22f9 100644 --- a/docs/guide/walkthrough/services.html +++ b/docs/guide/walkthrough/services.html @@ -11,7 +11,7 @@ - + diff --git a/docs/guide/walkthrough/transition.html b/docs/guide/walkthrough/transition.html index bfd27eea5..09122e99e 100644 --- a/docs/guide/walkthrough/transition.html +++ b/docs/guide/walkthrough/transition.html @@ -11,7 +11,7 @@ - + diff --git a/docs/intro.html b/docs/intro.html index 3c53d9bf0..4dfa63140 100644 --- a/docs/intro.html +++ b/docs/intro.html @@ -11,7 +11,7 @@ - + diff --git a/index.html b/index.html index 143dd6b71..c060ba34b 100644 --- a/index.html +++ b/index.html @@ -11,7 +11,7 @@ - + diff --git a/markdown-page.html b/markdown-page.html index 2f90c62c0..7cdd3e8bb 100644 --- a/markdown-page.html +++ b/markdown-page.html @@ -11,7 +11,7 @@ - + diff --git a/plugins.html b/plugins.html index e433433a2..3995bcfdd 100644 --- a/plugins.html +++ b/plugins.html @@ -11,7 +11,7 @@ - + diff --git a/search.html b/search.html index feee0045a..246a8922f 100644 --- a/search.html +++ b/search.html @@ -11,7 +11,7 @@ - + diff --git a/sponsors.html b/sponsors.html index 0976ddb1c..2c43f26fb 100644 --- a/sponsors.html +++ b/sponsors.html @@ -11,7 +11,7 @@ - +