コード例 #1
0
        public static async Task Resolution_Scaling_P4_PS2_Output_Resolution_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 = "💠 P4 (PlayStation® 2) Resolution & Scaling Menu | ❌ Close 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("P4-PS2", null));
            embed.WithThumbnailUrl(EmbedSettings.Get_Game_Logo("P4-PS2"));

            embed.WithDescription("" +
                                  $"Scenes will be output at a **`{account.P4_PS2_Resolution}`** resolution.\n");

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

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

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

                return;
            }

            // Edit the menu session according to the current message.
            menuSession.CurrentMenu = "Resolution_Scaling_P4_PS2_Output_Resolution_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);
        }
コード例 #2
0
            public async Task suggestions(params string[] args)
            {
                if (!HasExecutePermission)
                {
                    await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                    {
                        Title       = "Hol up",
                        Color       = Color.Red,
                        Description = "You do not have the correct authority ma'am/sir!"
                    }.Build());

                    return;
                }
                if (Context.User.Id == 259053800755691520 | Context.User.Id == 393448221944315915)
                {
                    goto skip;
                }
                if (Context.Guild.GetUser(Context.Message.Author.Id).Hierarchy < Context.Guild.GetRole(592755793808588840).Position)
                {
                    await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                    {
                        Title       = "Hol up",
                        Color       = Color.Red,
                        Description = "You do not have the correct authority ma'am/sir!"
                    }.Build());

                    return;
                }
