3 namespace App\TwitchBotCommands;
5 use App\Models\Channel;
6 use App\Models\ChatBotLog;
7 use App\Models\TwitchBotCommand;
8 use App\TwitchBot\IRCMessage;
9 use App\TwitchBot\TwitchBot;
10 use React\Promise\Promise;
12 class AdlibChatCommand extends BaseCommand {
14 public function __construct(TwitchBot $bot, TwitchBotCommand $cmd) {
15 parent::__construct($bot, $cmd);
18 public function execute() {
19 return new Promise(function($resolve) {
20 $channel = Channel::findOrFail($this->getParameter('channel'));
21 $db = $this->bot->getChatlibDatabase($channel);
22 $text = $db->generate();
23 $this->bot->sendIRCMessage(IRCMessage::privmsg($channel->twitch_chat, $text));
24 $log = new ChatBotLog();
25 $log->channel()->associate($channel);
27 $log->user()->associate($this->getExecutingUser());
28 $log->category = 'adlib';