Ejemplo n.º 1
0
 /**
  * Constructs the bot instance.
  *
  * @param string $configfile 
  * @param Logger $log 
  * @return void 
  */
 public function __construct($configfile, $log)
 {
     $this->configfile = $configfile;
     $this->log = $log;
     $config = Config::getConfig($this->configfile);
     $this->log->addInfo('Loaded config.', $config);
     $this->discord = Discord::createWithBotToken($config['token']);
     $this->websocket = new WebSocket($this->discord);
 }
Ejemplo n.º 2
0
 /**
  * Sovereign constructor.
  * @param Container $container
  */
 public function __construct(Container $container)
 {
     $this->container = $container;
     $this->log = $container->get('log');
     $this->globalConfig = $container->get('config');
     $this->db = $container->get('db');
     $this->curl = $container->get('curl');
     $this->settings = $container->get('settings');
     $this->permissions = $container->get('permissions');
     $this->users = $container->get('users');
     $this->extras['startTime'] = time();
     $this->extras['memberCount'] = 0;
     $this->extras['guildCount'] = 0;
     $this->pool = new \Pool(count($this->onMessage), \Worker::class);
     $this->timers = new \Pool(count($this->onTimer), \Worker::class);
     // Init Discord and Websocket
     $this->log->addInfo('Initializing Discord and Websocket connections..');
     $this->discord = Discord::createWithBotToken($this->globalConfig->get('token', 'bot'));
     Cache::setCache(new ArrayCacheDriver());
     $this->websocket = new WebSocket($this->discord);
 }