Exemplo n.º 1
0
        public static async Task Content_Filter_Confirm(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);

            // Search for a content filter list that corresponds to the user's ID.
            var filterSession = Global.ContentFilterList.SingleOrDefault(x => x.User.Id == menuSession.User.Id);

            // Create a list variable containing the content filter of the command user.
            List <string> user_filter = ContentFilterMethods.ParseContentFilter(account);

            // Using the newly created content filter list, create a new list that converts all the game acronyms into proper titles.
            List <string> filter_titles = ContentFilterMethods.AcronymToTitle(user_filter);

            // Create an empty string variable.
            string filter_text = "";

            // Iterating through the title list, add each entry to the string variable.
            for (int i = 0; i < filter_titles.Count; i++)
            {
                filter_text += $"**`{filter_titles[i]}`**\n";
            }

            // Create a new embed that will be displayed in the message.
            var embed  = new EmbedBuilder();
            var author = new EmbedAuthorBuilder
            {
                Name    = "Settings Saved",
                IconUrl = user.GetAvatarUrl()
            };

            embed.WithAuthor(author);

            var footer = new EmbedFooterBuilder
            {
                Text = "💠 General Settings Menu | ❌ Close Menu"
            };

            embed.WithFooter(footer);

            // Determine the color and thumbnail for the embeded message.
            if (account.Profile_Theme == "P3")
            {
                embed.WithColor(37, 149, 255);
                embed.WithThumbnailUrl("https://i.imgur.com/7xnoaQ7.png");
            }
            else if (account.Profile_Theme == "P4")
            {
                embed.WithColor(255, 229, 49);
                embed.WithThumbnailUrl("https://i.imgur.com/4vtG4On.png");
            }
            else if (account.Profile_Theme == "P5")
            {
                embed.WithColor(213, 27, 4);
                embed.WithThumbnailUrl("https://i.imgur.com/bVSsGsA.png");
            }

            // Create different descriptions depending on whether or not there are titles in the user's content filter.
            if (filter_text == "")
            {
                embed.WithDescription("No titles are currently being filtered out.");
            }
            else
            {
                embed.WithDescription("" +
                                      "The following titles will be filtered out:\n" +
                                      "\n" +
                                      $"{filter_text}");
            };

            // Attempt editing the message if it hasn't been deleted by the user yet.
            // If it has, catch the exception, remove the menu entry from the global list, 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)
            {
                Console.WriteLine(ex);

                // Remove the menu entry from the global list.
                Global.MenuIdList.Remove(menuSession);

                // Remove the content filter entry from the global list.
                Global.ContentFilterList.Remove(filterSession);

                return;
            }

            // Remove the content filter entry from the global list.
            Global.ContentFilterList.Remove(filterSession);

            // Edit the menu session according to the current message.
            menuSession.CurrentMenu = "Content_Filter_Confirm";
            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
            };

            // If the menu timer runs out, activate a function.
            menuSession.MenuTimer.Elapsed += (sender, e) => MenuTimer_Elapsed(sender, e, menuSession);

            // Create an empty list for reactions.
            List <IEmote> reaction_list = new List <IEmote> {
            };

            // Add needed emote reactions for the menu.
            reaction_list.Add(new Emoji("💠"));
            reaction_list.Add(new Emoji("❌"));

            // Add the reactions to the message.
            _ = ReactionHandling.AddReactionsToMenu(message, reaction_list);
        }
