Пример #1
0
        public static Task Nav_ShopDecorPreview(SocketReaction reaction, MenuIdStructure menuSession)
        {
            if (reaction.Emote.Name == "↩️")
            {
                // Stop the timeout timer associated with the menu
                menuSession.MenuTimer.Stop();

                // Go to a new menu
                _ = ShopMenu.ShopMainMenu(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            // If the user reacts with the checkmark emote, it's time to purchase the décor!
            else if (reaction.Emote.Name == "✅")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Search for an item list that corresponds to the user's ID. If a menu entry was found, this should also exist alongside it.
                var itemSession = Global.ItemIdList.SingleOrDefault(x => x.User.Id == reaction.UserId);

                // Get the information of the chosen décor index.
                var decor_info = DecorInfoMethods.GetDecorInfo(itemSession.SelectedItem);

                // If the user has not maxed out their Star Level rank, deduct the cost of the purchased décor from the user's P-Medal value.
                if (account.Level_Resets < 3)
                {
                    account.P_Medals -= decor_info.Price;
                }

                // Add the purchased item to the user's list of owned décor.
                account.Decor_Owned += $"{itemSession.SelectedItem};";

                //Update the user's account.
                UserInfoClasses.UpdateAccount(account);

                // Stop the timeout timer associated with the menu
                menuSession.MenuTimer.Stop();

                // Go to a new menu
                _ = ShopMenu.ShopDecorPurchased(menuSession.User, menuSession.MenuMessage);
                return(Task.CompletedTask);
            }

            return(Task.CompletedTask);
        }