コード例 #1
0
        internal static async void ExpressionRankUpMessage(SocketMessage message, int new_rank)
        {
            var user    = message.Author;
            var channel = message.Channel;

            var account = UserInfoClasses.GetAccount(user);

            var embed  = new EmbedBuilder();
            var author = new EmbedAuthorBuilder
            {
                Name    = "RANK UP!!",
                IconUrl = user.GetAvatarUrl()
            };

            embed.WithAuthor(author);

            //If the user sees a rank up message for the first time, display a notification for the settings menu.
            if (account.First_Rank_Msg_Sent == "No")
            {
                var footer = new EmbedFooterBuilder
                {
                    Text = $"You can disable rank up messages like these from the {BotConfig.bot.cmdPrefix}settings menu by choosing [General Settings]."
                };

                embed.WithFooter(footer);
            }

            //Determine color for embeded message
            if (account.Profile_Theme == "P3")
            {
                //Color for embeded message
                embed.WithColor(37, 149, 255);

                //Description and thumbnail for embeded message
                if (new_rank == 2)
                {
                    embed.WithThumbnailUrl("https://i.imgur.com/pX0dmWm.png");
                    embed.WithDescription(user.Username + "'s Expression has changed from **Rough** to **Eloquent**!");
                }
                else if (new_rank == 3)
                {
                    embed.WithThumbnailUrl("https://i.imgur.com/m4Uwh1b.png");
                    embed.WithDescription(user.Username + "'s Expression has changed from **Eloquent** to **Persuasive**!");
                }
                else if (new_rank == 4)
                {
                    embed.WithThumbnailUrl("https://i.imgur.com/e2hiyeZ.png");
                    embed.WithDescription(user.Username + "'s Expression has changed from **Persuasive** to **Touching**!");
                }
                else if (new_rank == 5)
                {
                    embed.WithThumbnailUrl("https://i.imgur.com/ioJGB7f.png");
                    embed.WithDescription(user.Username + "'s Expression has **maxed out**!");
                }
            }
            else if (account.Profile_Theme == "P4")
            {
                //Color for embeded message
                embed.WithColor(255, 229, 49);

                //Description and thumbnail for embeded message
                if (new_rank == 2)
                {
                    embed.WithThumbnailUrl("https://i.imgur.com/DGyo7Gq.png");
                    embed.WithDescription(user.Username + "'s Expression has changed from **Rough** to **Eloquent**!");
                }
                else if (new_rank == 3)
                {
                    embed.WithThumbnailUrl("https://i.imgur.com/8ZlESIt.png");
                    embed.WithDescription(user.Username + "'s Expression has changed from **Eloquent** to **Persuasive**!");
                }
                else if (new_rank == 4)
                {
                    embed.WithThumbnailUrl("https://i.imgur.com/0FaH1Ai.png");
                    embed.WithDescription(user.Username + "'s Expression has changed from **Persuasive** to **Touching**!");
                }
                else if (new_rank == 5)
                {
                    embed.WithThumbnailUrl("https://i.imgur.com/MF6p0oL.png");
                    embed.WithDescription(user.Username + "'s Expression has **maxed out**!");
                }
            }
            else if (account.Profile_Theme == "P5")
            {
                //Color for embeded message
                embed.WithColor(213, 27, 4);

                //Description and thumbnail for embeded message
                if (new_rank == 2)
                {
                    embed.WithThumbnailUrl("https://i.imgur.com/aM39SzA.png");
                    embed.WithDescription(user.Username + "'s Expression has increased to **Eloquent**!");
                }
                else if (new_rank == 3)
                {
                    embed.WithThumbnailUrl("https://i.imgur.com/HKei8f1.png");
                    embed.WithDescription(user.Username + "'s Expression has increased to **Persuasive**!");
                }
                else if (new_rank == 4)
                {
                    embed.WithThumbnailUrl("https://i.imgur.com/qmPnuGE.png");
                    embed.WithDescription(user.Username + "'s Expression has increased to **Touching**!");
                }
                else if (new_rank == 5)
                {
                    embed.WithThumbnailUrl("https://i.imgur.com/jJMuSB2.png");
                    embed.WithDescription(user.Username + "'s Expression has **maxed out**!");
                }
            }

            await channel.SendMessageAsync("", false, embed.Build());
        }
コード例 #2
0
        public static async Task SM_Tutorial_Basics_Page_5(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);

            var embed  = new EmbedBuilder();
            var author = new EmbedAuthorBuilder
            {
                Name    = "Cross-compatibility",
                IconUrl = user.GetAvatarUrl()
            };

            embed.WithAuthor(author);

            var footer = new EmbedFooterBuilder
            {
                Text = "" +
                       "◀️ Previous Page | ▶️ Next Page\n" +
                       "Page 5 / 6"
            };

            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_Help_Thumbnail(account));

            embed.WithDescription("" +
                                  "To use a character sprite in a template they don’t belong to, use a template keyword right before the character’s name when creating a scene.\n" +
                                  "\n" +
                                  "Some character sprites might be too small to appear normally in other templates. They’ll be formatted in other ways that are natural to the game’s aesthetics.");

            // 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 = "SM_Tutorial_Basics_Page_5";
            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);
        }
コード例 #3
0
        public static async Task SM_Tutorial_Basics_Page_2(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);

            var embed  = new EmbedBuilder();
            var author = new EmbedAuthorBuilder
            {
                Name    = "Character Lists and Templates",
                IconUrl = user.GetAvatarUrl()
            };

            embed.WithAuthor(author);

            var footer = new EmbedFooterBuilder
            {
                Text = "" +
                       "◀️ Previous Page | ▶️ Next Page\n" +
                       "Page 2 / 6"
            };

            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_Help_Thumbnail(account));

            embed.WithDescription("" +
                                  "There are multiple templates to choose from based on each title:\n" +
                                  "\n" +
                                  "<:P1:751133115531133112> `P1` - **Persona**\n" +
                                  "<:P2IS:788950080396328990> `P2IS` - **Persona 2: Innocent Sin**\n" +
                                  "<:P2EP:788950163363463172> `P2EP` - **Persona 2: Eternal Punishment**\n" +
                                  "<:P3:751133114918633483> `P3` - **Persona 3**\n" +
                                  "<:P4:751133120530612274> `P4` - **Persona 4**\n" +
                                  "<:P4AU:751133122342420572> `P4AU` - **Persona 4 Arena Ultimax**\n" +
                                  "<:P4D:751133120346062859> `P4D` - **Persona 4: Dancing All Night**\n" +
                                  "<:P5:751133123861020742> `P5` - **Persona 5**\n" +
                                  "<:BBTAG:751133123013771617> `BBTAG` - **BlazBlue: Cross Tag Battle**\n" +
                                  "\n" +
                                  $"Use the format **`{BotConfig.bot.cmdPrefix}maker [template]`** to view the names of characters with sprites for that title.");

            // 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 = "SM_Tutorial_Basics_Page_2";
            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);
        }
