diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..7ff10c5 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Ben Harris + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/BenBot.php b/src/BenBot.php index 7d1a56e..b0afa8d 100644 --- a/src/BenBot.php +++ b/src/BenBot.php @@ -30,6 +30,7 @@ class BenBot extends Discord { public $yomamajokes; public $copypastas; public $devbot; + public $chatgame; protected $help; protected $game; @@ -54,7 +55,8 @@ class BenBot extends Discord { $this->copypastas = explode("---", file_get_contents("$dir/copypasta.txt")); $this->yomamajokes = file("$dir/yomamajokes.txt"); $this->banner = file_get_contents("{$this->dir}/banner.txt"); - $this->devbot = false; + $this->devbot = true; + $this->chatgame = []; $this->game = $this->factory(Game::class, [ @@ -197,6 +199,8 @@ class BenBot extends Discord { Commands\Images::register($this); Commands\Jokes::register($this); Commands\Misc::register($this); + Commands\Music::register($this); + Commands\Poll::register($this); Commands\Time::register($this); Commands\Weather::register($this); } diff --git a/src/Commands/Music.php b/src/Commands/Music.php new file mode 100644 index 0000000..30bf6f1 --- /dev/null +++ b/src/Commands/Music.php @@ -0,0 +1,31 @@ +registerCommand('play', [__CLASS__, 'playSong'], [ + 'description' => 'plays', + ]); + + echo __CLASS__ . " registered", PHP_EOL; + } + + public static function playSong($msg, $args) + { + self::$bot->joinVoiceChannel($msg->channel)->then(function (VoiceClient $vc) { + echo "joined voice channel", PHP_EOL; + $vc->playFile(self::$bot->dir . "/music/mytype.m4a"); + }, function ($e) { + echo "there was an error joining the voice channel: {$e->getMessage()}", PHP_EOL, $e->getTraceAsString(), PHP_EOL; + }); + } + +} diff --git a/src/Commands/Poll.php b/src/Commands/Poll.php new file mode 100644 index 0000000..b1d9ab2 --- /dev/null +++ b/src/Commands/Poll.php @@ -0,0 +1,43 @@ +registerCommand('poll', [__CLASS__, 'createPoll'], [ + 'description' => 'yes/no poll. lasts 30 seconds.', + 'usage' => '', + 'registerHelp' => true, + ]); + + echo __CLASS__ . " registered", PHP_EOL; + } + + + public static function createPoll($msg, $args) + { + $question = implode(" ", $args); + $response = "{$msg->author}'s poll:\n**$question**"; + echo $response, PHP_EOL; + + Utils::send($msg, $response)->then(function ($result) use ($msg) { + print_r($result); + Utils::deleteMessage($msg); + $result->react("👍"); + $result->react("👎"); + + self::$bot->loop->addTimer(30, function ($timer) use ($result) { + Utils::deleteMessage($result); + + }); + }); + } + +} diff --git a/src/Commands/TicTacToe.php b/src/Commands/TicTacToe.php new file mode 100644 index 0000000..6f8dccb --- /dev/null +++ b/src/Commands/TicTacToe.php @@ -0,0 +1,23 @@ +