Compare commits

...
2 Commits
Author SHA1 Message Date
Dustin Pianalto 4895294969 fix role commands
CI / build (push) Has been cancelled
2021-01-25 23:09:21 -09:00
Dustin Pianalto 9d0d1ddd56 fix role commands
CI / build (push) Has been cancelled
2021-01-25 23:04:43 -09:00
2 changed files with 8 additions and 2 deletions
+2 -2
View File
@@ -113,8 +113,8 @@ func (s guildService) GetOrCreateGuild(id string) (geeksbot.Guild, error) {
}
func (s guildService) CreateOrUpdateRole(r geeksbot.Role) (geeksbot.Role, error) {
role, err := s.Role(r.ID)
if err.Error() == `pq: duplicate key value violates unique constraint "roles_pkey"` {
role, err := s.CreateRole(r)
if err != nil && err.Error() == `pq: duplicate key value violates unique constraint "roles_pkey"` {
role, err = s.UpdateRole(r)
}
return role, err
+6
View File
@@ -37,6 +37,9 @@ func addModeratorRoleCommandFunc(ctx disgoman.Context, args []string) {
if _, ok := added[id]; ok {
continue
}
if _, err = ctx.Session.State.Role(ctx.Guild.ID, id); err != nil {
_, _ = ctx.Send(fmt.Sprintf("%s does not reference a valid role for this guild.", id))
}
_, err := services.GuildService.CreateOrUpdateRole(geeksbot.Role{
ID: id,
RoleType: "moderator",
@@ -83,6 +86,9 @@ func addAdminRoleCommandFunc(ctx disgoman.Context, args []string) {
if _, ok := added[id]; ok {
continue
}
if _, err = ctx.Session.State.Role(ctx.Guild.ID, id); err != nil {
_, _ = ctx.Send(fmt.Sprintf("%s does not reference a valid role for this guild.", id))
}
_, err := services.GuildService.CreateOrUpdateRole(geeksbot.Role{
ID: id,
RoleType: "admin",