package commands import ( "github.com/bwmarrin/discordgo" "gitea.teamortix.com/chanbakjsd/Milen/db" "gitea.teamortix.com/chanbakjsd/Milen/util" ) func handleLevel(dg *discordgo.Session, m *discordgo.MessageCreate, arguments []string) { target := m.Author.ID switch len(m.Mentions) { case 0: case 1: target = m.Mentions[0].ID default: util.SendFailEmbed(dg, m.ChannelID, "Invalid Arguments", "You can only check the level of one person at a time.") return } xp := db.GetXP(target) member, err := util.GetMember(dg, m.GuildID, target) if err != nil { util.ReportError(dg, err) util.SendFailEmbed(dg, m.ChannelID, "Error", "Cannot find requested member.") return } embed := &discordgo.MessageEmbed{ Fields: []*discordgo.MessageEmbedField{ &discordgo.MessageEmbedField{ Name: "Active Time", Value: util.FormatPlural(xp, "second", "seconds") + " (or " + util.FormatTime(xp) + ")", }, &discordgo.MessageEmbedField{ Name: "Internal User ID", Value: target, }, }, Thumbnail: &discordgo.MessageEmbedThumbnail{ URL: util.GetAvatar(dg, member.User), }, } if member.Nick != "" { embed.Title = "Level for " + member.Nick + " (" + member.User.Username + "#" + member.User.Discriminator + ")" } else { embed.Title = "Level for " + member.User.Username + "#" + member.User.Discriminator } util.SendEmbed(dg, m.ChannelID, embed) }