Esempio n. 1
0
    public async Task AddServerAd(string search, int timeSpan = 1)
    {
        //timeSpan is in hours

        if (!GuildUtils.GetSettings(Context.Guild.Id).ServerSearch)
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Rust Servers", "Error", Language.ServerInfo_Disabled, Context.User)); return;
        }

        var server = await Utilities.GetServer(search);

        EmbedBuilder       eb = new EmbedBuilder();
        EmbedFooterBuilder fb = new EmbedFooterBuilder();

        fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

        eb.WithTitle($"Search");
        eb.WithColor(PremiumUtils.SelectEmbedColour(Context.User));
        eb.WithFooter(fb);

        eb.AddField("Rust Servers", Language.ServerInfo_AddedAd);

        Utilities.adServers.Add(search, DateTime.Now.AddHours(timeSpan));
        await ReplyAsync("", false, eb.Build());
    }
Esempio n. 2
0
    public async Task SendPremium()
    {
        string bulletPoint = "<:small_blue_diamond:759438353057316866>";



        EmbedBuilder       eb = new EmbedBuilder();
        EmbedFooterBuilder fb = new EmbedFooterBuilder();

        fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

        eb.WithTitle($"Premium");
        eb.WithColor(PremiumUtils.SelectEmbedColour(Context.User));
        eb.WithUrl("https://donatebot.io/checkout/701178110485463152");
        eb.WithThumbnailUrl("https://i.imgur.com/VA6V7Dn.png");

        eb.WithDescription("Consider [buying Premium](https://donatebot.io/checkout/701178110485463152) to support the development of the bot and gain access to some cool Premium benefits. Every penny spent goes straight back into keeping the bot up and running, and helps fund the development costs of new features. Thank you for your kindness. [Click here](https://donatebot.io/checkout/701178110485463152) to purchase a tier!");
        eb.AddField("High Quality Tier", $"This tier grants you access to the following benefits:\n{bulletPoint} Random Message Embed Colour\n{bulletPoint} A Spot on the r!thanks List\n{bulletPoint} Premium Embed Footer\n{bulletPoint} Stats Leaderboard");
        eb.AddField("Wooden Tier", $"This tier grants you access to the following benefits:\n{bulletPoint} Random Message Embed Colour\n{bulletPoint} A Spot on the r!thanks List\n{bulletPoint} Premium Embed Footer\n{bulletPoint} Stats Leaderboard");
        eb.AddField("Cloth Tier", $"This tier grants you access to the following benefits:\n{bulletPoint} Random Message Embed Colour\n{bulletPoint} A Spot on the r!thanks List\n{bulletPoint} Premium Embed Footer");

        fb.WithText(PremiumUtils.SelectFooterEmbedText(Context.User));
        eb.WithFooter(fb);

        await ReplyAsync("", false, eb.Build());
    }
Esempio n. 3
0
    public async Task SendITemStore()
    {
        Stopwatch sw = new Stopwatch();

        sw.Start();



        List <ItemStoreItem> itemStore = await Utilities.GetItemStore();

        if (itemStore == null)
        {
            await ReplyAsync("The item store is yet to refresh. Please wait a while and try again.");
        }

        EmbedBuilder       eb = new EmbedBuilder();
        EmbedFooterBuilder fb = new EmbedFooterBuilder();

        fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());
        eb.WithColor(PremiumUtils.SelectEmbedColour(Context.User));
        eb.WithTitle($"Item Store");
        eb.WithFooter(fb);

        foreach (var item in itemStore)
        {
            eb.AddField($"{item.ItemName}", $"Price: {Regex.Replace(item.ItemPrice, @"\t|\n|\r", "")}\nLink: [{item.ItemName}]({item.ItemURL})");
        }

        sw.Stop();
        fb.WithText(PremiumUtils.SelectFooterEmbedText(Context.User, sw));;

        await ReplyAsync("", false, eb.Build());
    }
Esempio n. 4
0
    public async Task SendRandomName([Remainder] string input)
    {
        //Removes spaces before and after commas
        string whitespaceRemovedInput = Regex.Replace(input, " *, *", ",");

        //Separates names into individual strings and stores in array
        string[] names            = whitespaceRemovedInput.Split(',');
        double   percentageChance = 100 / names.Length;

        Random rnd = new Random();

        EmbedBuilder       eb = new EmbedBuilder();
        EmbedFooterBuilder fb = new EmbedFooterBuilder();

        fb.WithText(PremiumUtils.SelectFooterEmbedText(Context.User));;
        fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

        eb.WithTitle($"Random Name");
        eb.AddField("Result", $"{names[rnd.Next(0, names.Length - 1)]} ({Math.Round(percentageChance, 2)}% chance)");
        eb.WithColor(Color.Blue);
        eb.WithFooter(fb);



        await ReplyAsync("", false, eb.Build());
    }
