Skill: ingejanben268/discord-hub-my (version 1.0.2)

--- name: discord-hub-my description: OpenClaw skill for Discord Bot API workflows, covering interactions, commands, messages, and operations using direct HTTPS requests. --- # Discord Bot API Skill (Advanced) ## Purpose Provide a production-oriented guide for building Discord bot workflows via the REST API and Interactions, focusing on professional command UX, safe operations, and direct HTTPS usage (no SDKs). ## Best fit - You want command-first bot behavior and clear interaction flows. - You prefer direct HTTP requests without a library dependency. - You need a structured map of Discord API surfaces. ## Not a fit - You need a full SDK or gateway client implementation. - You plan to stream large media uploads directly. ## Quick orientation - Read `references/discord-api-overview.md` for base URL, versioning, and object map. - Read `references/discord-auth-and-tokens.md` for token types and security boundaries. - Read `references/discord-interactions.md` for interaction lifecycle and response patterns. - Read `references/discord-app-commands.md` for slash, user, and message commands. - Read `references/discord-messages-components.md` for messages, embeds, and components. - Read `references/discord-gateway-webhooks.md` for gateway vs webhook tradeoffs. - Read `references/discord-rate-limits.md` for throttling and header-based handling. - Read `references/discord-request-templates.md` for HTTP payload templates. - Read `references/discord-feature-map.md` for the full surface checklist. ## Required inputs - Bot token and application ID. - Interaction endpoint public key (if using interaction webhooks). - Command list and UX tone. - Allowed intents and event scope. ## Expected output - A clear bot workflow plan, command design, and operational checklist. ## Operational notes - Prefer interactions and slash commands over prefix parsing. - Always validate incoming interaction signatures. - Keep payloads small and respond quickly to interactions. ## Security notes - Never log tokens or secrets. - Use least-privilege permissions and scopes.

path: _meta.json
content: ownerId: kn7ehv4at8yekzag31spcarxm180bev0
slug: discord-hub
version: 1.1.0
publishedAt: 1770265376283

path: discord_send.sh
content: #!/data/data/com.termux/files/usr/bin/bash
set -e

if [ -z "$WEBHOOK_URL" ]; then
  echo "WEBHOOK_URL is empty. Please export WEBHOOK_URL first."
  exit 1
fi

MSG="${1:-hello from termux 👋}"

curl -sS -H "Content-Type: application/json" \
  -d "{\"content\":\"$MSG\"}" \
  "$WEBHOOK_URL" >/dev/null

echo "sent ✅"


path: references/discord-api-overview.md
content: # Discord API Overview

## 1) Base URL and versioning
- Base: `https://discord.com/api`
- Use a pinned API version in the path: `/api/vX`.
- Avoid relying on the unversioned default.

## 2) Core object types
- `Guild`, `Channel`, `Message`, `User`, `Member`, `Role`.
- `Interaction`, `Application Command`, `Webhook`.

## 3) Primary surfaces
- REST API: request/response, CRUD for resources.
- Interactions: commands, buttons, select menus, modals.
- Gateway: real-time events and presence updates.

## 4) High-level flow
- Use REST for writes and reads.
- Use Interactions for command UX.
- Use Gateway when you need real-time events.


path: references/discord-app-commands.md
content: # Application Commands

## 1) Command types
- Slash commands (chat input)
- User context commands
- Message context commands

## 2) Registration scope
- Global commands (propagate slowly)
- Guild commands (propagate quickly)

## 3) Design rules
- Keep descriptions short and clear.
- Use options for structured input.
- Prefer autocomplete for large option sets.


path: references/discord-auth-and-tokens.md
content: # Auth and Tokens

## 1) Bot token
- Used for most REST endpoints.
- Include in `Authorization: Bot <token>`.

## 2) Interaction signatures
- Interaction webhooks are signed.
- Verify with your application public key.

## 3) OAuth2
- Use OAuth2 for user-authorized actions and installations.
- Scope and permissions should be minimal.

## 4) Security rules
- Never log tokens.
- Rotate compromised tokens immediately.
- Separate prod and dev applications.


path: references/discord-feature-map.md
content: # Discord Bot Feature Map

## Core
- Guilds, channels, roles, members
- Messages, embeds, attachments
- Webhooks

## Interactions
- Slash commands
- User and message context commands
- Buttons, select menus
- Modals
- Autocomplete

## Realtime
- Gateway events
- Presence and intents

## Community
- Threads
- Forum channels
- Scheduled events

## Safety and moderation
- Auto moderation rules
- Audit log awareness

## Optional surfaces
- Activities, voice, and stage features (if needed)


path: references/discord-gateway-webhooks.md
content: # Gateway vs Webhooks

## 1) Gateway
- Real-time event stream.
- Requires intents and session management.

## 2) Webhooks
- Interaction webhooks for commands.
- Useful when you do not need a full gateway client.

## 3) Choosing the path
- Use gateway if you need message events or presence.
- Use webhooks if you only need commands.


path: references/discord-interactions.md
content: # Interactions

## 1) Interaction types
- Application commands (slash, user, message)
- Message components (buttons, select menus)
- Modals (form input)

## 2) Response lifecycle
- Initial response must be fast.
- Use deferred responses when work is slow.
- Follow-up messages for later updates.

## 3) Ephemeral responses
- Use ephemeral messages for private results.

## 4) Webhook vs gateway
- Webhook-based interactions use signature validation.
- Gateway-based interactions still respond over HTTP.


path: references/discord-messages-components.md
content: # Messages and Components

## 1) Messages
- Create, edit, delete messages via REST.
- Use `allowed_mentions` to prevent accidental pings.
- Prefer embeds for structured content.

## 2) Components
- Buttons for primary actions.
- Select menus for multi-choice actions.
- Keep `custom_id` stable and parseable.

## 3) Modals
- Use modals for text input.
- Validate input server-side.


path: references/discord-rate-limits.md
content: # Rate Limits and Reliability

## 1) Rate limit handling
- Do not hard-code limits.
- Read `X-RateLimit-*` headers.
- Back off on 429 responses.

## 2) Invalid requests
- Avoid repeated 401/403/404 errors.
- Stop using invalid webhooks or tokens immediately.

## 3) Idempotency
- De-duplicate repeated interaction events.
- Make handlers safe to retry.


path: references/discord-request-templates.md
content: # HTTP Request Templates

## Create a message
POST `/channels/{channel_id}/messages`
```json
{
  "content": "Hello",
  "allowed_mentions": { "parse": [] }
}
```

## Edit a message
PATCH `/channels/{channel_id}/messages/{message_id}`
```json
{
  "content": "Updated"
}
```

## Create interaction response
POST `/interactions/{interaction_id}/{interaction_token}/callback`
```json
{
  "type": 4,
  "data": { "content": "Command received" }
}
```

## Deferred interaction response
POST `/interactions/{interaction_id}/{interaction_token}/callback`
```json
{
  "type": 5
}
```

## Follow-up message
POST `/webhooks/{application_id}/{interaction_token}`
```json
{
  "content": "Result is ready"
}
```


path: run.sh
content: #!/data/data/com.termux/files/usr/bin/bash
set -e

DIR="$(cd "$(dirname "$0")" && pwd)"

# 读取 .env
if [ -f "$DIR/.env" ]; then
  set -a
  . "$DIR/.env"
  set +a
fi

# 默认消息
MSG="${1:-OpenClaw test ✅}"

# 调用你之前做的发送脚本
"$DIR/discord_send.sh" "$MSG"


Security scan verdicts — ClawScan: suspicious | static analysis: clean | VirusTotal: suspicious | SkillSpector: suspicious (HIGH)