Skip to content
Entity Info serverIDs

$serverIDs[] — IDs of the Servers

$serverIDs[] returns the Discord IDs of the servers where the bot is installed, in the order returned by Discord. It is the way to go through every server in a scheduled task, which has no current server. $guildIDs does the same.

Syntax

$serverIDs[(Amount;Separator;Offset)]

Parameters

Parameter Description
Amount Optional. The number of IDs to return: a whole number, or -1 for every server. If omitted or empty, 10. Any other value raises Amount must be a whole number, or -1 for every server.
Separator Optional. The text placed between IDs. If omitted or empty, a comma.
Offset Optional. How many servers to skip first (0 by default). Read the list in batches: $serverIDs[100;,;0], then $serverIDs[100;,;100]… A negative value raises Offset must be a whole number of 0 or more.

Return value

The IDs as one text, empty when there are none (or past the end of the list).

Examples

Process the servers by batches of 100

$var[start;$ifEmpty[$getVar[cursor];0]]
$textSplit[$serverIDs[100;,;$var[start]];,]
$loop[$splitTextCount]
$dbSpace[guild;$splitText[$i]]
$var[_;$dbIncrement[daily;runs;n;1]]
$endLoop
$setVar[cursor;$sum[$var[start];100]]

The list is read from Discord (200 servers per request): read it once per run, not once per server. A script stops after 100 000 execution steps, so a very large bot processes the servers by batches.

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.