|
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' => 'enable', |
|
15
|
|
|
'aliases' => array('enable-command'), |
|
16
|
|
|
'group' => 'commands', |
|
17
|
|
|
'description' => 'Enables a command or command group.', |
|
18
|
|
|
'details' => 'The argument must be the name/ID (partial or whole) of a command or command group. Only administrators may use this command.', |
|
19
|
|
|
'examples' => array('enable utils'), |
|
20
|
|
|
'guildOnly' => false, |
|
21
|
|
|
'throttling' => array( |
|
22
|
|
|
'usages' => 2, |
|
23
|
|
|
'duration' => 3 |
|
24
|
|
|
), |
|
25
|
|
|
'userPermissions' => array('ADMINISTRATOR'), |
|
26
|
|
|
'args' => array( |
|
27
|
|
|
array( |
|
28
|
|
|
'key' => 'commandOrGroup', |
|
29
|
|
|
'label' => 'command/group', |
|
30
|
|
|
'prompt' => 'Which command or group would you like to enable?', |
|
31
|
|
|
'type' => 'command-or-group' |
|
32
|
|
|
) |
|
33
|
|
|
), |
|
34
|
|
|
'guarded' => true |
|
35
|
|
|
)); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
function run(\CharlotteDunois\Livia\Commands\Context $context, \ArrayObject $args, bool $fromPattern) { |
|
39
|
|
|
$type = ($args['commandOrGroup'] instanceof \CharlotteDunois\Livia\Commands\CommandGroup ? 'group' : 'command'); |
|
40
|
|
|
|
|
41
|
|
|
if($args['commandOrGroup']->isEnabledIn($context->message->guild)) { |
|
42
|
|
|
return $context->reply('The '.$type.' `'.$args['commandOrGroup']->name.'` is already enabled.'); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
$args['commandOrGroup']->setEnabledIn($context->message->guild, true); |
|
46
|
|
|
return $context->reply('Enabled the '.$type.' `'.$args['commandOrGroup']->name.'`.'); |
|
47
|
|
|
} |
|
48
|
|
|
}); |
|
49
|
|
|
}; |
|
50
|
|
|
|