-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86b21f6
commit 2ed4eca
Showing
4 changed files
with
126 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
/* | ||
* This file is a part of the DiscordPHP project. | ||
* | ||
* Copyright (c) 2015-present David Cole <david.cole1340@gmail.com> | ||
* | ||
* 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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/* | ||
* This file is a part of the DiscordPHP project. | ||
* | ||
* Copyright (c) 2015-present David Cole <david.cole1340@gmail.com> | ||
* | ||
* 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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
/* | ||
* This file is a part of the DiscordPHP project. | ||
* | ||
* Copyright (c) 2015-present David Cole <david.cole1340@gmail.com> | ||
* | ||
* 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]; | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|