skip:
                if (args.Length == 0)
                {
                    await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                    {
                        Title       = "bch daquafk??!!?!?!?",
                        Color       = Color.Red,
                        Description = "what you doing? what you want me to do? i aint no magician?",
                        ImageUrl    = "https://i.chzbgr.com/full/6113771776/hEF22755C/dafuk-was-that"
                    }.Build());

                    return;
                }
                State  state    = State.NotReviewed;
                Status status   = Status.NotReviewed;
                bool   dlt      = false;
                bool   isUpdate = false;
                bool   isStatus = false;

                switch (args[0].ToLower())
                {
                case "accept":
                    state = State.Accepted;
                    break;

                case "deny":
                    state = State.Denied;
                    break;

                case "delete":
                    dlt = true;
                    break;

                case "update":
                    isUpdate = true;
                    break;

                case "status":
                {
                    isStatus = true;
                    //<InTheWorks/Completed/NeedsStaffReview/NeedsApproval/NotReviewed>
                    switch (args[2].ToLower())
                    {
                    case "InTheWorks":
                        status = Status.InTheWorks;
                        break;

                    case "Completed":
                        status = Status.Completed;
                        break;

                    case "NeedsStaffReview":
                        status = Status.NeedsStaffReview;
                        break;

                    case "NeedsApproval":
                        status = Status.NeedsApproval;
                        break;

                    case "NotReviewed":
                        status = Status.NotReviewed;
                        break;

                    default:
                    {
                        await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                                {
                                    Title       = "What?",
                                    Color       = Color.Red,
                                    Description = $"Sorry but you need to follow this format `*suggestion status <MessageID> <InTheWorks/Completed/NeedsStaffReview/NeedsApproval/NotReviewed> <Reason>",
                                    ImageUrl    = "https://i.chzbgr.com/full/6113771776/hEF22755C/dafuk-was-that"
                                }.Build());

                        return;
                    }
                    }
                }
                break;

                default:
                {
                    await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                        {
                            Title       = "What?",
                            Color       = Color.Red,
                            Description = $"Sorry but you need to either `Accept` or `Deny` a suggestion. i dont know what {args[0].ToLower()} means..",
                            ImageUrl    = "https://i.chzbgr.com/full/6113771776/hEF22755C/dafuk-was-that"
                        }.Build());

                    return;
                }
                }
                if (args.Length == 1)
                {
                    await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                    {
                        Title       = "What suggestion do you want to accept or deny?",
                        Color       = Color.Red,
                        Description = "Please provide a message ID",
                    }.Build());

                    return;
                }
                if (args.Length == 2 && !dlt)
                {
                    await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                    {
                        Title       = "Whats the Reason?",
                        Color       = Color.Red,
                        Description = "Please provide a reason!",
                    }.Build());

                    return;
                }

                string reason = string.Join(' ', args.Skip(2));
                ulong  id     = 0;

                try
                {
                    id = ulong.Parse(args[1]);
                }
                catch
                {
                    await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                    {
                        Title       = "H u h ?",
                        Color       = Color.Red,
                        Description = "That Message ID is Invalid",
                    }.Build());

                    return;
                }
                if (!CurrentSuggestions.Any(x => x.MessageID == id))
                {
                    await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                    {
                        Title       = "Sorry, I can't find that Message :/",
                        Color       = Color.Red,
                        Description = "looks like that ID is not on record",
                    }.Build());

                    return;
                }
                var suggestion = CurrentSuggestions.Find(x => x.MessageID == id);

                if (suggestion.ReviewType != State.NotReviewed && !isUpdate && !isStatus)
                {
                    await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                    {
                        Title       = $"Sorry, you cant {state} that :/",
                        Color       = Color.Red,
                        Description = $"Someones already {suggestion.ReviewType} that suggestion, try updating it or changing the status",
                    }.Build());

                    return;
                }
                if (isUpdate)
                {
                    //update card
                }
                else if (isStatus)
                {
                    //update status
                }
                else
                {
                    int inx = CurrentSuggestions.IndexOf(suggestion);
                    suggestion.ReviewText   = reason == null ? "" : reason;
                    suggestion.ReviewType   = state;
                    suggestion.ReviewerID   = Context.Message.Author.Id;
                    CurrentSuggestions[inx] = suggestion;
                    Global.SaveSuggestions();
                    //try to get message
                    RestUserMessage msg = (RestUserMessage)await Context.Guild.GetTextChannel(Global.SuggestionChannelID).GetMessageAsync(suggestion.MessageID);

                    if (msg == null)
                    {
                        await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                        {
                            Title       = "Sorry, I can't find that Message :/",
                            Color       = Color.Red,
                            Description = "looks like that message is either deleted or is too old",
                        }.Build());

                        return;
                    }
                    if (dlt)
                    {
                        if ((DateTime.UtcNow - msg.Timestamp.UtcDateTime).TotalDays >= 14)
                        {
                            await Context.Channel.SendMessageAsync("Suggestion cannot be deleted as it is older than 14 days \n" + msg.GetJumpUrl());

                            CurrentSuggestions.Remove(suggestion);
                            return;
                        }
                        await msg.DeleteAsync();

                        await Context.Channel.SendMessageAsync("Deleted!");

                        CurrentSuggestions.Remove(suggestion);
                        Global.SaveSuggestions();
                        return;
                    }
                    await msg.ModifyAsync(x => x.Embed = new EmbedBuilder()
                    {
                        Title       = "User Suggestion!",
                        Color       = state == State.Accepted ? Color.Green : state == State.Denied ? Color.Red : Color.Red,
                        Description = suggestion.SuggestionText +
                                      $"\n\n-----------**{state}**-----------\n\n**{state} For:** {reason}",
                        Fields = new List <EmbedFieldBuilder>()
                        {
                            new EmbedFieldBuilder()
                            {
                                Name     = "Author",
                                Value    = $"<@{suggestion.AuthorID}>" + $"\nID: ({suggestion.AuthorID})          ",
                                IsInline = true
                            },
                            new EmbedFieldBuilder()
                            {
                                Name     = "Reviewed?",
                                Value    = $"**{state}** by {Context.Message.Author.Mention}\n  ",
                                IsInline = true
                            },
                            new EmbedFieldBuilder()
                            {
                                Name  = "Message ID",
                                Value = msg.Id,
                            }
                        }
                    }.Build());

                    try
                    {
                        //dm user
                        var usr = Context.Guild.GetUser(suggestion.AuthorID).SendMessageAsync($"Your Suggestion \"{suggestion.SuggestionText}\" was **{state}** by <@{suggestion.ReviewerID}>");
                    }
                    catch { }
                    await Context.Channel.SendMessageAsync("Success <3");
                }
            }