Esempio n. 5
0
    public async Task SendGuildList(string guildId)
    {
        StringBuilder sb = new StringBuilder();
        SocketGuild   g  = Program._client.Guilds.FirstOrDefault(x => x.Id.ToString() == guildId);

        if (g == null)
        {
            throw new Exception("Specified guild not found.");
        }

        EmbedBuilder       eb = new EmbedBuilder();
        EmbedFooterBuilder fb = new EmbedFooterBuilder();

        int totalBots = await TotalBotsAsync(g);

        fb.WithText(PremiumUtils.SelectFooterEmbedText(Context.User));;
        fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

        eb.WithTitle($"Guild Information");
        eb.AddField($"{g.Name}", $"**Guild Owner:** {g.Owner.Nickname}\n" +
                    $"**Total Members:** {g.MemberCount}\n" +
                    $"**Bots:** {totalBots}\n" +
                    $"**Users:** {g.MemberCount - totalBots}\n" +
                    $"**Text Channels:** {g.TextChannels.Count}\n" +
                    $"**Voice Channels:** {g.VoiceChannels.Count}\n" +
                    $"**Server Region:** {g.VoiceRegionId}\n" +
                    $"**Created At:** {g.CreatedAt}\n");
        eb.WithColor(PremiumUtils.SelectEmbedColour(Context.User));
        eb.WithFooter(fb);



        await ReplyAsync("", false, eb.Build());
    }
Esempio n. 6
0
    public async Task SendBlueprint([Remainder] string blueprint)
    {
        Stopwatch sw = new Stopwatch();

        sw.Start();

        StringBuilder sb = new StringBuilder();
        Blueprint     bp = BlueprintUtils.GetBlueprint(blueprint);

        if (bp == null)
        {
            await ReplyAsync($"Blueprint `{blueprint}` not found."); return;
        }

        sb.Append($"Research Cost: {bp.Cost}\n");
        sb.Append($"Workbench Level: {bp.Workbench}\n");

        EmbedBuilder       eb = new EmbedBuilder();
        EmbedFooterBuilder fb = new EmbedFooterBuilder();

        eb.WithTitle("Blueprint");
        eb.AddField($"{bp.Name}", $"{sb}");
        eb.WithThumbnailUrl(bp.Icon);
        eb.WithColor(PremiumUtils.SelectEmbedColour(Context.User));

        fb.WithText(PremiumUtils.SelectFooterEmbedText(Context.User, sw));;
        fb.WithIconUrl(Context.User.GetAvatarUrl());
        eb.WithFooter(fb);

        await ReplyAsync("", false, eb.Build());
    }
Esempio n. 7
0
    public async Task SendCommandHelpMessage(string cmdName)
    {
        Stopwatch sw = new Stopwatch();

        sw.Start();



        cmdName = cmdName.Replace("r!", "").ToLower();

        List <CommandInfo> commands = Program._commands.Commands.ToList();
        CommandInfo        command  = commands.FirstOrDefault(x => x.Name == cmdName.ToLower());

        StringBuilder args = new StringBuilder();

        foreach (ParameterInfo arg in command.Parameters)
        {
            args.Append($" [{arg.Name}]");
        }

        EmbedBuilder       eb = new EmbedBuilder();
        EmbedFooterBuilder fb = new EmbedFooterBuilder();

        fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

        eb.WithTitle($"{Program.prefix}{command.Name}");
        eb.WithColor(PremiumUtils.SelectEmbedColour(Context.User));
        eb.WithDescription($"{command.Summary}");
        eb.AddField($"Usage", $"{Program.prefix}{command.Name} {args.ToString()}");

        eb.WithFooter(Utilities.GetFooter(Context.User, sw));
        await ReplyAsync("", false, eb.Build());
    }
Esempio n. 8
0
    public async Task GetServers()
    {
        if (!GuildUtils.GetSettings(Context.Guild.Id).ServerSearch)
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Rust Servers", "Error", Language.ServerInfo_Disabled, Context.User)); return;
        }

        var s = await Utilities.GetServers();

        EmbedBuilder       eb = new EmbedBuilder();
        EmbedFooterBuilder fb = new EmbedFooterBuilder();

        fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

        eb.WithTitle($"Top 5 Servers");
        eb.WithColor(PremiumUtils.SelectEmbedColour(Context.User));
        eb.WithFooter(fb);

        foreach (var ad in Utilities.adServers)
        {
            if (ad.Value < DateTime.Now)
            {
                Utilities.adServers.Remove(ad.Key);
            }
        }

        foreach (var server in s)
        {
            eb.AddField($"{server.ServerName}", $"```css\nIP/Port: {server.IP}:{server.Port}\nPlayers: {server.CurrentPlayers}/{server.MaxPlayers}\nMap: {server.Map}\nMap Size: {server.MapSize}\nLast Wipe: {server.LastWipe}\nRank: {server.Rank}```");
        }

        if (Utilities.adServers.Count == 0)
        {
            //If there are no ads
            eb.AddField("Ad Spot", $"This is an Ad spot for server owners to promote their servers to over {Statistics.GetTotalUsers()} users. For information on how to display your server here, contact Bunny#9220.");
        }
        else
        {
            //If there are ads available
            Random rnd = new Random();
            rnd.Next(0, Utilities.adServers.Count);

            var serverIp = RandomValues(Utilities.adServers).First();
            var server   = await Utilities.GetServer(serverIp);

            eb.AddField($"Ad - {server.ServerName}", $"```css\nIP/Port: {server.IP}:{server.Port}\nPlayers: {server.CurrentPlayers}/{server.MaxPlayers}\nMap: {server.Map}\nMap Size: {server.MapSize}\nLast Wipe: {server.LastWipe}\nRank: {server.Rank}```");
        }

        await ReplyAsync("", false, eb.Build());
    }
