+ $activity = new Activity($discord);
+ $activity->type = Activity::TYPE_LISTENING;
+ $activity->name = 'HolySmoke';
+ $activity->url = 'https://alttp.localhorst.tv/';
+ $discord->updatePresence($activity);
+
+ $discord->getLoop()->addPeriodicTimer(1, function () use ($discord) {
+ $command = CommandModel::where('status', '=', 'pending')->oldest()->first();
+ if ($command) {
+ try {
+ $command->execute($discord);
+ } catch (\Exception $e) {
+ }
+ }
+ });
+
+ if (config('discord.enable_commands')) {
+ AosrPresetCommand::listen($discord);
+ }
+ if (config('discord.create_commands')) {
+ AosrPresetCommand::create($discord);
+ }
+ });
+ $discord->on(Event::GUILD_CREATE, function (Guild $guild, Discord $discord) {
+ try {
+ DiscordGuild::onUpstreamCreate($guild);
+ } catch (\Exception $e) {
+ $this->error('guild create: '.$e->getMessage());
+ }
+ });
+ $discord->on(Event::GUILD_UPDATE, function (Guild $guild, Discord $discord, ?Guild $old) {
+ try {
+ DiscordGuild::onUpstreamUpdate($guild);
+ } catch (\Exception $e) {
+ $this->error('guild update: '.$e->getMessage());
+ }
+ });
+ $discord->on(Event::CHANNEL_CREATE, function (Channel $channel, Discord $discord) {
+ try {
+ DiscordChannel::onUpstreamCreate($channel);
+ } catch (\Exception $e) {
+ $this->error('channel create: '.$e->getMessage());
+ }
+ });
+ $discord->on(Event::CHANNEL_UPDATE, function (Channel $channel, Discord $discord, ?Channel $old) {
+ try {
+ DiscordChannel::onUpstreamUpdate($channel);
+ } catch (\Exception $e) {
+ $this->error('channel update: '.$e->getMessage());
+ }
+ });
+ $discord->on(Event::CHANNEL_DELETE, function ($channel, Discord $discord) {
+ try {
+ DiscordChannel::onUpstreamDelete($channel);
+ } catch (\Exception $e) {
+ $this->error('channel delete: '.$e->getMessage());
+ }
+ });
+ $discord->on(Event::GUILD_ROLE_CREATE, function (Role $role, Discord $discord) {
+ try {
+ DiscordRole::onUpstreamCreate($role);
+ } catch (\Exception $e) {
+ $this->error('guild role create: '.$e->getMessage());
+ }
+ });
+ $discord->on(Event::GUILD_ROLE_UPDATE, function (Role $role, Discord $discord, ?Role $old) {
+ try {
+ DiscordRole::onUpstreamUpdate($role);
+ } catch (\Exception $e) {
+ $this->error('guild role update: '.$e->getMessage());
+ }
+ });
+ $discord->on(Event::GUILD_ROLE_DELETE, function ($role, Discord $discord) {
+ try {
+ DiscordRole::onUpstreamDelete($role);
+ } catch (\Exception $e) {
+ $this->error('guild role delete: '.$e->getMessage());
+ }