Skip to content

Commit

Permalink
mark event params as object that can be different instance
Browse files Browse the repository at this point in the history
  • Loading branch information
SQKo committed Sep 16, 2022
1 parent a8d8093 commit 5da11f8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions docs/src/pages/api/03_events/04_guilds.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ Requires the `Intents::GUILDS` intent.

Called with a `Guild` object in one of the following situations:

1. When the Bot is first starting and the guilds are becoming available.
1. When the Bot is first starting and the guilds are becoming available. (unless the listener is put inside after 'ready' event)
2. When a guild was unavailable and is now available due to an outage.
3. When the Bot joins a new guild.

```php
$discord->on(Event::GUILD_CREATE, function ($guild, Discord $discord) {
$discord->on(Event::GUILD_CREATE, function (object $guild, Discord $discord) {
if (! ($guild instanceof Guild)) {
// the guild is unavailable due to an outage, $guild is a stdClass
// {
Expand Down Expand Up @@ -137,7 +137,7 @@ $discord->on(Event::GUILD_MEMBER_REMOVE, function (Member $member, Discord $disc
Called with two `Member` objects when a member is updated in a guild. Note that the old member _may_ be `null` if `loadAllMembers` is disabled.

```php
$discord->on(Event::GUILD_MEMBER_UPDATE, function (Member $member, Discord $discord, Member $oldMember) {
$discord->on(Event::GUILD_MEMBER_UPDATE, function (Member $member, Discord $discord, ?Member $oldMember) {
// ...
});
```
Expand Down Expand Up @@ -171,7 +171,7 @@ $discord->on(Event::GUILD_ROLE_UPDATE, function (Role $role, Discord $discord, ?
Called with a `Role` object when a role is deleted in a guild. `$role` may return `Role` object if it was cached.

```php
$discord->on(Event::GUILD_ROLE_DELETE, function ($role, Discord $discord) {
$discord->on(Event::GUILD_ROLE_DELETE, function (object $role, Discord $discord) {
if ($role instanceof Role) {
// Role is present in cache
}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/api/03_events/05_invites.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $discord->on(Event::INVITE_CREATE, function (Invite $invite, Discord $discord) {
Called with an object when an invite is created.

```php
$discord->on(Event::INVITE_DELETE, function ($invite, Discord $discord) {
$discord->on(Event::INVITE_DELETE, function (object $invite, Discord $discord) {
if ($invite instanceof Invite) {
// Invite is present in cache
}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/api/03_events/07_messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The `Message` object may be the raw payload if `storeMessages` is not enabled _o
Discord does not provide a way to get deleted messages.

```php
$discord->on(Event::MESSAGE_DELETE, function ($message, Discord $discord) {
$discord->on(Event::MESSAGE_DELETE, function (object $message, Discord $discord) {
if ($message instanceof Message) {
// Message is present in cache
}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/api/03_events/11_webhooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ title: "Webhooks"
Called with a `Guild` and `Channel` object when a guild channel's webhooks are is created, updated, or deleted.

```php
$discord->on(Event::WEBHOOKS_UPDATE, function ($guild, Discord $discord, $channel) {
$discord->on(Event::WEBHOOKS_UPDATE, function (object $guild, Discord $discord, object $channel) {
if ($guild instanceof Guild && $channel instanceof Channel) {
// Guild and Channel is present in cache
}
Expand Down

0 comments on commit 5da11f8

Please sign in to comment.