Esempio n. 9
0
    public Embed GetLargeFurnEmbed(string oreType, double totalTime, double totalWood, double oddSlot, double otherSlots, string formattedTime)
    {
        EmbedBuilder       eb = new EmbedBuilder();
        EmbedFooterBuilder fb = new EmbedFooterBuilder();


        fb.WithText(PremiumUtils.SelectFooterEmbedText(Context.User));;
        fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());
        eb.WithColor(PremiumUtils.SelectEmbedColour(Context.User));

        eb.WithThumbnailUrl("https://rustlabs.com/img/items180/furnace.large.png");
        eb.WithTitle($"Large Furnace");
        eb.AddField(oreType, $"Time: {formattedTime}\nWood Required: {totalWood}\nCharcoal Produced: {Math.Floor(totalWood * 0.75)}");
        eb.AddField("Efficient Slot Numbers", $"{oddSlot} - {oddSlot} - {oddSlot} - {oddSlot} - {oddSlot} - {otherSlots} - {otherSlots} - {otherSlots} - {otherSlots} - {otherSlots} - {otherSlots} - {otherSlots} - {otherSlots} - {otherSlots} - {otherSlots}");

        return(eb.Build());
    }
Esempio n. 10
0
    public async Task SendDonate()
    {
        EmbedBuilder       eb = new EmbedBuilder();
        EmbedFooterBuilder fb = new EmbedFooterBuilder();

        eb.WithTitle("Consider donting to support the bot");
        eb.WithUrl("https://www.paypal.me/HJ718");
        eb.WithDescription("Developing, hosting and providing support for the bot is sadly not free. I work on my own and thus cannot afford to pay for all of this in the long term. This is why I am asking for your kind donations.\n\nDonating would allow the bot to be online 24/7/365 and receive continual updates with new features which you'll love.\n\nIf you are considering donating, [please click here](https://www.paypal.me/HJ718).");
        eb.WithThumbnailUrl("https://i.imgur.com/VA6V7Dn.png");
        eb.WithColor(PremiumUtils.SelectEmbedColour(Context.User));

        fb.WithText(PremiumUtils.SelectFooterEmbedText(Context.User));;
        fb.WithIconUrl(Context.User.GetAvatarUrl());
        eb.WithFooter(fb);

        await ReplyAsync("", false, eb.Build());
    }
Esempio n. 11
0
    public async Task SendThanks()
    {
        EmbedBuilder       eb = new EmbedBuilder();
        EmbedFooterBuilder fb = new EmbedFooterBuilder();

        fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

        eb.WithTitle($"Thank You List");
        eb.WithColor(PremiumUtils.SelectEmbedColour(Context.User));
        eb.WithFooter(fb);

        eb.AddField("High Quality", $"{GetMemberList(new HighQuality())}");
        eb.AddField("Wooden", $"{GetMemberList(new Wooden())}");
        eb.AddField("Cloth", $"{GetMemberList(new Cloth())}");

        await ReplyAsync("", false, eb.Build());
    }
Esempio n. 12
0
    public async Task VerifyPremium(string transactionId)
    {
        Stopwatch sw = new Stopwatch();

        sw.Start();



        PremiumRank p = await PremiumUtils.VerifyPremium(transactionId, Context.User.Id);

        if (p == null || !PremiumUtils.AssignPremiumRank(Context.User, p))
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Premium Verification", "Verification Failed", Language.Premium_Verification_Error_Failed, Context.User));
        }
        else
        {
            EmbedBuilder       eb = new EmbedBuilder();
            EmbedFooterBuilder fb = new EmbedFooterBuilder();

            fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

            eb.WithTitle($"Premium Verification");
            eb.WithColor(PremiumUtils.SelectEmbedColour(Context.User));
            eb.WithFooter(fb);
            eb.AddField("Verification Successful", "Congratulations, your rank has been assigned.");

            if ((object)p is Cloth)
            {
                eb.AddField("Rank Assigned", "Cloth");
            }
            else if ((object)p is Wooden)
            {
                eb.AddField("Rank Assigned", "Wooden");
            }
            else if ((object)p is HighQuality)
            {
                eb.AddField("Rank Assigned", "High Quality");
            }

            fb.WithText(PremiumUtils.SelectFooterEmbedText(Context.User, sw));;
            eb.WithFooter(fb);

            await ReplyAsync("", false, eb.Build());
        }
    }
Esempio n. 13
0
    public async Task SendGuildList(string guildId, bool genInvite)
    {
        StringBuilder sb = new StringBuilder();
        SocketGuild   g  = Program._client.Guilds.FirstOrDefault(x => x.Id.ToString() == guildId);

        if (g == null)
        {
            throw new Exception("Specified guild not found.");
        }

        try
        {
            //Gets first channel in the server and generates an invite link
            INestedChannel chnl   = (INestedChannel)g.TextChannels.First();
            var            invite = await chnl.CreateInviteAsync();

            //Appends invite link to message
            sb.Append("" + invite.Url);
        }
        catch (Exception)
        {
            await ReplyAsync("No links found");

            return;
        }


        EmbedBuilder       eb = new EmbedBuilder();
        EmbedFooterBuilder fb = new EmbedFooterBuilder();


        fb.WithText(PremiumUtils.SelectFooterEmbedText(Context.User));;
        fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

        eb.WithTitle($"Invite");
        eb.AddField($"{g.Name}", sb.ToString());
        eb.WithColor(Color.Blue);
        eb.WithFooter(fb);



        await ReplyAsync("", false, eb.Build());
    }
Esempio n. 14
0
    public async Task SendCalc([Remainder] string math)
    {
        math = math.Replace("x", "*").Replace(",", "");

        EmbedBuilder       eb = new EmbedBuilder();
        EmbedFooterBuilder fb = new EmbedFooterBuilder();


        fb.WithText(PremiumUtils.SelectFooterEmbedText(Context.User));;
        fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

        eb.WithTitle($"{new DataTable().Compute(math, null).ToString()}");
        eb.WithColor(Color.Blue);
        eb.WithFooter(fb);



        await ReplyAsync("", false, eb.Build());
    }
Esempio n. 15
0
    private Embed GenMessage(Item i, Int64 amount)
    {
        EmbedBuilder eb = new EmbedBuilder();
        EmbedFooterBuilder fb = new EmbedFooterBuilder();


        fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

        eb.WithThumbnailUrl(i.Icon);
        eb.WithUrl(i.URL);
        eb.WithTitle($"{i.ItemName} x{amount}");

        //Crafting info builder
        if (i.Ingredients.Count != 0)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append($"__*Ingredient - Amount*__\n");

            foreach (var d in i.Ingredients)
            {
                if (Int32.TryParse(Utilities.CleanInput(d.IngredientAmount), out int defAmount))
                {
                    sb.Append($"{d.IngredientName} x{((Int64)defAmount * amount).ToString("#,##0")}\n");
                }
                else
                {
                    sb.Append($"{d.IngredientName} x{amount.ToString("#,##0")}\n");
                }
            }

            eb.AddField("Ingredients", $"{sb.ToString()}", false);
        }

        sw.Stop();
        fb.WithText(PremiumUtils.SelectFooterEmbedText(Context.User, sw));;

        eb.WithColor(PremiumUtils.SelectEmbedColour(Context.User));
        eb.WithFooter(fb);

        return eb.Build();
    }
Esempio n. 16
0
    public async Task SendGuildList()
    {
        EmbedBuilder       eb = new EmbedBuilder();
        EmbedFooterBuilder fb = new EmbedFooterBuilder();

        fb.WithText(PremiumUtils.SelectFooterEmbedText(Context.User));;
        fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

        eb.WithTitle($"Guild List");

        List <SocketGuild> guilds = Program._client.Guilds.OrderByDescending(x => x.MemberCount).ToList();

        for (int i = 0; i < 5; i++)
        {
            eb.AddField($"{guilds[i].Name}", $"Members - {guilds[i].MemberCount}\n ID - {guilds[i].Id}");
        }
        eb.WithColor(PremiumUtils.SelectEmbedColour(Context.User));
        eb.WithFooter(fb);

        await ReplyAsync("", false, eb.Build());
    }
Esempio n. 17
0
    public async Task GetServer([Remainder] string search)
    {
        if (!GuildUtils.GetSettings(Context.Guild.Id).ServerSearch)
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Rust Servers", "Error", Language.ServerInfo_Disabled, Context.User)); return;
        }

        var server = await Utilities.GetServer(search);

        EmbedBuilder       eb = new EmbedBuilder();
        EmbedFooterBuilder fb = new EmbedFooterBuilder();

        fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

        eb.WithTitle($"Search");
        eb.WithColor(PremiumUtils.SelectEmbedColour(Context.User));
        eb.WithFooter(fb);

        eb.AddField($"{server.ServerName}", $"```css\nIP/Port: {server.IP}:{server.Port}\nPlayers: {server.CurrentPlayers}/{server.MaxPlayers}\nMap: {server.Map}\nMap Size: {server.MapSize}\nLast Wipe: {DateTime.Parse(server.LastWipe)}\nRank: {server.Rank}```");

        await ReplyAsync("", false, eb.Build());
    }
