Ejemplo n.º 1
0
 /**
  *
  */
 public function listen()
 {
     $this->discord->on(Event::GUILD_CREATE, function (Guild $guild) {
         $this->managerFactory->create($guild);
     });
     $this->discord->on(Event::MESSAGE_CREATE, [$this, 'onMessageCreate']);
     $this->discord->on(Event::CHANNEL_CREATE, function (Channel $channel) {
         $this->emitServerEvent($channel->guild, 'channelCreate', $channel);
     });
     $this->discord->on(Event::CHANNEL_UPDATE, function (Channel $channel, Discord $discord, Channel $oldChannel) {
         $this->emitServerEvent($channel->guild, 'channelUpdate', $channel, $oldChannel);
     });
     $this->discord->on(Event::CHANNEL_DELETE, function (Channel $channel) {
         $this->emitServerEvent($channel->guild, 'channelDelete', $channel);
     });
     $this->discord->on(Event::GUILD_BAN_ADD, function (Ban $ban) {
         $this->emitServerEvent($ban->guild, 'ban', $ban);
     });
     $this->discord->on(Event::GUILD_BAN_REMOVE, function (Ban $ban) {
         $this->emitServerEvent($ban->guild, 'unban', $ban);
     });
     $this->discord->on(Event::GUILD_DELETE, function (Guild $guild) {
         $this->emitServerEvent($guild, 'serverDelete', $guild);
     });
     $this->discord->on(Event::GUILD_MEMBER_ADD, function (Member $member) {
         $guild = $this->discord->guilds->get('id', $member->guild_id);
         $this->emitServerEvent($guild, 'memberCreate', $member);
     });
     $this->discord->on(Event::GUILD_MEMBER_REMOVE, function (Member $member) {
         $guild = $this->discord->guilds->get('id', $member->guild_id);
         $this->emitServerEvent($guild, 'memberDelete', $member);
     });
     $this->discord->on(Event::GUILD_MEMBER_UPDATE, function (Member $member, Discord $discord, Member $oldMember) {
         $guild = $this->discord->guilds->get('id', $member->guild_id);
         $this->emitServerEvent($guild, 'memberUpdate', $member, $oldMember);
     });
     $this->discord->on(Event::GUILD_ROLE_CREATE, function (Role $role) {
         $guild = $this->discord->guilds->get('id', $role->guild_id);
         $this->emitServerEvent($guild, 'roleCreate', $role);
     });
     $this->discord->on(Event::GUILD_ROLE_DELETE, function (Role $role) {
         $guild = $this->discord->guilds->get('id', $role->guild_id);
         $this->emitServerEvent($guild, 'roleDelete', $role);
     });
     $this->discord->on(Event::GUILD_ROLE_UPDATE, function (Role $role, Discord $discord, Role $oldRole) {
         $guild = $this->discord->guilds->get('id', $role->guild_id);
         $this->emitServerEvent($guild, 'roleUpdate', $role, $oldRole);
     });
     $this->discord->on(Event::GUILD_UPDATE, function (Guild $guild, Discord $discord, Guild $oldGuild) {
         $this->emitServerEvent($guild, 'serverUpdate', $guild, $oldGuild);
     });
     $this->discord->on(Event::MESSAGE_DELETE, function ($message) {
         if ($message instanceof Message) {
             $this->emitServerEvent($message->channel->guild, 'messageDelete', $message);
         }
     });
     $this->discord->on(Event::MESSAGE_UPDATE, function (Message $message, Discord $discord, Message $oldMessage) {
         $this->emitServerEvent($message->channel->guild, 'messageUpdate', $message, $oldMessage);
     });
     $this->discord->on(Event::PRESENCE_UPDATE, function (PresenceUpdate $presenceUpdate, Discord $discord, PresenceUpdate $oldPresenceUpdate) {
         $this->emitServerEvent($presenceUpdate->guild, 'presenceUpdate', $presenceUpdate, $oldPresenceUpdate);
     });
     $this->discord->on(Event::TYPING_START, function (TypingStart $typingStart) {
         $this->emitServerEvent($typingStart->channel->guild, 'typingStart', $typingStart);
     });
     $this->discord->on(Event::VOICE_STATE_UPDATE, function (VoiceStateUpdate $voiceStateUpdate) {
         $this->emitServerEvent($voiceStateUpdate->guild, 'voiceStateUpdate', $voiceStateUpdate);
     });
 }
Ejemplo n.º 2
0
 /**
  * Will add the services for the WebSocket.
  *
  * @param Service[] $services
  *
  * @return void
  */
 private function setServices($services)
 {
     foreach ($services as $service) {
         $this->discord->on($service->getEvent(), $service->getListener());
     }
 }