diff --git a/src/HasLaracord.php b/src/HasLaracord.php new file mode 100644 index 0000000..dea8926 --- /dev/null +++ b/src/HasLaracord.php @@ -0,0 +1,55 @@ +bot) { + return $this->bot; + } + + return $this->bot = app('bot'); + } + + /** + * Retrieve the Discord instance. + */ + public function discord(): Discord + { + return $this->bot()->discord(); + } + + /** + * Retrieve the console instance. + */ + public function console(): ConsoleCommand + { + return $this->bot()->console(); + } + + /** + * Build an embed for use in a Discord message. + * + * @param string $content + * @return \Laracord\Discord\Message + */ + public function message($content = '') + { + return Message::make($this) + ->content($content); + } +} diff --git a/src/Http/Controllers/Controller.php b/src/Http/Controllers/Controller.php index 88de318..492d77d 100644 --- a/src/Http/Controllers/Controller.php +++ b/src/Http/Controllers/Controller.php @@ -2,43 +2,10 @@ namespace Laracord\Http\Controllers; -use Discord\DiscordCommandClient as Discord; use Illuminate\Routing\Controller as BaseController; -use Laracord\Console\Commands\Command as ConsoleCommand; -use Laracord\Laracord; +use Laracord\HasLaracord; class Controller extends BaseController { - /** - * The bot instance. - */ - protected ?Laracord $bot; - - /** - * Retrieve the bot instance. - */ - public function bot(): Laracord - { - if ($this->bot) { - return $this->bot; - } - - return $this->bot = app('bot'); - } - - /** - * Retrieve the Discord instance. - */ - public function discord(): Discord - { - return $this->bot()->discord(); - } - - /** - * Retrieve the console instance. - */ - public function console(): ConsoleCommand - { - return $this->bot()->console(); - } + use HasLaracord; }