$dbSpace picks the space used by every $db* function that comes after it in the same run. Spaces never mix: the same collection and id in two spaces are two different documents.
$dbSpace[guild|user|bot;(serverID)]
| Parameter | Description |
|---|---|
guild|user|bot |
guild: the current server (default, the user’s own space in a direct message). user: data that follows the person who runs the command, across servers. bot: one space shared by the whole bot. |
serverID |
Optional, with guild only. The ID of a server where the bot is present: the rest of the run uses that server’s space instead of the current one. Use it in a scheduled task, which has no current server. An error The bot is not in this server. if the bot is not there. |
$dbSpace[user]
$dbSet[prefs;$authorID;{"lang":"fr"}]
$dbSpace[bot]
$dbGet[settings;maintenance;on;false]
A scheduled task has no current server. Name each one with $serverIDs; the bot’s data stay separated per server.
$textSplit[$serverIDs[100;,;0];,]
$loop[$splitTextCount]
$dbSpace[guild;$splitText[$i]]
$dbSet[daily;today;{"seen":true}]
$endLoop
In JavaScript: bc.db.space('guild', id).