function hasPermission(\CharlotteDunois\Livia\Commands\Context $context, bool $ownerOverride = true) {
        if($this->ownerOnly === false && empty($this->userPermissions)) {
            return true;
        }
        
        if($ownerOverride && $this->client->isOwner($context->message->author)) {
            return true;
        }
        
        if($this->ownerOnly && ($ownerOverride || !$this->client->isOwner($context->message->author))) {
            return 'The command `'.$this->name.'` can only be used by the bot owner.';
        }
        
        // Ensure the user has the proper permissions
        if($context->message->guild !== null && !empty($this->userPermissions)) {
            $perms = $context->message->channel->permissionsFor($context->message->member);
            
            $missing = array();
            foreach($this->userPermissions as $perm) {
                if($perms->missing($perm)) {
                    $missing[] = $perm;
                }
            }
            
            if(\count($missing) > 0) {
                $this->client->emit('commandBlocked', $context, 'userPermissions');
                
                if(\count($missing) === 1) {
                    $msg = 'The command `'.$this->name.'` requires you to have the `'.$missing[0].'` permission.';
                } else {
                    $missing = \implode(', ', \array_map(function ($perm) {
                        return '`'.\CharlotteDunois\Yasmin\Models\Permissions::resolveToName($perm).'`';
                    }, $missing));
                    $msg = 'The `'.$this->name.'` command requires you to have the following permissions:'.\PHP_EOL.$missing;
                }
                
                return $msg;
            }
        }
        
        return true;
    }
function hasPermission(\CharlotteDunois\Livia\Commands\Context $context, bool $ownerOverride = true) {
        if($this->ownerOnly === false && empty($this->userPermissions)) {
            return true;
        }
        
        if($ownerOverride && $this->client->isOwner($context->message->author)) {
            return true;
        }
        
        if($this->ownerOnly && ($ownerOverride || !$this->client->isOwner($context->message->author))) {
            return 'The command `'.$this->name.'` can only be used by the bot owner.';
        }
        
        // Ensure the user has the proper permissions
        if($context->message->guild !== null && !empty($this->userPermissions)) {
            $perms = $context->message->channel->permissionsFor($context->message->member);
            
            $missing = array();
            foreach($this->userPermissions as $perm) {
                if($perms->missing($perm)) {
                    $missing[] = $perm;
                }
            }
            
            if(\count($missing) > 0) {
                $this->client->emit('commandBlocked', $context, 'userPermissions');
                
                if(\count($missing) === 1) {
                    $msg = 'The command `'.$this->name.'` requires you to have the `'.$missing[0].'` permission.';
                } else {
                    $missing = \implode(', ', \array_map(function ($perm) {
                        return '`'.\CharlotteDunois\Yasmin\Models\Permissions::resolveToName($perm).'`';
                    }, $missing));
                    $msg = 'The `'.$this->name.'` command requires you to have the following permissions:'.\PHP_EOL.$missing;
                }
                
                return $msg;
            }
        }
        
        return true;
    }
function hasPermission ( \ CharlotteDunois \ Livia \ Commands \ Context $ context , bool $ ownerOverride = true ) { if ( $ this -> ownerOnly === false && empty ( $ this -> userPermissions ) ) { return true ; } if ( $ ownerOverride && $ this -> client -> isOwner ( $ context -> message -> author ) ) { return true ; } if ( $ this -> ownerOnly && ( $ ownerOverride || ! $ this -> client -> isOwner ( $ context -> message -> author ) ) ) { return 'The command `' . $ this -> name . '` can only be used by the bot owner.' ; } // Ensure the user has the proper permissions if ( $ context -> message -> guild !== null && ! empty ( $ this -> userPermissions ) ) { $ perms = $ context -> message -> channel -> permissionsFor ( $ context -> message -> member ) ; $ missing = array ( ) ; foreach ( $ this -> userPermissions as $ perm ) { if ( $ perms -> missing ( $ perm ) ) { $ missing [ ] = $ perm ; } } if ( \ count ( $ missing ) > 0 ) { $ this -> client -> emit ( 'commandBlocked' , $ context , 'userPermissions' ) ; if ( \ count ( $ missing ) === 1 ) { $ msg = 'The command `' . $ this -> name . '` requires you to have the `' . $ missing [ 0 ] . '` permission.' ; } else { $ missing = \ implode ( ', ' , \ array_map ( function ( $ perm ) { return '`' . \ CharlotteDunois \ Yasmin \ Models \ Permissions :: resolveToName ( $ perm ) . '`' ; } , $ missing ) ) ; $ msg = 'The `' . $ this -> name . '` command requires you to have the following permissions:' . \ PHP_EOL . $ missing ; } return $ msg ; } } return true ; }
Checks if the user has permission to use the command.
@param \CharlotteDunois\Livia\Commands\Context  $context
@param bool                                     $ownerOverride  Whether the bot owner(s) will always have permission.
@return bool|string  Whether the user has permission, or an error message to respond with if they don't.
Checks if the user has permission to use the command .