anonymous//src/Commands/commands/reload.php$0   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 31
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A reload.php$0 ➔ __construct() 0 19 1
A reload.php$0 ➔ run() 0 8 2
1
<?php
2
/**
3
 * Livia
4
 * Copyright 2017-2019 Charlotte Dunois, All Rights Reserved
5
 *
6
 * Website: https://charuru.moe
7
 * License: https://github.com/CharlotteDunois/Livia/blob/master/LICENSE
8
*/
9
10
return function ($client) {
11
    return (new class($client) extends \CharlotteDunois\Livia\Commands\Command {
12
        function __construct(\CharlotteDunois\Livia\Client $client) {
13
            parent::__construct($client, array(
14
                'name' => 'reload',
15
                'aliases' => array('reload-command'),
16
                'group' => 'commands',
17
                'description' => 'Reloads a command or command group.',
18
                'details' => 'The argument must be the name/ID (partial or whole) of a command or command group. Providing a command group will reload all of the commands in that group. Only the bot owner may use this command.',
19
                'examples' => array('enable utils'),
20
                'guildOnly' => false,
21
                'ownerOnly' => true,
22
                'args' => array(
23
                    array(
24
                        'key' => 'commandOrGroup',
25
                        'label' => 'command/group',
26
                        'prompt' => 'Which command or command group would you like to reload?',
27
                        'type' => 'command-or-group'
28
                    )
29
                ),
30
                'guarded' => true
31
            ));
32
        }
33
        
34
        function run(\CharlotteDunois\Livia\Commands\Context $context, \ArrayObject $args, bool $fromPattern) {
35
            if($args['commandOrGroup'] instanceof \CharlotteDunois\Livia\Commands\CommandGroup) {
36
                $args['commandOrGroup']->reload();
37
                return $context->reply('Reloaded the group `'.$args['commandOrGroup']->name.'`.');
38
            }
39
            
40
            $args['commandOrGroup']->reload();
41
            return $context->reply('Reloaded the command `'.$args['commandOrGroup']->name.'`.');
42
        }
43
    });
44
};
45