diff --git a/src/Discord/Discord.php b/src/Discord/Discord.php index 9c6b276ea..707d0107f 100644 --- a/src/Discord/Discord.php +++ b/src/Discord/Discord.php @@ -74,8 +74,12 @@ * @property bool $bot Whether the client is a bot. * @property User $user The user instance of the client. * @property Application $application The OAuth2 application of the bot. + + * @property EntitlementRepository $entitlements + * @property EmojiRepository $emojis * @property GuildRepository $guilds * @property PrivateChannelRepository $private_channels + * @property SKUsRepository $skus * @property UserRepository $users * @property EmojiRepository $emojis */ diff --git a/src/Discord/Parts/Entitlements/Entitlement.php b/src/Discord/Parts/Entitlements/Entitlement.php new file mode 100644 index 000000000..38cbdeb5e --- /dev/null +++ b/src/Discord/Parts/Entitlements/Entitlement.php @@ -0,0 +1,156 @@ + + * + * This file is subject to the MIT license that is bundled + * with this source code in the LICENSE.md file. + */ + +namespace Discord\Parts\Entitlements; + +use Carbon\Carbon; +use Discord\Http\Endpoint; +use Discord\Parts\Part; +use Discord\Parts\User\User; +use Discord\Parts\Guild\Guild; +use React\Promise\ExtendedPromiseInterface; + +/** + * An entitlement object represents a premium offering in the application that a user or guild has access to. + * + * @link https://discord.com/developers/docs/resources/entitlement + * + * @since 10.0.0 + * + * @property string $id ID of the entitlement. + * @property string $sku_id ID of the SKU. + * @property string $application_id ID of the parent application. + * @property string|null $user_id ID of the user that is granted access to the entitlement's SKU. + * @property int $type Type of entitlement. + * @property bool $deleted Entitlement was deleted. + * @property Carbon|null $starts_at Start date at which the entitlement is valid. + * @property Carbon|null $ends_at Date at which the entitlement is no longer valid. + * @property string|null $guild_id ID of the guild that is granted access to the entitlement's SKU. + * @property bool|null $consumed For consumable items, whether or not the entitlement has been consumed. + * @property-read Guild|null $guild The guild that is granted access to the entitlement's SKU. + * @property-read User|null $user The user that is granted access to the entitlement's SKU. + */ +class Entitlement extends Part +{ + public const OWNER_TYPE_GUILD = 1; + public const OWNER_TYPE_USER = 2; + + public const TYPE_PURCHASE = 1; + public const TYPE_PREMIUM_SUBSCRIPTION = 2; + public const TYPE_DEVELOPER_GIFT = 3; + public const TYPE_TEST_MODE_PURCHASE = 4; + public const TYPE_FREE_PURCHASE = 5; + public const TYPE_USER_GIFT = 6; + public const TYPE_PREMIUM_PURCHASE = 7; + public const TYPE_APPLICATION_SUBSCRIPTION = 8; + + /** + * {@inheritDoc} + */ + protected $fillable = [ + 'id', + 'sku_id', + 'application_id', + 'user_id', + 'type', + 'deleted', + 'starts_at', + 'ends_at', + 'guild_id', + 'consumed', + + // @internal + 'guild', + 'user', + ]; + + /** + * Returns the guild attribute that is granted access to the entitlement's sku. + * + * @return Guild|null + */ + protected function getGuildAttribute(): ?Guild + { + return $this->discord->guilds->get('id', $this->guild_id); + } + + /** + * Gets the user that is granted access to the entitlement's sku. + * + * @return User|null + */ + protected function getUserAttribute(): ?User + { + return $this->discord->users->get('id', $this->user_id); + } + + /** + * {@inheritDoc} + */ + public function getRepositoryAttributes(): array + { + return [ + 'application_id' => $this->application_id, + 'entitlement_id' => $this->id, + ]; + } + + /** + * Returns the starts at attribute. + * + * @return Carbon|null The time that the invite was created. + * + * @throws \Exception + */ + protected function getStartsAtAttribute(): ?Carbon + { + if (! isset($this->attributes['starts_at'])) { + return null; + } + + return new Carbon($this->attributes['starts_at']); + } + + /** + * Returns the ends at attribute. + * + * @return Carbon|null The time that the invite was created. + * + * @throws \Exception + */ + protected function getEndsAtAttribute(): ?Carbon + { + if (! isset($this->attributes['ends_at'])) { + return null; + } + + return new Carbon($this->attributes['ends_at']); + } + + /** + * Consumes an entitlement. + * + * For One-Time Purchase consumable SKUs, marks a given entitlement for the user as consumed. + * The entitlement will have consumed: true when using List Entitlements. + * + * @param Entitlement $part + * + * @return ExtendedPromiseInterface A promise that resolves to an Entitlement object. + */ + public function consume(Entitlement $part): ExtendedPromiseInterface + { + return $this->http->post(Endpoint::bind(Endpoint::APPLICATION_ENTITLEMENT_CONSUME, $this->application_id, $part->id)) + ->then(function ($response) use ($part) { // Returns a 204 No Content on success. + $part->consumed = true; + return $part; + }); + } +} diff --git a/src/Discord/Parts/Entitlements/SKU.php b/src/Discord/Parts/Entitlements/SKU.php new file mode 100644 index 000000000..e92592957 --- /dev/null +++ b/src/Discord/Parts/Entitlements/SKU.php @@ -0,0 +1,82 @@ + + * + * This file is subject to the MIT license that is bundled + * with this source code in the LICENSE.md file. + */ + +namespace Discord\Parts\Entitlements; + +use Discord\Parts\Part; + +/** + * An SKU object represents a premium offering in the application that a user or guild can purchase. + * + * @link https://discord.com/developers/docs/resources/sku + * + * @since 10.0.0 + * + * @property string $id ID of the SKU. + * @property int $type Type of SKU. + * @property string $application_id ID of the parent application. + * @property string $name Customer-facing name of the premium offering. + * @property string $slug System-generated URL slug based on the SKU's name. + * @property int $flags SKU flags combined as a bitfield. + */ +class SKU extends Part +{ + public const TYPE_DURABLE = 2; + public const TYPE_CONSUMABLE = 3; + public const TYPE_SUBSCRIPTION = 5; + public const TYPE_SUBSCRIPTION_GROUP = 6; + + public const FLAG_AVAILABLE = 1 << 2; + public const FLAG_GUILD_SUBSCRIPTION = 1 << 7; + public const FLAG_USER_SUBSCRIPTION = 1 << 8; + + /** + * {@inheritDoc} + */ + protected $fillable = [ + 'id', + 'type', + 'application_id', + 'name', + 'slug', + 'flags', + ]; + + /** + * Checks if the SKU is available for purchase. + * + * @return bool + */ + public function isAvailable(): bool + { + return ($this->flags & self::FLAG_AVAILABLE) === self::FLAG_AVAILABLE; + } + + /** + * Checks if the SKU is a guild subscription. + * + * @return bool + */ + public function isGuildSubscription(): bool + { + return ($this->flags & self::FLAG_GUILD_SUBSCRIPTION) === self::FLAG_GUILD_SUBSCRIPTION; + } + + /** + * Checks if the SKU is a user subscription. + * + * @return bool + */ + public function isUserSubscription(): bool + { + return ($this->flags & self::FLAG_USER_SUBSCRIPTION) === self::FLAG_USER_SUBSCRIPTION; + } +} diff --git a/src/Discord/Parts/Guild/Guild.php b/src/Discord/Parts/Guild/Guild.php index 323542598..2dc244804 100644 --- a/src/Discord/Parts/Guild/Guild.php +++ b/src/Discord/Parts/Guild/Guild.php @@ -23,6 +23,7 @@ use Discord\Parts\Part; use Discord\Parts\User\Member; use Discord\Parts\User\User; +use Discord\Repository\EntitlementRepository; use Discord\Repository\Guild\BanRepository; use Discord\Repository\Guild\ChannelRepository; use Discord\Repository\Guild\EmojiRepository; @@ -141,6 +142,7 @@ * * @property AutoModerationRuleRepository $auto_moderation_rules * @property BanRepository $bans + * @property EntitlementRepository $entitlements * @property GuildCommandRepository $commands * @property CommandPermissionsRepository $command_permissions * @property IntegrationRepository $integrations @@ -286,6 +288,7 @@ class Guild extends Part */ protected $repositories = [ 'roles' => RoleRepository::class, + 'entitlements' => EntitlementRepository::class, 'emojis' => EmojiRepository::class, 'stickers' => StickerRepository::class, 'members' => MemberRepository::class, diff --git a/src/Discord/Parts/User/Client.php b/src/Discord/Parts/User/Client.php index 5b4532914..92d1f36ff 100644 --- a/src/Discord/Parts/User/Client.php +++ b/src/Discord/Parts/User/Client.php @@ -15,9 +15,11 @@ use Discord\Http\Endpoint; use Discord\Parts\OAuth\Application; use Discord\Parts\Part; +use Discord\Repository\EntitlementRepository; use Discord\Repository\EmojiRepository; use Discord\Repository\GuildRepository; use Discord\Repository\PrivateChannelRepository; +use Discord\Repository\SKUsRepository; use Discord\Repository\SoundRepository; use Discord\Repository\UserRepository; use React\Promise\ExtendedPromiseInterface; @@ -42,9 +44,11 @@ * @property User $user The user instance of the client. * @property Application $application The OAuth2 application of the bot. * + * @property EntitlementRepository $entitlements * @property EmojiRepository $emojis * @property GuildRepository $guilds * @property PrivateChannelRepository $private_channels + * @property SKUsRepository $skus * @property SoundRepository $sounds * @property UserRepository $users */ @@ -75,9 +79,11 @@ class Client extends Part * {@inheritDoc} */ protected $repositories = [ + 'entitlements' => EntitlementRepository::class, 'emojis' => EmojiRepository::class, 'guilds' => GuildRepository::class, 'private_channels' => PrivateChannelRepository::class, + 'skus' => SKUsRepository::class, 'sounds' => SoundRepository::class, 'users' => UserRepository::class, ]; diff --git a/src/Discord/Repository/Entitlements/EntitlementRepository.php b/src/Discord/Repository/Entitlements/EntitlementRepository.php new file mode 100644 index 000000000..7bb02955b --- /dev/null +++ b/src/Discord/Repository/Entitlements/EntitlementRepository.php @@ -0,0 +1,126 @@ + + * + * This file is subject to the MIT license that is bundled + * with this source code in the LICENSE.md file. + */ + +namespace Discord\Repository; + +use Discord\Discord; +use Discord\Http\Endpoint; +use Discord\Parts\Entitlements\Entitlement; +use React\Promise\ExtendedPromiseInterface; + + +use function React\Promise\resolve; + +/** + * Contains entitlements of an application. + * + * @see Entitlement + * @see \Discord\Parts\User\Client + * + * @since 10.0.0 + * + * @method Entitlement|null get(string $discrim, $key) + * @method Entitlement|null pull(string|int $key, $default = null) + * @method Entitlement|null first() + * @method Entitlement|null last() + * @method Entitlement|null find(callable $callback) + */ +class EntitlementRepository extends AbstractRepository +{ + /** + * {@inheritDoc} + */ + protected $endpoints = [ + 'all' => Endpoint::APPLICATION_ENTITLEMENTS, + 'get' => Endpoint::APPLICATION_ENTITLEMENT, + 'create' => Endpoint::APPLICATION_ENTITLEMENTS, + 'delete' => Endpoint::APPLICATION_ENTITLEMENT, + ]; + + /** + * {@inheritDoc} + */ + protected $class = Entitlement::class; + + /** + * {@inheritDoc} + */ + public function __construct(Discord $discord, array $vars = []) + { + $vars['application_id'] = $discord->application->id; + + parent::__construct($discord, $vars); + } + + /** + * @param object $response + * + * @return ExtendedPromiseInterface + */ + protected function cacheFreshen($response): ExtendedPromiseInterface + { + foreach ($response as $value) foreach ($value as $value) { + $value = array_merge($this->vars, (array) $value); + $part = $this->factory->create($this->class, $value, true); + $items[$part->{$this->discrim}] = $part; + } + + if (empty($items)) { + return resolve($this); + } + + return $this->cache->setMultiple($items)->then(fn ($success) => $this); + } + + /** + * Creates a test entitlement to a given SKU for a given guild or user. + * + * @param string $sku_id ID of the SKU to grant the entitlement to. + * @param string $owner_id ID of the guild or user to grant the entitlement to. + * @param int $owner_type 1 for a guild subscription, 2 for a user subscription. + * + * @throws \InvalidArgumentException + * + * @return ExtendedPromiseInterface + */ + public function createTestEntitlement(string $sku_id, string $owner_id, int $owner_type): ExtendedPromiseInterface + { + $allowed_owner_types = [Entitlement::OWNER_TYPE_GUILD, Entitlement::OWNER_TYPE_USER]; + + if (! in_array($owner_type, $allowed_owner_types)) { + throw new \InvalidArgumentException("The given owner type `{$owner_type}` is not valid."); + } + + $payload = [ + 'sku_id' => $sku_id, + 'owner_id' => $owner_id, + 'owner_type' => $owner_type, + ]; + + return $this->http->post(new Endpoint(Endpoint::APPLICATION_ENTITLEMENT), $payload) + ->then(fn ($response) => $this->factory->create($this->class, (array) $response, true)); + } + + /* + * Deletes a currently-active test entitlement. + * Discord will act as though that user or guild no longer has entitlement to your premium offering. + * + * @param Entitlement $part + * + * @return ExtendedPromiseInterface + */ + public function deleteTestEntitlement(Entitlement $part): ExtendedPromiseInterface + { + return $this->http->delete(Endpoint::bind(Endpoint::APPLICATION_ENTITLEMENT, ['application_id' => $part->application_id, 'entitlement_id' => $part->id])) + ->then(fn ($response) => $this->cache->delete($part->{$this->discrim}) + ->then(fn ($success) => $part)); + } +} diff --git a/src/Discord/Repository/Entitlements/SKUsRepository.php b/src/Discord/Repository/Entitlements/SKUsRepository.php new file mode 100644 index 000000000..38d5a22cf --- /dev/null +++ b/src/Discord/Repository/Entitlements/SKUsRepository.php @@ -0,0 +1,78 @@ + + * + * This file is subject to the MIT license that is bundled + * with this source code in the LICENSE.md file. + */ + +namespace Discord\Repository; + +use Discord\Discord; +use Discord\Http\Endpoint; +use Discord\Parts\Entitlements\SKU; +use React\Promise\ExtendedPromiseInterface; + +use function React\Promise\resolve; + +/** + * Contains SKUs of an application. + * + * @see SKU + * @see \Discord\Parts\User\Client + * + * @since 10.0.0 + * + * @method SKU|null get(string $discrim, $key) + * @method SKU|null pull(string|int $key, $default = null) + * @method SKU|null first() + * @method SKU|null last() + * @method SKU|null find(callable $callback) + */ +class SKUsRepository extends AbstractRepository +{ + /** + * {@inheritDoc} + */ + protected $endpoints = [ + 'all' => Endpoint::APPLICATION_SKUS, + ]; + + /** + * {@inheritDoc} + */ + protected $class = SKU::class; + + /** + * {@inheritDoc} + */ + public function __construct(Discord $discord, array $vars = []) + { + $vars['application_id'] = $discord->application->id; + + parent::__construct($discord, $vars); + } + + /** + * @param object $response + * + * @return ExtendedPromiseInterface + */ + protected function cacheFreshen($response): ExtendedPromiseInterface + { + foreach ($response as $value) foreach ($value as $value) { + $value = array_merge($this->vars, (array) $value); + $part = $this->factory->create($this->class, $value, true); + $items[$part->{$this->discrim}] = $part; + } + + if (empty($items)) { + return resolve($this); + } + + return $this->cache->setMultiple($items)->then(fn ($success) => $this); + } +} diff --git a/src/Discord/WebSockets/Event.php b/src/Discord/WebSockets/Event.php index 05338b16c..23e57e91a 100644 --- a/src/Discord/WebSockets/Event.php +++ b/src/Discord/WebSockets/Event.php @@ -115,6 +115,15 @@ abstract class Event public const MESSAGE_POLL_VOTE_ADD = 'MESSAGE_POLL_VOTE_ADD'; public const MESSAGE_POLL_VOTE_REMOVE = 'MESSAGE_POLL_VOTE_REMOVE'; + // Entitlements and SKUs + public const ENTITLEMENT_CREATE = 'ENTITLEMENT_CREATE'; + public const ENTITLEMENT_UPDATE = 'ENTITLEMENT_UPDATE'; + public const ENTITLEMENT_DELETE = 'ENTITLEMENT_DELETE'; + + public const SUBSCRIPTION_CREATE = 'SUBSCRIPTION_CREATE'; + public const SUBSCRIPTION_UPDATE = 'SUBSCRIPTION_UPDATE'; + public const SUBSCRIPTION_DELETE = 'SUBSCRIPTION_DELETE'; + /** * The Discord client instance. * diff --git a/src/Discord/WebSockets/Events/EntitlementCreate.php b/src/Discord/WebSockets/Events/EntitlementCreate.php new file mode 100644 index 000000000..4658e1bb4 --- /dev/null +++ b/src/Discord/WebSockets/Events/EntitlementCreate.php @@ -0,0 +1,46 @@ + + * + * This file is subject to the MIT license that is bundled + * with this source code in the LICENSE.md file. + */ + +namespace Discord\WebSockets\Events; + +use Discord\Parts\Guild\Guild; +use Discord\Parts\Entitlements\Entitlement; +use Discord\WebSockets\Event; + +/** + * @link https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-create + * + * @since 10.0.0 + */ +class EntitlementCreate extends Event +{ + /** + * {@inheritDoc} + */ + public function handle($data) + { + /** @var Entitlement */ + $entitlementPart = $this->factory->part(Entitlement::class, (array) $data, true); + + if (isset($data->guild_id)) { + /** @var Guild|null */ + $guild = yield $this->discord->guilds->cacheGet($data->guild_id); + if ($guild instanceof Guild) { + $guild->entitlements->set($data->id, $entitlementPart); + return $entitlementPart; + } + } + + $this->discord->entitlements->set($data->id, $entitlementPart); + + return $entitlementPart; + } +} diff --git a/src/Discord/WebSockets/Events/EntitlementDelete.php b/src/Discord/WebSockets/Events/EntitlementDelete.php new file mode 100644 index 000000000..fb67d0d85 --- /dev/null +++ b/src/Discord/WebSockets/Events/EntitlementDelete.php @@ -0,0 +1,34 @@ + + * + * This file is subject to the MIT license that is bundled + * with this source code in the LICENSE.md file. + */ + +namespace Discord\WebSockets\Events; + +use Discord\Parts\Entitlements\Entitlement; +use Discord\WebSockets\Event; + +/** + * @link https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-delete + * + * @since 10.0.0 + */ +class EntitlementDelete extends Event +{ + /** + * {@inheritDoc} + */ + public function handle($data) + { + /** @var ?Entitlement */ + $entitlementPart = yield $this->discord->entitlements->cachePull($data->id); + + return $entitlementPart ?? $this->factory->part(Entitlement::class, (array) $data); + } +} diff --git a/src/Discord/WebSockets/Events/EntitlementUpdate.php b/src/Discord/WebSockets/Events/EntitlementUpdate.php new file mode 100644 index 000000000..857fde068 --- /dev/null +++ b/src/Discord/WebSockets/Events/EntitlementUpdate.php @@ -0,0 +1,68 @@ + + * + * This file is subject to the MIT license that is bundled + * with this source code in the LICENSE.md file. + */ + +namespace Discord\WebSockets\Events; + +use Discord\Parts\Guild\Guild; +use Discord\Parts\Entitlements\Entitlement; +use Discord\WebSockets\Event; + +/** + * @link https://discord.com/developers/docs/topics/gateway-events#guild-entitlementboard-entitlement-update + * + * @since 10.0.0 + */ +class EntitlementUpdate extends Event +{ + /** + * {@inheritDoc} + */ + public function handle($data) + { + $newEntitlementPart = $oldEntitlementPart = null; + + if (isset($data->guild_id)) { + /** @var Guild|null */ + $guild = yield $this->discord->guilds->cacheGet($data->guild_id); + if ($guild instanceof Guild) { + /** @var ?Entitlement */ + $oldEntitlementPart = yield $guild->entitlements->cacheGet($data->id); + if ($oldEntitlementPart instanceof Entitlement) { + $newEntitlementPart = clone $oldEntitlementPart; + $newEntitlementPart->fill((array) $data); + } + $guild->entitlements->set($data->id, $newEntitlementPart ?? $this->factory->part(Entitlement::class, (array) $data, true)); + } + } else { + /** @var ?Entitlement */ + $oldEntitlementPart = yield $this->discord->entitlements->cacheGet($data->id); + if ($oldEntitlementPart instanceof Entitlement) { + $newEntitlementPart = clone $oldEntitlementPart; + $newEntitlementPart->fill((array) $data); + } + } + + /** @var Entitlement */ + $newEntitlementPart = $newEntitlementPart ?? $this->factory->part(Entitlement::class, (array) $data, true); + + $this->discord->entitlements->set($data->id, $newEntitlementPart); + + return [$newEntitlementPart, $oldEntitlementPart]; + } +} + + + + + + + + diff --git a/src/Discord/WebSockets/Events/SubscriptionCreate.php b/src/Discord/WebSockets/Events/SubscriptionCreate.php new file mode 100644 index 000000000..aefcc0f66 --- /dev/null +++ b/src/Discord/WebSockets/Events/SubscriptionCreate.php @@ -0,0 +1,37 @@ + + * + * This file is subject to the MIT license that is bundled + * with this source code in the LICENSE.md file. + */ + +namespace Discord\WebSockets\Events; + +use Discord\Parts\Guild\Guild; +use Discord\Parts\Entitlements\SKU; +use Discord\WebSockets\Event; + +/** + * @link https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-create + * + * @since 10.0.0 + */ +class SKUCreate extends Event +{ + /** + * {@inheritDoc} + */ + public function handle($data) + { + /** @var SKU */ + $SKUPart = $this->factory->part(SKU::class, (array) $data, true); + + $this->discord->skus->set($data->id, $SKUPart); + + return $SKUPart; + } +} diff --git a/src/Discord/WebSockets/Events/SubscriptionDelete.php b/src/Discord/WebSockets/Events/SubscriptionDelete.php new file mode 100644 index 000000000..d0eef05d7 --- /dev/null +++ b/src/Discord/WebSockets/Events/SubscriptionDelete.php @@ -0,0 +1,34 @@ + + * + * This file is subject to the MIT license that is bundled + * with this source code in the LICENSE.md file. + */ + +namespace Discord\WebSockets\Events; + +use Discord\Parts\Entitlements\SKU; +use Discord\WebSockets\Event; + +/** + * @link https://discord.com/developers/docs/topics/gateway-events#guild-soundboard-sound-delete + * + * @since 10.0.0 + */ +class SKUDelete extends Event +{ + /** + * {@inheritDoc} + */ + public function handle($data) + { + /** @var ?SKU */ + $SKUPart = yield $this->discord->skus->cachePull($data->id); + + return $SKUPart ?? $this->factory->part(SKU::class, (array) $data); + } +} diff --git a/src/Discord/WebSockets/Events/SubscriptionUpdate.php b/src/Discord/WebSockets/Events/SubscriptionUpdate.php new file mode 100644 index 000000000..76311b745 --- /dev/null +++ b/src/Discord/WebSockets/Events/SubscriptionUpdate.php @@ -0,0 +1,54 @@ + + * + * This file is subject to the MIT license that is bundled + * with this source code in the LICENSE.md file. + */ + +namespace Discord\WebSockets\Events; + +use Discord\Parts\Guild\Guild; +use Discord\Parts\Entitlements\SKU; +use Discord\WebSockets\Event; + +/** + * @link https://discord.com/developers/docs/topics/gateway-events#guild-SKUboard-SKU-update + * + * @since 10.0.0 + */ +class SKUUpdate extends Event +{ + /** + * {@inheritDoc} + */ + public function handle($data) + { + $newSKUPart = $oldSKUPart = null; + + /** @var ?SKU */ + $oldSKUPart = yield $this->discord->skus->cacheGet($data->id); + if ($oldSKUPart instanceof SKU) { + $newSKUPart = clone $oldSKUPart; + $newSKUPart->fill((array) $data); + } + + /** @var SKU */ + $newSKUPart = $newSKUPart ?? $this->factory->part(SKU::class, (array) $data, true); + + $this->discord->skus->set($data->id, $newSKUPart); + + return [$newSKUPart, $oldSKUPart]; + } +} + + + + + + + + diff --git a/src/Discord/WebSockets/Handlers.php b/src/Discord/WebSockets/Handlers.php index 26b994ddb..d551f1372 100644 --- a/src/Discord/WebSockets/Handlers.php +++ b/src/Discord/WebSockets/Handlers.php @@ -117,6 +117,15 @@ public function __construct() $this->addHandler(Event::AUTO_MODERATION_RULE_UPDATE, \Discord\WebSockets\Events\AutoModerationRuleUpdate::class); $this->addHandler(Event::AUTO_MODERATION_RULE_DELETE, \Discord\WebSockets\Events\AutoModerationRuleDelete::class); $this->addHandler(Event::AUTO_MODERATION_ACTION_EXECUTION, \Discord\WebSockets\Events\AutoModerationActionExecution::class); + + // Entitlement Event Handlers + $this->addHandler(Event::ENTITLEMENT_CREATE, \Discord\WebSockets\Events\EntitlementCreate::class); + $this->addHandler(Event::ENTITLEMENT_UPDATE, \Discord\WebSockets\Events\EntitlementUpdate::class); + $this->addHandler(Event::ENTITLEMENT_DELETE, \Discord\WebSockets\Events\EntitlementDelete::class); + + $this->addHandler(Event::SUBSCRIPTION_CREATE, \Discord\WebSockets\Events\SubscriptionCreate::class); + $this->addHandler(Event::SUBSCRIPTION_UPDATE, \Discord\WebSockets\Events\SubscriptionUpdate::class); + $this->addHandler(Event::SUBSCRIPTION_DELETE, \Discord\WebSockets\Events\SubscriptionDelete::class); } /**