Spending lots of time on useless discord bots makes to make the pain go away

This commit is contained in:
2024-11-05 18:01:58 -06:00
parent 82c62658bb
commit 5a1158048d
10 changed files with 162 additions and 125 deletions

View File

@ -154,27 +154,3 @@ func runMigrations() error {
log.Println("Database migrations completed successfully")
return nil
}
func StoreUser(discordID, username string) error {
// Check if user exists
var exists bool
err := DBClient.QueryRow(
"SELECT EXISTS(SELECT 1 FROM users WHERE discord_id = ?)",
discordID).Scan(&exists)
if err != nil {
return fmt.Errorf("failed to check user existence: %w", err)
}
// If user doesn't exist, insert them
if !exists {
_, err = DBClient.Exec(
"INSERT INTO users (discord_id, username) VALUES (?, ?)",
discordID, username)
if err != nil {
return fmt.Errorf("failed to store user: %w", err)
}
log.Printf("New user stored: %s (%s)", username, discordID)
}
return nil
}