Create discord bot

From X-School-Academy/skill-pilot · View interactive version

Create discord bot is an AI agent skill from the GitHub repository X-School-Academy/skill-pilot. 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.

How to use this skill

Skill file

Create Discord Bot

Automate as much of the Discord setup flow as possible through the official Discord web UI,

then securely save the bot token, server ID, and user ID to config/.env.

When to Use This Skill

Your Roles in This Skill

Other Agent Skills Required

Role Communication

As an expert in your assigned roles, you must announce your actions before performing them using the following format:

As a {Role, and Role-XYZ if have more roles}, I will {action description}

Preconditions

Workflow Usage Requirement

When this skill is used in a workflow agent node:

Skip Condition

Check if the token is already saved:

If the output shows a non-empty value, ask user whether to skip or replace it.

Instructions

Only ask the user for manual help if you cannot finish a step or need to verify as a human.

Step 1: Check existing token

Use skill keys-safe-guard to get OPENCLAW_DISCORD_BOT_TOKEN.

If set and user confirms to keep it, skip.

Step 2: Warn user about external site

Security notice: About to open discord.com and discord.com/developers.

Confirm these are trusted before proceeding.

Step 3: Automation mode

Default to this execution model:

  1. AI opens the official Discord pages and performs the browser steps.
  2. The user only intervenes when Discord requires:
  1. After each user-only checkpoint, continue the browser flow automatically.

Do not ask the user to manually click through routine setup pages when AI can do it.

Step 4: Ensure Discord account and server

Open Discord in a headed browser (web browser agent skill):

https://discord.com/channels/@me

AI should:

  1. Wait for the user to sign in if Discord shows the login screen.
  2. Detect whether a suitable server already exists.
  1. If no server exists or need to create a new one, create one automatically:

Step 5: Create bot application in the Developer Portal

Open by web browser agent skill:

https://discord.com/developers/applications

AI should perform:

  1. Wait for the user to sign in if the Developer Portal requires login.
  2. Click skip in the onboard screen if have, and go to the developer portal directly.
  3. Click New Application → enter a clear name (OpenClaw or SkillPilot depending on the context) → Create (Tick the acccept terms checkbox first on behalf of the user)
  4. Open the Bot tab under overview
  1. Scroll to Privileged Gateway Intents:
  1. Click Reset Token and confirm the reset dialog (Ask user to verify if need).
  2. Capture the token immediately.

Token handling rules:

Step 6: Generate OAuth2 invite URL and add bot to server

AI should perform in Developer Portal:

  1. Open OAuth2 → URL Generator
  2. Select scopes: bot, applications.commands
  3. Select bot permissions: View Channels, Send Messages, Read Message History, Embed Links, Attach Files
  4. Open the generated invite URL

Then continue the invite flow:

  1. Select the created or chosen server
  2. Click Continue
  3. Click Authorize

If Discord shows CAPTCHA or extra anti-abuse verification, pause and ask the user to complete only that step.

Step 7: Enable Developer Mode and collect IDs

AI should try to collect IDs with the least manual work:

  1. In Discord web app, open User Settings → Advanced → enable Developer Mode
  2. Capture the server ID from the selected server by using Discord’s copy-ID UI if accessible
  3. Capture the user ID from the signed-in user profile/avatar menu if accessible

If Discord blocks automated copy or context-menu access, ask the user only for the missing values:

  1. Right-click server icon → Copy Server ID or find from url https://discord.com/channels/{SERVER_ID}/{CHANNEL_ID}
  2. Right-click own avatar → Copy User ID

Step 8: Allow DMs from server members

Right-click server icon → Privacy Settings → toggle Direct Messages ON if it is OFF

Step 9: Save credentials to .env

Use skill keys-safe-guard to save:

Then use skill keys-safe-guard to get:

Confirm the token is set without printing its value. Report only whether OPENCLAW_DISCORD_BOT_TOKEN is present.

Step 10: Safe guard behavior

When config/.env is protected by key safe guard:

Do not claim the command is stuck. Wait for the GUI dialog or terminal sudo prompt to be completed.

Step 11: Report result

Output result as plain text. If the user asked to save it to a file, write it there.

Output

Plain text result shown to user:

Discord bot:      created and configured
Bot token:        saved to config/.env (not shown)
Server ID:        <id>
User ID:          <id>
DM policy:        enabled

Common Issues

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.