コード例 #4
0
        public static string RandomizePatGif(SocketUser command_user, SocketUser command_target)
        {
            // Retrieve the account information of the both the command's user and the command's target.
            // These two may be the same account in some cases.
            var command_user_account   = UserInfoClasses.GetAccount(command_user);
            var command_target_account = UserInfoClasses.GetAccount(command_target);

            // Create a random variable.
            Random r = new Random();

            // Create an empty string variable that will return as the final answer.
            string imgurl = "";

            // Social command GIFs can be divided into subcategories for each title depending on the version, so create separate string arrays for each category.
            // First Title: Persona 3.
            // General P3 GIFs are scenes that can be applied to both versions of P3 or various P3-related media.
            string[] p3_general_pats = new string[]
            {
                "https://i.imgur.com/59oKG0T.gif",
                "https://i.imgur.com/mxyJzMB.gif",
                "https://i.imgur.com/NhuPqQM.gif"
            };

            // P3F GIFs are scenes that exclusively apply to the FES version of P3.
            string[] p3f_pats = new string[]
            {
                // There are no P3F-specific GIFs to add.
            };

            // P3P GIFs are scenes that exclusively apply to the Portable version of P3.
            string[] p3p_pats = new string[]
            {
                // There are no P3P-specific GIFs to add.
            };

            // Second Title: Persona 4.
            // General P4 GIFs are scenes that can be applied to both versions of P4 or various P4-related media.
            string[] p4_general_pats = new string[]
            {
                "https://i.imgur.com/VpNZQi4.gif",
                "https://i.imgur.com/A8hrKuy.gif"
            };

            // P4-PS2 GIFs are scenes that exclusively apply to the PlayStation 2 version of P4.
            string[] p4_ps2_pats = new string[]
            {
                // There are no P4-PS2-specific GIFs to add.
            };

            // P4G GIFs are scenes that exclusively apply to the Golden version of P4.
            string[] p4g_pats = new string[]
            {
                "https://i.imgur.com/KeHfyyI.gif",
                "https://i.imgur.com/G3oDiHb.gif"
            };

            // Third Title: Persona 5.
            // General P5 GIFs are scenes that can be applied to both versions of P5 or various P5-related media.
            string[] p5_general_pats = new string[]
            {
                "https://i.imgur.com/RJomCC2.gif",
                "https://i.imgur.com/N5DEjCZ.gif"
            };

            // P5-PS4 GIFs are scenes that exclusively apply to the PlayStation 3 version of P5.
            string[] p5_ps4_pats = new string[]
            {
                // There are no P5-PS4-specific GIFs to add.
            };

            // P5R GIFs are scenes that exclusively apply to the Royal version of P5.
            string[] p5r_pats = new string[]
            {
                "https://i.imgur.com/lxqRvBY.gif",
                "https://i.imgur.com/IbuuKav.gif",
                "https://i.imgur.com/ZJahCad.gif"
            };

            // Create two list variables containing the content filters of both the command's user and the command's target.
            // These two may be the same list in some cases.
            List <string> command_user_filter   = ParseContentFilter(command_user_account);
            List <string> command_target_filter = ParseContentFilter(command_target_account);

            // Create string lists for each of the profile themes that will store the final selection of GIFs to be chosen from.
            List <string> p3_selection_list = new List <string>();
            List <string> p4_selection_list = new List <string>();
            List <string> p5_selection_list = new List <string>();

            // If both the command user and command target allows either P3F and P3P content, add general P3 GIFs to the p3_selection_list.
            if ((command_user_filter.Contains("P3F") == false || command_user_filter.Contains("P3P") == false) &&
                (command_target_filter.Contains("P3F") == false || command_target_filter.Contains("P3P") == false))
            {
                p3_selection_list.AddRange(p3_general_pats);
            }

            // If the command user and command target allows P3F content, add P3F-specific GIFs to the p3_selection_list.
            if (command_user_filter.Contains("P3F") == false && command_target_filter.Contains("P3F") == false)
            {
                p3_selection_list.AddRange(p3f_pats);
            }

            // If the command user and command target allows P3P content, add P3P-specific GIFs to the p3_selection_list.
            if (command_user_filter.Contains("P3P") == false && command_target_filter.Contains("P3P") == false)
            {
                p3_selection_list.AddRange(p3p_pats);
            }

            // If both the command user and command target allows either P4-PS2 and P4G content, add general P4 GIFs to the p4_selection_list.
            if ((command_user_filter.Contains("P4-PS2") == false || command_user_filter.Contains("P4G") == false) &&
                (command_target_filter.Contains("P4-PS2") == false || command_target_filter.Contains("P4G") == false))
            {
                p4_selection_list.AddRange(p4_general_pats);
            }

            // If the command user and command target allows P4-PS2 content, add P4-PS2-specific GIFs to the p4_selection_list.
            if (command_user_filter.Contains("P4-PS2") == false && command_target_filter.Contains("P4-PS2") == false)
            {
                p4_selection_list.AddRange(p4_ps2_pats);
            }

            // If the command user and command target allows P4G content, add P4G-specific GIFs to the p4_selection_list.
            if (command_user_filter.Contains("P4G") == false && command_target_filter.Contains("P4G") == false)
            {
                p4_selection_list.AddRange(p4g_pats);
            }

            // If both the command user and command target allows either P5-PS4 and P5R content, add general P5 GIFs to the p5_selection_list.
            if ((command_user_filter.Contains("P5-PS4") == false || command_user_filter.Contains("P5R") == false) &&
                (command_target_filter.Contains("P5-PS4") == false || command_target_filter.Contains("P5R") == false))
            {
                p5_selection_list.AddRange(p5_general_pats);
            }

            // If the command user and command target allows P5-PS4 content, add P5-PS4-specific GIFs to the p5_selection_list.
            if (command_user_filter.Contains("P5-PS4") == false && command_target_filter.Contains("P5-PS4") == false)
            {
                p5_selection_list.AddRange(p5_ps4_pats);
            }

            // If the command user and command target allows P5R content, add P5R-specific GIFs to the p5_selection_list.
            if (command_user_filter.Contains("P5R") == false && command_target_filter.Contains("P5R") == false)
            {
                p5_selection_list.AddRange(p5r_pats);
            }

            // Using the created selection lists, get a random GIF based on the command user's profile theme.
            if (command_user_account.Profile_Theme == "P3" && p3_selection_list.Count != 0)
            {
                imgurl = p3_selection_list[r.Next(0, p3_selection_list.Count)];
            }
            if (command_user_account.Profile_Theme == "P4" && p4_selection_list.Count != 0)
            {
                imgurl = p4_selection_list[r.Next(0, p4_selection_list.Count)];
            }
            if (command_user_account.Profile_Theme == "P5" && p5_selection_list.Count != 0)
            {
                imgurl = p5_selection_list[r.Next(0, p5_selection_list.Count)];
            }

            return(imgurl);
        }
コード例 #5
0
        public static async Task SM_Tutorial_Basics_Page_3(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);

            var embed  = new EmbedBuilder();
            var author = new EmbedAuthorBuilder
            {
                Name    = "Using Sprite Sheets",
                IconUrl = user.GetAvatarUrl()
            };

            embed.WithAuthor(author);

            var footer = new EmbedFooterBuilder
            {
                Text = "" +
                       "◀️ Previous Page | ▶️ Next Page\n" +
                       "Page 3 / 6"
            };

            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_Help_Thumbnail(account));

            embed.WithDescription("" +
                                  $"Once you find a character you want, use the format **`{BotConfig.bot.cmdPrefix}maker [character]`** to display their sprite sheet.\n" +
                                  "\n" +
                                  "If the character appears in more than one title, this will only bring up their sprite sheet from the game they originated from. " +
                                  "To specify their sprite sheet from another title, type one of the template keywords after their name.");

            // 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 = "SM_Tutorial_Basics_Page_3";
            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);
        }
コード例 #6
0
ファイル: Settings.cs プロジェクト: Microjack5/social-linker
        public static async Task SettingsMenu(SocialLinkerCommand command)
        {
            // If there is a cooldown session active for the command type "menu", return the method immediately.
            if (await UserCooldownMethods.IsCooldownActive(command, "menu") == true)
            {
                return;
            }

            // Get the account information of the command's user.
            var command_user_account = UserInfoClasses.GetAccount(command.User);

            // Check if the user's account has been activated. If not, send them to the initial usage setup menu.
            if (command_user_account.Account_Activated == "No")
            {
                await First_Use_Content_Filter_Menu.First_Use_Content_Filter_Start((SocketTextChannel)command.Channel, (SocketGuildUser)command.User);

                return;
            }

            // End of initial usage and cooldown checks.

            // Create two variables to check if there is a menu list entry with either the current channel ID or current user ID.
            var channelSearch = Global.MenuIdList.SingleOrDefault(x => x.MenuMessage.Channel.Id == command.Channel.Id);
            var userSearch    = Global.MenuIdList.SingleOrDefault(x => x.User.Id == command.User.Id);

            // If the channel entry exists and the user is not the same, send an error message.
            if (channelSearch != null && channelSearch.User.Id != command.User.Id)
            {
                // Case 1: Search by channel successful, user ID does not match. Create new entry for new user.
                // Create a new menu in the current channel.
                await Settings_Menu.Settings_Start((SocketTextChannel)command.Channel, (SocketGuildUser)command.User);

                return;
            }
            // Else, if the channel entry exists and the user is the same, assume they want to reset the menu and delete the previous entry.
            else if (channelSearch != null && channelSearch.User.Id == command.User.Id)
            {
                // Case 2: Search by channel successful, user ID matches. Resetting menu in same channel.
                // Attempt deleting the message if it hasn't been deleted by the user yet.
                try
                {
                    // Delete the currently active menu.
                    await channelSearch.MenuMessage.DeleteAsync();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }

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

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

                // Create a new menu in the current channel.
                await Settings_Menu.Settings_Start((SocketTextChannel)command.Channel, (SocketGuildUser)command.User);

                return;
            }
            // Else, if an entry exists where the user is found but they're in a different channel now, delete previous entry and reset the menu.
            else if (userSearch != null && userSearch.MenuMessage.Channel.Id != command.Channel.Id)
            {
                // Case 3: Search by user successful, channel ID does not match. Resetting menu in new channel.
                // Attempt deleting the message if it hasn't been deleted by the user yet.
                try
                {
                    // Delete the currently active menu.
                    await userSearch.MenuMessage.DeleteAsync();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }

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

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

                // Create a new menu in the current channel.
                await Settings_Menu.Settings_Start((SocketTextChannel)command.Channel, (SocketGuildUser)command.User);

                return;
            }
            // For any other condition (if one should exist and not be handled here), create a new menu entry.
            else
            {
                // Case 4: No previous entry found. Create new entry.
                // Create a new menu in the current channel.
                await Settings_Menu.Settings_Start((SocketTextChannel)command.Channel, (SocketGuildUser)command.User);

                return;
            }
        }
