diff --git a/src/internal/bot/commands.go b/src/internal/bot/commands.go index 2bfbca2..6394be6 100644 --- a/src/internal/bot/commands.go +++ b/src/internal/bot/commands.go @@ -137,7 +137,12 @@ func showTopEmojis(s *discordgo.Session, i *discordgo.InteractionCreate) { sort.Ints(subkeys) users := []string{} - msg += fmt.Sprintf("<:%s:%s> %d", top[v].EmojiName, top[v].EmojiID, top[v].Count) + if top[v].EmojiID == top[v].EmojiName { + // Handle bad data with stock emojis + msg += fmt.Sprintf(":%s: %d", top[v].EmojiName, top[v].Count) + } else { + msg += fmt.Sprintf("<:%s:%s> %d", top[v].EmojiName, top[v].EmojiID, top[v].Count) + } for _, sv := range subkeys { users = append(users, fmt.Sprintf("<@%s>: %d", topUsers[sv].EmojiID, topUsers[sv].Count)) } @@ -197,7 +202,12 @@ func showTopUsers(s *discordgo.Session, i *discordgo.InteractionCreate) { users := []string{} msg += fmt.Sprintf("<@%s>: %d", top[v].EmojiID, top[v].Count) for _, sv := range subkeys { - users = append(users, fmt.Sprintf("<:%s:%s> %d", topUsers[sv].EmojiName, topUsers[sv].EmojiID, topUsers[sv].Count)) + if topUsers[sv].EmojiID == topUsers[sv].EmojiName { + // Handle bad data with stock emojis + users = append(users, fmt.Sprintf(":%s: %d", topUsers[sv].EmojiName, topUsers[sv].Count)) + } else { + users = append(users, fmt.Sprintf("<:%s:%s> %d", topUsers[sv].EmojiName, topUsers[sv].EmojiID, topUsers[sv].Count)) + } } msg += " (" + strings.Join(users, ", ") + ")\n" } diff --git a/src/internal/db/database.go b/src/internal/db/database.go index 6366cda..26a78c9 100644 --- a/src/internal/db/database.go +++ b/src/internal/db/database.go @@ -61,9 +61,21 @@ func (db *Database) runMigrations() (*Database, error) { return db, err } - _, err = db.db.Exec("CREATE INDEX IF NOT EXISTS `idx_emoji_usage_emoji_id,guild_id` ON `emoji_usage` (`guild_id`, `emoji_id`)") + // emojitest := map[string]string{ + // "pepe_analyze": "579431592624390147", + // "kekw": "1317987954102112347", + // "pepe_kek": "1300985103182336010", + // "KEKW": "649918246119669770", + // } - return db, err + // for name, id := range emojitest { + // _, err = db.db.Exec("UPDATE `emoji_usage` SET `emoji_id` = '" + id + "' WHERE `emoji_name` = '" + name + "'") + // if err != nil { + // return db, err + // } + // } + + return db, nil } // CloseDbConn - Closes DB connection