discord-setup
/discord-setup
First-time setup of this Discord bot boilerplate (Discord app, token, server ID, invite, permissions), diagnosing "the bot isn't working", and deploying to Railway. Use when the user is starting out, something is broken, or they want it online 24/7.
- Author
- KenKaiii ↗
- Repository
- discord-magic ↗
- Licence
- AGPL-3.0
- Last repository change
- 10.11.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 5
No signals detected. Repository changed on 10.11.2026, without references to retired models or APIs.
AGPL-3.0, copyleft: przeróbki udostępniane innym muszą mieć tę samą licencję.
What it does and when to use it
First-time setup of this Discord bot boilerplate (Discord app, token, server ID, invite, permissions), diagnosing "the bot isn't working", and deploying to Railway. Use when the user is starting out, something is broken, or they want it online 24/7.
Triggers from the description
Original author description
First-time setup of this Discord bot boilerplate (Discord app, token, server ID, invite, permissions), diagnosing "the bot isn't working", and deploying to Railway. Use when the user is starting out, something is broken, or they want it online 24/7.
How it works
- 0. Where are we?
- 1. Bot token (user does this in the browser)
- 2. Invite the bot and find the server (one click for the user)
- 3. Existing server with roles?
- 4. Verify
- 5. Shape the server
- 6. Try it locally
- 7. Put it online with Railway (24/7)
- Moving an existing Railway bot off railway.json / railway.toml
- Troubleshooting
SKILL.md preview
---
name: discord-setup
description: First-time setup of this Discord bot boilerplate (Discord app, token, server ID, invite, permissions), diagnosing "the bot isn't working", and deploying to Railway. Use when the user is starting out, something is broken, or they want it online 24/7.
---
# Discord setup and deploy
The user is probably not a developer. Do every step you can yourself; for steps that need their
browser or Discord account, give one short instruction at a time with the exact link, then wait.
## 0. Where are we?
If the user only pasted the repo link, you're not in the project yet: install anything missing
(`node -v` must be 24+; macOS `brew install node git`, Windows
`winget install OpenJS.NodeJS.LTS Git.Git`, Linux the package manager or nvm), then
`git clone https://github.com/KenKaiii/discord-magic.git`, `cd discord-magic`, `npm install`. Your
skill list won't have this project's skills yet, so read `AGENTS.md` and the skill files from
`.agents/skills/` directly. When setup is done, tell the user to open the `discord-magic` folder in
their agent from now on.
```bash
ls .env node_modules >/dev/null 2>&1 || npm install
npm run doctor
```
`doctor` prints `ok` / `warn` / `FAIL` lines, each FAIL with its fix. Jump to the step that fixes
the first FAIL. If everything is `ok`, setup is done; go to step 6 or 7. `warn` lines about
Railway mean step 7 isn't finished yet.
## 1. Bot token (user does this in the browser)
`.env.example` lists every variable the bot needs, each with a comment saying where to get it.
Fill in whatever you can yourself (the server ID comes from step 2) and ask for the rest in **one
message**. For a fresh clone that's only the token. Open the page for them first (macOS
`open <url>`, Linux `xdg-open <url>`, Windows `start "" "<url>"`), and still show the link in case
no browser opens:
> I just opened the Discord Developer Portal for you (https://discord.com/developers/applications):
> 1. Click **New Application**, name it (that's your bot's name) and click **Create**.
> 2. Left menu **Bot** → **Reset Token** → **Copy**, then paste it here.
> 3. Same page, under **Privileged Gateway Intents**, turn on **Server Members Intent** →
> **Save Changes**.
>
> No Discord server yet? In Discord, click **+** at the bottom of your server list →
> **Create My Own**.
When they paste it:
```bash
test -f .env || cp .env.example .env
```
Then set `DISCORD_TOKEN=` in `.env` with a file edit. Never echo it, put it in a shell command, or
repeat it back; just confirm "Got it, saved." `npm run doctor` names anything still missing, with
the same where-to-get-it note. Railway gets the values later from `npm run deploy`, so the user
never types anything in twice, and never edits `.env` or the Railway dashboard.
## 2. Invite the bot and find the server (one click for the user)
```bash
npm run invite -- --open
```
It opens the invite in their browser. Tell them:
> A Discord page just opened: pick your server and click **Authorize**. Tell me when that's done.
Then save the server ID yourself:
```bash
npm run server:pick
```
The bot reads which servers it's in. If it's in exactly one, it saves that ID to `.env`. If it's in
several, it lists them: ask the user which one by **name** (choices), then
`npm run server:pick -- <id>`. Never send them to Developer Mode unless this fails.
The invite grants Administrator so `server:apply` can set any permission; if the user wants a
scoped bot, use `npm run invite -- --minimal --open` and expect permission errors for roles that
grant more than the bot has. Once the server ID is saved, `npm run invite` preselects it, so a
re-invite is just **Authorize**.
## 3. Existing server with roles?
If the server already has roles, the bot's role must be above them (a Discord-only step):
> In Discord: **Server Settings → Roles**, drag **<bot name>** to the very top, then
> **Save Changes**. Tell me when that's done.
## 4. Verify
```bash
npm run doctor
```
Repeat until there is no FAIL.
## 5. Shape the server
Ask the user which they want (use the question tool, recommend the first for an existing server
with history, the second for a fresh server):
- **Keep the current layout**: `npm run server:export`, review `server.config.exported.ts`, then
replace `server.config.ts` with it (keep the `bot:` section from the old file if they want the
start-here guide, welcome message and auto-role, and point their channels at ones that exist). From now on changes go through the config.
- **Build a new layout**: do "Get to know their server" in the `discord-magic` skill first (what
it's for, who's coming, vibe, must-haves, plus what's possible), then tailor `server.config.ts`
to their answers. The starter file is only a starting point; don't apply it unchanged.
Then follow the `discord-server` skill (plan -> user approves -> apply).
## 6. Try it locally
```bash
npm run dev
```
Run it in the background, wait for `Connected to Discord` and `Slash commands registered`, then
ask the user to type `/ping` in their server. Stop the dev bot before deploying, or two copies
will answer every command.
## 7. Put it online with Railway (24/7)
You do the heavy lifting. The user only signs in to Railway (and GitHub, for auto-deploys) and
clicks approve in their browser. Work through these in order and skip any that are already done.
**a. Cost check (ask once).** Railway pricing as of Nov 2026 (https://railway.com/pricing): a
30-day Free Trial with $5 of credit (no card), then the Free plan ($1/month of usage) or Hobby
($5/month including $5 of usage). A small bot like this normally fits in Hobby's included usage.
Ask with choices; recommend continuing.
**b. Railway CLI (you install it).** Check `railway --version`.
- Missing: install it yourself with `npm i -g @railway/cli` (works on macOS, Windows and Linux;
Node is already installed). If npm's global install fails with a permissions error, use
`brew install railway` on macOS or `bash <(curl -fsSL railway.com/install.sh)` on macOS/Linux/WSL.
- Older than 5.42.1 (needed for `.railway/railway.ts`): `railway upgrade --yes`.
- Tell the user in one line what you installed. Don't ask them to run it.
**c. Sign in (the user approves).** Check `railway whoami`. If not signed in, run `railway login`
yourself (in the background; it opens their browser). It also creates a free account if they don't
have one. Tell them:
> A Railway page just opened in your browser:
> 1. Sign in (or sign up with GitHub, the quickest way).
> 2. Click **Authorize**.
>
> Tell me when that's done.
If no browser opens (SSH or remote machine), use `railway login --browserless` and give them the
link and code it prints.
**d. Deploy.**
```bash
npm run deploy
```
This creates or reuses the Railway project and the `discord-bot` service, copies every variable
listed in `.env.example` from `.env` into Railway (values never printed), applies
`.railway/railway.ts` (Dockerfile build, `/health` check, single replica) and uploads this folder.
If they have several Railway workspaces, `railway list --json` shows them; ask which one, then run
`RAILWAY_WORKSPACE=<name> npm run deploy`. `RAILWAY_PROJECT_NAME` overrides the project name.
**e. Auto-deploy from GitHub (recommended once it's live).** Afterwards every `git push` ships
the bot on its own, and only after the GitHub checks pass.
1. The project must be in the user's own GitHub repo. Check `git remote get-url origin`. If it
points at the boilerplate they cloned (not their account), or there's no remote:
- GitHub CLI missing? Install it yourself (`brew install gh`, `winget install GitHub.cli`, or
https://cli.github.com), then run `gh auth login --web` and tell the user to enter the code it
shows on the page that opens.
- Keep the boilerplate as `upstream` (`git remote rename origin upstream`), commit, then
`gh repo create <name> --private --source . --remote origin --push`. Recommend private.
2. Commit and push any changes, then run:
```bash
npm run deploy -- --github
```
It connects the service to `origin` on the current branch, records the link in
`.railway/github.json` (keyed by Railway project ID, so other people's clones aren't affected),
turns on Wait for CI, and waits for the first GitHub deploy to go live. Commit and push
`.railway/github.json` afterwards.
3. If it says Railway can't access the repo, that's a user step:
> Railway needs permission to see your GitHub repo:
> 1. Open https://github.com/apps/railway-app/installations/new
> 2. Pick your account, choose **Only select repositories**, select **<repo>**, click
> **Install** (or **Save**).
>
> Tell me when that's done.
Then run `npm run deploy -- --github` again.
`npm run deploy -- --unlink-github` goes back to uploading from this folder.
**f. Check it's live.** `railway logs --service discord-bot --lines 50` should show
`Connected to Discord` and `Slash commands registered`. `npm run doctor` shows whether Railway
auto-deploys from GitHub. Then ask the user to try `/ping` in Discord.
### Shipping changes later
| Change | How it goes live |
| --- | --- |
| Server layout (`server.config.ts` roles/channels/settings) | `npm run server:apply`; instant, no deploy. |
| Code, commands, features, `bot:` settings | Linked to GitHub: commit and `git push` (after the user OKs it); Railway deploys once CI passes. Not linked: `npm run deploy`. |
| A value in `.env` added or changed (new token, API key) | `npm run deploy` (copies every variable, then redeploys). `npm run doctor` warns when Railway is missing one. |
| Hosting settings (`.railway/railway.ts`) | `npm run deploy`. |
Stop any local `npm run dev` before shipping, or two bots answer every command.
If `railway config apply` reports it would delete something, stop and show the user; never add
`--confirm-destructive`. A resource added in the Railway dashboard must also be added to
`.railway/railway.ts`, or the next apply will try to remove it. Variables don't need that: every
`.env.example` key is kept automatically, so add new ones there, not in the dashboard.
## Moving an existing Railway bot off railway.json / railway.toml
Railway stops reading `railway.json` / `railway.toml` on **2026-12-01**; services that still use
them need `.railway/railway.ts`. If the user brings an older bot that's already on Railway:
1. Link the folder to its project (`railway link`), then `npm i -D -E railway` (the SDK
`.railway/railway.ts` imports).
2. `railway config pull` imports the live setup: services, volumes and their mounts, and variables
as `preserve()` (values never written to the file). It also writes `.railway/README.md`, which is
fine to keep. `railway config migrate` (a dry run by default) shows how the old file's
build/start settings translate; copy those into the pulled file instead of applying migrate
over it.
3. `railway config plan` must show **0 to destroy**. Show the user the plan in plain words, and get
a yes before `railway config apply --yes`.
4. Delete the old file, commit, redeploy the way that project normally deploys, and check the logs.
A service with a volume has a few seconds of downtime on redeploy; startup logs that re-seed or
recreate data mean the volume didn't reattach, so stop and tell the user.
Never pass `--confirm-destructive`, above all when there's a volume: it holds the bot's data.
## Troubleshooting
| Symptom | Fix |
| ----------------------------------- | --------------------------------------------------------------------------------------------- |
| `Discord rejected DISCORD_TOKEN` | Reset the token (step 1), update `.env` and redeploy (`npm run deploy` re-copies it). |
| `Discord refused a privileged intent` | `npm run doctor` names the toggle; switch it on (step 1.3), then restart/redeploy. |
| Slash commands don't show | Wait a few seconds, restart Discord (Ctrl/Cmd+R). Check logs for `Slash commands registered`. |
| `Missing Permissions` on apply | Bot role not at the top, or bot invited with `--minimal`. Run `npm run doctor`. |
| Commands answer twice | Two bots are running (local `npm run dev` and Railway). Stop one. |
| Railway healthcheck fails | Logs: `railway logs --service discord-bot`. Usually a bad token or missing variable. |
| `railway: command not found` | Step 7b: install it yourself with `npm i -g @railway/cli`. |
| Pushed but Railway didn't deploy | GitHub checks failed (Railway waits for CI): `gh run list`, fix, push again. Or not linked: `npm run doctor`. |
| Railway can't access the GitHub repo | Step 7e.3: the user gives Railway's GitHub app access to that repo. |
Versions
The database has no other skills named discord-setup.
Database snapshot: 13.11.2026 · package version 3f55f1fbfbf1 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Similar skills
- 100create-discord-bot
Create a Discord server and bot application with browser automation, collect the bot token, server ID, and user ID, then save credentials to .env via the keys-safe-guard skill. Skip if OPENCLAW_DISCORD_BOT_TOKEN is already set. Use for any project that needs a Discord bot. - 100discord-expert
Expert in Discord bot development using discord.js and discord.py, slash commands, embeds, voice channels, moderation, and bot deployment. Use when the user mentions communication, community, bots, API, Discord bot, or discord.js, or when the task involves Discord Platform, Bot… - 100build-discord-bot
Build a production discord.py bot from scratch: intents, cogs, async setup, config from environment, logging, and a project layout that survives real use. Use when the user says 'build me a Discord bot', 'my bot does not answer', or 'set up a new bot project'. Do NOT use for… - 95discord-bot-helper
Discord.js v14 for building Discord bots - slash commands, events, components, embeds, and permissions When user works with Discord bots, discord.js, slash commands, Discord API, or mentions discord.js patterns - 100discord-channel
Discord for a Pots bot. How to connect a Discord bot yourself (the application, its token, inviting it to a server, bot.json), send and edit messages, threads, call Discord's REST API, files and limits, and how to post buttons, menus and forms (components and modals), get clicks… - 90discord
Read, post, and react in the connected Discord server via the Discord REST API, and help the user invite the bot / finish setup. Use when the user asks to send a Discord message, list channels/servers, read or react to messages, or connect/invite the bot.