Channels
Class · Sharkord\Collections\Channels
Class Channels
An array-accessible, iterable cache of Channel objects keyed by channel ID (string).
Supports lookup by both integer ID and channel name via get().
Examples
Section titled “Examples”// Look up by ID or name$channel = $sharkord->channels->collection()->get(1);$channel = $sharkord->channels->collection()->get('general');
// Iterate all cached channelsforeach ($sharkord->channels->collection() as $id => $channel) { echo "{$channel->name}\n";}
echo count($sharkord->channels->collection());Methods
Section titled “Methods”__construct()
Section titled “__construct()”Channels constructor.
Parameters
| Parameter | Type | Description |
|---|---|---|
$sharkord | Sharkord | Reference to the main bot instance. |
Retrieves a channel by ID or name.
Parameters
| Parameter | Type | Description |
|---|---|---|
$identifier | `int | string` |
Returns \Channel|null
offsetExists()
Section titled “offsetExists()”Parameters
| Parameter | Type | Description |
|---|---|---|
$offset | mixed |
Returns bool
offsetGet()
Section titled “offsetGet()”Parameters
| Parameter | Type | Description |
|---|---|---|
$offset | mixed |
Returns ?Channel
offsetSet()
Section titled “offsetSet()”Parameters
| Parameter | Type | Description |
|---|---|---|
$offset | mixed | |
$value | mixed |
Throws
\LogicException
offsetUnset()
Section titled “offsetUnset()”Parameters
| Parameter | Type | Description |
|---|---|---|
$offset | mixed |
Throws
\LogicException
count()
Section titled “count()”Returns int
getIterator()
Section titled “getIterator()”Returns \ArrayIterator<string,\Channel>