diff --git a/LorisAngel.Bot/Database/ProfileDatabase.cs b/LorisAngel.Bot/Database/ProfileDatabase.cs index 38d1f52..d98a2a5 100644 --- a/LorisAngel.Bot/Database/ProfileDatabase.cs +++ b/LorisAngel.Bot/Database/ProfileDatabase.cs @@ -135,7 +135,7 @@ private static async Task> GetAllUsersAsync() if (motto == null) motto = ""; if (claimedAt == null) claimedAt = new DateTime(); - LoriUser newUser = new LoriUser(id, name, createdOn, joinedOn, lastSeen, status, "", lastUpdated, motto, activity, currency, claimedAt); + LoriUser newUser = new LoriUser(id, name, createdOn, joinedOn, lastSeen, status, new List(), lastUpdated, motto, activity, currency, claimedAt); users.Add(newUser); } } @@ -350,7 +350,7 @@ public static void CreateNewUser(IUser user) { DateTime lastseen = new DateTime(); if (user.Status != UserStatus.Offline && user.Status != UserStatus.Invisible) lastseen = DateTime.Now; - LoriUser newUser = new LoriUser(user.Id, "", user.CreatedAt.DateTime, DateTime.Now, lastseen, user.Status.ToString(), "", DateTime.Now); + LoriUser newUser = new LoriUser(user.Id, "", user.CreatedAt.DateTime, DateTime.Now, lastseen, user.Status.ToString(), new List(), DateTime.Now); newUser.SetNew(); Users.Add(newUser); } diff --git a/LorisAngel.Common/Objects/LoriUser.cs b/LorisAngel.Common/Objects/LoriUser.cs index 613ff69..2e8fdec 100644 --- a/LorisAngel.Common/Objects/LoriUser.cs +++ b/LorisAngel.Common/Objects/LoriUser.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Text.RegularExpressions; namespace LorisAngel.Common.Objects @@ -13,7 +14,7 @@ public class LoriUser public string Status { get; private set; } public string Activity { get; private set; } public string Motto { get; private set; } - public string Badges { get; private set; } // WILL BE A LIST OF BADGES ONCE BADGES ADDED + public List Badges { get; private set; } public int Currency; public string Avatar { get; private set; } // WILL BE THE AVATAR ON THEIR PROFILE public string ProfileCard { get; private set; } // WILL BE THE PROFILE BACKGROUND @@ -22,7 +23,7 @@ public class LoriUser public bool IsNew { get; set; } public DateTime Claimed { get; set; } - public LoriUser(ulong id, string name, DateTime createdOn, DateTime joinedOn, DateTime lastSeen, string status, string badges, DateTime lastUpdated, string activity = "", string motto = "", int currency = 0, DateTime claimedAt = new DateTime()) + public LoriUser(ulong id, string name, DateTime createdOn, DateTime joinedOn, DateTime lastSeen, string status, List badges, DateTime lastUpdated, string activity = "", string motto = "", int currency = 0, DateTime claimedAt = new DateTime()) { Id = id; Name = name.Normalize() ?? throw new ArgumentNullException(nameof(name)); @@ -123,6 +124,14 @@ public void UpdateName(string newName) } } + public void AddBadge(int badgeId) + { + if (!Badges.Contains(badgeId)) Badges.Add(badgeId); + + HasChanged = true; + LastUpdated = DateTime.Now; + } + private string Fix(string text) { string fixedText = text.Normalize();