Ejemplo n.º 1
0
        public async Task NowPlaying(SocketCommandContext Context)
        {
            try
            {
                List <SongStruct> queue = new List <SongStruct>();
                if (queueDict.TryGetValue(Context.Guild.Id, out queue))
                {
                    if (queue.Count != 0)
                    {
                        var infoJson = File.ReadAllText($"{queue[0].name}.info.json");
                        var info     = JObject.Parse(infoJson);

                        var title = info["fulltitle"];

                        var eb = new EmbedBuilder()
                        {
                            Color  = new Color(4, 97, 247),
                            Footer = new EmbedFooterBuilder()
                            {
                                Text    = $"Requested by {Context.User.Username}#{Context.User.Discriminator}",
                                IconUrl = (Context.User.GetAvatarUrl())
                            }
                        };

                        eb.AddField((efb) =>
                        {
                            int duration = 0;
                            var con      = Int32.TryParse(info["duration"].ToString(), out duration);
                            string dur   = "00:00";
                            if (con)
                            {
                                dur = Convert(duration);
                            }
                            efb.Name     = "Now playing";
                            efb.IsInline = false;
                            efb.Value    = $"[{dur}] - [{title}]({StringEncoder.Base64Decode(queue[0].name)})";
                        });

                        eb.AddField((x) =>
                        {
                            x.Name     = "Requested by";
                            x.IsInline = false;
                            x.Value    = queue[0].user;
                        });

                        await Context.Channel.SendMessageAsync("", false, eb.Build());
                    }
                    else
                    {
                        await Context.Channel.SendMessageAsync(":no_entry_sign: Queue is empty!");
                    }
                }
                else
                {
                    await Context.Channel.SendMessageAsync(
                        ":no_entry_sign: You first have to create a Queue by adding atleast one song!");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 2
0
        public async Task QueueList(SocketCommandContext Context)
        {
            List <SongStruct> queue = new List <SongStruct>();

            if (queueDict.TryGetValue(Context.Guild.Id, out queue))
            {
                if (queue.Count != 0)
                {
                    try
                    {
                        var eb = new EmbedBuilder()
                        {
                            Color  = new Color(4, 97, 247),
                            Footer = new EmbedFooterBuilder()
                            {
                                Text    = $"Requested by {Context.User.Username}#{Context.User.Discriminator}",
                                IconUrl = (Context.User.GetAvatarUrl())
                            }
                        };

                        eb.Title = "Queue List";
                        var infoJsonT = File.ReadAllText($"{queue[0].name}.info.json");
                        var infoT     = JObject.Parse(infoJsonT);

                        var titleT = infoT["fulltitle"].ToString();
                        if (String.IsNullOrWhiteSpace(titleT))
                        {
                            titleT = "Couldn't find name";
                        }

                        eb.AddField((efb) =>
                        {
                            int duration = 0;
                            var con      = Int32.TryParse(infoT["duration"].ToString(), out duration);
                            string dur   = "00:00";
                            if (con)
                            {
                                dur = Convert(duration);
                            }
                            efb.Name     = "Now playing";
                            efb.IsInline = true;
                            efb.Value    = $"[{dur}] - **[{titleT}]({StringEncoder.Base64Decode(queue[0].name)})** \n      \t*by {queue[0].user}*";
                        });



                        int lenght = 0;
                        if (queue.Count > 11)
                        {
                            lenght = 11;
                        }
                        else
                        {
                            lenght = queue.Count;
                        }
                        for (int i = 1; i < lenght; i++)
                        {
                            eb.AddField((efb) =>
                            {
                                efb.Name     = $"#{i} by {queue[i].user}";
                                efb.IsInline = false;
                                var infoJson = File.ReadAllText($"{queue[i].name}.info.json");
                                var info     = JObject.Parse(infoJson);

                                int duration = 0;
                                var con      = Int32.TryParse(info["duration"].ToString(), out duration);
                                string dur   = "00:00";
                                if (con)
                                {
                                    dur = Convert(duration);
                                }

                                var title = info["fulltitle"].ToString();
                                if (String.IsNullOrWhiteSpace(title))
                                {
                                    title = "Couldn't find name";
                                }
                                efb.Value += $"[{dur}] - **[{title}]({StringEncoder.Base64Decode(queue[i].name)})**";
                            });
                        }
                        if (queue.Count == 1)
                        {
                            eb.AddField((efb) =>
                            {
                                efb.Name     = "Queue";
                                efb.IsInline = false;
                                efb.Value    = "No Songs in Queue";
                            });
                        }


                        await Context.Channel.SendMessageAsync("", false, eb.Build());
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
                else
                {
                    await Context.Channel.SendMessageAsync(":no_entry_sign: Queue is empty!");
                }
            }
            else
            {
                await Context.Channel.SendMessageAsync(
                    ":no_entry_sign: You first have to create a Queue by adding atleast one song!");
            }
        }