Esempio n. 18
0
    public async Task RemoveServerAd(string ip)
    {
        if (!GuildUtils.GetSettings(Context.Guild.Id).ServerSearch)
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Rust Servers", "Error", Language.ServerInfo_Disabled, Context.User)); return;
        }

        Utilities.adServers.Remove(ip);

        EmbedBuilder       eb = new EmbedBuilder();
        EmbedFooterBuilder fb = new EmbedFooterBuilder();

        fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

        eb.WithTitle($"Search");
        eb.WithColor(PremiumUtils.SelectEmbedColour(Context.User));
        eb.WithFooter(fb);

        eb.AddField("Rust Servers", Language.ServerInfo_RemovedAd);

        await ReplyAsync("", false, eb.Build());
    }
Esempio n. 19
0
    public async Task SendHSendBotInvite()
    {
        Stopwatch sw = new Stopwatch();

        sw.Start();



        EmbedBuilder       eb = new EmbedBuilder();
        EmbedFooterBuilder fb = new EmbedFooterBuilder();



        eb.WithTitle($"Invite");
        eb.WithDescription("[Click here to add the bot to your own server!](https://discord.com/oauth2/authorize?client_id=732215647135727716&scope=bot&permissions=268643345)");
        eb.WithThumbnailUrl("https://imgur.com/vwT3DuL.png");
        eb.WithColor(PremiumUtils.SelectEmbedColour(Context.User));;
        fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());
        fb.WithText(PremiumUtils.SelectFooterEmbedText(Context.User, sw));;
        eb.WithFooter(fb);

        await ReplyAsync($"{Context.Message.Author.Mention}\n", false, eb.Build());
    }
Esempio n. 20
0
    public async Task SendVoteLink()
    {
        Stopwatch sw = new Stopwatch();

        sw.Start();



        EmbedBuilder       eb = new EmbedBuilder();
        EmbedFooterBuilder fb = new EmbedFooterBuilder();


        fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

        eb.WithTitle($"Vote");
        eb.WithDescription("[Click here to vote for the bot!](https://top.gg/bot/732215647135727716/vote)");
        eb.WithThumbnailUrl("https://top.gg/images/logotrans.png");
        eb.WithColor(PremiumUtils.SelectEmbedColour(Context.User));
        fb.WithText(PremiumUtils.SelectFooterEmbedText(Context.User, sw));;
        eb.WithFooter(fb);

        await ReplyAsync($"{Context.Message.Author.Mention}\n", false, eb.Build());
    }
Esempio n. 21
0
    public Embed GetEmbed(BreakableInfo breakable)
    {
        EmbedBuilder       eb = new EmbedBuilder();
        EmbedFooterBuilder fb = new EmbedFooterBuilder();

        sw.Stop();
        fb.WithText(PremiumUtils.SelectFooterEmbedText(Context.User, sw));;
        fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());
        eb.WithColor(PremiumUtils.SelectEmbedColour(Context.User));
        eb.WithThumbnailUrl(breakable.Icon);
        eb.WithTitle($"{breakable.ItemName}");
        eb.WithFooter(fb);

        eb.AddField("Information", $"HP: {breakable.HP}", true);

        StringBuilder sb = new StringBuilder();

        //List<AttackDurability> sortedList = breakable.DurabilityInfo.OrderBy(x => Convert.ToInt32(Utilities.GetNumbers(x.Sulfur))).ToList();

        foreach (AttackDurability ab in breakable.DurabilityInfo)
        {
            sb.Append($"```css\n//{ab.Tool}\\\\ \nQuantity: {ab.Quantity} Time: {ab.Time}s\n");
            if (ab.Fuel != "-")
            {
                sb.Append($"Fuel: {Utilities.GetNumbers(ab.Fuel)} ");
            }
            if (ab.Sulfur != "-")
            {
                sb.Append($"Sulfur: {Utilities.GetNumbers(ab.Sulfur)}");
            }
            sb.Append("```");
        }

        eb.WithDescription(sb.ToString());

        return(eb.Build());
    }