コード例 #3
0
        public static async void RenderImage(SocketUser user, ISocketMessageChannel channel)
        {
            RestUserMessage loader = await channel.SendMessageAsync("", false, LoadingMessage().Build());

            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_Mamori_1//chara_bg.png");
            Bitmap ui_overlay = (Bitmap)System.Drawing.Image.FromFile($@"{AssetDirectoryConfig.assetDirectory.assetFolderPath}//Profile//StatusScreens//Decor//Decor_TMS_Mamori_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);

            try
            {
                await channel.SendFileAsync(memoryStream, $"status_{user.Id}_{DateTime.UtcNow}.png");
            }
            catch (Exception ex)
            {
                _ = ErrorHandling.Scene_Upload_Failed(user, channel);
                Console.WriteLine(ex);

                memoryStream.Dispose();
                await loader.DeleteAsync();

                return;
            }

            memoryStream.Dispose();
            await loader.DeleteAsync();
        }
コード例 #4
0
        public static async Task Backgrounds_Default_Color_Error(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    = "Invalid Hex Color Code",
                IconUrl = user.GetAvatarUrl()
            };

            embed.WithAuthor(author);

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

            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("" +
                                  "It looks like an invalid hex code was typed in. React with ↩️ to try again.\n");

            embed.AddField("Tips", "" +
                           "Hex codes are the same ones used to set colors for Discord roles. Try using the role color picker if you need reference for a color's code.");

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

            // Add the reactions to the message.
            _ = ReactionHandling.AddReactionsToMenu(message, reaction_list);
        }
コード例 #5
0
        public static async Task Backgrounds_Default_Color(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    = "Default Background Color",
                IconUrl = user.GetAvatarUrl()
            };

            embed.WithAuthor(author);

            var footer = new EmbedFooterBuilder
            {
                Text = "↩️ Backgrounds 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("" +
                                  "**Choose a default color to use for scene maker backgrounds by typing in a hex color code.**\n" +
                                  "\n" +
                                  $"⚙️ **Current setting:** **`{account.Setting_BG_Color}`**\n" +
                                  "\n" +
                                  "To use clear backgrounds, select :white_square_button:.");

            // 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 = "Backgrounds_Default_Color";
            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
        private async void Timer_SendNextMessageEvent(object sender, ElapsedEventArgs e)
        {
            if (Waiting)
            {
                if (KickLast > 0)
                {
                    BanroyaleMessageDict.Remove(this.Message.Id);
                }

                var usersReac = (await Message.GetReactionUsersAsync(Emote, 100).FlattenAsync()).Select(x => x.Id).ToHashSet();
                var users     = Role.Members.Where(x => !usersReac.Contains(x.Id)).ToList();

                BanroyaleMessageDict.Remove(this.Message.Id);
                Waiting = false;

                if (await LostUsers(this, users))
                {
                    return;
                }
            }

            var rnd = new Random();
            int x   = rnd.Next(3);

            KickLast = Role.Members.Count();
            if (KickLast > 20)
            {
                KickLast = KickLast / 10 + x;
            }
            else if (KickLast > 5)
            {
                KickLast = x;
            }
            else
            {
                KickLast = x - 1 >= 0 ? x - 1 : 0;
            }

            int emoteCount = 4;
            var emotes     = BanroyaleUtil.DrawEmotes(emoteCount);
            int r          = rnd.Next(emoteCount);

            Emote = emotes[r];

            Message = await Channel.SendMessageAsync($"{Role.Mention}", embed : new EmbedBuilderPrepared($"Click the {Emote} reaction to stay in the game!\n" +
                                                                                                         $"{(KickLast > 0 ? $"Last **{KickLast}** participants to react will lose!" : "")}")
                                                     .WithColor(Color.Blue)
                                                     .Build());

            foreach (var emote in emotes)
            {
                _ = Message.AddReactionAsync(emote);
            }

            await BanroyaleMessageDb.AddMessage(new BanroyaleMessage
            {
                Active      = true,
                BanroyaleId = Banroyale.Id,
                MessageId   = Message.Id,
                EmoteId     = Emote.Id
            });

            if (KickLast > 0)
            {
                BanroyaleMessageDict.Add(Message.Id, this);
            }

            Waiting = true;

            double interval = new Random().Next(Banroyale.MaxFrequency - Banroyale.MinFrequency) + Banroyale.MinFrequency;

            Timer.Interval = interval * 1000;
            Timer.Start();
        }
