So, what does a command module look like with plugins?
- -Typescript: -```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: -```typescript -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`. - -If all plugins return `controller.next()`, this command replies `Pong 🏓` - -# 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 errors that are recoverable, the `error` event - -So, what does a command module look like with plugins?
+ +Typescript: +```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: +```typescript +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`. + +If all plugins return `controller.next()`, this command replies `Pong 🏓` \ No newline at end of file diff --git a/guide-en/walkthrough/sern-emitter.md b/guide-en/walkthrough/sern-emitter.md new file mode 100644 index 000000000..d4640f33c --- /dev/null +++ b/guide-en/walkthrough/sern-emitter.md @@ -0,0 +1,7 @@ +# 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 errors that are recoverable, the `error` event + +