コード例 #7
0
        public static Bitmap RenderLevelProgressBar(SocketUser user)
        {
            var account = UserInfoClasses.GetAccount(user);

            Bitmap new_bitmap = new Bitmap(template_width, template_height);

            int total_exp = account.Total_Exp;

            Rectangle main_bar   = new Rectangle(357, 262, 352, 18);
            Rectangle shadow_bar = new Rectangle(357, 278, 352, 2);

            int bar_max_value    = 0;
            int bar_filled_value = 0;

            System.Drawing.Color      tms_pink       = System.Drawing.Color.FromArgb(233, 125, 174);
            System.Drawing.SolidBrush tms_pink_brush = new SolidBrush(tms_pink);

            System.Drawing.Color      tms_pink_shadow       = System.Drawing.Color.FromArgb(130, 89, 107);
            System.Drawing.SolidBrush tms_pink_shadow_brush = new SolidBrush(tms_pink_shadow);

            // Create a variable for the minimum total EXP requirement of the next level
            int next_level_total_exp_required = Core.LevelSystem.Leveling.CalculateExp(account.Level + 1);

            // Create a variable for the minimum total EXP requirement of the current level
            int current_level_total_exp_required = Core.LevelSystem.Leveling.CalculateExp(account.Level);

            bar_max_value = next_level_total_exp_required - current_level_total_exp_required;

            // Draw a progress bar that has a max value set to the minimum total EXP requirement of the next level minus the minimum total EXP requirement of the current level
            ProgressBar progress_bar        = new ProgressBar(tms_pink_brush, main_bar, bar_max_value);
            ProgressBar progress_bar_shadow = new ProgressBar(tms_pink_shadow_brush, shadow_bar, bar_max_value);

            // However, if the user's level is 99, set the progress bar's max value to 1
            if (account.Level == 99)
            {
                bar_max_value       = 1;
                progress_bar        = new ProgressBar(tms_pink_brush, main_bar, bar_max_value);
                progress_bar_shadow = new ProgressBar(tms_pink_brush, shadow_bar, bar_max_value);
            }

            // Determine how the progress bar should be filled based on the user's level
            if (account.Level != 99)
            {
                // If the level is below 99, fill the progress bar by subtracting the total EXP the user has by the minimum total EXP requirement of the current level
                bar_filled_value = total_exp - current_level_total_exp_required;
                progress_bar.SetCurrent(bar_filled_value);
                progress_bar_shadow.SetCurrent(bar_filled_value);
            }
            else
            {
                // If the level is at 99, fill the progress bar completely up
                bar_filled_value = 1;
                progress_bar.SetCurrent(bar_filled_value);
                progress_bar_shadow.SetCurrent(bar_filled_value);
            }

            // Use a graphics object to edit the bitmap
            using (Graphics graphics = Graphics.FromImage(new_bitmap))
            {
                // Draw the progress bar to the bitmap
                graphics.DrawImage(progress_bar.GiveGraphic(), progress_bar.GiveCorner());
                graphics.DrawImage(progress_bar_shadow.GiveGraphic(), progress_bar_shadow.GiveCorner());
            }

            return(new_bitmap);
        }
コード例 #8
0
        public static async Task Template_Layout_P3F_Date_Moon(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);

            var embed  = new EmbedBuilder();
            var author = new EmbedAuthorBuilder
            {
                Name    = "Date & Moon Phases",
                IconUrl = user.GetAvatarUrl()
            };

            embed.WithAuthor(author);

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

            embed.WithFooter(footer);

            // Assign a color and thumbnail to the embeded message based on the title being edited.
            embed.WithColor(EmbedSettings.Get_Game_Color("P3F", null));
            embed.WithThumbnailUrl(EmbedSettings.Get_Game_Logo("P3F"));

            embed.WithDescription("" +
                                  "**Toggle parts of the date & moon HUD on and off.**\n" +
                                  "\n" +
                                  $"⚙️ **Current setting:** **`{account.P3F_TS_HUD}`**\n" +
                                  "\n" +
                                  ":one: Display All\n" +
                                  ":two: Countdown Off\n" +
                                  ":three: Date Only\n" +
                                  ":four: None");

            // 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 = "Template_Layout_P3F_Date_Moon";
            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("\u0031\ufe0f\u20e3"));
            reaction_list.Add(new Emoji("\u0032\ufe0f\u20e3"));
            reaction_list.Add(new Emoji("\u0033\ufe0f\u20e3"));
            reaction_list.Add(new Emoji("\u0034\ufe0f\u20e3"));

            // Add the reactions to the message.
            _ = ReactionHandling.AddReactionsToMenu(message, reaction_list);
        }
コード例 #9
0
        public static async Task SM_Tutorial_Cutin_Page_2(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);

            var embed  = new EmbedBuilder();
            var author = new EmbedAuthorBuilder
            {
                Name    = "Cut-In Lists",
                IconUrl = user.GetAvatarUrl()
            };

            embed.WithAuthor(author);

            var footer = new EmbedFooterBuilder
            {
                Text = "" +
                       "◀️ Previous Page | ▶️ Next Page\n" +
                       "Page 2 / 4"
            };

            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_Help_Thumbnail(account));

            embed.WithDescription("" +
                                  $"Use **`{BotConfig.bot.cmdPrefix}maker cut-in`** to view the list of compatible templates and choose the one you’re interested in. A character list of usable cut-ins for that template will appear to reference.");

            // 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 = "SM_Tutorial_Cutin_Page_2";
            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);
        }
コード例 #10
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);
        }