コード例 #7
0
        public static async Task Template_Layout_P5_PS3_Date_Weather(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 & Weather",
                IconUrl = user.GetAvatarUrl()
            };

            embed.WithAuthor(author);

            var footer = new EmbedFooterBuilder
            {
                Text = "↩️ Return to P5 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("P5-PS4", null));
            embed.WithThumbnailUrl(EmbedSettings.Get_Game_Logo("P5-PS4"));

            embed.WithDescription("" +
                                  "**Toggle the date & weather HUD on and off.**\n" +
                                  "\n" +
                                  $"⚙️ **Current setting:** **`{account.P5_PS4_TS_HUD}`**\n" +
                                  "\n" +
                                  ":one: On\n" +
                                  ":two: Off\n");

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

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

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

                return;
            }

            // Edit the menu session according to the current message.
            menuSession.CurrentMenu = "Template_Layout_P5_PS3_Date_Weather";
            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);
        }
コード例 #8
0
        public async Task List()
        {
            var    target   = Context.Guild;
            var    getguild = GuildInfos.GetGuild(target);
            string item     = getguild.movies;

            string[] movies  = item.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            var      myEmoji = new Emoji("👍");

            foreach (string items in movies)
            {
                string thething = items.Remove(0, items.Length - 9);
                string json     = "";
                using (WebClient Client = new WebClient())
                {
                    json = Client.DownloadString($"http://www.omdbapi.com/?apikey=5bbab599&i={thething}");
                }
                var    DataObject = JsonConvert.DeserializeObject <dynamic>(json);
                string Response   = DataObject.Response.ToString();
                if (Response == "True")
                {
                    string Name       = DataObject.Title.ToString();
                    string Year       = DataObject.Year.ToString();
                    string Runtime    = DataObject.Runtime.ToString();
                    string Genre      = DataObject.Genre.ToString();
                    string Country    = DataObject.Country.ToString();
                    string Poster     = DataObject.Poster.ToString();
                    string imdbRating = DataObject.imdbRating.ToString();
                    string imdbVotes  = DataObject.imdbVotes.ToString();
                    string Type       = DataObject.Type.ToString();
                    string Plot       = DataObject.Plot.ToString();
                    string ImdbID     = DataObject.imdbID.ToString();
                    string Released   = DataObject.Released.ToString();
                    string Rated      = DataObject.Rated.ToString();

                    string mvs4u = Name;
                    mvs4u = mvs4u.Replace(' ', '-');
                    mvs4u = Regex.Replace(mvs4u, "[^a-zA-Z0-9.-]", string.Empty);

                    string fus = $"https://www.fushaar.com/movie/{mvs4u}";
                    mvs4u = $"https://www.mvs4u.org/movie/مترجم-{mvs4u}-فيلم/";
                    string Time         = Runtime.Remove(Runtime.Length - 3);
                    int    thetimeinmin = Convert.ToInt32(Time);
                    int    moviehours   = 0;
                    int    moviemin     = 0;
                    while (thetimeinmin != 0)
                    {
                        if (thetimeinmin >= 60)
                        {
                            moviehours   = moviehours + 1;
                            thetimeinmin = thetimeinmin - 60;
                        }
                        else
                        {
                            moviemin     = thetimeinmin;
                            thetimeinmin = 0;
                        }
                    }
                    if (moviehours != 0)
                    {
                        if (moviemin != 0)
                        {
                            Runtime = $"{moviehours} hour and {moviemin} min";
                        }
                        else
                        {
                            Runtime = $"{moviehours} hour ";
                        }
                    }
                    else
                    {
                        if (moviemin != 0)
                        {
                            Runtime = $"{moviemin} min";
                        }
                        else
                        {
                            Runtime = $"There is no recorded Runtime ";
                        }
                    }

                    ImdbID = $"https://www.imdb.com/title/{ImdbID}/";
                    Random random = new Random();
                    var    Embed  = new EmbedBuilder();
                    //need to add a web handle to see if the server send a 404 error if
                    WebClient wb = new WebClient();

                    if (1 == 1)
                    {
                        Embed.AddInlineField("fushaar link", fus);
                    }
                    else
                    {
                        Embed.AddInlineField("mvs4u link", mvs4u);
                    }
                    if (Poster != null)
                    {
                        Embed.WithThumbnailUrl(Poster);
                    }
                    Embed.WithTitle(Name);
                    Embed.WithUrl(ImdbID);
                    Embed.AddInlineField("Released in", Released);
                    Embed.AddInlineField("Time", Runtime);
                    Embed.AddInlineField("Country", Country);
                    Embed.AddField("Genre", Genre);
                    Embed.AddInlineField("Rating", imdbRating);
                    Embed.AddInlineField("Votes", imdbVotes);
                    Embed.AddInlineField("Type", $"{Type} {Rated}");
                    Embed.AddInlineField("Description", Plot);

                    RestUserMessage msg = await Context.Channel.SendMessageAsync("", false, Embed);

                    await msg.AddReactionAsync(myEmoji);
                }
                else
                {
                    await Context.Channel.SendMessageAsync("Error, Please check the name.");
                }
            }
        }
コード例 #9
0
        public static async Task Resolution_Scaling_P1_PS1_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 = "↩️ Revelations: Persona 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("P1-PS1", null));
            embed.WithThumbnailUrl(EmbedSettings.Get_Game_Logo("P1-PS1"));

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

            embed.AddField(":one: 320 × 240", "" +
                           "Original PlayStation® output resolution.");

            embed.AddField(":two: 1440 × 1080", "" +
                           "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_P1_PS1_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);
        }
コード例 #10
0
ファイル: ValorantStatusEvent.cs プロジェクト: Ayresia/Trexia
        public static async void EditEmbed(bool successful, List <ValorantEvent> jsonParsed, int counter, RestUserMessage message)
        {
            var currentTime     = DateTime.Now.ToLongTimeString();
            var currentTimeZone = TZNames.GetAbbreviationsForTimeZone(TimeZoneInfo.Local.Id, "en-GB").Standard;
            var region          = jsonParsed[0].Regions[counter];
            var embedBuilder    = new EmbedBuilder();

            if (successful)
            {
                embedBuilder = new EmbedBuilder
                {
                    Title       = $"{jsonParsed[0].Regions[counter].Name.ToUpper()} Maintenance Status:",
                    Color       = Color.Green,
                    Description = "There is no scheduled Maintenance!"
                };
                embedBuilder.WithFooter($"Trexia A1.0 | Updated on {currentTime} {currentTimeZone}");

                await message.ModifyAsync(m =>
                {
                    m.Embed = embedBuilder.Build();
                });
            }
            else
            {
                embedBuilder = new EmbedBuilder
                {
                    Title = $"{region.Name.ToUpper()} Maintenance Status:",
                    Color = Color.Red
                };

                if (region.Maintenances[0].MaintenanceStatus.Equals("scheduled"))
                {
                    embedBuilder.AddField("Status:", "Scheduled Maintenance", false);
                }

                embedBuilder.AddField("Description:", jsonParsed[0].Regions[counter].Maintenances[0].Updates[0].Description, false);
                embedBuilder.WithFooter($"Trexia A1.0 | Updated on {currentTime} {currentTimeZone}");

                await message.ModifyAsync(m =>
                {
                    m.Embed = embedBuilder.Build();
                });
            }
        }
