/// <summary>
        /// Method that checks for titles related to rep. Called whenever a user reps another user.
        /// </summary>
        /// <remarks>
        /// This method has a lot of checks, they are all there without return statements for a reason.
        /// It will make sure to fill in any missing titles the user should have gotten.
        /// </remarks>
        /// <param name="from">The user doing the repping</param>
        /// <param name="to">The user who has been repped</param>
        /// <returns></returns>
        public static async Task OnRep(SocketGuildUser from, SocketGuildUser to)
        {
            UserDataNode f = UserDataManager.GetUserData(from);
            UserDataNode t = UserDataManager.GetUserData(to);

            // rep given
            if (f.RepGiven >= 1)
            {
                await AddTitle(from, TitleIDs.WARM_WELCOMER);
            }

            if (f.RepGiven >= 10)
            {
                await AddTitle(from, TitleIDs.DECAREPPER);
            }

            if (f.RepGiven >= 50)
            {
                await AddTitle(from, TitleIDs.CHARITABLE);
            }

            if (f.RepGiven >= 100)
            {
                await AddTitle(from, TitleIDs.HUNDRED_REP_GIVEN);
            }

            if (f.RepGiven >= 500)
            {
                await AddTitle(from, TitleIDs.REPPER_OF_D);
            }

            // rep recieved
            if (t.Reputation >= 1)
            {
                await AddTitle(to, TitleIDs.WARMLY_WELCOMED);
            }

            if (t.Reputation >= 10)
            {
                await AddTitle(to, TitleIDs.TEN_REP);
            }

            if (t.Reputation >= 30)
            {
                await AddTitle(to, TitleIDs.COOL_KID);
            }

            if (t.Reputation >= 100)
            {
                await AddTitle(to, TitleIDs.POPULAR);
            }

            if (t.Reputation >= 1000)
            {
                await AddTitle(to, TitleIDs.MILLENIAL_MEMBER);
            }
        }
        public static UserInventoryNode GetInventory(ulong userId)
        {
            UserDataManager.AddUserIfNotExists(BotUtils.GetGUser(userId));

            if (UserDataManager.GetUserData(BotUtils.GetGUser(userId)).Inventory == null)
            {
                UserDataManager.GetUserData(BotUtils.GetGUser(userId)).Inventory = new UserInventoryNode();
                SaveInventories();
            }

            return(UserDataManager.GetUserData(BotUtils.GetGUser(userId)).Inventory);
        }
        public static void SaveInventories()
        {
            Dictionary <ulong, UserInventoryNode> UserInventories = new Dictionary <ulong, UserInventoryNode>();

            foreach (ulong i in UserDataManager.UserData.Keys)
            {
                if (BotUtils.GetGUser(i) == null)
                {
                    continue;                                // null checking.
                }
                UserInventories.Add(i, UserDataManager.GetUserData(BotUtils.GetGUser(i)).Inventory ?? new UserInventoryNode());
            }

            BotUtils.WriteToJson(UserInventories, DataFileNames.UserInventoriesFile);
            KLog.Info("Saved Inventories.");
        }
        public static async Task AddTitle(SocketGuildUser user, int titleid)
        {
            if (!NodeMap.ContainsKey(titleid))
            {
                KLog.Error($"Attempted to give user {BotUtils.GetFullUsername(user)} invalid title ID #{titleid}");
                return;
            }

            TitleNode node = NodeMap[titleid];

            if (node == null)
            {
                KLog.Error($"Attempted to give user {BotUtils.GetFullUsername(user)} null title with ID #{titleid}");
                return;
            }

            UserDataNode u = UserDataManager.GetUserData(user);

            if (u.Titles == null)
            {
                u.Titles = new List <int>();
            }

            if (u.Titles.Contains(titleid))
            {
                return;                              // Don't give duplicate titles
            }
            u.Titles.Add(titleid);
            node.OnComplete(user);

            KLog.Important($"User {BotUtils.GetFullUsername(user)} has earned title {node.Name}");

            UserDataManager.SaveUserData();

            await AnnounceAchievement(user, node);
        }
 public static bool HasTitleUnlocked(SocketGuildUser user, int title)
 {
     return(UserDataManager.GetUserData(user).Titles.Contains(title));
 }