Exemplo n.º 2
0
        public static async Task Content_Filter_Main(SocketGuildUser user, RestUserMessage message)
        {
            // Get the account information of the command's user.
            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);

            // Find a filter session associated with the current user.
            var filterSession = Global.ContentFilterList.SingleOrDefault(x => x.User.Id == user.Id);

            // Check if the filter session is null.
            if (filterSession != null)
            {
                // If not, remove the content filter entry from the global list.
                Global.ContentFilterList.Remove(filterSession);
            }

            // Create a new content filter identifier entry for this current session and user to keep track of the overall status.
            filterSession = new ContentFilter()
            {
                User = user
            };

            // Add the filter session to the global list.
            Global.ContentFilterList.Add(filterSession);

            // Create a list variable containing the content filter of the command user.
            List <string> user_filter = ContentFilterMethods.ParseContentFilter(account);

            // Using the newly created content filter list, create a new list that converts all the game acronyms into proper titles.
            List <string> filter_titles = ContentFilterMethods.AcronymToTitle(user_filter);

            // Create an empty string variable.
            string filter_text = "";

            // Iterating through the title list, add each entry to the string variable.
            for (int i = 0; i < filter_titles.Count; i++)
            {
                filter_text += $"**`{filter_titles[i]}`**\n";
            }

            // If the string variable is still empty afterwards (meaning the user had no titles filtered), assign "None" to it.
            if (filter_text == "")
            {
                filter_text = "**`None`**\n";
            }

            // In case the user backtracks to this menu, set the values to activate all the other interactive menus and title options to false.
            filterSession.P1_Select    = false;
            filterSession.P2IS_Select  = false;
            filterSession.P2EP_Select  = false;
            filterSession.P3_Select    = false;
            filterSession.P4_Select    = false;
            filterSession.P4AU_Select  = false;
            filterSession.P4D_Select   = false;
            filterSession.P5_Select    = false;
            filterSession.BBTAG_Select = false;

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

            embed.WithAuthor(author);

            var footer = new EmbedFooterBuilder
            {
                Text = "↩️ Cancel | ✅ Confirm"
            };

            embed.WithFooter(footer);

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

            embed.WithDescription("" +
                                  "Choose to hide content related to certain titles. Select any titles you wish to filter out (or select nothing), then react with ✅ to continue.\n" +
                                  "\n" +
                                  $"⚙️ **Currently Filtered Titles:**\n" +
                                  $"\n" +
                                  $"{filter_text}" +
                                  "\n" +
                                  "<:P1:751133115531133112> **Persona**\n" +
                                  "<:P2IS:788950080396328990> **Persona 2: Innocent Sin**\n" +
                                  "<:P2EP:788950163363463172> **Persona 2: Eternal Punishment**\n" +
                                  "<:P3:751133114918633483> **Persona 3**\n" +
                                  "<:P4:751133120530612274> **Persona 4**\n" +
                                  "<:P4AU:751133122342420572> **Persona 4 Arena Ultimax**\n" +
                                  "<:P4D:751133120346062859> **Persona 4: Dancing All Night**\n" +
                                  "<:P5:751133123861020742> **Persona 5**\n" +
                                  "<:BBTAG:751133123013771617> **BlazBlue: Cross Tag Battle**\n");

            // Attempt editing the message if it hasn't been deleted by the user yet.
            // If it has, catch the exception, remove the menu entry from the global list, 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)
            {
                Console.WriteLine(ex);

                // Remove the menu entry from the global list.
                Global.MenuIdList.Remove(menuSession);

                return;
            }

            // Edit the menu session according to the current message.
            menuSession.CurrentMenu = "Content_Filter_Main";
            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
            };

            // If the menu timer runs out, activate a function.
            menuSession.MenuTimer.Elapsed += (sender, e) => MenuTimer_Elapsed(sender, e, menuSession);

            // Create an empty list for reactions.
            List <IEmote> reaction_list = new List <IEmote> {
            };

            // Add needed emote reactions for the menu.
            reaction_list.Add(new Emoji("↩️"));
            reaction_list.Add(Emote.Parse("<:P1:751133115531133112>"));
            reaction_list.Add(Emote.Parse("<:P2IS:788950080396328990>"));
            reaction_list.Add(Emote.Parse("<:P2EP:788950163363463172>"));
            reaction_list.Add(Emote.Parse("<:P3:751133114918633483>"));
            reaction_list.Add(Emote.Parse("<:P4:751133120530612274>"));
            reaction_list.Add(Emote.Parse("<:P4AU:751133122342420572>"));
            reaction_list.Add(Emote.Parse("<:P4D:751133120346062859>"));
            reaction_list.Add(Emote.Parse("<:P5:751133123861020742>"));
            reaction_list.Add(Emote.Parse("<:BBTAG:751133123013771617>"));
            reaction_list.Add(new Emoji("✅"));

            // Add the reactions to the message.
            _ = ReactionHandling.AddReactionsToMenu(message, reaction_list);
        }