feat(discord-control): add private-channel and member-list admin API
This commit is contained in:
85
docs/DISCORD_CONTROL.md
Normal file
85
docs/DISCORD_CONTROL.md
Normal file
@@ -0,0 +1,85 @@
|
||||
# Discord Control API
|
||||
|
||||
目标:补齐 OpenClaw 内置 message 工具当前未覆盖的两个能力:
|
||||
|
||||
1. 创建指定名单可见的私人频道
|
||||
2. 查看 server 成员列表(分页)
|
||||
|
||||
## Start
|
||||
|
||||
```bash
|
||||
cd discord-control-api
|
||||
export DISCORD_BOT_TOKEN='xxx'
|
||||
# optional
|
||||
# export AUTH_TOKEN='strong-token'
|
||||
node server.mjs
|
||||
```
|
||||
|
||||
Health:
|
||||
|
||||
```bash
|
||||
curl -sS http://127.0.0.1:8790/health
|
||||
```
|
||||
|
||||
## Unified action endpoint
|
||||
|
||||
`POST /v1/discord/action`
|
||||
|
||||
- Header: `Authorization: Bearer <AUTH_TOKEN>`(若配置)
|
||||
- Body: `{ "action": "...", ... }`
|
||||
|
||||
---
|
||||
|
||||
## Action: channel-private-create
|
||||
|
||||
与 OpenClaw `channel-create` 参数保持风格一致,并增加私密覆盖参数。
|
||||
|
||||
### Request
|
||||
|
||||
```json
|
||||
{
|
||||
"action": "channel-private-create",
|
||||
"guildId": "123",
|
||||
"name": "private-room",
|
||||
"type": 0,
|
||||
"parentId": "456",
|
||||
"topic": "secret",
|
||||
"position": 3,
|
||||
"nsfw": false,
|
||||
"allowedUserIds": ["111", "222"],
|
||||
"allowedRoleIds": ["333"],
|
||||
"allowMask": "67648",
|
||||
"denyEveryoneMask": "1024"
|
||||
}
|
||||
```
|
||||
|
||||
说明:
|
||||
- 默认 deny `@everyone` 的 `VIEW_CHANNEL`。
|
||||
- 默认给 allowed targets 放行:`VIEW_CHANNEL + SEND_MESSAGES + READ_MESSAGE_HISTORY`。
|
||||
- `allowMask/denyEveryoneMask` 使用 Discord permission bit string。
|
||||
|
||||
---
|
||||
|
||||
## Action: member-list
|
||||
|
||||
### Request
|
||||
|
||||
```json
|
||||
{
|
||||
"action": "member-list",
|
||||
"guildId": "123",
|
||||
"limit": 100,
|
||||
"after": "0"
|
||||
}
|
||||
```
|
||||
|
||||
说明:
|
||||
- `limit` 1~1000
|
||||
- `after` 用于分页(Discord snowflake)
|
||||
|
||||
---
|
||||
|
||||
## Notes
|
||||
|
||||
- 这不是 bot 自提权工具;bot 仍需由管理员授予足够权限。
|
||||
- 若无权限,Discord API 会返回 403 并原样透出错误信息。
|
||||
Reference in New Issue
Block a user