Skip to content

Instantly share code, notes, and snippets.

@sylae
Created October 22, 2017 20:42
Show Gist options
  • Save sylae/eaa1c3efb47284d162e70554ae387892 to your computer and use it in GitHub Desktop.
Save sylae/eaa1c3efb47284d162e70554ae387892 to your computer and use it in GitHub Desktop.
<?php
/**
* From the command-line, run this before starting: composer require team-reflex/discord-php
*/
include __DIR__ . '/vendor/autoload.php';
class Scapegoat {
/**
* @var Discord\Discord
*/
private $discord;
/**
* @var Discord\Parts\Channel\Channel
*/
private $channel;
private $channels;
const CHANNEL = "356885321071198208";
const TOKEN = "dont upload this";
function __construct() {
$this->discord = new Discord\Discord(['token' => self::TOKEN]);
$this->discord->on('ready', function ($discord) {
foreach ($this->discord->guilds as $guild) {
foreach ($guild->channels as $channel) {
if ($channel->id = self::CHANNEL) {
$this->channel = $channel;
}
}
}
// $this->channel->sendMessage("Hi!");
$discord->on('message', function ($message, $discord) {
if (!$message->channel->is_private || $message->author->username == "Scapegoat") {
return;
}
$this->channel->sendMessage("Message received anonymously at " . $message->timestamp->toRssString() . PHP_EOL . "```" . $message->content . "```");
$message->reply("Your feedback has been received :)");
});
});
$this->discord->run();
}
}
$scapegoat = new Scapegoat();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment