Skip to content

new server

Terminal window
holocron new server --name <name> --owner <member id> [--provider <name>] [--force] [--resume] [--dry-run]

Builds the server from nothing. A bot can create a server (Discord allows it while the bot is in fewer than ten), and a server it creates already has the bot in it, so there is no invite step for the bot. The command then:

  1. checks the layout can be applied, the way setup notifications --dry-run does, and that a secrets provider exists if the layout stores webhook URLs or role ids. If not, it stops before a server exists.
  2. creates the server, owned by the bot at first;
  3. writes the new server id into your holocron.config.ts (guildId), so every other command finds it. If the file has no single live guildId: "…" property to replace (a comment or string that mentions one does not count) it leaves the file alone and tells you what to set;
  4. applies the whole layout, exactly as setup notifications does (the bot owns the server, so it may do everything, including turning community features on, with no elevation step);
  5. invites the owner: a single-use link into the system channel (else the rules channel, else the first channel), valid for a day;
  6. waits for the owner to join (up to 15 minutes, looking every few seconds), then hands the server over to them.

The whole flow, including how to find your owner id and how to update the server afterwards, is in Server as Code.

Ownership can only go to someone who is already in the server, which is why the owner joins first. Until then the bot owns it and doctor notifications says so (step 16).

Option Default Description
--name <name> — What the new server is called (not needed with --resume)
--owner <id> — The member id, on the provider, of the person who will own it. For Discord, the user id: Developer Mode → right-click yourself → Copy User ID. After link account it is also in the links file
--provider <name> — Which notifications provider, when more than one can create a server
--force false The config already names a server (guildId): create another anyway and replace the id. Without it the command refuses, so it can never make a second server by accident
--resume false The server exists and is set up (an earlier run stopped at the invite): skip creating, run setup again (it only fills in what is missing), make a fresh invite and finish the hand-over. It works on the server guildId names and refuses one the bot no longer owns, or (when you pass --name) one with a different name, so a stale guildId cannot send the hand-over to the wrong server
--dry-run false Say what would happen without calling the provider
  • The layout fails to apply. The server exists and the bot owns it. Nothing is handed over. Fix what went wrong and run setup notifications, then create-server --resume --owner <id>.
  • The owner does not join in time. Same state. Open the invite (or run --resume for a new one) and run create-server --resume --owner <id>.
  • The config file could not be edited (unreadable, unwritable, or no single live guildId; a commented-out one is ignored). The command carries on and prints the id to set by hand. Set it before --resume, which uses the server the config names.
  • The hand-over answer is lost. If the request went through, the command asks who owns the server and counts it as done when that is the owner.

A run takes a lock file next to the config (holocron.config.ts.create-server.lock) and removes it when it ends, however it ends. A second run while it exists stops at once, so two runs cannot create two servers and overwrite each other’s guildId. If a run was stopped abruptly and left the file behind, delete it.

  • Discord lets a bot create a server only while it is in fewer than ten. Past that, POST /guilds is refused and the command says so.
  • If Discord creates the server but the answer is lost, the next run finds it: before creating, the bot lists the servers it is in and reuses one it owns with the same name, so no second one is made. This needs two runs to ask one after the other; two machines asking at the same instant can still each create one, so run it from one place.
  • A new server starts with Discord’s own default channels (such as general). The layout is added to them; nothing is deleted.
  • Anything the API cannot do stays manual, as for setup notifications: the developer-portal settings of the bot itself belong to the application, not to a server, so they carry over.