Modules
moduleSetting
$moduleSetting
$moduleSetting reads a setting that a server can change (a channel, a role, a number, a toggle, a text), or one of its properties.
Syntax
$moduleSetting[id;key;field;separator;guildID]
Parameters
| Parameter | Description |
|---|---|
id |
Required. The identifier of the module. |
key |
Required. The key of the setting (see $moduleInfo[id;settings]). |
field |
Optional. value (default, falls back to the default), set (true when the server chose a value), default, type, label, description, min, max or choices. |
separator |
Optional. Text between the items of choices. Default ,. |
guildID |
Optional. The server to read. Default: the current server. |
Return value
- Type: String
- The value, empty when nothing is set and there is no default.
JavaScript
await bc.module.setting(id, key, field, guildId) returns a number for number settings, a boolean for toggles, an array for choices, a string otherwise.
Behavior
- The value is stored in the server variable
mod_<module>_<key>(dashes become underscores). labelanddescriptionfollow the language of the person, then of the bot, then English.- Only server-scoped settings are readable here; a setting hidden by a turned-off feature raises
has no setting.
Examples
$if[$moduleInfo[tickets;installed]==true]
Tickets open at once: $moduleSetting[tickets;max-open]
Limit: $moduleSetting[tickets;max-open;min] to $moduleSetting[tickets;max-open;max]
$endif
Notes
- Everything is read from the modules installed on the bot, so a module added later is covered with no change to your script.
- See the guide Module and command functions.
Try it
Paste an example into the playground to preview its message (functions that act on Discord are not run), or build the same thing with blocks.