This commit is contained in:
2024-11-05 13:03:06 -06:00
parent 46c24134d5
commit ce580e77fd
3 changed files with 27 additions and 8 deletions

View File

@ -114,12 +114,6 @@ func ProcessMessage(s *discordgo.Session, m *discordgo.MessageCreate) error {
func GetBalance(discordID, guildID string) (int, error) {
var balance int
_, syncError := DBConnector.Sync()
if syncError != nil {
fmt.Println("Error syncing database:", syncError)
}
queryError := DBClient.QueryRow(`
SELECT h.balance
FROM himbucks h
@ -135,6 +129,17 @@ func GetBalance(discordID, guildID string) (int, error) {
return balance, nil
}
func SyncBalance() error {
_, syncError := DBConnector.Sync()
if syncError != nil {
fmt.Println("Error syncing database:", syncError)
return syncError
}
return nil
}
func GetLeaderboard(guildID string, limit int) ([]HimbucksEntry, error) {
rows, err := DBClient.Query(`
SELECT u.username, h.balance, h.message_count