diff --git a/commands/macro.go b/commands/macro.go index fce8168..66de882 100644 --- a/commands/macro.go +++ b/commands/macro.go @@ -14,7 +14,7 @@ var ( ) func handleMacro(dg *discordgo.Session, m *discordgo.MessageCreate, split []string) { - for k, _ := range split { + for k := range split { split[k] = strings.ToLower(split[k]) if val, ok := CommonReplacement[split[k]]; ok { split[k] = val diff --git a/db/db.go b/db/db.go index d0d9641..4a6b544 100644 --- a/db/db.go +++ b/db/db.go @@ -18,5 +18,8 @@ func init() { } func Close() { - db.Close() + err := db.Close() + if err != nil { + panic(err) + } } diff --git a/level/roles.go b/level/roles.go index fe0177a..bb60157 100644 --- a/level/roles.go +++ b/level/roles.go @@ -17,7 +17,7 @@ func QueueRoles(dg *discordgo.Session) { for { time.Sleep(5 * time.Second) for guildID, v := range ShouldCheck { - for userID, _ := range v { + for userID := range v { rank, _ := GetLevelFromXP(db.GetXP(userID)) AssignRoles(dg, guildID, userID, rank) delete(v, userID) @@ -46,6 +46,10 @@ OuterLoop: continue OuterLoop } } - dg.GuildMemberRoleAdd(guildID, userID, Roles[i]) + err := dg.GuildMemberRoleAdd(guildID, userID, Roles[i]) + if err != nil { + util.ReportError(dg, err) + return + } } } diff --git a/main.go b/main.go index 80894e2..b639498 100644 --- a/main.go +++ b/main.go @@ -42,8 +42,11 @@ func main() { } fmt.Println("Bot is now running. Press CTRL-C to exit.") sc := make(chan os.Signal, 1) - signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill) + signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt) <-sc - dg.Close() + err = dg.Close() + if err != nil { + fmt.Println("error closing connection,", err) + } db.Close() }