Skip to content

Commit

Permalink
fix: role api issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrs4s committed Nov 23, 2021
1 parent b4d797a commit bb76994
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
23 changes: 17 additions & 6 deletions coolq/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,25 @@ func (bot *CQBot) CQGetGuildMembers(guildID uint64) global.MSG {
// CQGetGuildRoles 获取频道角色列表
// @route(get_guild_roles)
func (bot *CQBot) CQGetGuildRoles(guildID uint64) global.MSG {
roles, err := bot.Client.GuildService.GetGuildRoles(guildID)
r, err := bot.Client.GuildService.GetGuildRoles(guildID)
if err != nil {
log.Errorf("获取频道 %v 角色列表时出现错误: %v", guildID, err)
return Failed(100, "API_ERROR", err.Error())
}
return OK(global.MSG{
"roles": roles,
})
roles := make([]global.MSG, len(r))
for i, role := range r {
roles[i] = global.MSG{
"role_id": fU64(role.RoleId),
"role_name": role.RoleName,
"argb_color": role.ArgbColor,
"independent": role.Independent,
"member_count": role.Num,
"max_count": role.MaxNum,
"owned": role.Owned,
"disabled": role.Disabled,
}
}
return OK(roles)
}

// CQCreateGuildRole 创建频道角色
Expand All @@ -182,7 +193,7 @@ func (bot *CQBot) CQCreateGuildRole(guildID uint64, name string, color uint32, i
return Failed(100, "API_ERROR", err.Error())
}
return OK(global.MSG{
"role": role,
"role_id": fU64(role),
})
}

Expand Down Expand Up @@ -215,7 +226,7 @@ func (bot *CQBot) CQSetGuildMemberRole(guildID uint64, set bool, roleID uint64,
}

// CQModifyRoleInGuild 修改频道角色
// @route(modify_role_in_guild)
// @route(update_guild_role)
func (bot *CQBot) CQModifyRoleInGuild(guildID uint64, roleID uint64, name string, color uint32, indepedent bool) global.MSG {
err := bot.Client.GuildService.ModifyRoleInGuild(guildID, roleID, name, color, indepedent)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.17
require (
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f
github.com/Microsoft/go-winio v0.5.1
github.com/Mrs4s/MiraiGo v0.0.0-20211122140519-ec4cd4a6f3fe
github.com/Mrs4s/MiraiGo v0.0.0-20211123160412-4c60c8ee4740
github.com/dustin/go-humanize v1.0.0
github.com/fumiama/go-hide-param v0.1.4
github.com/gabriel-vasile/mimetype v1.4.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f/g
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Microsoft/go-winio v0.5.1 h1:aPJp2QD7OOrhO5tQXqQoGSJc+DjDtWTGLOmNyAm6FgY=
github.com/Microsoft/go-winio v0.5.1/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
github.com/Mrs4s/MiraiGo v0.0.0-20211122140519-ec4cd4a6f3fe h1:ydfvvxZsVwbqzyfmQ5ExOhQhiZr/5IyjauBIBnupkFA=
github.com/Mrs4s/MiraiGo v0.0.0-20211122140519-ec4cd4a6f3fe/go.mod h1:imVKbfKqqeit+C/eaWGb4MKQ3z3gN6pRpBU5RMtp5so=
github.com/Mrs4s/MiraiGo v0.0.0-20211123160412-4c60c8ee4740 h1:8i8ILE2q+jw8zhmTtsNRhwrufkJQJ2kOyVhncmAfhTg=
github.com/Mrs4s/MiraiGo v0.0.0-20211123160412-4c60c8ee4740/go.mod h1:imVKbfKqqeit+C/eaWGb4MKQ3z3gN6pRpBU5RMtp5so=
github.com/bits-and-blooms/bitset v1.2.1 h1:M+/hrU9xlMp7t4TyTDQW97d3tRPVuKFC6zBEK16QnXY=
github.com/bits-and-blooms/bitset v1.2.1/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
14 changes: 7 additions & 7 deletions modules/api/api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bb76994

Please sign in to comment.