Compare commits

..
3 Commits
Author SHA1 Message Date
Dustin Pianalto 81f6e23487 Fix array in guild service
CI / build (push) Has been cancelled
2021-01-24 00:46:41 -09:00
Dustin Pianalto 6cf574b22d Add prefix commands
CI / build (push) Has been cancelled
2021-01-24 00:40:02 -09:00
Dustin Pianalto 623df1d55a Add prefix commands
CI / build (push) Has been cancelled
2021-01-24 00:26:34 -09:00
4 changed files with 17 additions and 9 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
}
@@ -12,19 +12,22 @@ BEGIN;
ALTER COLUMN created_at DROP NOT NULL,
ALTER COLUMN content DROP NOT NULL,
ALTER COLUMN channel_id DROP NOT NULL,
ALTER COLUMN author_id DROP NOT NULL,
ALTER COLUMN author_id DROP NOT NULL;
ALTER TABLE messages
ADD COLUMN embed json,
ADD COLUMN previous_embeds json[];
ALTER TABLE patreon_creators
RENAME TO patreon_creator,
ALTER COLUMN creator DROP NOT NULL,
ALTER COLUMN link DROP NOT NULL,
ALTER COLUMN guild_id DROP NOT NULL;
ALTER TABLE patreon_creators
RENAME TO patreon_creator;
ALTER TABLE patreon_tiers
RENAME TO patreon_tier,
ALTER COLUMN name DROP NOT NULL,
ALTER COLUMN creator DROP NOT NULL,
ALTER COLUMN role DROP NOT NULL;
ALTER TABLE patreon_tiers
RENAME TO patreon_tier;
ALTER TABLE requests
ALTER COLUMN author_id DROP NOT NULL,
ALTER COLUMN channel_id DROP NOT NULL,
@@ -12,19 +12,22 @@ BEGIN;
ALTER COLUMN created_at SET NOT NULL,
ALTER COLUMN content SET NOT NULL,
ALTER COLUMN channel_id SET NOT NULL,
ALTER COLUMN author_id SET NOT NULL,
ALTER COLUMN author_id SET NOT NULL;
ALTER TABLE messages
DROP COLUMN embed,
DROP COLUMN previous_embeds;
ALTER TABLE patreon_creator
RENAME TO patreon_creators,
ALTER COLUMN creator SET NOT NULL,
ALTER COLUMN link SET NOT NULL,
ALTER COLUMN guild_id SET NOT NULL;
ALTER TABLE patreon_creator
RENAME TO patreon_creators;
ALTER TABLE patreon_tier
RENAME TO patreon_tiers,
ALTER COLUMN name SET NOT NULL,
ALTER COLUMN creator SET NOT NULL,
ALTER COLUMN role SET NOT NULL;
ALTER TABLE patreon_tier
RENAME TO patreon_tiers;
ALTER TABLE requests
ALTER COLUMN author_id SET NOT NULL,
ALTER COLUMN channel_id SET NOT NULL,
+1
View File
@@ -0,0 +1 @@
package utils