Skip to content

discord-rose/admin-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Admin Middleware

Admin middleware for discord-rose

Install

npm i @discord-rose/admin-middleware

Usage

Setting CommandOptions.admin to true will let the middleware run and lock a command if a user is not an admin.

The middleware can either take an ID of an admin, an array of an IDs of an admin, or an async function to check.

const adminMiddleware = require('@discord-rose/admin-middleware')

worker.commands
  .middleware(adminMiddleware('142408079177285632'))
  .add({
    admin: true,
    command: 'eval',
    exec: (ctx) => {
      // naughty eval code
    }
  })

This command will now only run if the user has an ID of 142408079177285632, essentially admin locking the command.

Alternate methods

worker.commands
  .middleware(adminMiddleware(['142408079177285632', '277183033344524288']))

Or

worker.commands
  .middleware(adminMiddleware(async (id) => { // author id
    return await isAdmin(id)
  }))

Releases

No releases published

Packages

No packages published