Skip to content

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.

$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";
});
PropertyTypeDescription
$name (read-only)stringServer display name.
$description (read-only)stringServer description.
$password (read-only)`stringnull`
$serverId (read-only)stringUnique server UUID.
$secretToken (read-only)`stringnull`
$logoId (read-only)`intnull`
$allowNewUsers (read-only)boolWhether new user registrations are permitted.
$directMessagesEnabled (read-only)boolWhether direct messaging is enabled server-wide.
$storageUploadEnabled (read-only)boolWhether file uploads are enabled.
$storageQuota (read-only)intTotal server storage quota in bytes.
$storageUploadMaxFileSize (read-only)intMaximum upload size per file in bytes.
$storageMaxAvatarSize (read-only)intMaximum avatar file size in bytes.
$storageMaxBannerSize (read-only)intMaximum banner file size in bytes.
$storageMaxFilesPerMessage (read-only)intMaximum number of files attachable per message.
$storageFileSharingInDirectMessages (read-only)boolWhether file sharing is allowed in DMs.
$storageSpaceQuotaByUser (read-only)intPer-user storage quota in bytes, or 0 for unlimited.
$storageOverflowAction (read-only)stringAction taken when storage is full (e.g. ‘prevent’).
$enablePlugins (read-only)boolWhether server plugins are enabled.
$enableSearch (read-only)boolWhether server search is enabled.
$webRtcMaxBitrate (read-only)`intnull`
$logo (read-only)`\Attachmentnull`

ServerSettings constructor.

Parameters

ParameterTypeDescription
$sharkordSharkordReference to the main bot instance.
$rawDataarrayThe raw settings payload from the API.

Factory method to create a ServerSettings instance from a raw API data array.

Parameters

ParameterTypeDescription
$rawarrayThe raw settings payload.
$sharkordSharkordReference to the main bot instance.

Returns self


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

ParameterTypeDescription
$name (optional)?stringNew server display name.
$description (optional)?stringNew server description.
$password (optional)?stringNew server password. Pass an empty string to remove an existing password.
$allowNewUsers (optional)?boolWhether to permit new user registrations.
$directMessagesEnabled (optional)?boolWhether to enable direct messaging server-wide.
$enablePlugins (optional)?boolWhether to enable server plugins.
$enableSearch (optional)?boolWhether 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";
});

Returns the settings data as a plain array.

Returns array<string,mixed>


Magic getter for settings properties.

Parameters

ParameterTypeDescription
$namestringProperty name.

Returns mixed


Magic isset check.

Parameters

ParameterTypeDescription
$namestringProperty name.

Returns bool