Skip to content

Instantly share code, notes, and snippets.

@ayuxsec
Created March 3, 2026 18:32
Show Gist options
  • Select an option

  • Save ayuxsec/b79defb1da2546fa560239daaa5d2424 to your computer and use it in GitHub Desktop.

Select an option

Save ayuxsec/b79defb1da2546fa560239daaa5d2424 to your computer and use it in GitHub Desktop.

Step 1 — Create a Discord Server (if you don’t have one)

  • Open Discord
  • Click + → Create Server
  • Name it

Done.


Step 2 — Create the Bot

  1. Go to: https://discord.com/developers/applications

  2. Click New Application

  3. Name it (e.g., AlertsBot)

  4. Click Create

Now:

  1. Go to Bot (left sidebar)
  2. Click Add Bot
  3. Click Reset Token
  4. Copy the token somewhere safe

That token is your BOT_TOKEN.


Step 3 — Invite the Bot to Your Server

  1. Go to OAuth2 → URL Generator

  2. Select:

    • bot (under Scopes)
  3. Under Bot Permissions select:

    • ✅ Send Messages
    • ✅ View Channels
  4. Copy the generated URL

  5. Open it in browser

  6. Choose your server

  7. Click Authorize

Your bot is now inside your server.


Step 4 — Get Channel ID

  1. Discord → User Settings
  2. Advanced → Enable Developer Mode
  3. Right-click the channel where alerts should go
  4. Click Copy Channel ID

You now have:

BOT_TOKEN=your_token_here
CHANNEL_ID=123456789012345678

Step 5 — Send Alert (cURL)

curl -X POST "https://discord.com/api/v10/channels/CHANNEL_ID/messages" \
  -H "Authorization: Bot BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"content":"🚨 Alert triggered!"}'

Replace:

  • CHANNEL_ID
  • BOT_TOKEN

If correct, message appears instantly.


Example With Variables (Linux/Mac)

BOT_TOKEN="YOUR_TOKEN"
CHANNEL_ID="123456789012345678"

curl -X POST "https://discord.com/api/v10/channels/$CHANNEL_ID/messages" \
  -H "Authorization: Bot $BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"content":"Server CPU usage high"}'

That’s It

You do NOT need:

  • WebSocket
  • Gateway connection
  • Intents
  • Any library

Just REST API.


Common Errors

401 Unauthorized

→ Wrong token

403 Missing Access

→ Bot not invited or no permission in that channel

404 Unknown Channel

→ Wrong channel ID

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment