Beispiel #1
0
        public async Task Seppuku(CommandContext ctx)
        {
            await ctx.TriggerTypingAsync();

            await ctx.Member.RemoveAsync("Popełnił Seppuku. Gloria Victis!");


            var embed = new DSharpPlus.Entities.DiscordEmbedBuilder()
            {
                Color = Helpers.ColorHelper.RandomColor()
            };
            var candle = DSharpPlus.Entities.DiscordEmoji.FromName(ctx.Client, ":candle:");

            embed.AddField($"{ctx.Member.DisplayName} popełnił Seppuku", candle.ToString());
            embed.ImageUrl = "https://media1.tenor.com/images/6f64764b4b7874465d83de68342347cc/tenor.gif?itemid=4854729";
            await ctx.RespondAsync(embed : embed);
        }
Beispiel #2
0
        static async Task MainAsync(string[] args)
        {
            string prefix = "";
            string token  = "";

            botclient = new DiscordClient(new DiscordConfiguration
            {
                Token     = token,
                TokenType = TokenType.Bot
            });
            botclient.Ready += async client =>
            {
                Console.WriteLine(botclient.CurrentUser.Username + " is Ready!");
            };
            botclient.MessageCreated += async msg =>
            {
                if (msg.Message.Content == prefix + "help")
                {
                    var helpembed = new DSharpPlus.Entities.DiscordEmbedBuilder()
                    {
                        Color  = new DSharpPlus.Entities.DiscordColor(299646),
                        Author = new DSharpPlus.Entities.DiscordEmbedBuilder.EmbedAuthor
                        {
                            Name    = msg.Author.Username,
                            IconUrl = msg.Author.AvatarUrl
                        },
                        Title       = "Help Command",
                        Description = "List of **Commands** of this bot.\nLook **Below**.",
                        Footer      = new DSharpPlus.Entities.DiscordEmbedBuilder.EmbedFooter
                        {
                            Text = "DSharpPlus Example"
                        },
                    };
                    helpembed.AddField("Basic Commands", "`help`", true);
                    var helpembedbuild = helpembed.Build();
                    await msg.Message.Channel.SendMessageAsync(embed : helpembedbuild);
                }
            };
            await botclient.ConnectAsync();

            await Task.Delay(-1);
        }
