add admin role command

This commit is contained in:
Dustin Pianalto
2021-01-25 22:41:51 -09:00
parent c62f0f2f47
commit dc20dcf959
3 changed files with 43 additions and 3 deletions
+5 -3
View File
@@ -113,7 +113,9 @@ func (s guildService) GetOrCreateGuild(id string) (geeksbot.Guild, error) {
}
func (s guildService) CreateOrUpdateRole(r geeksbot.Role) (geeksbot.Role, error) {
queryString := "INSERT INTO roles (id, role_type, guild_id) VALUES ($1, $2, $3)"
_, err := s.db.Exec(queryString, r.ID, r.RoleType, r.Guild.ID)
return r, err
role, err := s.Role(r.ID)
if err.Error() == `pq: duplicate key value violates unique constraint "roles_pkey"` {
role, err = s.UpdateRole(r)
}
return role, err
}