forked from spacejewelhosting/raspberry-bot
Added missing help command
This commit adds the missing help command for the bot.
This commit is contained in:
41
src/Bot/Commands/Help.php
Normal file
41
src/Bot/Commands/Help.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace nogueiracodes\RaspberryBot\Bot\Commands;
|
||||
|
||||
use Exception;
|
||||
use nogueiracodes\RaspberryBot\Core\Interfaces\Command;
|
||||
use nogueiracodes\RaspberryBot\Traits\HasSignature;
|
||||
use Zttp\Zttp;
|
||||
|
||||
class Help implements Command
|
||||
{
|
||||
use HasSignature;
|
||||
|
||||
|
||||
public $signature = "help {section: The section to retrieve help for}";
|
||||
|
||||
|
||||
public function run(array $parameters)
|
||||
{
|
||||
|
||||
switch($parameters['section'])
|
||||
{
|
||||
case "commands":
|
||||
|
||||
if(file_exists(PROJECT_ROOT . "/Commandfiles/help.txt"))
|
||||
{
|
||||
return str_replace("<prefix>", $_ENV['COMMAND_PREFIX'], file_get_contents(PROJECT_ROOT . "/Commandfiles/help.txt"));
|
||||
}
|
||||
else
|
||||
{
|
||||
return ":x: There is currently no available help.";
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
return ":x: There is no help section named " . $parameters['section'] . ".";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -8,3 +8,4 @@ $dotenv->load();
|
||||
$dotenv->required('BOT_AUTH_TOKEN')->notEmpty();
|
||||
$dotenv->required('COMMAND_PREFIX')->notEmpty();
|
||||
|
||||
define('PROJECT_ROOT', realpath(__DIR__ . '/../../'));
|
||||
|
Reference in New Issue
Block a user