61 lines
1.3 KiB
PHP

<?php declare(strict_types=1);
namespace nogueiracodes\RaspberryBot\Bot\Commands;
use Analog\Analog;
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 __construct()
{
Analog::info('Commands: Loaded Help!');
}
public function run(array $parameters)
{
// This could be a little cleaner.
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;
case "fun":
if(file_exists(PROJECT_ROOT . "/Commandfiles/fun.txt"))
{
return str_replace("<prefix>", $_ENV['COMMAND_PREFIX'], file_get_contents(PROJECT_ROOT . "/Commandfiles/fun.txt"));
}
else
{
return ":x: There is currently no available help.";
}
break;
default:
return ":x: There is no help section named " . $parameters['section'] . ".";
break;
}
}
}