UserManager
Class · Sharkord\Managers\UserManager
Class UserManager
Manages user lifecycle events, delegating all cache storage to a Users collection instance.
Accessible via $sharkord->users.
Examples
Section titled “Examples”$user = $sharkord->users->get(42);
if ($user) { echo "{$user->name} is currently {$user->status}.\n";}
$sharkord->on(\Sharkord\Events::USER_JOIN, function(\Sharkord\Models\User $user): void { echo "{$user->name} just came online.\n";});Methods
Section titled “Methods”__construct()
Section titled “__construct()”UserManager constructor.
Parameters
| Parameter | Type | Description |
|---|---|---|
$sharkord | Sharkord | The main bot instance. |
Retrieves a cached user by ID or display name.
Parameters
| Parameter | Type | Description |
|---|---|---|
$idOrName | `int | string` |
Returns \User|null — The cached User model, or null if not found.
Example
$user = $sharkord->users->get(42);$user = $sharkord->users->get('Buzz');
if ($user) { echo "{$user->name} is {$user->status}.\n";}count()
Section titled “count()”Returns the number of users currently held in the cache.
Returns int
Example
echo "Online users cached: " . $sharkord->users->count() . "\n";collection()
Section titled “collection()”Returns the underlying Users collection.
Returns \UsersCollection
Example
foreach ($sharkord->users->collection() as $id => $user) { echo "{$id}: {$user->name}\n";}