import { PermissionResolvable } from 'discord.js' ; import { Inhibitor , InhibitorOptions } from './Inhibitor' ; import { CommandContext } from '../lib/structures/contexts/CommandContext' ; import { ComponentContext } from '../lib/structures/contexts/ComponentContext' ; export interface UserPermissionsOptions extends InhibitorOptions { permissions : Array < PermissionResolvable > ; } export class UserPermissions extends Inhibitor { public readonly permissions : Array < PermissionResolvable > ; constructor ( options ) { super ( options ) ; this . permissions = options . permissions ; } run ( ctx ) { if ( ! ctx . inGuild ( ) ) return ; if ( ! ctx . memberPermissions . has ( this . permissions ) ) return ctx . reply ( { content : this . resolveMessage ( ctx ) || `You need the following permissions to execute this command: ${ this . permissions . join ( ', ' ) . replace ( /_/g , ' ' ) . toLowerCase ( ) }` , ephemeral : this . ephemeral , } ) ; else return true ; } }