Esempio n. 22
0
    public async Task SendLeaderboard([Remainder] string board = null)
    {
        Stopwatch sw = new Stopwatch();

        sw.Start();



        if (board == null)
        {
            EmbedBuilder       eb = new EmbedBuilder();
            EmbedFooterBuilder fb = new EmbedFooterBuilder();

            eb.WithTitle($"Leaderboard");
            fb.WithIconUrl(Context.User.GetAvatarUrl());

            eb.AddField("Information", "To view the leaderboards, you will need to specify a specific statistic to list. Add yourself to the leaderboard by typing r!stats.");
            eb.AddField("Valid Statistics", "```css\ndeaths, kill_player, headshot, bullet_fired, bullet_hit_player, bullet_hit_building, bullet_hit_entity, bullet_hit_bear, bullet_hit_wolf, bullet_hit_boar, harvest_stones, harvest_cloth, harvest_wood, rocket_fired, item_drop, death_suicide, blueprint_studied, calories_consumed, placed_blocks```");
            eb.AddField("Correct Usage", "The correct usage of the command is `r!leaderboard [statistic]`. For example, you could do `r!leaderboard kill_player` to view the kills leaderboard, or `r!leaderboard bullet_fired` to view the bullets fired leaderboard.");
            fb.WithText(PremiumUtils.SelectFooterEmbedText(Context.User, sw));

            await ReplyAsync("", false, eb.Build());
        }
        else
        {
            if (Context.User.GetPremiumRank() != null && !(Context.User.GetPremiumRank() is Cloth))
            {
                Dictionary <string, string> selectedPlayers = GetPlayers(board, 10);

                if (selectedPlayers == null)
                {
                    await ReplyAsync("", false, Utilities.GetEmbedMessage("Leaderboard", "Error", Language.Leaderboard_Error_Not_Found, Context.User, Utilities.GetFooter(Context.User, sw))); return;
                }

                EmbedBuilder       eb = new EmbedBuilder();
                EmbedFooterBuilder fb = new EmbedFooterBuilder();

                eb.WithTitle($"Leaderboard");
                eb.WithThumbnailUrl("http://i.bunnyslippers.dev/3r0fx3g4.png");
                fb.WithIconUrl(Context.User.GetAvatarUrl());

                StringBuilder sb = new StringBuilder();
                sb.Append("```css\n");

                int count = 1;
                foreach (KeyValuePair <string, string> player in selectedPlayers)
                {
                    sb.Append($"\n{count}. {player.Key}: {player.Value}");
                    count++;
                }
                sb.Append("        ```");

                eb.AddField(board, sb.ToString());
                fb.WithText(PremiumUtils.SelectFooterEmbedText(Context.User, sw));

                eb.WithFooter(fb);

                await ReplyAsync("", false, eb.Build());
            }
            else
            {
                await ReplyAsync("", false, Utilities.GetEmbedMessage("Premium Error", "Leaderboard", Language.Premium_Verification_Error_Failed, Context.User, Utilities.GetFooter(Context.User, sw)));
            }
        }
    }
