Compare commits

...
3 Commits
Author SHA1 Message Date
Dustin Pianalto 888d356b67 debug removing prefix
CI / build (push) Has been cancelled
2021-01-24 00:57:00 -09:00
Dustin Pianalto c776b25899 debug removing prefix
CI / build (push) Has been cancelled
2021-01-24 00:53:04 -09:00
Dustin Pianalto 81f6e23487 Fix array in guild service
CI / build (push) Has been cancelled
2021-01-24 00:46:41 -09:00
2 changed files with 7 additions and 4 deletions
+4 -3
View File
@@ -5,6 +5,7 @@ import (
"log"
"github.com/dustinpianalto/geeksbot"
"github.com/lib/pq"
)
type guildService struct {
@@ -15,7 +16,7 @@ func (s guildService) Guild(id string) (geeksbot.Guild, error) {
var g geeksbot.Guild
queryString := "SELECT id, new_patron_message, prefixes FROM guilds WHERE id = $1"
row := s.db.QueryRow(queryString, id)
err := row.Scan(&g.ID, &g.NewPatronMessage, &g.Prefixes)
err := row.Scan(&g.ID, &g.NewPatronMessage, pq.Array(&g.Prefixes))
if err != nil {
return geeksbot.Guild{}, err
}
@@ -24,7 +25,7 @@ func (s guildService) Guild(id string) (geeksbot.Guild, error) {
func (s guildService) CreateGuild(g geeksbot.Guild) (geeksbot.Guild, error) {
queryString := "INSERT INTO guilds (id, new_patron_message, prefixes) VALUES ($1, $2, $3)"
_, err := s.db.Exec(queryString, g.ID, g.NewPatronMessage, g.Prefixes)
_, err := s.db.Exec(queryString, g.ID, g.NewPatronMessage, pq.Array(g.Prefixes))
return g, err
}
@@ -36,7 +37,7 @@ func (s guildService) DeleteGuild(g geeksbot.Guild) error {
func (s guildService) UpdateGuild(g geeksbot.Guild) (geeksbot.Guild, error) {
queryString := "UPDATE guilds SET new_patron_message = $2, prefixes = $3 WHERE id = $1"
_, err := s.db.Exec(queryString, g.ID, g.NewPatronMessage, g.Prefixes)
_, err := s.db.Exec(queryString, g.ID, g.NewPatronMessage, pq.Array(g.Prefixes))
return g, err
}
+3 -1
View File
@@ -2,6 +2,7 @@ package guild
import (
"fmt"
"log"
"github.com/dustinpianalto/disgoman"
"github.com/dustinpianalto/geeksbot"
@@ -80,13 +81,14 @@ func removePrefixCommandFunc(ctx disgoman.Context, args []string) {
}
} else {
for _, a := range args {
l := len(guild.Prefixes) - 1
l := len(guild.Prefixes)
for i := 0; i < l; i++ {
if a == guild.Prefixes[i] {
guild.Prefixes = append(guild.Prefixes[:i], guild.Prefixes[i+1:]...)
l--
i--
removed = append(removed, a)
log.Println(a)
}
}
}