github.com/fumiama/NanoBot@v0.0.0-20231122134259-c22d8183efca/openapi_guild.go (about) 1 package nano 2 3 import "time" 4 5 // Guild 频道对象 6 // 7 // https://bot.q.qq.com/wiki/develop/api/openapi/guild/model.html 8 type Guild struct { 9 ID string `json:"id"` 10 Name string `json:"name"` 11 Icon string `json:"icon"` 12 OwnerID string `json:"owner_id"` 13 Owner bool `json:"owner"` 14 JoinedAt time.Time `json:"joined_at"` 15 MemberCount int `json:"member_count"` 16 MaxMembers int `json:"max_members"` 17 Description string `json:"description"` 18 OpUserID string `json:"op_user_id"` // https://bot.q.qq.com/wiki/develop/api/gateway/guild.html#%E4%BA%8B%E4%BB%B6%E5%86%85%E5%AE%B9 19 } 20 21 // GetGuildByID 获取 guild_id 指定的频道的详情 22 // 23 // https://bot.q.qq.com/wiki/develop/api/openapi/guild/get_guild.html 24 func (bot *Bot) GetGuildByID(id string) (*Guild, error) { 25 return bot.getOpenAPIofGuild("/guilds/" + id) 26 } 27 28 // SetAllMuteInGuild 禁言全员 / 解除全员禁言 29 // 30 // https://bot.q.qq.com/wiki/develop/api/openapi/guild/patch_guild_mute.html 31 func (bot *Bot) SetAllMuteInGuild(id string, endtimestamp string, seconds string) error { 32 return bot.PatchOpenAPI("/guilds/"+id+"/mute", "", nil, WriteBodyFromJSON(&struct { 33 T string `json:"mute_end_timestamp"` 34 S string `json:"mute_seconds"` 35 }{endtimestamp, seconds})) 36 } 37 38 // SetUserMuteInGuild 禁言 / 解除禁言频道 guild_id 下的成员 user_id 39 // 40 // https://bot.q.qq.com/wiki/develop/api/openapi/guild/patch_guild_mute.html 41 func (bot *Bot) SetUserMuteInGuild(guildid, userid string, endtimestamp string, seconds string) error { 42 return bot.PatchOpenAPI("/guilds/"+guildid+"/members/"+userid+"/mute", "", nil, WriteBodyFromJSON(&struct { 43 T string `json:"mute_end_timestamp"` 44 S string `json:"mute_seconds"` 45 }{endtimestamp, seconds})) 46 } 47 48 // SetUsersMuteInGuild 批量禁言 / 解除禁言频道 guild_id 下的成员 user_id 49 // 50 // https://bot.q.qq.com/wiki/develop/api/openapi/guild/patch_guild_mute.html 51 func (bot *Bot) SetUsersMuteInGuild(guildid string, endtimestamp string, seconds string, userids ...string) ([]string, error) { 52 resp := &struct { 53 CodeMessageBase 54 U []string `json:"user_ids"` 55 }{} 56 err := bot.PatchOpenAPI("/guilds/"+guildid+"/mute", "", resp, WriteBodyFromJSON(&struct { 57 T string `json:"mute_end_timestamp"` 58 S string `json:"mute_seconds"` 59 U []string `json:"user_ids"` 60 }{endtimestamp, seconds, userids})) 61 return resp.U, err 62 }