| Lines of Code | 39 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | const middlware = require('../lib/structure/AbstractMiddleware') |
||
| 2 | class coreCommands extends middlware { |
||
| 3 | setUp (client, next) { |
||
| 4 | this.client = client |
||
| 5 | var register = client.createRegister('core', 'core') |
||
| 6 | register.textCommand('help', null, function (req, res) { |
||
| 7 | var message = 'This command was instantied inside a middleware\n' |
||
| 8 | client.registers.forEach(function (register) { |
||
| 9 | message += '__' + register.name + '__:\n' |
||
| 10 | register.forEach(function (command) { |
||
| 11 | message += '`' + command.name + '` ' |
||
| 12 | }) |
||
| 13 | message += '\n' |
||
| 14 | }) |
||
| 15 | res.send(message) |
||
| 16 | }) |
||
| 17 | register.textCommand('block', null, function (req, res) { |
||
| 18 | // this will be blocked |
||
| 19 | }) |
||
| 20 | register.textCommand('exception', null, function (req, res) { |
||
| 21 | // this will be blocked |
||
| 22 | }) |
||
| 23 | next() |
||
| 24 | } |
||
| 25 | handle (req, res, next) { |
||
| 26 | console.log('handle') |
||
| 27 | if (req.isCommand && req.command.name === 'block') { |
||
| 28 | res.send('Blocking the middleware chain') |
||
| 29 | next(true) |
||
| 30 | } |
||
| 31 | if (req.isCommand && req.command.name === 'exception') { |
||
| 32 | res.send('Creating an exception') |
||
| 33 | next(new Error('Exception')) |
||
| 34 | } |
||
| 35 | req.test = true |
||
| 36 | next(null, req, res) |
||
| 37 | } |
||
| 38 | } |
||
| 39 | module.exports = coreCommands |
||
| 40 |
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.