public static async Task SetFirstThemeMain(SocketTextChannel channel, SocketGuildUser user)
        {
            // Get the account information of the command's user.
            var account = UserInfoClasses.GetAccount(user);

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

            // Create bool values for each of the profile themes.
            // These are meant to check whether or not all versions of a title are completely blocked in the user's content filter.
            // False indicates at least one version is allowed, True indicates no versions are allowed. The condition is False by default.
            bool p3_filter_check = false;
            bool p4_filter_check = false;
            bool p5_filter_check = false;

            // If both versions of P3 are blocked in the user's content filter, set p3_filter_check to true.
            if (user_filter.Contains("P3F") == true && user_filter.Contains("P3P") == true)
            {
                p3_filter_check = true;
            }

            // If both versions of P4 are blocked in the user's content filter, set p4_filter_check to true.
            if (user_filter.Contains("P4-PS2") == true && user_filter.Contains("P4G") == true)
            {
                p4_filter_check = true;
            }

            // If both versions of P5 are blocked in the user's content filter, set p5_filter_check to true.
            if (user_filter.Contains("P5-PS4") == true && user_filter.Contains("P5R") == true)
            {
                p5_filter_check = true;
            }

            // Start building the embeded message.
            var embed  = new EmbedBuilder();
            var author = new EmbedAuthorBuilder
            {
                Name    = "Setting a Theme",
                IconUrl = user.GetAvatarUrl()
            };

            embed.WithAuthor(author);

            embed.WithThumbnailUrl("https://i.imgur.com/DJyqN5w.png");

            // Create a default string to be used as the description's text. This can change depending on the circumstances.
            string description_text = "" +
                                      "Set your profile theme by reacting to one of the icons below.\n" +
                                      "\n" +
                                      "The appearance of your commands will change based on each one, and you can switch to a different profile theme at any time.\n\n";

            // If all versions for all profile themes are filtered out, replace the default description text and add a footer.
            if (p3_filter_check == true && p4_filter_check == true && p5_filter_check == true)
            {
                description_text = "" +
                                   "Profile themes based on certain Persona titles can be chosen to customize your experience.\n" +
                                   "\n" +
                                   "The appearance of your commands will change based on each one, and you can switch to a different profile theme at any time.\n" +
                                   "\n" +
                                   ":warning: No profile themes can be chosen due to your content filter. " +
                                   $"You can edit your content filter at any time from the **`{BotConfig.bot.cmdPrefix}settings`** menu by choosing [General Settings] > [Content Filter].";

                var footer = new EmbedFooterBuilder
                {
                    Text = $"❌ Close Menu"
                };
                embed.WithFooter(footer);
            }
            // Else, if at least one title is completely filtered out but some are still remaining, add on to the end of the default description text.
            else if (p3_filter_check == true || p4_filter_check == true || p5_filter_check == true)
            {
                description_text += ":warning: Some options are unavailable due to your content filter.";
            }

            // Add the description text to the embeded message.
            embed.WithDescription(description_text);

            // 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 new menu identifier entry for this current message and user to keep track of the overall menu status.
            var menuSession = new MenuIdStructure()
            {
                User        = user,
                MenuMessage = message,
                CurrentMenu = "Set_First_Theme_Main",
                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(menuSession);

            // 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> {
            };

            // Depending on the user's content filter settings, add needed emote reactions to the menu.
            if (p3_filter_check == false)
            {
                reaction_list.Add(Emote.Parse("<:P3:751133114918633483>"));
            }

            if (p4_filter_check == false)
            {
                reaction_list.Add(Emote.Parse("<:P4:751133120530612274>"));
            }

            if (p5_filter_check == false)
            {
                reaction_list.Add(Emote.Parse("<:P5:751133123861020742>"));
            }

            if (p3_filter_check == true && p4_filter_check == true && p5_filter_check == true)
            {
                reaction_list.Add(new Emoji("❌"));
            }

            // Add the reactions to the message.
            _ = ReactionHandling.AddReactionsToMenu(message, reaction_list);
        }
Beispiel #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);
        }