コード例 #11
0
        public static async Task Set_Decor_Confirm(SocketGuildUser user, RestUserMessage message)
        {
            // Get the account information of the command's target
            var account = UserInfoClasses.GetAccount(user);

            // Find both the menu session and item session associated with the current user and store them in variables.
            var menuSession = Global.MenuIdList.SingleOrDefault(x => x.User.Id == user.Id);
            var itemSession = Global.ItemIdList.SingleOrDefault(x => x.User.Id == user.Id);

            // Create a string variable that will hold the title of the user's currently set décor.
            string set_decor_title = DecorInfoMethods.GetDecorTitle(user);

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

            // 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($"Your décor has been set to **`{set_decor_title}`**.");

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

            // Add the footer to the embed.
            embed.WithFooter(footer);

            // Attempt deleting the message if it hasn't been deleted by the user yet.
            try
            {
                // Delete the current message from the channel.
                await message.DeleteAsync();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            // If the bot lacks permission to send messages, catch the exception and return.
            try
            {
                // Reassign the menu session's message to a new message generated from the created embed.
                menuSession.MenuMessage = (RestUserMessage)await message.Channel.SendMessageAsync("", false, embed.Build());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return;
            }

            // Set the "message" variable to the menu session's message.
            message = menuSession.MenuMessage;

            // Edit the menu session according to the current message.
            menuSession.CurrentMenu = "Set_Decor_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, itemSession);

            // 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);
        }
コード例 #12
0
        public static async Task Status_Decor_Main(SocketGuildUser user, RestUserMessage message)
        {
            // Get the account information of the command's user.
            var account = UserInfoClasses.GetAccount(user);

            // Find both the menu session and item session associated with the current user and store them in variables.
            var menuSession = Global.MenuIdList.SingleOrDefault(x => x.User.Id == user.Id);
            var itemSession = Global.ItemIdList.SingleOrDefault(x => x.User.Id == user.Id);

            var embed  = new EmbedBuilder();
            var author = new EmbedAuthorBuilder
            {
                Name    = "Status Screen Décor",
                IconUrl = user.GetAvatarUrl()
            };

            embed.WithAuthor(author);

            // 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 a string variable to store the text that will be displayed on the message's body.
            string displayed_decor_list = "";

            // Create an int variable from the number of items in the list minus the starting index to count from.
            // Since the ItemIndexBase should always initially start at zero, nothing will be subtracted at first but will adjust as the index moves when the page changes.
            int remaining_list_length = itemSession.ItemList.Count - itemSession.ItemIndexBase;

            // Create another int variable that will indicate a subset of the item list that the user is currently viewing.
            int sublist_length = 0;

            // If the remaining number of items in the list is greater than or equal to the max amount of items that should be displayed, make the sublist_length int also equal to max_items_displayed.
            if (remaining_list_length >= itemSession.MaxItemsDisplayed)
            {
                sublist_length = itemSession.MaxItemsDisplayed;
            }
            // Else, if the number of remaining items is less than max_items_displayed, make sublist_length equal to the remaining number of items.
            else
            {
                sublist_length = remaining_list_length;
            }

            // Create an int to properly display the needed emotes when iterating through the item list.
            int displayed_list_counter = 0;

            // Iterate through the item list starting from the ItemBaseIndex and up until sublist_length.
            for (int i = itemSession.ItemIndexBase; i < (itemSession.ItemIndexBase + sublist_length); i++)
            {
                // Increase the displayed_list_counter by one.
                displayed_list_counter += 1;

                // Get the information of the current décor iteration.
                var decor_info = DecorInfoMethods.GetDecorInfo(itemSession.ItemList[i]);

                // Add the entry to the displayed_shop_list string.
                displayed_decor_list += $":{DecorInfoMethods.NumberToWords(displayed_list_counter)}: {decor_info.Title}\n";
            }

            // Create a string variable to store text for the footer. This will change depending on the state of the menu.
            string footer_text = "";

            // Depending on whether or not the user owns or can set any décor, perform different actions.
            if (displayed_decor_list.Length > 0)
            {
                // Add a "Back" button to be displayed on the footer.
                footer_text += "↩️ Profile Settings | ";

                // Check if the starting item index is greater than or equal to max_items_displayed.
                if (itemSession.ItemIndexBase >= itemSession.MaxItemsDisplayed)
                {
                    // If so, there will be a "Previous Page" button displayed on the footer.
                    footer_text += "◀️ Previous Page | ";
                }
                // Check if the number of items in the list minus the starting item index is more than max_items_displayed.
                if (remaining_list_length > itemSession.MaxItemsDisplayed)
                {
                    // If so, there will be a "Next Page" button on the footer.
                    footer_text += "▶️ Next Page | ";
                }

                // Calculate the amount of pages there will be in total and store it in a variable.
                int pageCount = (itemSession.ItemList.Count + itemSession.MaxItemsDisplayed - 1) / itemSession.MaxItemsDisplayed;

                // Add two icons to the end of footer_text regardless of the state, plus a page counter on a new line.
                footer_text += $"⚙️ Sort\nPage {itemSession.CurrentPage} / {pageCount}";

                // Create the footer object for the embed.
                var footer = new EmbedFooterBuilder
                {
                    Text = footer_text
                };

                // Add the footer to the embed.
                embed.WithFooter(footer);

                // Create an empty string variable. This will hold part of the embeded message's description
                string description_text = "";

                // If the user has a décor and a profile theme currently set, create a description text explaining how to remove the currently set décor.
                if (account.Decor_Setting != "" && account.Profile_Theme != "")
                {
                    description_text = "" +
                                       "**Select a décor to view.**\n" +
                                       "**To remove your current décor and set the default one for your profile theme, select :white_square_button:.**";
                }
                // If not, create a default description text instructing to select a décor.
                else
                {
                    description_text = "**Select a décor to view.**";
                }

                // Create a string variable that will hold the title of the user's currently set décor.
                string set_decor_title = DecorInfoMethods.GetDecorTitle(user);

                embed.WithDescription("" +
                                      $"{description_text}\n" +
                                      "\n" +
                                      $"⚙️ **Current setting:** **`{set_decor_title}`**\n" +
                                      "\n" +
                                      $"{displayed_decor_list}");

                // Attach a locally generated image to the embed.
                embed.WithImageUrl($"attachment://preview.png");

                // Create a new stream. We'll use this to create the locally generated image.
                MemoryStream memoryStream = new MemoryStream();

                // Generate a bitmap comprised of thumbnail previews of the décor being listed on the current page.
                Bitmap decor_preview = DecorInfoMethods.DecorPreviews(itemSession, sublist_length);

                // Save the décor preview bitmap to the stream as a PNG.
                decor_preview.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png);

                // Ensure the stream is set to the beginning of itself.
                memoryStream.Seek(0, SeekOrigin.Begin);

                // Attempt deleting the message if it hasn't been deleted by the user yet.
                try
                {
                    // Delete the current message from the channel.
                    await message.DeleteAsync();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }

                // If the bot lacks permission to attach files, catch the exception, send an error message, and return.
                try
                {
                    // Reassign the menu session's message to a new message generated from the created embed and preview image.
                    menuSession.MenuMessage = (RestUserMessage)await message.Channel.SendFileAsync(memoryStream, "preview.png", "", false, embed.Build());
                }
                catch (Exception ex)
                {
                    await ErrorHandling.AttachFilesError((SocketTextChannel)message.Channel);

                    Console.WriteLine(ex);
                    return;
                }

                // Set the "message" variable to the menu session's message.
                message = menuSession.MenuMessage;
            }
            else
            {
                // Add a "Back" button to be displayed on the footer.
                footer_text += "↩️ Profile Settings";

                // Create the footer object for the embed.
                var footer = new EmbedFooterBuilder
                {
                    Text = footer_text
                };

                // Add the footer to the embed.
                embed.WithFooter(footer);

                embed.WithDescription("You don't have any other décor to set. Visit the Décor Shop with the **`>shop`** command to browse and buy décor for your collection.");

                // 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_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 timer runs out, activate a function.
            menuSession.MenuTimer.Elapsed += (sender, e) => MenuTimer_Elapsed(sender, e, menuSession, itemSession);

            // 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("↩️"));

            // Check if the starting item index is greater than or equal to max_items_displayed.
            if (itemSession.ItemIndexBase >= itemSession.MaxItemsDisplayed)
            {
                // If so, there will be a "Previous Page" button added as a reaction.
                reaction_list.Add(new Emoji("◀️"));
            }

            // Check if the number of items in the list minus the starting item index is more than max_items_displayed.
            if (remaining_list_length > itemSession.MaxItemsDisplayed)
            {
                // If so, there will be a "Next Page" button added as a reaction.
                reaction_list.Add(new Emoji("▶️"));
            }

            // Reset the displayed_list_counter to zero.
            displayed_list_counter = 0;

            for (int i = 0; i < sublist_length; i++)
            {
                // Increase the displayed_list_counter by one.
                displayed_list_counter += 1;

                // For each loop iteration, add a keycap emote representing an item entry being displayed to the user.
                reaction_list.Add(new Emoji($"{DecorInfoMethods.NumberToKeycapEmoji(displayed_list_counter)}"));
            }

            // If the user owns any décor, add a gear reaction in order to sort entries.
            if (displayed_decor_list.Length > 0)
            {
                reaction_list.Add(new Emoji("⚙️"));
            }

            // If the user has a décor and a profile theme currently set, add a box reaction. This gives the option to remove the set décor and return to the default one.
            if (account.Decor_Setting != "" && account.Profile_Theme != "")
            {
                reaction_list.Add(new Emoji("🔳"));
            }

            // Add the reactions to the message.
            _ = ReactionHandling.AddReactionsToMenu(message, reaction_list);
        }
コード例 #13
0
        public static async Task Settings_Main_Menu(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);

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

            embed.WithAuthor(author);

            var footer = new EmbedFooterBuilder
            {
                Text = "❌ Close Menu"
            };

            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.AddField(":one: General Settings",
                           "Set your time zone, weather, notification, and content settings.");
            embed.AddField(":two: Profile Settings",
                           "Change your profile theme and status screen décor.");
            embed.AddField(":three: Scene Maker Settings",
                           "Change general scene maker settings.");

            // 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 = "Settings_Main_Menu";
            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("\u0031\ufe0f\u20e3"));
            reaction_list.Add(new Emoji("\u0032\ufe0f\u20e3"));
            reaction_list.Add(new Emoji("\u0033\ufe0f\u20e3"));
            reaction_list.Add(new Emoji("❌"));

            // Add the reactions to the message.
            _ = ReactionHandling.AddReactionsToMenu(message, reaction_list);
        }
コード例 #14
0
        internal static void AddDiligence(SocketMessage message)
        {
            var      account      = UserInfoClasses.GetAccount(message.Author);
            DateTime current_time = DateTime.UtcNow;

            // Create a variable for max Diligence value.
            int max_diligence = SocialStatRanks.diligence_rank_5_max;

            // If the daily loop point has not passed and the daily Diligence cap has been reached, return.
            TimeSpan time_since_last_day = (TimeSpan)(current_time - account.Loop_Point_Day);

            if ((time_since_last_day.TotalHours < 24) && (account.Daily_Diligence_Gained == "Yes"))
            {
                return;
            }
            // If the amount of time that has passed is between 24 and 48 hours since the daily loop point, reset the daily parameter.
            else if ((time_since_last_day.TotalHours >= 24) && (time_since_last_day.TotalHours <= 48))
            {
                account.Daily_Diligence_Gained = "No";
            }
            // If the amount of time that has passed is over 48 hours, set the Diligence multiplier back to 10, add a P-Medal, then return. The user does not gain Diligence for the day.
            else if (time_since_last_day.TotalHours > 48)
            {
                account.Diligence_Multiplier = 10;
                account.P_Medals            += 1;
                return;
            }

            // If the user has already reached the Diligence cap, return the function.
            if (account.Diligence == max_diligence)
            {
                return;
            }

            // Add Diligence and a P-Medal to the user, then set the daily cap value.
            account.Diligence += account.Diligence_Multiplier;

            // Calculate the amount of P-Medals the user keeps before reaching the P-Medal cap.
            account.P_Medals += LevelSystem.Leveling.CalculateMedalsKept(message, 1);

            // Daily_Diligence_Gained is set to "yes" to signify the day has been counted for any amount.
            account.Daily_Diligence_Gained = "Yes";

            // Increase the Diligence multiplier for the next day if its cap hasn't been reached.
            if (account.Diligence_Multiplier < 20)
            {
                account.Diligence_Multiplier += 1;
            }

            // Check if the user has crossed the Diligence cap. If so, set Diligence exactly at the cap.
            if (account.Diligence > max_diligence)
            {
                account.Diligence = max_diligence;
            }

            // Establish variables for keeping track of the user's rank before and after adding Diligence.
            int old_rank = account.Diligence_Rank;
            int new_rank = CalculateDiligenceRank(account.Diligence);

            // Compare old_rank to new_rank. If the values are different, the user ranked up.
            if (old_rank != new_rank)
            {
                // Replace previous stored value with new one.
                account.Diligence_Rank = new_rank;

                // If the user's account is actiated, has a profile theme set, and has notifications set to on, send a rank up message.
                if (account.Account_Activated == "Yes" && account.Profile_Theme != "" && account.Rank_Up_Notifications == "On")
                {
                    DiligenceRankUpMessage(message, new_rank);

                    // If this is the first time the user is receiving a rank up message, set the First_Rank_Msg_Sent field to "yes" after the message is sent.
                    if (account.First_Rank_Msg_Sent == "No")
                    {
                        account.First_Rank_Msg_Sent = "Yes";
                    }
                }
            }

            //Update user information with new data
            UserInfoClasses.UpdateAccount(account);

            //Check if the user has maxed out all social stats.
            AllRanksMaxedCheck(message);
        }
コード例 #15
0
        public static async Task ShopSortConfirm(SocketGuildUser user, RestUserMessage message)
        {
            // Get the account information of the command's target
            var account = UserInfoClasses.GetAccount(user);

            // Find both the menu session and item session associated with the current user and store them in variables.
            var menuSession = Global.MenuIdList.SingleOrDefault(x => x.User.Id == user.Id);
            var itemSession = Global.ItemIdList.SingleOrDefault(x => x.User.Id == user.Id);

            // 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()
            };

            var footer = new EmbedFooterBuilder
            {
                Text = "💠 Return to Shop"
            };

            embed.WithAuthor(author);
            embed.WithFooter(footer);

            embed.WithDescription($"Shop décor will now be sorted **`{DecorInfoMethods.SortSettingToString(account.Shop_Sort)}`**.");

            // Determine the color and thumbnail for the 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);
            }

            // 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 = "Shop_Sort_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 timer runs out, activate a function.
            menuSession.MenuTimer.Elapsed += (sender, e) => MenuTimer_Elapsed(sender, e, menuSession, itemSession);

            // 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("💠"));

            // Add the reactions to the message.
            _ = ReactionHandling.AddReactionsToMenu(message, reaction_list);
        }
コード例 #16
0
        public static async Task Level_Up_Notifications_Confirm(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);

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

            embed.WithAuthor(author);

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

            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($"Level up notifications have been set to **`{account.Level_Up_Notifications}`**.");

            // 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 = "Level_Up_Notifications_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);
        }
コード例 #17
0
        public static Task Nav_Template_Layout_P4D_Navigator_Caller_Location(SocketReaction reaction, MenuIdStructure menuSession)
        {
            if (reaction.Emote.Name == "💠")
            {
                // Stop the timeout timer associated with the menu.
                menuSession.MenuTimer.Stop();

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

            // Keycap One
            else if (reaction.Emote.Name == "\u0031\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P4D_TS_Nav_Call_Location = 1;

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

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

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

            // Keycap Two
            else if (reaction.Emote.Name == "\u0032\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P4D_TS_Nav_Call_Location = 2;

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

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

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

            // Keycap Three
            else if (reaction.Emote.Name == "\u0033\ufe0f\u20e3")
            {
                // Get the account information of the user.
                var account = UserInfoClasses.GetAccount(menuSession.User);

                // Assign the chosen setting to the user's account.
                account.P4D_TS_Nav_Call_Location = 3;

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

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

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

            return(Task.CompletedTask);
        }
コード例 #18
0
        public static async Task Template_Layout_VC_P2IS_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);

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

            embed.WithAuthor(author);

            var footer = new EmbedFooterBuilder
            {
                Text = "↩️ Return to Template Layout Menu"
            };

            embed.WithFooter(footer);

            // Assign a color and thumbnail to the embeded message based on the title being edited.
            embed.WithColor(EmbedSettings.Get_Game_Color("P2IS-PSP", null));
            embed.WithThumbnailUrl(EmbedSettings.Get_Game_Logo("P2IS-PSP"));

            embed.WithDescription("" +
                                  "**Which version would you like to edit?**\n" +
                                  "\n" +
                                  ":one: Persona 2: Innocent Sin (PlayStation®️)\n" +
                                  ":two: Persona 2: Innocent Sin (Remake)");

            // 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 = "Template_Layout_VC_P2IS_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(new Emoji("\u0031\ufe0f\u20e3"));
            reaction_list.Add(new Emoji("\u0032\ufe0f\u20e3"));

            // Add the reactions to the message.
            _ = ReactionHandling.AddReactionsToMenu(message, reaction_list);
        }
コード例 #19
0
        public static async void RenderImage(SocketUser user, ISocketMessageChannel channel)
        {
            // Send a loading message while the status screen gets made
            RestUserMessage loader = await channel.SendMessageAsync("", false, LoadingMessage().Build());

            try
            {
                var account = UserInfoClasses.GetAccount(user);

                string username = Shorten_Long_Strings(user.Username, 32);

                //Establish other variables of the user's data
                string level             = $"{account.Level}";
                int    total_exp         = account.Total_Exp;
                string pmedals           = $"{account.P_Medals}";
                string proficiency_title = Core.LevelSystem.SocialStats.ProficiencyRankTitle(account.Proficiency_Rank);
                string diligence_title   = Core.LevelSystem.SocialStats.DiligenceRankTitle(account.Diligence_Rank);
                string expression_title  = Core.LevelSystem.SocialStats.ExpressionRankTitle(account.Expression_Rank);

                //Determine the Next Exp value
                int next_exp = 0;
                if (account.Level != 99)
                {
                    next_exp = Core.LevelSystem.Leveling.CalculateExp(account.Level + 1) - account.Total_Exp;
                }

                Bitmap base_template = new Bitmap(template_width, template_height);

                Bitmap chara_bg   = (Bitmap)System.Drawing.Image.FromFile($@"{AssetDirectoryConfig.assetDirectory.assetFolderPath}//Profile//StatusScreens//Decor//Decor_TMS_Kiria_1//chara_bg.png");
                Bitmap ui_overlay = (Bitmap)System.Drawing.Image.FromFile($@"{AssetDirectoryConfig.assetDirectory.assetFolderPath}//Profile//StatusScreens//Decor//Decor_TMS_Kiria_1//ui_overlay.png");

                using (Graphics graphics = Graphics.FromImage(base_template))
                {
                    graphics.TextRenderingHint = TextRenderingHint.AntiAlias;

                    graphics.DrawImage(chara_bg, 0, 0, template_width, template_height);
                    graphics.DrawImage(ui_overlay, 0, 0, template_width, template_height);

                    graphics.DrawImage(RenderFont(user, account), 0, 0, template_width, template_height);
                    graphics.DrawImage(RenderLevelProgressBar(user), 0, 0, template_width, template_height);
                    graphics.DrawImage(CombineSocialStatRankBitmaps(account), 0, 0, template_width, template_height);

                    if (account.Level_Resets > 0)
                    {
                        graphics.DrawImage(RenderPrestigeCounter(account.Level_Resets), 0, 0, template_width, template_height);
                    }
                }

                MemoryStream memoryStream = new MemoryStream();
                base_template.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png);
                memoryStream.Seek(0, SeekOrigin.Begin);

                await channel.SendFileAsync(memoryStream, $"status_{user.Id}_{DateTime.UtcNow}.png");

                await loader.DeleteAsync();
            }
            catch (Exception ex)
            {
                _ = ErrorHandling.Scene_Upload_Failed(user, channel);
                Console.WriteLine(ex);

                await loader.DeleteAsync();

                return;
            }
        }
コード例 #20
0
        public static async Task ShopMainMenu(SocketGuildUser user, RestUserMessage message)
        {
            //Get the account information of the command's target
            var account = UserInfoClasses.GetAccount(user);

            // Find both the menu session and item session associated with the current user and store them in variables.
            var menuSession = Global.MenuIdList.SingleOrDefault(x => x.User.Id == user.Id);
            var itemSession = Global.ItemIdList.SingleOrDefault(x => x.User.Id == user.Id);

            var embed  = new EmbedBuilder();
            var author = new EmbedAuthorBuilder
            {
                Name    = "Décor Shop",
                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);
            }

            embed.AddField("Wallet", $"<:PMedals:672637091171139615> **{account.P_Medals}**");

            // Create a string variable to store the text that will be displayed on the message's body.
            string displayed_shop_list = "";

            // Create an int variable from the number of items in the list minus the starting index to count from.
            // Since the ItemIndexBase should always initially start at zero, nothing will be subtracted at first but will adjust as the index moves when the page changes.
            int remaining_list_length = itemSession.ItemList.Count - itemSession.ItemIndexBase;

            // Create another int variable that will indicate a subset of the item list that the user is currently viewing.
            int sublist_length = 0;

            // If the remaining number of items in the list is greater than or equal to the max amount of items that should be displayed, make the sublist_length int also equal to max_items_displayed.
            if (remaining_list_length >= itemSession.MaxItemsDisplayed)
            {
                sublist_length = itemSession.MaxItemsDisplayed;
            }
            // Else, if the number of remaining items is less than max_items_displayed, make sublist_length equal to the remaining number of items.
            else
            {
                sublist_length = remaining_list_length;
            }

            // Create an int to properly display the needed emotes when iterating through the item list.
            int displayed_list_counter = 0;

            // Iterate through the item list starting from the ItemBaseIndex and up until sublist_length.
            for (int i = itemSession.ItemIndexBase; i < (itemSession.ItemIndexBase + sublist_length); i++)
            {
                // Increase the displayed_list_counter by one.
                displayed_list_counter += 1;

                // Get the information of the current décor iteration.
                var decor_info = DecorInfoMethods.GetDecorInfo(itemSession.ItemList[i]);

                // Add the entry to the displayed_shop_list string.
                displayed_shop_list += $":{DecorInfoMethods.NumberToWords(displayed_list_counter)}: {decor_info.Title} - <:cost:780352551945895936> **{decor_info.Price}**\n";
            }

            // Add the displayed_shop_list as a new field to the embed.
            embed.AddField("What would you like to purchase? Select a number you wish to view.", $"{displayed_shop_list}");

            // Create a string variable to store text for the footer. This will change depending on the state of the menu.
            string footer_text = "";

            // Check if the starting item index is greater than or equal to max_items_displayed.
            if (itemSession.ItemIndexBase >= itemSession.MaxItemsDisplayed)
            {
                // If so, there will be a "Previous Page" button displayed on the footer.
                footer_text += "◀️ Previous Page | ";
            }
            // Check if the number of items in the list minus the starting item index is more than max_items_displayed.
            if (remaining_list_length > itemSession.MaxItemsDisplayed)
            {
                // If so, there will be a "Next Page" button on the footer.
                footer_text += "▶️ Next Page | ";
            }

            // Calculate the amount of pages there will be in total and store it in a variable.
            int pageCount = (itemSession.ItemList.Count + itemSession.MaxItemsDisplayed - 1) / itemSession.MaxItemsDisplayed;

            // Add two icons to the end of footer_text regardless of the state, plus a page counter on a new line.
            footer_text += $"⚙️ Sort | ❌ Exit Shop\nPage {itemSession.CurrentPage} / {pageCount}";

            // Create the footer object for the embed.
            var footer = new EmbedFooterBuilder
            {
                Text = footer_text
            };

            // Add the footer to the embed.
            embed.WithFooter(footer);

            // Attach a locally generated image to the embed. This image hasn't been created yet, so the filename is just a placeholder for now.
            embed.WithImageUrl($"attachment://preview.png");

            // Create a new stream. We'll use this to create the locally generated image.
            MemoryStream memoryStream = new MemoryStream();

            // Generate a bitmap comprised of thumbnail previews of the décor being listed on the current page.
            Bitmap decor_preview = DecorInfoMethods.DecorPreviews(itemSession, sublist_length);

            // Save the décor preview bitmap to the stream as a PNG.
            decor_preview.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png);

            // Ensure the stream is set to the beginning of itself.
            memoryStream.Seek(0, SeekOrigin.Begin);

            // Attempt deleting the message if it hasn't been deleted by the user yet.
            try
            {
                // Delete the current message from the channel.
                await message.DeleteAsync();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            // If the bot lacks permission to attach files, catch the exception, send an error message, and return.
            try
            {
                // Reassign the menu session's message to a new message generated from the created embed and preview image.
                menuSession.MenuMessage = (RestUserMessage)await message.Channel.SendFileAsync(memoryStream, "preview.png", "", false, embed.Build());
            }
            catch (Exception ex)
            {
                await ErrorHandling.AttachFilesError((SocketTextChannel)message.Channel);

                Console.WriteLine(ex);
                return;
            }

            // Set the "message" variable to the menu session's message.
            message = menuSession.MenuMessage;

            // Edit the menu session according to the current message.
            menuSession.CurrentMenu = "Shop_Main_Menu";
            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 timer runs out, activate a function.
            menuSession.MenuTimer.Elapsed += (sender, e) => MenuTimer_Elapsed(sender, e, menuSession, itemSession);

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

            // Add needed emote reactions for the menu.
            // Check if the starting item index is greater than or equal to max_items_displayed.
            if (itemSession.ItemIndexBase >= itemSession.MaxItemsDisplayed)
            {
                // If so, there will be a "Previous Page" button added as a reaction.
                reaction_list.Add(new Emoji("◀️"));
            }

            // Check if the number of items in the list minus the starting item index is more than max_items_displayed.
            if (remaining_list_length > itemSession.MaxItemsDisplayed)
            {
                // If so, there will be a "Next Page" button added as a reaction.
                reaction_list.Add(new Emoji("▶️"));
            }

            // Reset the displayed_list_counter to zero.
            displayed_list_counter = 0;

            for (int i = 0; i < sublist_length; i++)
            {
                // Increase the displayed_list_counter by one.
                displayed_list_counter += 1;

                // For each loop iteration, add a keycap emote representing an item entry being displayed to the user.
                reaction_list.Add(new Emoji($"{DecorInfoMethods.NumberToKeycapEmoji(displayed_list_counter)}"));
            }

            // Add two more reactions to the end of the message.
            reaction_list.Add(new Emoji("⚙️"));
            reaction_list.Add(new Emoji("❌"));

            // Add the reactions to the message.
            _ = ReactionHandling.AddReactionsToMenu(message, reaction_list);
        }
コード例 #21
0
        public static async Task PatCommand(SocialLinkerCommand command)
        {
            // If there is a cooldown session active for the command type "social", return the method immediately.
            if (await UserCooldownMethods.IsCooldownActive(command, "social") == true)
            {
                return;
            }

            // Get the account information of the command's user.
            var command_user_account = UserInfoClasses.GetAccount(command.User);

            // Check if the user's account has been activated. If not, send them to the initial usage setup menu.
            if (command_user_account.Account_Activated == "No")
            {
                await First_Use_Content_Filter_Menu.First_Use_Content_Filter_Start((SocketTextChannel)command.Channel, (SocketGuildUser)command.User);

                return;
            }

            // End of initial usage and cooldown checks.

            //Establish variables for both the user of the command and the user who is pinged
            SocketUser commandTarget = null;
            SocketUser commandUser   = null;

            //Retreive the first mentioned user of the message if there is one
            var mentionedUser = command.Message.MentionedUsers.FirstOrDefault();

            //If a mentioned user exists, assign them to commandTarget. If not, set commandTarget to the command user.
            commandTarget = mentionedUser ?? command.User;
            commandUser   = command.User;

            //Check if the mentioned user is null. If so, send an error-tutorial message.
            if (mentionedUser == null)
            {
                PatError(command.Message);
                return;
            }
            //If the mentioned user is the command user, send a special message and return
            else if (mentionedUser == commandUser)
            {
                PatSelf(command.Message);
                return;
            }
            //If the mentioned user is the bot itself, send a special message and return
            else if (mentionedUser.Id == BotConfig.bot.id)
            {
                PatBot(command.Message);
                return;
            }

            //If the previous conditions are false, get the command user's account information
            var account = UserInfoClasses.GetAccount(commandTarget);

            //If a user is mentioned and they're not the command user and not a bot, add Expression to both users
            if ((mentionedUser != null) && (mentionedUser != command.User) && (mentionedUser.IsBot == false))
            {
                Core.LevelSystem.SocialStats.AddExpression(command.Message, commandUser);
                Core.LevelSystem.SocialStats.AddExpression(command.Message, commandTarget);
            }

            //Send a hug message to the mentioned user
            PatUser(command.Message, commandTarget);

            await Task.CompletedTask;
        }
