discord

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
We drive the Discord API with
curl + jq
. The user's OAuth bearer token is in
$DISCORD_TOKEN
; every call needs it as
Authorization: Bearer $DISCORD_TOKEN
. Use the versioned base URL
https://discord.com/api/v10
.
Discord returns standard JSON. Errors look like
{"code": <n>, "message": "<reason>"}
. A
401 Unauthorized
means the token expired or the connection was revoked — tell the user to re-connect Discord at
auth.acedata.cloud/user/connections
. A
429
carries a
retry_after
(seconds) field — sleep that long, then retry; never parallelize.
Scope is read-only
identify
+
email
+
guilds
.
This OAuth connection can ONLY read the account's identity and the list of guilds it belongs to. It CANNOT read/send channel messages, list a guild's channels or members, or manage anything — those require a Discord Bot (bot token + gateway), which this connector does not provide. Do not call
/guilds/{id}/channels
,
/channels/...
, or
/guilds/{id}/members
— they return 401/403 with a user OAuth token. If the user asks for those, say it needs a Discord bot integration, which isn't set up.
我们使用
curl + jq
调用Discord API 用户的OAuth承载令牌存储在
$DISCORD_TOKEN
中; 每次调用都需要将其作为
Authorization: Bearer $DISCORD_TOKEN
传入。使用 带版本的基础URL
https://discord.com/api/v10
Discord返回标准JSON格式数据。错误信息格式为
{"code": <n>, "message": "<reason>"}
401 Unauthorized
表示令牌已过期或连接已被撤销——请告知用户前往
auth.acedata.cloud/user/connections
重新连接Discord。
429
错误包含
retry_after
(秒数)字段——等待对应时长后重试;切勿并行请求。
权限范围为只读的
identify
+
email
+
guilds
此OAuth 连接仅能读取账户身份信息和所属guilds列表。无法读取/发送频道消息、列出guild的频道或成员,也无法进行任何管理操作——这些功能需要Discord Bot(机器人令牌+网关),而本连接器不提供该功能。请勿调用
/guilds/{id}/channels
/channels/...
/guilds/{id}/members
接口——使用用户OAuth令牌调用会返回401/403错误。如果用户请求这些功能,请告知需要Discord机器人集成,目前尚未设置该功能。

Recipes

使用示例

Verify auth + identity (always run first)

验证授权 + 身份信息(始终先执行此步骤)

sh
curl -sS -H "Authorization: Bearer $DISCORD_TOKEN" \
  "https://discord.com/api/v10/users/@me" \
  | jq '{id, username, global_name, email, avatar}'
sh
curl -sS -H "Authorization: Bearer $DISCORD_TOKEN" \
  "https://discord.com/api/v10/users/@me" \
  | jq '{id, username, global_name, email, avatar}'

List the servers (guilds) the user is in

列出用户加入的服务器(guilds)

sh
curl -sS -H "Authorization: Bearer $DISCORD_TOKEN" \
  "https://discord.com/api/v10/users/@me/guilds" \
  | jq 'map({id, name, owner, approximate_member_count})'
Add
?with_counts=true
to include
approximate_member_count
/
approximate_presence_count
:
sh
curl -sS -H "Authorization: Bearer $DISCORD_TOKEN" \
  "https://discord.com/api/v10/users/@me/guilds?with_counts=true" \
  | jq 'map({id, name, owner, members: .approximate_member_count})'
sh
curl -sS -H "Authorization: Bearer $DISCORD_TOKEN" \
  "https://discord.com/api/v10/users/@me/guilds" \
  | jq 'map({id, name, owner, approximate_member_count})'
添加
?with_counts=true
参数以包含
approximate_member_count
/
approximate_presence_count
信息:
sh
curl -sS -H "Authorization: Bearer $DISCORD_TOKEN" \
  "https://discord.com/api/v10/users/@me/guilds?with_counts=true" \
  | jq 'map({id, name, owner, members: .approximate_member_count})'

Notes

注意事项

  • A "server" in the UI is a "guild" in the API.
    owner: true
    means the user owns that guild.
  • Guild icon URL (when
    icon
    is non-null):
    https://cdn.discordapp.com/icons/<guild_id>/<icon>.png
    (use
    .gif
    if the icon hash starts with
    a_
    ).
  • The guild list paginates at 200; the typical user is in far fewer, so a single call is usually enough. If you ever hit 200, paginate with
    ?after=<last_guild_id>
    .
  • UI中的"server"在API中称为"guild"。
    owner: true
    表示用户是该guild的所有者。
  • Guild图标URL(当
    icon
    不为空时):
    https://cdn.discordapp.com/icons/<guild_id>/<icon>.png
    (如果图标哈希以
    a_
    开头,则使用
    .gif
    格式)。
  • Guild列表分页限制为200条;普通用户加入的数量远少于此,因此通常一次调用即可获取全部数据。如果遇到200条的限制,请使用
    ?after=<last_guild_id>
    参数进行分页。