コード例 #11
0
        public static async Task Render_Quick_Scene_P2IS_PS1(SocialLinkerCommand sl_command, OfficialSetData set_data, MakerCommandData command_data)
        {
            // Create variables to store the width and height of the template.
            int template_width  = 320;
            int template_height = 240;

            // Create two variables for the command user and the command channel, derived from the message object taken in.
            SocketUser        user    = sl_command.User;
            SocketTextChannel channel = (SocketTextChannel)sl_command.Channel;

            // Send a loading message to the channel while the sprite sheet is being made.
            RestUserMessage loader = await channel.SendMessageAsync("", false, P2IS_PS1_Loading_Message().Build());

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

            BustupData bustup_data = BustupDataMethods.Get_Bustup_Data(account, set_data, command_data);

            // Create a starting base bitmap to render all graphics on.
            Bitmap base_template = new Bitmap(template_width, template_height);

            // Create another bitmap the same size.
            // In case the user has set a colored bitmap in their settings, we'll need to use this to render it.
            Bitmap colored_background_bitmap = new Bitmap(template_width, template_height);

            // Here, we want to grab any images attached to the message to use it as a background.
            // Create a variable for the message attachment.
            var attachments = sl_command.Attachments;

            // Create an empty string variable to hold the URL of the attachment.
            string url = "";

            // If there are no attachments on the message, set the URL string to "None".
            if (attachments == default || attachments.LongCount() == 0)
            {
                url = "None";
            }
            // Else, assign the URL of the attachment to the URL string.
            else
            {
                url = attachments.ElementAt(0).Url;
            }

            // Initialize a bitmap object for the user's background. It's small now because we'll reassign it depending on our circumstances.
            Bitmap background = new Bitmap(2, 2);

            // If a URL for a message attachment exists, download it and copy its contents to the bitmap variable we just created.
            if (url != "None")
            {
                // Here, we'll want to try and retrieve the user's input image.
                try
                {
                    // Declare variables for a web request to retrieve the image.
                    System.Net.HttpWebRequest webRequest = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(url);
                    webRequest.AllowWriteStreamBuffering = true;
                    webRequest.Timeout = 30000;

                    // Create a stream and download the image to it.
                    System.Net.WebResponse webResponse = webRequest.GetResponse();
                    System.IO.Stream       stream      = webResponse.GetResponseStream();

                    // Copy the stream's contents to the background bitmap variable.
                    background = (Bitmap)System.Drawing.Image.FromStream(stream);

                    webResponse.Close();
                }
                // If an exception occurs here, the filetype is likely incompatible.
                // Send an error message, delete the loading message, and return.
                catch (System.ArgumentException e)
                {
                    Console.WriteLine(e);
                    await loader.DeleteAsync();

                    _ = ErrorHandling.Incompatible_File_Type(sl_command);
                    return;
                }
            }

            // Render the uploaded image based on the user's background settings.
            switch (account.Setting_BG_Upload)
            {
            case "Maintain Aspect Ratio":
                background = Center_Image(background);
                break;

            case "Stretch to Fit":
                background = Stretch_To_Fit(background);
                break;
            }

            // The user may have a custom mono-colored background designated in their settings. Let's handle that now.
            // Check if the user's background color setting is set to something other than "Transparent".
            // If so, we have a color to render for the background!
            if (account.Setting_BG_Color != "Transparent")
            {
                // Convert the user's HTML color setting to one we can use and assign it to a color variable.
                System.Drawing.Color user_background_color = System.Drawing.ColorTranslator.FromHtml(account.Setting_BG_Color);

                // Color the entirety of the background bitmap the user's selected color.
                using (Graphics graphics = Graphics.FromImage(colored_background_bitmap))
                {
                    graphics.Clear(user_background_color);
                }
            }

            // Next, time for the conversation portrait! Create and initialize a new bitmap variable for it.
            Bitmap bustup = new Bitmap(2, 2);

            // Check if the base sprite number is something other than zero.
            // If it is zero, we have nothing to render. Otherwise, retrieve the bustup.
            if (command_data.Base_Sprite != 0)
            {
                bustup = OfficialSetMethods.Bustup_Selection(sl_command, account, set_data, bustup_data, command_data);
            }

            // If the bustup returns as null, however, something went wrong with rendering the animation frames.
            // An error message has already been sent in the frame rendering method, so delete the loading message and return.
            if (bustup == null)
            {
                await loader.DeleteAsync();

                return;
            }

            List <string>[] dialogue_lines = Line_Parser(sl_command, command_data.Dialogue);

            // Time to put it all together!
            using (Graphics graphics = Graphics.FromImage(base_template))
            {
                // Draw the input dialogue to the template.
                graphics.DrawImage(Render_Bustup(account, bustup_data, bustup), 0, 0, template_width, template_height);
                graphics.DrawImage(Render_Message_Window(account), 0, 0, template_width, template_height);
                graphics.DrawImage(Combined_Text_Layers(bustup_data, dialogue_lines), 0, 0, template_width, template_height);
            }

            // Save the entire base template to a data stream.
            MemoryStream memoryStream = new MemoryStream();

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

            try
            {
                // Send the image.
                await sl_command.Channel.SendFileAsync(memoryStream, $"scene_{sl_command.User.Id}_{DateTime.UtcNow}.png");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);

                // Send an error message to the user if the image upload fails.
                _ = ErrorHandling.Image_Upload_Failed(sl_command);

                // Clean up resources used by the stream, delete the loading message, and return.
                memoryStream.Dispose();
                await loader.DeleteAsync();

                return;
            }

            // Clean up resources used by the stream and delete the loading message.
            memoryStream.Dispose();
            await loader.DeleteAsync();

            // If the user has auto-delete for their commands set to on, delete their command as well.
            if (account.Auto_Delete_Commands == "On")
            {
                await sl_command.Message.DeleteAsync();
            }
        }
