2020-12-27 18:21:03 +00:00
|
|
|
<?php declare(strict_types=1);
|
2020-12-25 16:38:27 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
|
2020-12-27 18:21:03 +00:00
|
|
|
// This could be a little cleaner.
|
2020-12-25 16:38:27 +00:00
|
|
|
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.";
|
|
|
|
}
|
|
|
|
|
2020-12-27 18:21:03 +00:00
|
|
|
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;
|
2020-12-25 16:38:27 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
return ":x: There is no help section named " . $parameters['section'] . ".";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|