1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package config
import (
"context"
"git.anhgelus.world/anhgelus/les-copaings-bot/common"
)
type XpRole struct {
XP uint
RoleID uint64
GuildID uint64
}
func (xp XpRole) Save(ctx context.Context) error {
_, err := common.GetDB(ctx).ExecContext(
ctx,
`INSERT INTO xp_roles (xp, role, guild_id) VALUES (?, ?, ?)`,
xp.XP, xp.RoleID, xp.GuildID,
)
return err
}
func (xp XpRole) Delete(ctx context.Context) error {
_, err := common.GetDB(ctx).ExecContext(
ctx,
`DELETE FROM xp_roles WHERE xp = ? AND role = ? AND guild_id = ?`,
xp.XP, xp.RoleID, xp.GuildID,
)
return err
}
|