コード例 #12
0
 public void AddOptionMessage(RestUserMessage option)
 {
     Options.Add(option);
 }
コード例 #13
0
ファイル: MonitorList.cs プロジェクト: tylormclaughlin/foxbot
 public static void DeleteMonitoredMessage()
 {
     message = null;
 }
コード例 #14
0
        public static async Task Help_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    = "Social Linker Help",
                IconUrl = user.GetAvatarUrl()
            };

            embed.WithAuthor(author);

            var footer = new EmbedFooterBuilder
            {
                Text = "⚖️ Legal Notices | 📄 Credits | ❌ 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_Help_Thumbnail(account));

            embed.WithDescription(
                "> **Tutorials**\n" +
                ":large_blue_diamond: **`Status Screens`**\n" +
                ":orange_circle: **`Scene Maker`**\n" +
                "\n" +
                "> **General Commands**\n" +
                $"`{BotConfig.bot.cmdPrefix}help`\n" +
                $"`{BotConfig.bot.cmdPrefix}settings`\n" +
                "\n" +
                "> **Social Commands**\n" +
                $"`{BotConfig.bot.cmdPrefix}hug [user]`\n" +
                $"`{BotConfig.bot.cmdPrefix}pat [user]`\n" +
                $"`{BotConfig.bot.cmdPrefix}slap [user]`\n" +
                $"`{BotConfig.bot.cmdPrefix}punch [user]`\n");
            embed.AddField("Links",
                           "[Social Linker Support](https://discord.gg/ZbEeZRjVvU)\n" +
                           "[Add Social Linker to your Server](https://discord.gg/ZbEeZRjVvU)\n" +
                           "");

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

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

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

                return;
            }

            // Edit the menu session according to the current message.
            menuSession.CurrentMenu = "Help_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("🔷"));
            reaction_list.Add(new Emoji("🟠"));
            reaction_list.Add(new Emoji("⚖️"));
            reaction_list.Add(new Emoji("📄"));
            reaction_list.Add(new Emoji("❌"));

            // Add the reactions to the message.
            _ = ReactionHandling.AddReactionsToMenu(message, reaction_list);
        }
コード例 #15
0
        public async Task HandleReactionMessage()
        {
            RestUserMessage msg = await Context.Channel.SendMessageAsync("React to me!");

            Global.MessageIdToTrack = msg.Id;
        }
コード例 #16
0
        public static async Task SM_Settings_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    = "Scene Maker Settings",
                IconUrl = user.GetAvatarUrl()
            };

            embed.WithAuthor(author);

            var footer = new EmbedFooterBuilder
            {
                Text = "↩️ Return to Settings Main 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: Version Control",
                           "Change the default templates and sprite sets available for different versions of the same title.");
            embed.AddField(":two: Template Layout",
                           "Change select visual elements while using various templates.");
            embed.AddField(":three: Sprite Mode",
                           "Change the type of sprites used for certain scene maker templates.");
            embed.AddField(":four: Display Names",
                           "Change the displayed names of various characters and sprite sets.");
            embed.AddField(":five: Sprite Sheet Order",
                           "Change whether sprite sets are ordered by costume or by expression.");
            embed.AddField(":six: Backgrounds",
                           "Determine how background images are rendered within the scene maker.");
            embed.AddField(":seven: Resolution & Scaling",
                           "Change output resolutions and scaling methods per template.");
            embed.AddField(":eight: Auto-Delete",
                           "Toggle auto-deletion of error messages and scene maker commands.");

            // 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_Settings_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("↩️"));
            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"));
            reaction_list.Add(new Emoji("\u0037\ufe0f\u20e3"));
            reaction_list.Add(new Emoji("\u0038\ufe0f\u20e3"));

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