-
Notifications
You must be signed in to change notification settings - Fork 237
Guilds
Requires the Intents::GUILDS
intent.
Called with a Guild
object in one of the following situations:
- When the Bot is first starting and the guilds are becoming available. (unless the listener is put inside after 'ready' event)
- When a guild was unavailable and is now available due to an outage.
- When the Bot joins a new guild.
$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
// {
// "id": "",
// "unavailable": true,
// }
return;
}
// the Bot has joined the guild
});
Called with two Guild
objects when a guild is updated.
$discord->on(Event::GUILD_UPDATE, function (Guild $guild, Discord $discord, ?Guild $oldGuild) {
// ...
});
Called with a Guild
object in one of the following situations:
- The Bot was removed from a guild.
- The guild is unavailable due to an outage.
$discord->on(Event::GUILD_DELETE, function (object $guild, Discord $discord, bool $unavailable) {
// ...
if ($unavailable) {
// the guild is unavailabe due to an outage, $guild is a stdClass
// {
// "guild_id": "",
// "unavailable": "",
// }
} else {
// the Bot has been kicked from the guild
}
});
Requires the Intents::GUILD_MODERATION
intent and ban_members
or view_audit_log
permission.
Called with an Audit Log Entry
object when an audit log entry is created. Requires the view_audit_log
permission.
$discord->on(Event::GUILD_AUDIT_LOG_ENTRY_CREATE, function (Entry $entry, Discord $discord) {
// ...
});
Called with a Ban
object when a member is banned from a guild. Requires the ban_members
permission.
$discord->on(Event::GUILD_BAN_ADD, function (Ban $ban, Discord $discord) {
// ...
});
Called with a Ban
object when a user is unbanned from a guild. Requires the ban_members
permission.
$discord->on(Event::GUILD_BAN_REMOVE, function (Ban $ban, Discord $discord) {
// ...
});
Requires the Intents::GUILD_EMOJIS_AND_STICKERS
intent.
Called with two Collections of Emoji
objects when a guild's emojis have been added/updated/deleted. $oldEmojis
may be empty if it was not cached or there were previously no emojis.
$discord->on(Event::GUILD_EMOJIS_UPDATE, function (Collection $emojis, Discord $discord, Collection $oldEmojis) {
// ...
});
Called with two Collections of Sticker
objects when a guild's stickers have been added/updated/deleted. $oldStickers
may be empty if it was not cached or there were previously no stickers.
$discord->on(Event::GUILD_STICKERS_UPDATE, function (Collection $stickers, Discord $discord, Collecetion $oldStickers) {
// ...
});
Requires the Intents::GUILD_MEMBERS
intent. This intent is a priviliged intent, it must be enabled in your Discord Bot developer settings.
Called with a Member
object when a new user joins a guild.
$discord->on(Event::GUILD_MEMBER_ADD, function (Member $member, Discord $discord) {
// ...
});
Called with a Member
object when a member is removed from a guild (leave/kick/ban). Note that the member may only have User
data if loadAllMembers
is disabled.
$discord->on(Event::GUILD_MEMBER_REMOVE, function (Member $member, Discord $discord) {
// ...
});
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.
$discord->on(Event::GUILD_MEMBER_UPDATE, function (Member $member, Discord $discord, ?Member $oldMember) {
// ...
});
Requires the Intents::GUILDS
intent.
Called with a Role
object when a role is created in a guild.
$discord->on(Event::GUILD_ROLE_CREATE, function (Role $role, Discord $discord) {
// ...
});
Called with two Role
objects when a role is updated in a guild.
$discord->on(Event::GUILD_ROLE_UPDATE, function (Role $role, Discord $discord, ?Role $oldRole) {
// ...
});
Called with a Role
object when a role is deleted in a guild. $role
may return Role
object if it was cached.
$discord->on(Event::GUILD_ROLE_DELETE, function (object $role, Discord $discord) {
if ($role instanceof Role) {
// $role was cached
}
// $role was not in cache:
else {
// {
// "guild_id": "" // role guild ID
// "role_id": "", // role ID,
// }
}
});
Requires the Intents::GUILD_SCHEDULED_EVENTS
intent.
Called with a ScheduledEvent
object when a scheduled event is created in a guild.
$discord->on(Event::GUILD_SCHEDULED_EVENT_CREATE, function (ScheduledEvent $scheduledEvent, Discord $discord) {
// ...
});
Called with a ScheduledEvent
object when a scheduled event is updated in a guild.
$discord->on(Event::GUILD_SCHEDULED_EVENT_UPDATE, function (ScheduledEvent $scheduledEvent, Discord $discord, ?ScheduledEvent $oldScheduledEvent) {
// ...
});
Called with a ScheduledEvent
object when a scheduled event is deleted in a guild.
$discord->on(Event::GUILD_SCHEDULED_EVENT_DELETE, function (ScheduledEvent $scheduledEvent, Discord $discord) {
// ...
});
Called when a user has subscribed to a scheduled event in a guild.
$discord->on(Event::GUILD_SCHEDULED_EVENT_USER_ADD, function ($data, Discord $discord) {
// ...
});
Called when a user has unsubscribed from a scheduled event in a guild.
$discord->on(Event::GUILD_SCHEDULED_EVENT_USER_REMOVE, function ($data, Discord $discord) {
// ...
});
Requires the Intents::GUILD_INTEGRATIONS
intent.
Called with a cached Guild
object when a guild integration is updated.
$discord->on(Event::GUILD_INTEGRATIONS_UPDATE, function (object $guild, Discord $discord) {
if ($guild instanceof Guild) {
// $guild was cached
}
// $guild was not in cache:
else {
// {
// "guild_id": "",
// }
}
});
Called with an Integration
object when an integration is created in a guild.
$discord->on(Event::INTEGRATION_CREATE, function (Integration $integration, Discord $discord) {
// ...
});
Called with an Integration
object when a integration is updated in a guild.
$discord->on(Event::INTEGRATION_UPDATE, function (Integration $integration, Discord $discord, ?Integration $oldIntegration) {
// ...
});
Called with an old Integration
object when a integration is deleted from a guild.
$discord->on(Event::INTEGRATION_DELETE, function (object $integration, Discord $discord) {
if ($integration instanceof Integration) {
// $integration was cached
}
// $integration was not in cache:
else {
// {
// "id": "",
// "guild_id": "",
// "application_id": ""
// }
}
});
Note: This wiki is currently Work In Progress. Consider reading the docs instead.
- Application Command (Slash based)
Command Client (Message based)
- Activity
- Application
- Guild
- Private Channel
- User
Components
-
ActionRow
- Buttons
- Option (commands)
- SelectMenu
- TextInput
Builders