Server
Class · Sharkord\Models\Server
Class Server
Represents the server environment and its settings.
Methods
Section titled “Methods”__construct()
Section titled “__construct()”Server constructor.
Parameters
| Parameter | Type | Description |
|---|---|---|
$sharkord | Sharkord | Reference to the main bot instance. |
$rawData | array | The raw array of data from the API. |
static fromArray()
Section titled “static fromArray()”Factory method to create a Server from raw API data.
Parameters
| Parameter | Type | Description |
|---|---|---|
$raw | array | The raw server data from the server. |
$sharkord | Sharkord | Reference to the main bot instance. |
Returns self
getSettings()
Section titled “getSettings()”Fetches the full administrative settings for this server.
Convenience wrapper around {@see \Sharkord\Managers\ServerManager::getSettings()}.
Returns a {@see \ServerSettings} model containing privileged fields such as
secretToken and allowNewUsers that are not included in the public settings.
Requires the MANAGE_SETTINGS permission.
Returns \PromiseInterface — Resolves with a {@see \ServerSettings} instance, rejects on failure.
Example
$server->getSettings()->then(function(\Sharkord\Models\ServerSettings $settings) { echo "Server: {$settings->name}\n"; echo "Allow signup: " . ($settings->allowNewUsers ? 'Yes' : 'No') . "\n";});edit()
Section titled “edit()”Updates one or more server settings.
Convenience wrapper that fetches the current {@see \ServerSettings} and
delegates to {@see \ServerSettings::update()}. The server will broadcast
an onServerSettingsUpdate event, which updates the cached Server model
automatically.
Requires the MANAGE_SETTINGS permission.
Parameters
| Parameter | Type | Description |
|---|---|---|
$name (optional) | ?string | New server display name. |
$description (optional) | ?string | New server description. |
$password (optional) | ?string | New server password. Pass an empty string to remove. |
$allowNewUsers (optional) | ?bool | Whether to permit new user registrations. |
$directMessagesEnabled (optional) | ?bool | Whether to enable direct messaging server-wide. |
$enablePlugins (optional) | ?bool | Whether to enable server plugins. |
$enableSearch (optional) | ?bool | Whether to enable server-wide search. |
Returns \PromiseInterface — Resolves with true on success, rejects on failure.
Example
$server->edit(name: 'The Boyz', allowNewUsers: false)->then(function() { echo "Settings updated!\n";});toArray()
Section titled “toArray()”Returns all the attributes as an array. Perfect for debugging!
Returns array
Example
var_dump($sharkord->servers->getFirst()?->toArray());__isset()
Section titled “__isset()”Magic isset check. Allows isset() and empty() to work correctly against both stored attributes and virtual relational properties.
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | Property name. |
Returns bool
__get()
Section titled “__get()”Magic getter. Triggered whenever you try to access a property that isn’t explicitly defined.
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | Property name. |
Returns mixed