discord
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWe drive the Discord API
with . The user's OAuth bearer token is in ;
every call needs it as . Use the
versioned base URL .
curl + jq$DISCORD_TOKENAuthorization: Bearer $DISCORD_TOKENhttps://discord.com/api/v10Discord returns standard JSON. Errors look like
. A means the
token expired or the connection was revoked — tell the user to re-connect
Discord at . A carries a
(seconds) field — sleep that long, then retry; never
parallelize.
{"code": <n>, "message": "<reason>"}401 Unauthorizedauth.acedata.cloud/user/connections429retry_afterScope is read-only + + . 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
, , or — 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.
identifyemailguilds/guilds/{id}/channels/channels/.../guilds/{id}/members我们使用调用Discord API
用户的OAuth承载令牌存储在中;
每次调用都需要将其作为传入。使用
带版本的基础URL 。
curl + jq$DISCORD_TOKENAuthorization: Bearer $DISCORD_TOKENhttps://discord.com/api/v10Discord返回标准JSON格式数据。错误信息格式为
。表示令牌已过期或连接已被撤销——请告知用户前往重新连接Discord。错误包含
(秒数)字段——等待对应时长后重试;切勿并行请求。
{"code": <n>, "message": "<reason>"}401 Unauthorizedauth.acedata.cloud/user/connections429retry_after权限范围为只读的 + + 。 此OAuth
连接仅能读取账户身份信息和所属guilds列表。无法读取/发送频道消息、列出guild的频道或成员,也无法进行任何管理操作——这些功能需要Discord Bot(机器人令牌+网关),而本连接器不提供该功能。请勿调用
、或接口——使用用户OAuth令牌调用会返回401/403错误。如果用户请求这些功能,请告知需要Discord机器人集成,目前尚未设置该功能。
identifyemailguilds/guilds/{id}/channels/channels/.../guilds/{id}/membersRecipes
使用示例
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 to include /
:
?with_counts=trueapproximate_member_countapproximate_presence_countsh
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=trueapproximate_member_countapproximate_presence_countsh
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. means the user owns that guild.
owner: true - Guild icon URL (when is non-null):
icon(usehttps://cdn.discordapp.com/icons/<guild_id>/<icon>.pngif the icon hash starts with.gif).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"。表示用户是该guild的所有者。
owner: true - Guild图标URL(当不为空时):
icon(如果图标哈希以https://cdn.discordapp.com/icons/<guild_id>/<icon>.png开头,则使用a_格式)。.gif - Guild列表分页限制为200条;普通用户加入的数量远少于此,因此通常一次调用即可获取全部数据。如果遇到200条的限制,请使用参数进行分页。
?after=<last_guild_id>