Skip to content

Commit

Permalink
Modify Event::GUILD_DELETE behavior & build docs
Browse files Browse the repository at this point in the history
  • Loading branch information
SQKo committed Aug 17, 2022
1 parent 3943958 commit 44ced1d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 5 additions & 1 deletion docs/src/pages/api/03_events/04_guilds.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ Called with a `Guild` object in one of the following situations:
2. The guild is unavailable due to an outage.

```php
$discord->on(Event::GUILD_DELETE, function (?Guild $guild, Discord $discord, bool $unavailable) {
$discord->on(Event::GUILD_DELETE, function ($guild, Discord $discord, bool $unavailable) {
// ...
if ($unavailable) {
// the guild is unavailabe due to an outage
// {
// "id": "" // guild ID
// "unavailable": true
// }
} else {
// the Bot has been kicked from the guild
}
Expand Down
2 changes: 1 addition & 1 deletion src/Discord/Discord.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Discord
*
* @var string Version.
*/
public const VERSION = 'v7.2.1';
public const VERSION = 'v7.2.2';

/**
* The logger.
Expand Down
3 changes: 1 addition & 2 deletions src/Discord/WebSockets/Events/GuildDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Discord\WebSockets\Events;

use Discord\Parts\Guild\Guild;
use Discord\WebSockets\Event;
use Discord\Helpers\Deferred;

Expand All @@ -25,6 +24,6 @@ class GuildDelete extends Event
*/
public function handle(Deferred &$deferred, $data): void
{
$deferred->resolve([$this->discord->guilds->pull($data->id), $data->unavailable ?? false]);
$deferred->resolve([$this->discord->guilds->pull($data->id) ?? $data, $data->unavailable ?? false]);
}
}

0 comments on commit 44ced1d

Please sign in to comment.