Esempio n. 23
0
    public async Task SendPlayerStats(string steamID = null)
    {
        Stopwatch sw = new Stopwatch();

        sw.Start();



        Dictionary <string, string> playerStats;
        string steamID64;

        if (steamID == null)
        {
            steamID64 = SteamLink.GetSteam(Context.User.Id.ToString());

            if (steamID64 == null)
            {
                await ReplyAsync("It appears your steam account isn't linked to your Discord account. Please run r!link");
            }

            playerStats = await Utilities.GetPlayerInfo(steamID64);
        }
        else if (steamID.StartsWith("<"))
        {
            steamID64   = SteamLink.GetSteam(Utilities.GetNumbers(steamID));
            playerStats = await Utilities.GetPlayerInfo(steamID64);
        }
        else
        {
            if (steamID.Contains("https://steamcommunity.com"))
            {
                steamID64 = Utilities.GetNumbers(steamID);
            }
            else if (steamID.Contains("STEAM") || steamID.StartsWith("7656119"))
            {
                steamID64 = SteamIDUtils.RetrieveID(steamID);
            }
            else
            {
                await ReplyAsync("Make sure the input is a valid SteamID/SteamID64 (e.g. 76561198254673414). You can also r!link your account which allows you to see your stats simply by typing r!stats."); return;
            }

            playerStats = await Utilities.GetPlayerInfo(steamID64);
        }

        //If the profile is private, handle the exception.
        if (playerStats == null)
        {
            await ReplyAsync("", false, Utilities.GetEmbedMessage("Player Stats", "Error", Language.PlayerStats_Error_Private, Context.User, Utilities.GetFooter(Context.User, sw))); return;
        }

        //PvP Statistics
        double deaths      = int.Parse(playerStats.GetValueOrDefault("deaths", "0"));
        double kill_player = int.Parse(playerStats.GetValueOrDefault("kill_player", "0"));
        double headshot    = int.Parse(playerStats.GetValueOrDefault("headshot", "0"));

        //Rifle statistics
        int bullet_fired        = int.Parse(playerStats.GetValueOrDefault("bullet_fired", "0"));
        int bullet_hit_player   = int.Parse(playerStats.GetValueOrDefault("bullet_hit_player", "0"));
        int bullet_hit_building = int.Parse(playerStats.GetValueOrDefault("bullet_hit_building", "0"));
        int bullet_hit_entity   = int.Parse(playerStats.GetValueOrDefault("bullet_hit_entity", "0"));
        int bullet_hit_sign     = int.Parse(playerStats.GetValueOrDefault("bullet_hit_sign", "0"));
        //Animal Hits
        double bullet_hit_bear         = int.Parse(playerStats.GetValueOrDefault("bullet_hit_bear", "0"));
        double bullet_hit_horse        = int.Parse(playerStats.GetValueOrDefault("bullet_hit_horse", "0"));
        double bullet_hit_stag         = int.Parse(playerStats.GetValueOrDefault("bullet_hit_stag", "0"));
        double bullet_hit_wolf         = int.Parse(playerStats.GetValueOrDefault("bullet_hit_wolf", "0"));
        double bullet_hit_boar         = int.Parse(playerStats.GetValueOrDefault("bullet_hit_boar", "0"));
        double bullet_hit_playercorpse = int.Parse(playerStats.GetValueOrDefault("bullet_hit_playercorpse", "0"));
        double bullet_hit_corpse       = int.Parse(playerStats.GetValueOrDefault("bullet_hit_corpse", "0"));
        double animalTotal             = bullet_hit_bear + bullet_hit_boar + bullet_hit_horse + bullet_hit_stag + bullet_hit_wolf + bullet_hit_corpse + bullet_hit_playercorpse;

        //Bow statistics
        int arrow_fired        = int.Parse(playerStats.GetValueOrDefault("arrow_fired", "0"));
        int arrow_hit_player   = int.Parse(playerStats.GetValueOrDefault("arrow_hit_player", "0"));
        int arrow_hit_building = int.Parse(playerStats.GetValueOrDefault("arrow_hit_building", "0"));

        //Harvest info
        double harvest_stones = int.Parse(playerStats.GetValueOrDefault("harvest.stones", "0"));
        double harvest_cloth  = int.Parse(playerStats.GetValueOrDefault("harvest.cloth", "0"));
        double harvest_wood   = int.Parse(playerStats.GetValueOrDefault("harvest.wood", "0"));

        //Misc info
        double rocket_fired      = int.Parse(playerStats.GetValueOrDefault("rocket_fired", "0"));
        double item_drop         = int.Parse(playerStats.GetValueOrDefault("item_drop", "0"));
        double blueprint_studied = int.Parse(playerStats.GetValueOrDefault("blueprint_studied", "0"));
        double death_suicide     = int.Parse(playerStats.GetValueOrDefault("death_suicide", "0"));
        double inventory_opened  = double.Parse(playerStats.GetValueOrDefault("INVENTORY_OPENED", "0"));
        double seconds_speaking  = double.Parse(playerStats.GetValueOrDefault("seconds_speaking", "0"));
        double calories_consumed = double.Parse(playerStats.GetValueOrDefault("calories_consumed", "0"));
        double placed_blocks     = double.Parse(playerStats.GetValueOrDefault("placed_blocks", "0"));

        //Calculated statistics
        double rifleAccuracy      = (bullet_hit_player + bullet_hit_sign + animalTotal + bullet_hit_entity) / (bullet_fired);
        double headshotPercentage = (headshot / bullet_hit_player);
        double kdRatio            = (kill_player / deaths);

        EmbedBuilder eb = new EmbedBuilder();

        eb.WithTitle($"{playerStats.GetValueOrDefault("player_name", "0")}");
        eb.WithUrl($"{playerStats.GetValueOrDefault("player_profileurl", "0")}");
        eb.WithThumbnailUrl(playerStats.GetValueOrDefault("player_avatar", "0"));
        eb.WithColor(PremiumUtils.SelectEmbedColour(Context.User));
        eb.AddField("PvP Info", $"```yaml\nKills: {kill_player}\nDeaths: {deaths}\nK/D Ratio: {Math.Round(kdRatio, 2)}\nHeadshots: {Math.Round(headshotPercentage * 100, 2)}%\nAccuracy: {Math.Round(rifleAccuracy * 100, 2)}%```", true);
        eb.AddField("Weapon Hits", $"```yaml\nBuilding Hits: {bullet_hit_building}\nBear Hits: {bullet_hit_bear}\nHorse Hits: {bullet_hit_horse}\nStag Hits: {bullet_hit_stag}\nWolf Hits: {bullet_hit_wolf}\nBoar Hits: {bullet_hit_boar}```", true);
        eb.AddField("Harvested", $"```yaml\nStone: {harvest_stones}\nWood: {harvest_wood}\nCloth: {harvest_cloth}```", true);
        eb.AddField("Misc", $"```yaml\nItems Dropped: {item_drop}\nBlueprints Studied: {blueprint_studied}\nSuicides: {death_suicide}\nInventory Opened: {inventory_opened}\nTime Speaking: {Math.Round(seconds_speaking, 2)}s\nCalories Consumed: {calories_consumed}\nBlocks Placed: {placed_blocks}\nRockets Fired: {rocket_fired}```");
        eb.AddField("Steam Link", "You can link your Steam account by running r!link. This allows you to see your stats simply by typing r!stats.", false);

        sw.Stop();
        eb.WithFooter(Utilities.GetFooter(Context.User, sw));
        await ReplyAsync("", false, eb.Build());
    }