Beispiel #3
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);
        }
        public static async Task Profile_Theme_Main(SocketGuildUser user, RestUserMessage message)
        {
            // Get the account information of the command's user.
            var account = UserInfoClasses.GetAccount(user);

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

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

            // Create bool values for each of the profile themes.
            // These are meant to check whether or not all versions of a title are completely blocked in the user's content filter.
            // False indicates at least one version is allowed, True indicates no versions are allowed. The condition is False by default.
            bool p3_filter_check = false;
            bool p4_filter_check = false;
            bool p5_filter_check = false;

            // If both versions of P3 are blocked in the user's content filter, set p3_filter_check to true.
            if (user_filter.Contains("P3F") == true && user_filter.Contains("P3P") == true)
            {
                p3_filter_check = true;
            }

            // If both versions of P4 are blocked in the user's content filter, set p4_filter_check to true.
            if (user_filter.Contains("P4-PS2") == true && user_filter.Contains("P4G") == true)
            {
                p4_filter_check = true;
            }

            // If both versions of P5 are blocked in the user's content filter, set p5_filter_check to true.
            if (user_filter.Contains("P5-PS4") == true && user_filter.Contains("P5R") == true)
            {
                p5_filter_check = true;
            }

            // Start building the embeded message.
            var embed  = new EmbedBuilder();
            var author = new EmbedAuthorBuilder
            {
                Name    = "Profile Theme",
                IconUrl = user.GetAvatarUrl()
            };

            embed.WithAuthor(author);

            var footer = new EmbedFooterBuilder
            {
                Text = "↩️ Return to Profile Settings"
            };

            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));

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

            // Based on the user's profile theme, assign proper titles to the set acronym.
            if (account.Profile_Theme == "P3")
            {
                title = "Persona 3";
            }
            else if (account.Profile_Theme == "P4")
            {
                title = "Persona 4";
            }
            else if (account.Profile_Theme == "P5")
            {
                title = "Persona 5";
            }
            else
            {
                title = "None";
            }

            // Create a default string to be used as the description's text. This can change depending on the circumstances.
            string description_text = "" +
                                      "Choose a profile theme. The appearance of your commands will change based on each one.\n\n";

            // If at least one title is completely filtered out but some are still remaining, add on to the end of the default description text.
            if (p3_filter_check == true || p4_filter_check == true || p5_filter_check == true)
            {
                description_text += ":warning: Some options are unavailable due to your content filter.\n\n";
            }

            // Append the currently set profile theme to the description text.
            description_text += $"⚙️ **Current Setting:** **`{title}`**\n\n";

            // Based on the user's content filter, append possible profile theme choices to the end of the description text.
            if (p3_filter_check == false)
            {
                description_text += "<:P3:751133114918633483> **Persona 3**\n";
            }

            if (p4_filter_check == false)
            {
                description_text += "<:P4:751133120530612274> **Persona 4**\n";
            }

            if (p5_filter_check == false)
            {
                description_text += "<:P5:751133123861020742> **Persona 5**\n";
            }

            // If all versions for all profile themes are filtered out, replace the default description text and add a footer.
            if (p3_filter_check == true && p4_filter_check == true && p5_filter_check == true)
            {
                description_text = "" +
                                   "Profile themes based on certain Persona titles can be chosen to customize your experience.\n" +
                                   "\n" +
                                   "The appearance of your commands will change based on each one, and you can switch to a different profile theme at any time.\n" +
                                   "\n" +
                                   ":warning: No profile themes can be chosen due to your content filter. " +
                                   $"You can edit your content filter at any time from the **`{BotConfig.bot.cmdPrefix}settings`** menu by choosing [General Settings] > [Content Filter].";
            }

            // Add the description text to the embeded message.
            embed.WithDescription(description_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);

                return;
            }

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

            // Depending on the user's content filter settings, add needed emote reactions to the menu.
            reaction_list.Add(new Emoji("↩️"));

            if (p3_filter_check == false)
            {
                reaction_list.Add(Emote.Parse("<:P3:751133114918633483>"));
            }

            if (p4_filter_check == false)
            {
                reaction_list.Add(Emote.Parse("<:P4:751133120530612274>"));
            }

            if (p5_filter_check == false)
            {
                reaction_list.Add(Emote.Parse("<:P5:751133123861020742>"));
            }

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