标准对象格式

本文档列出了常见实例的标准格式,如果不做特殊说明,用户可以参照该文档格式。

用户 User

参数名 类型 说明
id string 用户的 id
username string 用户的名称
nickname string 用户在当前服务器的昵称
identify_num string 用户名的认证数字,用户名正常为:user_name#identify_num
online boolean 当前是否在线
bot boolean 是否为机器人
status int 用户的状态, 0 和 1 代表正常,10 代表被封禁
avatar string 用户的头像的 url 地址
vip_avatar string vip 用户的头像的 url 地址,可能为 gif 动图
mobile_verified boolean 是否手机号已验证
roles Array 用户在当前服务器中的角色 id 组成的列表

示例

  1. {
  2. "id": "2418200000",
  3. "username": "tz-un",
  4. "identify_num": "5618",
  5. "online": false,
  6. "avatar": "https://img.kaiheila.cn/avatars/2020-02/xxxx.jpg/icon",
  7. "vip_avatar": "https://img.kaiheila.cn/avatars/2020-02/xxxx.jpg/icon",
  8. "bot": false,
  9. "status" : 0,
  10. "mobile_verified": true,
  11. "nickname": "12316993",
  12. "roles": [
  13. 111,
  14. 112
  15. ],
  16. }

服务器 Guild

字段 类型 说明
id string 服务器 id
name string 服务器名称
topic string 服务器主题
master_id string 服务器主的 id
icon string 服务器 icon 的地址
notify_type int 通知类型, 0代表默认使用服务器通知设置,1代表接收所有通知, 2代表仅@被提及,3代表不接收通知
region string 服务器默认使用语音区域
enable_open boolean 是否为公开服务器
open_id string 公开服务器 id
default_channel_id string 默认频道 id
welcome_channel_id string 欢迎频道 id
roles array 角色列表
channels array 频道列表

示例

  1. {
  2. "id": "2405000000000",
  3. "name": "工具",
  4. "topic": "",
  5. "master_id": "9200000000",
  6. "icon": "",
  7. "notify_type": 1,
  8. "region": "beijing",
  9. "enable_open": false,
  10. "open_id": "0",
  11. "default_channel_id": "2369000000000",
  12. "welcome_channel_id": "0",
  13. "roles": [
  14. {
  15. "role_id": 109472,
  16. "name": "管理员",
  17. "color": 0,
  18. "position": 1,
  19. "hoist": 0,
  20. "mentionable": 0,
  21. "permissions": 1
  22. }
  23. ],
  24. "channels": [
  25. {
  26. "id": "2369000000000",
  27. "master_id": "9200000000",
  28. "parent_id": "",
  29. "name": "你好",
  30. "type": 1,
  31. "level": 1,
  32. "limit_amount": 0,
  33. "is_category": false
  34. },
  35. ]
  36. }

角色 Role

字段 类型 说明
role_id int 角色 id
name string 角色名称
color int 颜色色值
position int 顺序位置
hoist int 是否为角色设定(与普通成员分开显示)
mentionable int 是否允许任何人@提及此角色
permissions int 权限码

示例

  1. {
  2. "role_id": 11111,
  3. "name": "新角色",
  4. "color": 0,
  5. "position": 5,
  6. "hoist": 0,
  7. "mentionable": 0,
  8. "permissions": 142924296
  9. }

频道 Channel

字段 类型 说明
id string 频道 id
name string 频道名称
user_id string 创建者 id
guild_id string 服务器 id
topic string 频道简介
is_category boolean 是否为分组,事件中为 int 格式
parent_id string 上级分组的 id
level int 排序 level
slow_mode int 慢速模式下限制发言的最短时间间隔, 单位为秒(s)
type int 频道类型: 1 文字频道, 2 语音频道
permission_overwrites Array 针对角色在该频道的权限覆写规则组成的列表
permission_users array 针对用户在该频道的权限覆写规则组成的列表
permission_sync int 权限设置是否与分组同步, 1 or 0

示例

  1. {
  2. "id": "53002000000000",
  3. "name": "新的频道",
  4. "user_id": "2418239356",
  5. "guild_id": "6016389000000",
  6. "is_category": false,
  7. "parent_id": "6016400000000000",
  8. "level": 12,
  9. "slow_mode": 0,
  10. "topic": "新的频道的说明",
  11. "type": 1,
  12. "permission_overwrites": [
  13. {
  14. "role_id": 0,
  15. "allow": 0,
  16. "deny": 0
  17. }
  18. ],
  19. "permission_users": [
  20. {
  21. //user字段参见 https://developer.kaiheila.cn/doc/objects#%E7%94%A8%E6%88%B7User
  22. "user": {
  23. "id": "0",
  24. "username": "花荣",
  25. "identify_num": "12",
  26. "online": true,
  27. "os": "Websocket",
  28. "status": 1,
  29. "avatar": "xxxx",
  30. "mobile_verified": true,
  31. "nickname": "test",
  32. "roles": [],
  33. "joined_at": 1602596021000,
  34. "active_time": 1612703344396
  35. },
  36. "allow": 0,
  37. "deny": 0
  38. }
  39. ],
  40. "permission_sync": 1
  41. }

引用消息 Quote

字段 类型 说明
id string 引用消息 id
type int 引用消息类型
content string 引用消息内容
create_at int 引用消息创建时间(毫秒)
author map 作者的用户信息

示例

  1. {
  2. "id": "1c4532f6-*********-93e9-6347f410f91c",
  3. "type": 1,
  4. "content": "hello world",
  5. "create_at": 1628069285358,
  6. "author": {
  7. "id": "308****000",
  8. "username": "盖 伦",
  9. "identify_num": "**10",
  10. "online": true,
  11. "os": "Websocket",
  12. "status": 1,
  13. "avatar": "https://xxx.jpg/icon",
  14. "vip_avatar": "",
  15. "nickname": "***11377",
  16. "roles": [
  17. 102,
  18. 816
  19. ],
  20. "is_vip": false,
  21. "bot": false,
  22. "mobile_verified": true,
  23. "joined_at": 1573816459000,
  24. "active_time": 1628229821490
  25. }
  26. }

附加的多媒体数据 Attachments

字段 类型 说明
type string 多媒体类型
url int 多媒体地址
name string 多媒体名
size int 大小 单位(B)

示例

  1. {
  2. "type": "video",
  3. "url": "https://***.mp4",
  4. "name": "***.mp4",
  5. "size": 2575670,
  6. }

含有附件的消息示例详见消息相关事件