Merge pull request #6 from dustinpianalto/development
Some checks are pending
CI / build (push) Waiting to run
Some checks are pending
CI / build (push) Waiting to run
Attempt to insert user into db before creating tag
This commit is contained in:
commit
f6f020ff48
@ -7,7 +7,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/dustinpianalto/disgoman"
|
"github.com/dustinpianalto/disgoman"
|
||||||
|
"github.com/dustinpianalto/goff"
|
||||||
"github.com/dustinpianalto/goff/internal/postgres"
|
"github.com/dustinpianalto/goff/internal/postgres"
|
||||||
|
"github.com/dustinpianalto/goff/internal/services"
|
||||||
)
|
)
|
||||||
|
|
||||||
var AddTagCommand = &disgoman.Command{
|
var AddTagCommand = &disgoman.Command{
|
||||||
@ -55,6 +57,10 @@ func addTagCommandFunc(ctx disgoman.Context, input []string) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
err = services.UserService.CreateUser(&goff.User{ID: ctx.User.ID})
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error creating user %s: %s", ctx.User.ID, err.Error())
|
||||||
|
}
|
||||||
queryString = `INSERT INTO tags (tag, content, creator, guild_id) VALUES ($1, $2, $3, $4);`
|
queryString = `INSERT INTO tags (tag, content, creator, guild_id) VALUES ($1, $2, $3, $4);`
|
||||||
_, err := postgres.DB.Exec(queryString, tag, value, ctx.Message.Author.ID, ctx.Guild.ID)
|
_, err := postgres.DB.Exec(queryString, tag, value, ctx.Message.Author.ID, ctx.Guild.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -38,7 +38,7 @@ func (s *UserService) User(id string) (*goff.User, error) {
|
|||||||
|
|
||||||
func (s *UserService) CreateUser(u *goff.User) error {
|
func (s *UserService) CreateUser(u *goff.User) error {
|
||||||
queryString := `INSERT INTO users (id, banned, logging, steam_id, is_active, is_staff, is_admin)
|
queryString := `INSERT INTO users (id, banned, logging, steam_id, is_active, is_staff, is_admin)
|
||||||
VALUES ($1, $2, $3, $4, $5, $6, $7)`
|
VALUES ($1, $2, $3, $4, $5, $6, $7) ON CONFLICT (id) DO NOTHING`
|
||||||
_, err := s.DB.Exec(queryString, u.ID, u.Banned, u.Logging, u.SteamID, u.IsActive, u.IsStaff, u.IsAdmin)
|
_, err := s.DB.Exec(queryString, u.ID, u.Banned, u.Logging, u.SteamID, u.IsActive, u.IsStaff, u.IsAdmin)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user