Beispiel #3
0
        static async Task MainAsync()
        {
            //called whenever message created
            discord.MessageCreated += async(e) =>
            {
                if (e.Message.Content == "/vb help")
                {
                    await PrintHelp();
                }
                if (e.Message.Content == "/vb topdog")
                {
                    bool killproc = false;
                    //level id is day+month+year, this is me getting these values and adding them
                    string currentDay   = DateTime.Now.Day.ToString();
                    string currentMonth = DateTime.Now.Month.ToString();
                    string currentYear  = DateTime.Now.Year.ToString();
                    string levelID      = DateTime.UtcNow.ToString("dMMyyyy");

                    //get data and make it look good
                    var stream = client.DownloadString(Environment.GetEnvironmentVariable("APIURL") + levelID + "&callback=?");
                    Console.WriteLine((Environment.GetEnvironmentVariable("APIURL") + levelID + "&callback=?"));
                    stream = stream.Replace(",{\"position", ",\n{\"position");
                    File.WriteAllText(Directory.GetCurrentDirectory() + @"/topdog.json", stream);

                    Thread.Sleep(300);
                    string[] topjson = File.ReadAllLines(Directory.GetCurrentDirectory() + @"/topdog.json");
                    string   top7    = "asc\n";
                    foreach (var line in topjson)
                    {
                        if (line.Contains("{\"position\":8"))
                        {
                            killproc = true;
                        }
                        if (!killproc)
                        {
                            string posNum = line.Substring(line.IndexOf(",\"levelUnique") - line.IndexOf("\"position\":"), line.IndexOf(",\"levelUnique"));
                            posNum = posNum.Replace(":", "");
                            posNum = posNum.Replace(",\"levelUniqu", "");


                            string name = line.Substring(line.IndexOf("\"id\":"), line.IndexOf("\",\"registerdUserId") - line.IndexOf("\"id\":"));
                            name = name.Replace("\"id\":\"", "");

                            top7 += posNum + ".) " + name + "\n";
                        }
                    }


                    if (topjson.Length < 7)
                    {
                        string topnum    = "The current top " + (topjson.Length).ToString() + " in top dog are:\n";
                        var    embuilder = new DSharpPlus.Entities.DiscordEmbedBuilder();
                        top7 = "```" + top7 + "```";
                        embuilder.AddField(topnum, top7);

                        var emb = embuilder.Build();
                        await e.Message.RespondAsync("", false, emb);
                    }
                    else
                    {
                        string topnum    = "The current top 7 in top dog are:\n";
                        var    embuilder = new DSharpPlus.Entities.DiscordEmbedBuilder();
                        top7 = "```" + top7 + "```";
                        embuilder.AddField(topnum, top7);
                        var emb = embuilder.Build();
                        await e.Message.RespondAsync("", false, emb);
                    }
                }
                if (e.Message.Content == "/vb hardcore")
                {
                    bool killproc = false;
                    //level id is day+month+year, this is me getting these values and adding them
                    string currentDay   = DateTime.Now.Day.ToString();
                    string currentMonth = DateTime.Now.Month.ToString();
                    string currentYear  = DateTime.Now.Year.ToString();
                    string levelID      = DateTime.UtcNow.ToString("dMMyyyy");

                    //get data and make it look good
                    var stream = client.DownloadString(Environment.GetEnvironmentVariable("APIURL") + "55" + levelID + "&callback=?");
                    stream = stream.Replace(",{\"position", ",\n{\"position");
                    File.WriteAllText(Directory.GetCurrentDirectory() + @"/hardcore.json", stream);

                    Thread.Sleep(300);
                    string[] topjson = File.ReadAllLines(Directory.GetCurrentDirectory() + @"/hardcore.json");
                    string   top7    = "asc\n";
                    foreach (var line in topjson)
                    {
                        if (line.Contains("{\"position\":8"))
                        {
                            killproc = true;
                        }
                        if (!killproc)
                        {
                            string posNum = line.Substring(line.IndexOf(",\"levelUnique") - line.IndexOf("\"position\":"), line.IndexOf(",\"levelUnique"));
                            posNum = posNum.Replace(":", "");
                            posNum = posNum.Replace(",\"levelUniqu", "");


                            string name = line.Substring(line.IndexOf("\"id\":"), line.IndexOf("\",\"registerdUserId") - line.IndexOf("\"id\":"));
                            name = name.Replace("\"id\":\"", "");

                            top7 += posNum + ".) " + name + "\n";
                        }
                    }

                    if (topjson.Length < 7)
                    {
                        string topnum    = "The current top " + (topjson.Length).ToString() + " in hardcore are:\n";
                        var    embuilder = new DSharpPlus.Entities.DiscordEmbedBuilder();
                        top7 = "```" + top7 + "```";
                        embuilder.AddField(topnum, top7);
                        var emb = embuilder.Build();
                        await e.Message.RespondAsync("", false, emb);
                    }
                    else
                    {
                        string topnum    = "The current top 7 in hardcore are:\n";
                        var    embuilder = new DSharpPlus.Entities.DiscordEmbedBuilder();
                        top7 = "```" + top7 + "```";
                        embuilder.AddField(topnum, top7);
                        var emb = embuilder.Build();
                        await e.Message.RespondAsync("", false, emb);
                    }
                    Thread.Sleep(300);
                    if (File.Exists(Directory.GetCurrentDirectory() + "/hardcore.json"))
                    {
                        File.Delete(Directory.GetCurrentDirectory() + "/hardcore.json");
                    }
                }
                if (e.Message.Content == "/vb speeddemon")
                {
                    bool killproc = false;
                    //level id is day+month+year, this is me getting these values and adding them
                    string currentDay   = DateTime.Now.Day.ToString();
                    string currentMonth = DateTime.Now.Month.ToString();
                    string currentYear  = DateTime.Now.Year.ToString();
                    string levelID      = DateTime.UtcNow.ToString("dMMyyyy");

                    //get data and make it look good
                    var stream = client.DownloadString(Environment.GetEnvironmentVariable("APIURL") + "77" + levelID + "&callback=?");
                    stream = stream.Replace(",{\"position", ",\n{\"position");
                    File.WriteAllText(Directory.GetCurrentDirectory() + @"/speeddemon.json", stream);

                    Thread.Sleep(300);
                    string[] topjson = File.ReadAllLines(Directory.GetCurrentDirectory() + @"/speeddemon.json");
                    string   top7    = "asc\n";
                    foreach (var line in topjson)
                    {
                        if (topjson.Length < 8)
                        {
                        }
                        if (line.Contains("{\"position\":8"))
                        {
                            killproc = true;
                        }
                        if (!killproc)
                        {
                            string posNum = line.Substring(line.IndexOf(",\"levelUnique") - line.IndexOf("\"position\":"), line.IndexOf(",\"levelUnique"));
                            posNum = posNum.Replace(":", "");
                            posNum = posNum.Replace(",\"levelUniqu", "");


                            string name = line.Substring(line.IndexOf("\"id\":"), line.IndexOf("\",\"registerdUserId") - line.IndexOf("\"id\":"));
                            name  = name.Replace("\"id\":\"", "");
                            top7 += posNum + ".) " + name + "\n";
                        }
                    }
                    //bruh

                    if (topjson.Length < 7)
                    {
                        string topnum    = "The current top " + (topjson.Length).ToString() + " in speed-demon are:\n";
                        var    embuilder = new DSharpPlus.Entities.DiscordEmbedBuilder();
                        top7 = "```" + top7 + "```";
                        embuilder.AddField(topnum, top7);
                        var emb = embuilder.Build();
                        await e.Message.RespondAsync("", false, emb);
                    }
                    else
                    {
                        string topnum    = "The current top 7 in speed-demon are:\n";
                        var    embuilder = new DSharpPlus.Entities.DiscordEmbedBuilder();
                        top7 = "```" + top7 + "```";
                        embuilder.AddField(topnum, top7);
                        var emb = embuilder.Build();
                        await e.Message.RespondAsync("", false, emb);
                    }
                    Thread.Sleep(300);
                    if (File.Exists(Directory.GetCurrentDirectory() + "/speeddemon.json"))
                    {
                        File.Delete(Directory.GetCurrentDirectory() + "/speeddemon.json");
                    }
                }
                if (e.Message.Content.StartsWith("/vb seed "))
                {
                    bool   killproc = false;
                    string seed     = e.Message.Content.Replace("/vb seed ", "");
                    if (seed == "")
                    {
                        e.Message.RespondAsync("um, you forgot to specify a seed :)");
                    }
                    else
                    {
                        var stream = client.DownloadString(Environment.GetEnvironmentVariable("APIURL") + "9" + seed + "&callback=?");
                        stream = stream.Replace(",{\"position", ",\n{\"position");
                        File.WriteAllText(Directory.GetCurrentDirectory() + @"/seed" + seed + ".json", stream);
                        Thread.Sleep(300);
                        string[] topjson = File.ReadAllLines(Directory.GetCurrentDirectory() + @"/seed" + seed + ".json");
                        string   top7    = "asc\n";
                        try
                        {
                            foreach (var line in topjson)
                            {
                                if (topjson.Length < 8)
                                {
                                }
                                if (line.Contains("{\"position\":8"))
                                {
                                    killproc = true;
                                }
                                if (!killproc)
                                {
                                    string posNum = line.Substring(line.IndexOf(",\"levelUnique") - line.IndexOf("\"position\":"), line.IndexOf(",\"levelUnique"));
                                    posNum = posNum.Replace(":", "");
                                    posNum = posNum.Replace(",\"levelUniqu", "");

                                    string name = line.Substring(line.IndexOf("\"id\":"), line.IndexOf("\",\"registerdUserId") - line.IndexOf("\"id\":"));
                                    name = name.Replace("\"id\":\"", "");

                                    top7 += posNum + ".) " + name + "\n";
                                }
                            }
                            if (topjson.Length < 7)
                            {
                                string topnum    = "The current top " + (topjson.Length).ToString() + " in your seed are:\n";
                                var    embuilder = new DSharpPlus.Entities.DiscordEmbedBuilder();
                                top7 = "```" + top7 + "```";
                                embuilder.AddField(topnum, top7);
                                var emb = embuilder.Build();
                                await e.Message.RespondAsync("", false, emb);
                            }
                            else
                            {
                                string topnum    = "The current top 7 in your seed are:\n";
                                var    embuilder = new DSharpPlus.Entities.DiscordEmbedBuilder();
                                top7 = "```" + top7 + "```";
                                embuilder.AddField(topnum, top7);
                                var emb = embuilder.Build();
                                await e.Message.RespondAsync("", false, emb);
                            }
                            Thread.Sleep(300);
                            if (File.Exists(Directory.GetCurrentDirectory() + "/seed" + seed + ".json"))
                            {
                                File.Delete(Directory.GetCurrentDirectory() + "/seed" + seed + ".json");
                            }
                        }
                        catch
                        {
                            await e.Message.RespondAsync("oops, your seed gave no results!");
                        }
                    }
                }

                async Task PrintHelp()
                {
                    var help = new DSharpPlus.Entities.DiscordEmbedBuilder();

                    help.AddField("Available Commands:", "all commands start with \"/vb\"\n\n```/vb help\n/vb topdog\n/vb hardcore\n/vb speeddemon\n/vb seed [ your seed ]\n```");
                    var helpEm = help.Build();
                    await e.Message.RespondAsync("", false, helpEm);
                }
            };
            await discord.ConnectAsync();

            await Task.Delay(-1);
        }
    }