github.com/fumiama/NanoBot@v0.0.0-20231122134259-c22d8183efca/openapi_member.go (about) 1 package nano 2 3 import "time" 4 5 // Member 成员对象 Member and MemberWithGuildID 6 // 7 // https://bot.q.qq.com/wiki/develop/api/openapi/member/model.html 8 type Member struct { 9 GuildID string `json:"guild_id"` // MemberWithGuildID only 10 User *User `json:"user"` 11 Nick string `json:"nick"` 12 Roles []string `json:"roles"` 13 JoinedAt time.Time `json:"joined_at"` 14 Deaf bool `json:"deaf"` 15 Mute bool `json:"mute"` 16 Pending bool `json:"pending"` 17 OpUserID string `json:"op_user_id"` // https://bot.q.qq.com/wiki/develop/api/gateway/guild_member.html#%E5%86%85%E5%AE%B9 18 } 19 20 // GetGuildMembersIn 获取 guild_id 指定的频道中所有成员的详情列表,支持分页 21 // 22 // https://bot.q.qq.com/wiki/develop/api/openapi/member/get_members.html 23 func (bot *Bot) GetGuildMembersIn(id, after string, limit uint32) (members []Member, err error) { 24 err = bot.GetOpenAPI(WriteHTTPQueryIfNotNil("/guilds/"+id+"/members", 25 "after", after, 26 "limit", limit, 27 ), "", &members) 28 return 29 } 30 31 // RoleMembers 频道身份组成员列表 32 // 33 // https://bot.q.qq.com/wiki/develop/api/openapi/member/get_role_members.html#%E8%BF%94%E5%9B%9E 34 type RoleMembers struct { 35 Data []Member `json:"data"` 36 Next string `json:"next"` 37 } 38 39 // GetRoleMembersOf 获取 guild_id 频道中指定role_id身份组下所有成员的详情列表,支持分页 40 // 41 // https://bot.q.qq.com/wiki/develop/api/openapi/member/get_role_members.html 42 func (bot *Bot) GetRoleMembersOf(guildid, roleid, startindex string, limit uint32) (*RoleMembers, error) { 43 return bot.getOpenAPIofRoleMembers(WriteHTTPQueryIfNotNil("/guilds/"+guildid+"/roles/"+roleid+"/members", 44 "start_index", startindex, 45 "limit", limit, 46 )) 47 } 48 49 // GetGuildMemberOf 获取 guild_id 指定的频道中 user_id 对应成员的详细信息 50 // 51 // https://bot.q.qq.com/wiki/develop/api/openapi/member/get_member.html 52 func (bot *Bot) GetGuildMemberOf(guildid, userid string) (*Member, error) { 53 return bot.getOpenAPIofMember("/guilds/" + guildid + "/members/" + userid) 54 } 55 56 // DeleteGuildMemberOf 删除 guild_id 指定的频道下的成员 user_id 57 // 58 // https://bot.q.qq.com/wiki/develop/api/openapi/member/delete_member.html 59 // 60 // - delhistmsgdays: 消息撤回时间范围仅支持固定的天数:3,7,15,30。 特殊的时间范围:-1: 撤回全部消息。默认值为0不撤回任何消息。 61 func (bot *Bot) DeleteGuildMemberOf(guildid, userid string, addblklst bool, delhistmsgdays int) error { 62 return bot.DeleteOpenAPI("/guilds/"+guildid+"/members/"+userid, "", WriteBodyFromJSON(&struct { 63 A bool `json:"add_blacklist"` 64 D int `json:"delete_history_msg_days"` 65 }{addblklst, delhistmsgdays})) 66 }