コード例 #22
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);
        }
コード例 #23
0
        public static async Task SM_Tutorial_Basics_Page_1(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);

            var embed  = new EmbedBuilder();
            var author = new EmbedAuthorBuilder
            {
                Name    = "Persona Scene Maker",
                IconUrl = user.GetAvatarUrl()
            };

            embed.WithAuthor(author);

            var footer = new EmbedFooterBuilder
            {
                Text = "" +
                       "↩️ Return to Previous Menu | ▶️ Next Page\n" +
                       "Page 1 / 6"
            };

            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_Help_Thumbnail(account));

            embed.WithDescription("" +
                                  "The scene maker lets you generate images resembling screenshots from the Persona series.\n" +
                                  "\n" +
                                  $"Each image is called a “scene” and can be generated with a variety of commands with the prefix **`{BotConfig.bot.cmdPrefix}maker`**.");

            // 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 = "SM_Tutorial_Basics_Page_1";
            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);
        }
コード例 #24
0
        public static async Task ShopDecorPreview(SocketGuildUser user, RestUserMessage message, int item_index)
        {
            // Get the account information of the command's target
            var account = UserInfoClasses.GetAccount(user);

            // Find both the menu session and item session associated with the current user and store them in variables.
            var menuSession = Global.MenuIdList.SingleOrDefault(x => x.User.Id == user.Id);
            var itemSession = Global.ItemIdList.SingleOrDefault(x => x.User.Id == user.Id);

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

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

            embed.WithAuthor(author);

            // Create an empty string variable for the description text.
            string description_text = "";

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

            // Perform a check to see if the user has enough money to purchase the décor. If so, state the cost.
            if (account.P_Medals >= decor_info.Price)
            {
                description_text = $"Purchase this décor for <:cost:780352551945895936> **{decor_info.Price}**?";
            }
            // If the user does not have enough money, prevent them from purchasing the décor.
            else
            {
                description_text = $"You do not have enough P-Medals to purchase this décor.";
            }

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

            embed.WithThumbnailUrl($"{decor_info.Thumbnail_Link}");

            embed.AddField("Wallet", $"<:PMedals:672637091171139615> **{account.P_Medals}**");
            embed.AddField("Title", $"{decor_info.Title}", true);
            embed.AddField("Game", $"{decor_info.Game}", true);
            embed.AddField("Designer", $"[{decor_info.Designer_Name}]({decor_info.Designer_Link})", true);

            // If a description exists for the décor itself, add it as a field.
            if (decor_info.Description != null)
            {
                embed.AddField("Description", $"{decor_info.Description}", false);
            }

            // Set the color of the embed by converting the décor's stored hex value to a usable format.
            embed.WithColor((Discord.Color)System.Drawing.ColorTranslator.FromHtml($"{decor_info.Embed_Color}"));

            // Create a string variable for text that will be displayed in the footer.
            string footer_text = "↩️ Back";

            // If the user doesn't own the décor being displayed and has enough money to purchase it, add a "Confirm" emote to the footer.
            if (owned_decor.Contains(decor_info.Decor_ID) == false && account.P_Medals >= decor_info.Price)
            {
                footer_text += $" | ✅ Confirm";
            }

            var footer = new EmbedFooterBuilder
            {
                Text = footer_text
            };

            // Add the footer to the embed.
            embed.WithFooter(footer);

            // Attach a locally generated image to the embed. This image hasn't been created yet, so the filename is just a placeholder for now.
            embed.WithImageUrl($"attachment://{decor_info.Decor_ID}_preview.png");

            // Create a new stream. We'll use this to create the locally generated image.
            MemoryStream memoryStream = new MemoryStream();

            // Generate a bitmap comprised of the thumbnail of the current décor.
            Bitmap decor_preview = (Bitmap)System.Drawing.Image.FromFile($@"{AssetDirectoryConfig.assetDirectory.assetFolderPath}//Profile//StatusScreens//Decor//{decor_info.Decor_ID}//_Thumbnails//preview_1.png");

            // Save the décor preview bitmap to the stream as a PNG.
            decor_preview.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png);

            // Ensure the stream is set to the beginning of itself.
            memoryStream.Seek(0, SeekOrigin.Begin);

            // Attempt deleting the message if it hasn't been deleted by the user yet.
            try
            {
                // Delete the current message from the channel.
                await message.DeleteAsync();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            // If the bot lacks permission to attach files, catch the exception, send an error message, and return.
            try
            {
                // Reassign the menu session's message to a new message generated from the created embed and preview image.
                menuSession.MenuMessage = (RestUserMessage)await message.Channel.SendFileAsync(memoryStream, $"{decor_info.Decor_ID}_preview.png", "", false, embed.Build());
            }
            catch (Exception ex)
            {
                await ErrorHandling.AttachFilesError((SocketTextChannel)message.Channel);

                Console.WriteLine(ex);
                return;
            }

            // Set the "message" variable to the menu session's message.
            message = menuSession.MenuMessage;

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

            // Edit the item session to save the selected décor's ID to a variable.
            // If the user chooses to buy it, we will be able to pass its information to other methods.
            itemSession.SelectedItem = decor_info.Decor_ID;

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

            // 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("↩️"));

            // If the user does not own this décor and has enough money to purchase it, add a checkmark reaction to the message.
            if (owned_decor.Contains(decor_info.Decor_ID) == false && account.P_Medals >= decor_info.Price)
            {
                reaction_list.Add(new Emoji("✅"));
            }

            // Add the reactions to the message.
            _ = ReactionHandling.AddReactionsToMenu(message, reaction_list);
        }
コード例 #25
0
        public static async Task SM_Tutorial_Basics_Page_4(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);

            var embed  = new EmbedBuilder();
            var author = new EmbedAuthorBuilder
            {
                Name    = "Creating a Scene",
                IconUrl = user.GetAvatarUrl()
            };

            embed.WithAuthor(author);

            var footer = new EmbedFooterBuilder
            {
                Text = "" +
                       "◀️ Previous Page | ▶️ Next Page\n" +
                       "Page 4 / 6"
            };

            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_Help_Thumbnail(account));

            embed.WithDescription("" +
                                  "String together a character keyword, one of their sprite numbers, and the dialogue you want them to say within quotation marks to create a scene.\n" +
                                  "\n" +
                                  $"The template will form according to your settings, which you can adjust by typing **`{BotConfig.bot.cmdPrefix}settings`** and choosing [Scene Maker Settings].");

            // 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 = "SM_Tutorial_Basics_Page_4";
            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);
        }
コード例 #26
0
        public static async Task ShopDecorPurchased(SocketGuildUser user, RestUserMessage message)
        {
            // Get the account information of the command's target
            var account = UserInfoClasses.GetAccount(user);

            // Find both the menu session and item session associated with the current user and store them in variables.
            var menuSession = Global.MenuIdList.SingleOrDefault(x => x.User.Id == user.Id);
            var itemSession = Global.ItemIdList.SingleOrDefault(x => x.User.Id == user.Id);

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

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

            embed.WithAuthor(author);

            // Determine the color and thumbnail for the 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);
            }

            embed.WithDescription($"Do you want to set `{decor_info.Title}` as your décor right now?");

            var footer = new EmbedFooterBuilder
            {
                Text = "❌ No | ✅ Yes"
            };

            // Add the footer to the embed.
            embed.WithFooter(footer);

            // Attempt deleting the message if it hasn't been deleted by the user yet.
            try
            {
                // Delete the current message from the channel.
                await message.DeleteAsync();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            // If the bot lacks permission to send messages, catch the exception and return.
            try
            {
                // Reassign the menu session's message to a new message generated from the created embed.
                menuSession.MenuMessage = (RestUserMessage)await message.Channel.SendMessageAsync("", false, embed.Build());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return;
            }

            // Set the "message" variable to the menu session's message.
            message = menuSession.MenuMessage;

            // Edit the menu session according to the current message.
            menuSession.CurrentMenu = "Shop_Decor_Purchased";
            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, itemSession);

            // 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);
        }