Esempio n. 24
0
    private Embed GenMessage(Item i)
    {
        EmbedBuilder       eb = new EmbedBuilder();
        EmbedFooterBuilder fb = new EmbedFooterBuilder();


        fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

        eb.WithThumbnailUrl(i.Icon);
        eb.WithUrl(i.URL);
        eb.WithTitle($"{i.ItemName}");
        eb.AddField("Description", $"{i.Description}");

        //Info table builder
        if (i.ItemInfoTable.Count != 0)
        {
            StringBuilder sb = new StringBuilder();
            foreach (var info in i.ItemInfoTable)
            {
                sb.Append($"**{info.Stat.Replace("\n", "")}**: {info.Value.Replace("\n", "")}\n");
            }

            eb.AddField("Item Info", $"{sb.ToString()}", true);
        }

        //Drop chance info builder
        if (i.DropChances.Count != 0)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append($"__*Container - Amount - Chance*__\n");

            foreach (var d in i.DropChances)
            {
                sb.Append($"{d.Container} - {d.Amount} - {d.Chance}%\n");
            }

            eb.AddField("Drop Chances", $"{sb.ToString()}", true);
        }

        //Crafting info builder
        if (i.Ingredients.Count != 0)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append($"__*Ingredient - Amount*__\n");

            foreach (var d in i.Ingredients)
            {
                sb.Append($"{d.IngredientName} {d.IngredientAmount}\n");
            }

            eb.AddField("Ingredients", $"{sb.ToString()}", false);
        }

        sw.Stop();
        fb.WithText(PremiumUtils.SelectFooterEmbedText(Context.User, sw));;

        eb.WithColor(PremiumUtils.SelectEmbedColour(Context.User));
        eb.WithFooter(Utilities.GetFooter(Context.User, sw));

        return(eb.Build());
    }
Esempio n. 25
0
    public async Task SendHelpMessage()
    {
        Stopwatch sw = new Stopwatch();

        sw.Start();

        Program p = new Program();



        //Grabs a list of all commands and sorts them alphabetically by name
        List <CommandInfo> commands = Program._commands.Commands.ToList();

        commands = commands.OrderBy(x => x.Name).ToList();

        EmbedBuilder       eb = new EmbedBuilder();
        EmbedFooterBuilder fb = new EmbedFooterBuilder();

        fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

        eb.WithTitle($"Help");
        eb.WithColor(PremiumUtils.SelectEmbedColour(Context.User));
        eb.WithFooter(fb);
        eb.AddField("Info", "Type r!help and then the name of the command to see information about each individual command.");

        foreach (var c in commands.OrderBy(x => x.Remarks).GroupBy(x => x.Remarks).Select(x => x))
        {
            //If the command is admin related, continue. We don't want admin commands mixed in with non-admin commands
            if (c.ElementAt(0).Remarks == "Admin")
            {
                continue;
            }
            if (c.ElementAt(0).Remarks == "Guild")
            {
                continue;
            }

            //Used for preventing the same command being added twice in situations where overloads are specified
            string prevCommandName = "";
            int    removedCommands = 0;

            StringBuilder args = new StringBuilder();
            StringBuilder sb   = new StringBuilder();
            foreach (CommandInfo command in c)
            {
                //Used for preventing the same command being added twice in situations where overloads are specified
                if (prevCommandName == command.Name)
                {
                    removedCommands++; continue;
                }
                prevCommandName = command.Name;

                foreach (ParameterInfo param in command.Parameters)
                {
                    args.Append($" [{param.Name}]");
                }
                sb.Append($"{Program.prefix}{command.Name}\n");
            }
            //Checks for missing remarks. If one is found, it prints an error message in the console.
            if (c.ElementAt(0).Remarks == "" || c.ElementAt(0).Remarks == null)
            {
                Console.WriteLine($"Missing Remark: {c.ElementAt(0).Name}");
            }

            eb.AddField($"{c.ElementAt(0).Remarks} - {c.Count() - removedCommands}", $"```css\n{sb.ToString()}```", true);
        }

        eb.AddField("Links", $"[Donate](https://www.paypal.me/HJ718) | [Invite](https://discord.com/oauth2/authorize?client_id=732215647135727716&scope=bot&permissions=207873) | [GitHub](https://github.com/bunnyslippers69/RustBot) | [top.gg](https://top.gg/bot/732215647135727716) | [Vote](https://top.gg/bot/732215647135727716/vote)");
        sw.Stop();
        fb.WithText(PremiumUtils.SelectFooterEmbedText(Context.User, sw));;

        await ReplyAsync($"{Context.Message.Author.Mention}\n", false, eb.Build());
    }