/** * Handles the message. * * @param Message $message * @param array $params * @param Discord $discord * @param Config $config * @return void */ public static function handleMessage($message, $params, $discord, $config) { if (preg_match('/https:\\/\\/discord.gg\\/(.+)/', $params[1], $matches)) { $invite = $discord->acceptInvite($matches[1]); $message->reply("Joined server {$invite->guild->name}"); } }
/** * Handles the message. * * @param Message $message * @param array $params * @param Discord $discord * @param Config $config * @return void */ public static function handleMessage($message, $params, $discord, $config) { if ($discord->bot) { $appId = isset($config['app_id']) ? $config['app_id'] : '157746770539970560'; $message->reply("This bot can't accpet invites, sorry! Please use this OAuth invite link: https://discordapp.com/oauth2/authorize?client_id={$appId}&scope=bot&permissions=36703232"); return; } if (preg_match('/https:\\/\\/discord.gg\\/(.+)/', $params[0], $matches)) { $invite = $discord->acceptInvite($matches[1]); $message->reply("Joined server {$invite->guild->name}"); } }
public function __construct($client, $data) { parent::__construct($client, $data); $this->name = $data['name']; $this->guild_id = $data['guild_id']; $this->permission_overwrites = $data['permission_overwrites']; $this->topic = $data['topic']; $this->position = $data['position']; $this->last_message_id = $data['last_message_id']; $this->type = $data['type']; $this->id = $data['id']; $this->is_private = $data['is_private']; //$this->client = $client; }
$cmd->option("c")->aka("config")->title("Path to configuration file")->describedAs("Defines the configuration file that the bot will use to run")->file(true)->require(); $cmd->option("ccp")->title("Install the ccp database")->describedAs("Installs the CCP database. Required before the bot can start properly")->boolean(); $cmd->option("conv")->aka("convert")->title("Converts a username/password login to token login")->describedAs("Converts the username/password login for Discord, to the new bot API token login"); $args = $cmd->getFlagValues(); // Define the path for the logfile $configPath = $args["c"] ? $args["c"] : \Exception("Error, config file not loaded"); // Bot start time $startTime = time(); // Load in the config require_once $configPath; // define the bots name define("BOTNAME", strtolower($config["bot"]["botName"])); // Conversion path triggered if ($args["conv"]) { $discord = new \Discord\Discord($config["discord"]["email"], $config["discord"]["password"]); $bot = Discord::createOauthApp($args["conv"], $config["bot"]["botName"]); $discord->convertToBot($args["conv"], $bot->id, $bot->secret); echo "Bot has been converted to the new Token API.."; exit; } // Start the bot, and load up all the Libraries and Models include BASEDIR . "/src/init.php"; // Check if the CCP Database exists if (!file_exists(BASEDIR . "/config/database/ccpData.sqlite") || filesize(BASEDIR . "/config/database/ccpData.sqlite") == 0) { throw new \Exception("Error, ccpData.sqlite does not exist. Please start the bot with --ccp, to update it"); } // --ccp was passed, lets update the database! if ($args["ccp"]) { $app->ccpdatabaseupdater->createCCPDB(); echo "Updated the CCP Database, now exiting, please start the bot without --ccp"; exit;