Fix duplicate leaderboard entries, add /version command, fix jail DNS
- db/db.go: Add write-time username sync in AddLog to prevent duplicate leaderboard entries when users change display names. Revert correlated subqueries back to GROUP BY user_id, username (simpler approach). - db/db.go: Early return in onMessageCreate if bot already reacted (prevents duplicate emoji reactions on Discord reconnection). - bot/bot.go: Add /version slash command with build version injection. - main.go: Add version variable with ldflags support. - Makefile: Add dns-fix, test, vet, build-native, pg-*, boot targets. Prepend test+vet to deploy pipeline. Add version ldflags to build. - db/migrations/002_fix_usernames.sql: One-time SQL to backfill old usernames. - scripts/fix-jail-dns.sh: Script to update jail resolv.conf from 8.8.8.8 to reachable nameservers (1.1.1.1, 9.9.9.9, 172.16.0.1). Signed-off-by: Blake Ridgway <blake@blakeridgway.com>
This commit is contained in:
7
main.go
7
main.go
@@ -13,6 +13,9 @@ import (
|
||||
"cycling-discord-bot/db"
|
||||
)
|
||||
|
||||
// Build version, set via ldflags at build time (see Makefile)
|
||||
var version = "dev"
|
||||
|
||||
func main() {
|
||||
_ = godotenv.Load()
|
||||
|
||||
@@ -26,7 +29,7 @@ func main() {
|
||||
}
|
||||
defer database.Close()
|
||||
|
||||
b, err := bot.New(token, database, guildID)
|
||||
b, err := bot.New(token, database, guildID, version)
|
||||
if err != nil {
|
||||
log.Fatalf("create bot: %v", err)
|
||||
}
|
||||
@@ -39,6 +42,8 @@ func main() {
|
||||
// Give the session a moment to identify before registering commands
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
|
||||
log.Printf("starting cycling-discord-bot version %s", version)
|
||||
|
||||
if err := b.RegisterCommands(); err != nil {
|
||||
log.Fatalf("register commands: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user