forked from miguel456/luke-bot
Added missing help command
This commit adds the missing help command for the bot.
This commit is contained in:
parent
4911163c71
commit
2a2d2a0b7e
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
:white_check_mark: Raspberry Bot Command Help :arrow_down:
|
||||||
|
|
||||||
|
Active prefix: <prefix>
|
||||||
|
|
||||||
|
Available commands:
|
||||||
|
- numberfact [random/ (int) number] (Example: <prefix> numberfact 20)
|
||||||
|
- help (This command)
|
|
@ -1,9 +1,11 @@
|
||||||
|
#!/usr/bin/env php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use nogueiracodes\RaspberryBot\Bot\Actions\MessageLogger;
|
use nogueiracodes\RaspberryBot\Bot\Actions\MessageLogger;
|
||||||
use nogueiracodes\RaspberryBot\Bot\Commands\MinecraftInfo;
|
use nogueiracodes\RaspberryBot\Bot\Commands\MinecraftInfo;
|
||||||
use nogueiracodes\RaspberryBot\Bot\Commands\NumberFact;
|
use nogueiracodes\RaspberryBot\Bot\Commands\NumberFact;
|
||||||
use nogueiracodes\RaspberryBot\Bot\Commands\SimplePlayback;
|
use nogueiracodes\RaspberryBot\Bot\Commands\SimplePlayback;
|
||||||
|
use nogueiracodes\RaspberryBot\Bot\Commands\Help;
|
||||||
use nogueiracodes\RaspberryBot\Core\RaspberryBot;
|
use nogueiracodes\RaspberryBot\Core\RaspberryBot;
|
||||||
|
|
||||||
require 'src/Bot/init.php';
|
require 'src/Bot/init.php';
|
||||||
|
@ -18,8 +20,9 @@ $raspberryBot
|
||||||
->addCommand([
|
->addCommand([
|
||||||
new SimplePlayback,
|
new SimplePlayback,
|
||||||
new NumberFact,
|
new NumberFact,
|
||||||
new MinecraftInfo
|
new MinecraftInfo,
|
||||||
|
new Help
|
||||||
])
|
])
|
||||||
->addAction(new MessageLogger)
|
->addAction(new MessageLogger)
|
||||||
->setCommandPrefix($_ENV['COMMAND_PREFIX'])
|
->setCommandPrefix($_ENV['COMMAND_PREFIX'])
|
||||||
->run();
|
->run();
|
||||||
|
|
|
@ -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('BOT_AUTH_TOKEN')->notEmpty();
|
||||||
$dotenv->required('COMMAND_PREFIX')->notEmpty();
|
$dotenv->required('COMMAND_PREFIX')->notEmpty();
|
||||||
|
|
||||||
|
define('PROJECT_ROOT', realpath(__DIR__ . '/../../'));
|
||||||
|
|
Loading…
Reference in New Issue