ServerSettings
Class · Sharkord\Models\ServerSettings
Class ServerSettings
Represents the full administrative settings for the connected server,
as returned by the others.getSettings RPC endpoint.
Unlike the {@see \Server} model — which is hydrated from public settings
pushed to all connected clients — this model includes privileged fields
such as secretToken and allowNewUsers that are only accessible to
users with the MANAGE_SETTINGS permission.
Obtain an instance via $sharkord->servers->getSettings(). Mutations
made through update() will broadcast an onServerSettingsUpdate event
to all connected clients, which will in turn update the cached {@see \Server}
model automatically.
Examples
Section titled “Examples”$sharkord->servers->getSettings()->then(function (\Sharkord\Models\ServerSettings $settings) { echo "Server: {$settings->name}\n"; echo "New users allowed: " . ($settings->allowNewUsers ? 'Yes' : 'No') . "\n"; echo "Storage quota: " . number_format($settings->storageQuota / 1073741824, 1) . " GB\n";});Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
$name (read-only) | string | Server display name. |
$description (read-only) | string | Server description. |
$password (read-only) | `string | null` |
$serverId (read-only) | string | Unique server UUID. |
$secretToken (read-only) | `string | null` |
$logoId (read-only) | `int | null` |
$allowNewUsers (read-only) | bool | Whether new user registrations are permitted. |
$directMessagesEnabled (read-only) | bool | Whether direct messaging is enabled server-wide. |
$storageUploadEnabled (read-only) | bool | Whether file uploads are enabled. |
$storageQuota (read-only) | int | Total server storage quota in bytes. |
$storageUploadMaxFileSize (read-only) | int | Maximum upload size per file in bytes. |
$storageMaxAvatarSize (read-only) | int | Maximum avatar file size in bytes. |
$storageMaxBannerSize (read-only) | int | Maximum banner file size in bytes. |
$storageMaxFilesPerMessage (read-only) | int | Maximum number of files attachable per message. |
$storageFileSharingInDirectMessages (read-only) | bool | Whether file sharing is allowed in DMs. |
$storageSpaceQuotaByUser (read-only) | int | Per-user storage quota in bytes, or 0 for unlimited. |
$storageOverflowAction (read-only) | string | Action taken when storage is full (e.g. ‘prevent’). |
$enablePlugins (read-only) | bool | Whether server plugins are enabled. |
$enableSearch (read-only) | bool | Whether server search is enabled. |
$webRtcMaxBitrate (read-only) | `int | null` |
$logo (read-only) | `\Attachment | null` |
Methods
Section titled “Methods”__construct()
Section titled “__construct()”ServerSettings constructor.
Parameters
| Parameter | Type | Description |
|---|---|---|
$sharkord | Sharkord | Reference to the main bot instance. |
$rawData | array | The raw settings payload from the API. |
static fromArray()
Section titled “static fromArray()”Factory method to create a ServerSettings instance from a raw API data array.
Parameters
| Parameter | Type | Description |
|---|---|---|
$raw | array | The raw settings payload. |
$sharkord | Sharkord | Reference to the main bot instance. |
Returns self
update()
Section titled “update()”Updates one or more server settings via the others.updateSettings RPC.
Only fields explicitly passed (i.e. not null) are included in the mutation
payload. After a successful update the server will broadcast an
onServerSettingsUpdate event, which the framework will use to refresh the
cached {@see \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 an existing password. |
$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
$sharkord->servers->getSettings()->then(function (\Sharkord\Models\ServerSettings $settings) { return $settings->update( name: 'The Boyz', allowNewUsers: false, directMessagesEnabled: true, nableSearch: true, );})->then(function () { echo "Settings updated!\n";});toArray()
Section titled “toArray()”Returns the settings data as a plain array.
Returns array<string,mixed>
__get()
Section titled “__get()”Magic getter for settings properties.
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | Property name. |
Returns mixed
__isset()
Section titled “__isset()”Magic isset check.
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | Property name. |
Returns bool