The middleware system is provided by koa-compose. I recommend reading this article to learn about its extremely powerful middleware system.
const { Client } = require('hershel')
const bot = new Client({
logger: {
level: 'info',
stream: myStream,
},
})
bot.use(({ id }, next) => {
console.log(`#${id}`)
next()
})
// assert.stricEqual(bot.middleware.length, 1)
await bot.login(TOKEN)
// assert.stricEqual(bot.started, true)
bot.use(({ message }, next) => {
console.log(message.content)
next()
})
// ERROR: Cannot add new middleware while client is already started
Once the client has started, the middleware stack is sealed and can no longer be modified.