コード例 #27
0
        public static async Task SM_Tutorial_Basics_Page_6(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);

            var embed  = new EmbedBuilder();
            var author = new EmbedAuthorBuilder
            {
                Name    = "Backgrounds & Deleting Scenes",
                IconUrl = user.GetAvatarUrl()
            };

            embed.WithAuthor(author);

            var footer = new EmbedFooterBuilder
            {
                Text = "" +
                       "◀️ Previous Page | 💠 Return to Tutorial Menu\n" +
                       "Page 6 / 6"
            };

            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_Help_Thumbnail(account));

            embed.WithDescription("" +
                                  "To use a background, upload an image alongside your command when creating a scene.\n" +
                                  "\n" +
                                  "You can also delete scenes you’ve already made by reacting to them with the :x: emote.");

            // 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 = "SM_Tutorial_Basics_Page_6";
            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);
        }
コード例 #28
0
        public static async Task ShopSort(SocketGuildUser user, RestUserMessage message)
        {
            // Get the account information of the command's target
            var account = UserInfoClasses.GetAccount(user);

            // Find both the menu session and item session associated with the current user and store them in variables.
            var menuSession = Global.MenuIdList.SingleOrDefault(x => x.User.Id == user.Id);
            var itemSession = Global.ItemIdList.SingleOrDefault(x => x.User.Id == user.Id);

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

            var footer = new EmbedFooterBuilder
            {
                Text = "↩️ Back"
            };

            embed.WithAuthor(author);
            embed.WithFooter(footer);

            embed.AddField("Choose a method to sort décor entries by.", $"" +
                           $"⚙️ **Current Setting:** **`{DecorInfoMethods.SortSettingToString(account.Shop_Sort)}`**\n" +
                           $"\n" +
                           $":one: By Title (A - Z)\n" +
                           $":two: By Title (Z - A)\n" +
                           $":three: By Cost (Low - High)\n" +
                           $":four: By Cost (High - Low)\n" +
                           $":five: By Release Order (Old - New)\n" +
                           $":six: By Release Order (New - Old)");

            // Determine the color and thumbnail for the 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);
            }

            // Attempt deleting the message if it hasn't been deleted by the user yet.
            try
            {
                // Delete the current message from the channel.
                await message.DeleteAsync();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            // If the bot lacks permission to send messages, catch the exception and return.
            try
            {
                // Reassign the menu session's message to a new message generated from the created embed.
                menuSession.MenuMessage = (RestUserMessage)await message.Channel.SendMessageAsync("", false, embed.Build());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return;
            }

            // Set the "message" variable to the menu session's message.
            message = menuSession.MenuMessage;

            // Edit the menu session according to the current message.
            menuSession.CurrentMenu = "Shop_Sort";
            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 timer runs out, activate a function.
            menuSession.MenuTimer.Elapsed += (sender, e) => MenuTimer_Elapsed(sender, e, menuSession, itemSession);

            // 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("\u0031\ufe0f\u20e3"));
            reaction_list.Add(new Emoji("\u0032\ufe0f\u20e3"));
            reaction_list.Add(new Emoji("\u0033\ufe0f\u20e3"));
            reaction_list.Add(new Emoji("\u0034\ufe0f\u20e3"));
            reaction_list.Add(new Emoji("\u0035\ufe0f\u20e3"));
            reaction_list.Add(new Emoji("\u0036\ufe0f\u20e3"));

            // Add the reactions to the message.
            _ = ReactionHandling.AddReactionsToMenu(message, reaction_list);
        }
コード例 #29
0
        public static async Task Resolution_Scaling_P2IS_PSP_Output_Resolution(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);

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

            embed.WithAuthor(author);

            var footer = new EmbedFooterBuilder
            {
                Text = "↩️ P2IS (Remake) Resolution & Scaling Menu"
            };

            embed.WithFooter(footer);

            // Assign a color and thumbnail to the embeded message based on the title being edited.
            embed.WithColor(EmbedSettings.Get_Game_Color("P2IS-PSP", null));
            embed.WithThumbnailUrl(EmbedSettings.Get_Game_Logo("P2IS-PSP"));

            embed.WithDescription("" +
                                  "**Choose a resolution to output your scenes in.**\n" +
                                  "\n" +
                                  $"⚙️ **Current setting:** **`{account.P2IS_PSP_Resolution}`**\n" +
                                  "\n" +
                                  "** **");

            embed.AddField(":one: 480 × 272", "" +
                           "Original PlayStation® Portable output resolution.");

            embed.AddField(":two: 1920 × 1088", "" +
                           "Scaled HD resolution.");

            // 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 = "Resolution_Scaling_P2IS_PSP_Output_Resolution";
            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("\u0031\ufe0f\u20e3"));
            reaction_list.Add(new Emoji("\u0032\ufe0f\u20e3"));

            // Add the reactions to the message.
            _ = ReactionHandling.AddReactionsToMenu(message, reaction_list);
        }
コード例 #30
0
        internal static async void DiligenceRankUpMessage(SocketMessage message, int new_rank)
        {
            var user    = message.Author;
            var channel = message.Channel;

            var account = UserInfoClasses.GetAccount(user);

            var embed  = new EmbedBuilder();
            var author = new EmbedAuthorBuilder
            {
                Name    = "RANK UP!!",
                IconUrl = user.GetAvatarUrl()
            };

            embed.WithAuthor(author);

            //If the user sees a rank up message for the first time, display a notification for the settings menu.
            if (account.First_Rank_Msg_Sent == "No")
            {
                var footer = new EmbedFooterBuilder
                {
                    Text = $"You can disable rank up messages like these from the {BotConfig.bot.cmdPrefix}settings menu by choosing [General Settings]."
                };

                embed.WithFooter(footer);
            }

            //Determine details that are specific to each profile theme
            if (account.Profile_Theme == "P3")
            {
                //Color for embeded message
                embed.WithColor(37, 149, 255);

                //Description and thumbnail for embeded message
                if (new_rank == 2)
                {
                    embed.WithThumbnailUrl("https://i.imgur.com/gnp8Sb1.png");
                    embed.WithDescription(user.Username + "'s Diligence has changed from **Callow** to **Persistent**!");
                }
                else if (new_rank == 3)
                {
                    embed.WithThumbnailUrl("https://i.imgur.com/VZcDdhm.png");
                    embed.WithDescription(user.Username + "'s Diligence has changed from **Persistent** to **Strong**!");
                }
                else if (new_rank == 4)
                {
                    embed.WithThumbnailUrl("https://i.imgur.com/AbotQvE.png");
                    embed.WithDescription(user.Username + "'s Diligence has changed from **Strong** to **Thorough**!");
                }
                else if (new_rank == 5)
                {
                    embed.WithThumbnailUrl("https://i.imgur.com/tU8DoUC.png");
                    embed.WithDescription(user.Username + "'s Diligence has **maxed out**!");
                }
            }
            else if (account.Profile_Theme == "P4")
            {
                //Color for embeded message
                embed.WithColor(255, 229, 49);

                //Description and thumbnail for embeded message
                if (new_rank == 2)
                {
                    embed.WithThumbnailUrl("https://i.imgur.com/qDysKKu.png");
                    embed.WithDescription(user.Username + "'s Diligence has changed from **Callow** to **Persistent**!");
                }
                else if (new_rank == 3)
                {
                    embed.WithThumbnailUrl("https://i.imgur.com/tIlZX2I.png");
                    embed.WithDescription(user.Username + "'s Diligence has changed from **Persistent** to **Strong**!");
                }
                else if (new_rank == 4)
                {
                    embed.WithThumbnailUrl("https://i.imgur.com/dtjdeeG.png");
                    embed.WithDescription(user.Username + "'s Diligence has changed from **Strong** to **Thorough**!");
                }
                else if (new_rank == 5)
                {
                    embed.WithThumbnailUrl("https://i.imgur.com/h3wtkot.png");
                    embed.WithDescription(user.Username + "'s Diligence has **maxed out**!");
                }
            }
            else if (account.Profile_Theme == "P5")
            {
                //Color for embeded message
                embed.WithColor(213, 27, 4);

                //Description and thumbnail for embeded message
                if (new_rank == 2)
                {
                    embed.WithThumbnailUrl("https://i.imgur.com/O9g4vsY.png");
                    embed.WithDescription(user.Username + "'s Diligence has increased to **Persistent**!");
                }
                else if (new_rank == 3)
                {
                    embed.WithThumbnailUrl("https://i.imgur.com/XXeil53.png");
                    embed.WithDescription(user.Username + "'s Diligence has increased to **Strong**!");
                }
                else if (new_rank == 4)
                {
                    embed.WithThumbnailUrl("https://i.imgur.com/mKKsnzm.png");
                    embed.WithDescription(user.Username + "'s Diligence has increased to **Thorough**!");
                }
                else if (new_rank == 5)
                {
                    embed.WithThumbnailUrl("https://i.imgur.com/GVx284g.png");
                    embed.WithDescription(user.Username + "'s Diligence has **maxed out**!");
                }
            }

            await channel.SendMessageAsync("", false, embed.Build());
        }