Events
Class · Sharkord\Events
Class Events
Centralised registry of every event name emitted by the SharkordPHP framework.
Use these constants anywhere you register a listener via {@see \Sharkord\Sharkord::on()} to benefit from IDE autocompletion, static analysis, and a single source of truth for event name strings.
Each constant’s value is the exact string passed to {@see \Evenement\EventEmitter::emit()} internally, so the two styles are always interchangeable:
$sharkord->on('message', $handler);$sharkord->on(Events::MESSAGE_CREATE, $handler);Constants
Section titled “Constants”Value 'ready'
Fired once the bot has fully connected, hydrated its caches, and is ready to receive and dispatch events.
Callback signature: function(\Sharkord\Models\User $bot): void
Example
$sharkord->on(Events::READY, function(\Sharkord\Models\User $bot): void { echo "Logged in as {$bot->name}!";});MESSAGE_CREATE
Section titled “MESSAGE_CREATE”Value 'message'
Fired when a new message is posted to any channel.
Callback signature: function(\Sharkord\Models\Message $message): void
Example
$sharkord->on(Events::MESSAGE_CREATE, function(\Sharkord\Models\Message $message): void { echo "{$message->author->name}: {$message->content}";});MESSAGE_UPDATE
Section titled “MESSAGE_UPDATE”Value 'messageupdate'
Fired when an existing message is edited.
Callback signature: function(\Sharkord\Models\Message $message): void
Example
$sharkord->on(Events::MESSAGE_UPDATE, function(\Sharkord\Models\Message $message): void { echo "Message {$message->id} was updated.";});MESSAGE_DELETE
Section titled “MESSAGE_DELETE”Value 'messagedelete'
Fired when a message is deleted.
Because the message no longer exists on the server, the full model cannot
be reconstructed. The raw payload array is passed directly instead.
The array is guaranteed to contain a scalar id key; channelId is
present where the server includes it but must be treated as optional.
Callback signature: function(array $data): void
Example
$sharkord->on(Events::MESSAGE_DELETE, function(array $data): void { $messageId = $data['id']; $channelId = $data['channelId'] ?? null; echo "Message {$messageId} was deleted" . ($channelId ? " from channel {$channelId}" : '') . '.';});MESSAGE_REACTION
Section titled “MESSAGE_REACTION”Value 'messagereaction'
Fired when the reaction set on a message changes.
Only emitted when a messageupdate payload contains a reactions key
and the reaction data has actually changed since the previous state.
Callback signature:
function(\Sharkord\Models\Message $message, array $reactions): void
Example
$sharkord->on(Events::MESSAGE_REACTION, function( \Sharkord\Models\Message $message, array $reactions,): void { echo "Message {$message->id} reactions updated.";});MESSAGE_TYPING
Section titled “MESSAGE_TYPING”Value 'messagetyping'
Fired when a user begins typing in a channel.
Both the User and Channel must be resolvable from cache; if either
is missing the event is silently dropped.
Callback signature:
function(\Sharkord\Models\User $user, \Sharkord\Models\Channel $channel): void
Example
$sharkord->on(Events::MESSAGE_TYPING, function( \Sharkord\Models\User $user, \Sharkord\Models\Channel $channel,): void { echo "{$user->name} is typing in #{$channel->name}...";});CHANNEL_CREATE
Section titled “CHANNEL_CREATE”Value 'channelcreate'
Fired when a new channel is created.
Callback signature: function(\Sharkord\Models\Channel $channel): void
Example
$sharkord->on(Events::CHANNEL_CREATE, function(\Sharkord\Models\Channel $channel): void { echo "Channel #{$channel->name} was created.";});CHANNEL_UPDATE
Section titled “CHANNEL_UPDATE”Value 'channelupdate'
Fired when an existing channel is updated.
Callback signature: function(\Sharkord\Models\Channel $channel): void
Example
$sharkord->on(Events::CHANNEL_UPDATE, function(\Sharkord\Models\Channel $channel): void { echo "Channel #{$channel->name} was updated.";});CHANNEL_DELETE
Section titled “CHANNEL_DELETE”Value 'channeldelete'
Fired just before a channel is removed from the cache.
The Channel model is still fully populated at the time the event fires.
Callback signature: function(\Sharkord\Models\Channel $channel): void
Example
$sharkord->on(Events::CHANNEL_DELETE, function(\Sharkord\Models\Channel $channel): void { echo "Channel #{$channel->name} was deleted.";});USER_CREATE
Section titled “USER_CREATE”Value 'usercreate'
Fired when a new user account is created on the server.
Callback signature: function(\Sharkord\Models\User $user): void
Example
$sharkord->on(Events::USER_CREATE, function(\Sharkord\Models\User $user): void { echo "New user registered: {$user->name}.";});USER_JOIN
Section titled “USER_JOIN”Value 'userjoin'
Fired when a user comes online (connects to the server).
The user’s status will already be set to 'online' when the callback fires.
Callback signature: function(\Sharkord\Models\User $user): void
Example
$sharkord->on(Events::USER_JOIN, function(\Sharkord\Models\User $user): void { echo "{$user->name} just came online.";});USER_LEAVE
Section titled “USER_LEAVE”Value 'userleave'
Fired when a user goes offline (disconnects from the server).
The user’s status will already be set to 'offline' when the callback fires.
Callback signature: function(\Sharkord\Models\User $user): void
Example
$sharkord->on(Events::USER_LEAVE, function(\Sharkord\Models\User $user): void { echo "{$user->name} went offline.";});USER_DELETE
Section titled “USER_DELETE”Value 'userdelete'
Fired just before a user is permanently removed from the cache.
The User model is still fully populated at the time the event fires.
Callback signature: function(\Sharkord\Models\User $user): void
Example
$sharkord->on(Events::USER_DELETE, function(\Sharkord\Models\User $user): void { echo "User {$user->name} was deleted from the server.";});USER_NAME_CHANGE
Section titled “USER_NAME_CHANGE”Value 'namechange'
Fired when a user changes their display name.
The User model reflects the new name at the time the callback fires.
Callback signature: function(\Sharkord\Models\User $user): void
Example
$sharkord->on(Events::USER_NAME_CHANGE, function(\Sharkord\Models\User $user): void { echo "A user changed their name to {$user->name}.";});USER_BAN
Section titled “USER_BAN”Value 'ban'
Fired when a user is banned from the server.
Callback signature: function(\Sharkord\Models\User $user): void
Example
$sharkord->on(Events::USER_BAN, function(\Sharkord\Models\User $user): void { echo "{$user->name} has been banned.";});USER_UNBAN
Section titled “USER_UNBAN”Value 'unban'
Fired when a user’s ban is lifted.
Callback signature: function(\Sharkord\Models\User $user): void
Example
$sharkord->on(Events::USER_UNBAN, function(\Sharkord\Models\User $user): void { echo "{$user->name} has been unbanned.";});ROLE_CREATE
Section titled “ROLE_CREATE”Value 'rolecreate'
Fired when a new role is created.
Callback signature: function(\Sharkord\Models\Role $role): void
Example
$sharkord->on(Events::ROLE_CREATE, function(\Sharkord\Models\Role $role): void { echo "Role '{$role->name}' was created.";});ROLE_UPDATE
Section titled “ROLE_UPDATE”Value 'roleupdate'
Fired when an existing role is updated.
Callback signature: function(\Sharkord\Models\Role $role): void
Example
$sharkord->on(Events::ROLE_UPDATE, function(\Sharkord\Models\Role $role): void { echo "Role '{$role->name}' was updated.";});ROLE_DELETE
Section titled “ROLE_DELETE”Value 'roledelete'
Fired just before a role is removed from the cache.
The Role model is still fully populated at the time the event fires.
Callback signature: function(\Sharkord\Models\Role $role): void
Example
$sharkord->on(Events::ROLE_DELETE, function(\Sharkord\Models\Role $role): void { echo "Role '{$role->name}' was deleted.";});CATEGORY_CREATE
Section titled “CATEGORY_CREATE”Value 'categorycreate'
Fired when a new category is created.
Callback signature: function(\Sharkord\Models\Category $category): void
Example
$sharkord->on(Events::CATEGORY_CREATE, function(\Sharkord\Models\Category $category): void { echo "Category '{$category->name}' was created.";});CATEGORY_UPDATE
Section titled “CATEGORY_UPDATE”Value 'categoryupdate'
Fired when an existing category is updated.
Callback signature: function(\Sharkord\Models\Category $category): void
Example
$sharkord->on(Events::CATEGORY_UPDATE, function(\Sharkord\Models\Category $category): void { echo "Category '{$category->name}' was updated.";});CATEGORY_DELETE
Section titled “CATEGORY_DELETE”Value 'categorydelete'
Fired just before a category is removed from the cache.
The Category model is still fully populated at the time the event fires.
Callback signature: function(\Sharkord\Models\Category $category): void
Example
$sharkord->on(Events::CATEGORY_DELETE, function(\Sharkord\Models\Category $category): void { echo "Category '{$category->name}' was deleted.";});SERVER_UPDATE
Section titled “SERVER_UPDATE”Value 'serverupdate'
Fired when the server’s public settings are updated (e.g. name, description).
Callback signature: function(\Sharkord\Models\Server $server): void
Example
$sharkord->on(Events::SERVER_UPDATE, function(\Sharkord\Models\Server $server): void { echo "Server settings updated. Name is now: {$server->name}";});