예제 #1
0
        public static async Task ShopStart(SocketTextChannel channel, SocketGuildUser user)
        {
            //Get the account information of the command's target
            var account = UserInfoClasses.GetAccount(user);

            var embed  = new EmbedBuilder();
            var author = new EmbedAuthorBuilder
            {
                Name    = "Now Loading...",
                IconUrl = user.GetAvatarUrl()
            };

            embed.WithAuthor(author);

            //Determine color for embeded message
            if (account.Profile_Theme == "P3")
            {
                embed.WithColor(37, 149, 255);
            }
            else if (account.Profile_Theme == "P4")
            {
                embed.WithColor(255, 229, 49);
            }
            else if (account.Profile_Theme == "P5")
            {
                embed.WithColor(213, 27, 4);
            }

            // Create a null variable for the message.
            RestUserMessage message = null;

            // Try to send a message to the channel. If the bot lacks permissions, catch the exception and return.
            try
            {
                message = await channel.SendMessageAsync("", false, embed.Build());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return;
            }

            // Create a string list variable.
            List <string> original_decor_list;

            // Depending on the user's settings, fill the string list with an assortment of décor according to how the user wishes for it to be organized.
            original_decor_list = DecorInfoMethods.CreateSortSettingList(account.Shop_Sort);

            // Create an empty string list.
            List <string> owned_decor = new List <string> {
            };

            // Check if the user owns any décor.
            if (account.Decor_Owned != "")
            {
                // If so, convert their Decor_Owned value into a string list and assign it to the owned_decor string list.
                owned_decor = DecorInfoMethods.StringToStringArray(account.Decor_Owned);
            }

            // Start comparing the user's owned_decor list to the created decor_list for the shop.
            // If the user owns any décor from the decor_list or has content blocked, remove the matching entry from the list
            var new_decor_list = original_decor_list.Except(owned_decor).ToList();

            // Create another empty string list.
            List <string> user_content_filter = new List <string> {
            };

            // Check if the user has any titles listed in their content filter.
            if (account.Content_Filter != "")
            {
                // If so, convert their Content_Filter value into a string list and assign it to the user_content_filter string list.
                user_content_filter = DecorInfoMethods.StringToStringArray(account.Content_Filter);
            }

            // Create a new list by removing any décor that contains content specified in the user's content filter and assign it to the new_decor_list variable.
            new_decor_list = DecorInfoMethods.RemoveBlockedContentFromList(new_decor_list, user_content_filter);

            // Search for an item list that corresponds to the user's ID.
            var itemSession = Global.ItemIdList.SingleOrDefault(x => x.User.Id == user.Id);

            // If an item session already exists, remove it from the global list.
            if (itemSession != null)
            {
                Global.ItemIdList.Remove(itemSession);
            }

            // Create a new item identifier entry for this current user to keep track of the position of décor on the menu.
            itemSession = new ItemListIterator()
            {
                User              = user,
                ItemList          = new_decor_list,
                ItemIndexBase     = 0,
                MaxItemsDisplayed = 6,
                CurrentPage       = 1
            };

            // Add the item entry to the global list.
            Global.ItemIdList.Add(itemSession);

            // Create a new menu identifier entry for this current message and user to keep track of the overall menu status.
            var idTracker = new MenuIdStructure()
            {
                User        = user,
                MenuMessage = message,
                CurrentMenu = "Shop_Start",
                MenuTimer   = new Timer()
                {
                    // Create a timer that expires as a "time out" duration for the user.
                    Interval  = MenuConfig.menu.timerDuration,
                    AutoReset = false,
                    Enabled   = true
                }
            };

            // Add the menu entry to the global list.
            Global.MenuIdList.Add(idTracker);

            // Create a new menu in the current channel.
            await ShopMainMenu(idTracker.User, idTracker.MenuMessage);
        }
예제 #2
0
        public static async Task Status_Decor_Start(SocketGuildUser user, RestUserMessage message)
        {
            //Get the account information of the command's target
            var account = UserInfoClasses.GetAccount(user);

            // Find the menu session associated with the current user.
            var menuSession = Global.MenuIdList.SingleOrDefault(x => x.User.Id == user.Id);

            var embed  = new EmbedBuilder();
            var author = new EmbedAuthorBuilder
            {
                Name    = "Now Loading...",
                IconUrl = user.GetAvatarUrl()
            };

            embed.WithAuthor(author);

            // Determine the color and thumbnail for the embeded message.
            embed.WithColor(EmbedSettings.Get_Profile_Embed_Color(account));

            // Create an empty string list.
            List <string> owned_decor = new List <string> {
            };

            // Check if the user owns any décor.
            if (account.Decor_Owned != "")
            {
                // If so, convert their Decor_Owned value into a string list and assign it to the owned_decor string list.
                owned_decor = DecorInfoMethods.StringToStringArray(account.Decor_Owned);
            }

            // Create another empty string list.
            List <string> user_content_filter = new List <string> {
            };

            // Check if the user has any titles listed in their content filter.
            if (account.Content_Filter != "")
            {
                // If so, convert their Content_Filter value into a string list and assign it to the user_content_filter string list.
                user_content_filter = DecorInfoMethods.StringToStringArray(account.Content_Filter);
            }

            // Create a new list by removing any décor that contains content specified in the user's content filter and assign it to the owned_decor variable.
            owned_decor = DecorInfoMethods.RemoveBlockedContentFromList(owned_decor, user_content_filter);

            // Search for an item list that corresponds to the user's ID.
            var itemSession = Global.ItemIdList.SingleOrDefault(x => x.User.Id == user.Id);

            // If an item session already exists, remove it from the global list.
            if (itemSession != null)
            {
                Global.ItemIdList.Remove(itemSession);
            }

            // Create a new item identifier entry for this current user to keep track of the position of décor on the menu.
            itemSession = new ItemListIterator()
            {
                User              = user,
                ItemList          = owned_decor,
                ItemIndexBase     = 0,
                MaxItemsDisplayed = 6,
                CurrentPage       = 1
            };

            // Add the item entry to the global list.
            Global.ItemIdList.Add(itemSession);

            // Attempt editing the message if it hasn't been deleted by the user yet. If it has, catch the exception, send an error message, and return.
            try
            {
                // Remove all reactions from the current message.
                await message.RemoveAllReactionsAsync();

                // Edit the current active message by replacing it with the recently created embed.
                await message.ModifyAsync(x => {
                    x.Embed = embed.Build();
                });
            }
            catch (Exception ex)
            {
                await ErrorHandling.MissingMessageError((SocketTextChannel)message.Channel);

                Console.WriteLine(ex);
                return;
            }

            // Edit the menu session according to the current message.
            menuSession.CurrentMenu = "Status_Decor_Start";
            menuSession.MenuTimer   = new Timer()
            {
                // Create a timer that expires as a "time out" duration for the user.
                Interval  = MenuConfig.menu.timerDuration,
                AutoReset = false,
                Enabled   = true
            };

            // Create a new menu in the current channel.
            await Status_Decor_Main(menuSession.User, menuSession.MenuMessage);
        }