コード例 #1
0
        public async static Task DisplayQuote(Quote q, IGuildUser[] users, ICommandContext context)
        {
            EmbedBuilder ebm = new EmbedBuilder()
            {
                Color = Color.Blue
            };

            IGuildUser quotee = users[0];

            ebm.WithTitle($"Quote #{q.Id} by {(quotee == null ? q.Qoutee.Username : (quotee.Nickname??quotee.Username))}");

            if (quotee != null)
            {
                ebm.WithThumbnailUrl(quotee.GetAvatarUrl());
            }
            if (ebm.ThumbnailUrl == null)
            {
                ebm.WithThumbnailUrl("https://discordapp.com/assets/dd4dbc0016779df1378e7812eabaa04d.png");
            }

            ebm.AddField("Quote", $"```\r\n{q.QuoteText.RemoveAbuseCharacters()}\r\n```");

            EmbedFooterBuilder efb     = new EmbedFooterBuilder();
            IGuildUser         creator = users[1];

            if (creator != null)
            {
                efb.WithIconUrl(creator.GetAvatarUrl());
            }
            if (efb.IconUrl == null)
            {
                efb.WithIconUrl("https://discordapp.com/assets/dd4dbc0016779df1378e7812eabaa04d.png");
            }

            efb.WithText($"Quoted by {(creator == null ? q.Creator.Username : (creator.Nickname??creator.Username))} on {q.Time.ToShortDateString()}");
            ebm.WithFooter(efb);

            await context.Channel.SendMessageAsync(embed : ebm.Build());
        }
コード例 #2
0
            public async Task DisplayCurrentAudioAsync()
            {
                var queue              = _audio.Queue(Context.Guild).ToList();
                var displayEmbed       = new EmbedBuilder();
                var displayEmbedFooter = new EmbedFooterBuilder();

                displayEmbed.WithColor(213, 16, 93);
                displayEmbed.WithTitle("Stopped:");
                if (queue.Count == 0)
                {
                    displayEmbed.WithDescription("Nothing is currently playing.");
                    await ReplyAsync(null, false, displayEmbed.Build());

                    return;
                }
                var prevQueue = queue[0].Value;

                displayEmbed.WithDescription($"{prevQueue.Title} ({prevQueue.Duration})");
                if (_audio.IsPlaying(Context.Guild))
                {
                    displayEmbed.WithColor(129, 243, 193);
                    displayEmbed.WithTitle("Now playing:");
                }
                else if (_audio.Stream(Context.Guild))
                {
                    displayEmbed.WithColor(EmbedData.GetColor("yield"));
                    displayEmbed.WithTitle("Paused:");
                }
                if (queue.Count == 1)
                {
                    await ReplyAsync(null, false, displayEmbed.Build());

                    return;
                }
                var nextQueue = queue[1].Value;

                displayEmbed.WithFooter(displayEmbedFooter.WithText($"Up Next => {nextQueue.Title} ({nextQueue.Duration})"));
                var msg = await ReplyAsync(null, false, displayEmbed.Build());
            }
コード例 #3
0
ファイル: InventoryCommands.cs プロジェクト: Floowey/IodemBot
        private Embed GetShopEmbed()
        {
            var shop  = ItemDatabase.GetShop();
            var embed = new EmbedBuilder();

            embed.WithColor(new Color(66, 45, 45));
            embed.WithThumbnailUrl(ItemDatabase.Shopkeeper);

            //if (DateTime.Now.Date >= new DateTime(day: 1, month: 3, year: 2021) &&
            //    DateTime.Now.Date < new DateTime(day: 15, month: 3, year: 2021))
            //{
            //    embed.WithDescription("It's the Tolbi market! Up until March 14th you'll get a chance to find more and rarer gear! With this many, the stalls are rotated every 6 hours!");
            //}

            embed.AddField("Shop:", shop.InventoryToString(Detail.NameAndPrice), true);

            var fb = new EmbedFooterBuilder();

            fb.WithText($"{ItemDatabase.RestockMessage} {ItemDatabase.TimeToNextReset:hh\\h\\ mm\\m}");
            embed.WithFooter(fb);
            return(embed.Build());
        }
コード例 #4
0
ファイル: GoldenSun.cs プロジェクト: Arcblade/IodemBot
        public async Task Status([Remainder] SocketUser user = null)
        {
            user ??= Context.User;
            var account = UserAccounts.GetAccount(user);
            var factory = new PlayerFighterFactory();
            var p       = factory.CreatePlayerFighter(user);

            var author = new EmbedAuthorBuilder();

            author.WithName($"{(user is SocketGuildUser sguser ? sguser.DisplayName() : user.Username)}");
            author.WithIconUrl(user.GetAvatarUrl());


            var embed = new EmbedBuilder()
                        .WithColor(Colors.Get(account.Element.ToString()))
                        .WithAuthor(author)
                        .WithTitle($"Level {account.LevelNumber} {account.GsClass} {string.Join("", account.TrophyCase.Trophies.Select(t => t.Icon))} (Rank {UserAccounts.GetRank(user) + 1})")
                        .AddField("Current Equip", account.Inv.GearToString(AdeptClassSeriesManager.GetClassSeries(account).Archtype), true)
                        .AddField("Psynergy", p.GetMoves(false), true)
                        .AddField("Djinn", account.DjinnPocket.GetDjinns().GetDisplay(DjinnDetail.None), true)

                        .AddField("Stats", p.Stats.ToString(), true)
                        .AddField("Elemental Stats", p.ElStats.ToString(), true)

                        .AddField("Unlocked Classes", account.BonusClasses.Count == 0 ? "none" : string.Join(", ", account.BonusClasses))

                        .AddField("XP", $"{account.XP} - next in {account.XPneeded}{(account.NewGames > 1 ? $"\n({account.TotalXP} total | {account.NewGames} resets)" : "")}", true)
                        .AddField("Colosso wins | Endless Streaks", $"{account.ServerStats.ColossoWins}", true)
                        .AddField("Endless Streaks", $"Solo: {account.ServerStats.EndlessStreak.Solo} | Duo: {account.ServerStats.EndlessStreak.Duo} \nTrio: {account.ServerStats.EndlessStreak.Trio} | Quad: {account.ServerStats.EndlessStreak.Quad}", true);

            if (user is SocketGuildUser socketGuildUser)
            {
                var Footer = new EmbedFooterBuilder();
                Footer.WithText("Joined this Server on " + socketGuildUser.JoinedAt.Value.Date.ToString("dd-MM-yyyy"));
                Footer.WithIconUrl(Sprites.GetImageFromName("Iodem"));
                embed.WithFooter(Footer);
            }
            await Context.Channel.SendMessageAsync("", false, embed.Build());
        }
コード例 #5
0
ファイル: IWerewolf.cs プロジェクト: sermetk/Orikivo.Classic
        public async void Refresh(SocketGuild g, string title, string description, string footerText)
        {
            EmbedFooterBuilder f = new EmbedFooterBuilder();

            f.WithText(footerText);

            Panel.WithTitle(title);
            Panel.WithDescription(description);
            Panel.WithFooter(f);

            if (!Message.Exists())
            {
                if (g.TryGetTextChannel(ChannelId, out SocketTextChannel c))
                {
                    Message = c.SendMessageAsync(embed: Panel.Build()).Result;
                }
            }
            else
            {
                await Message.ModifyAsync(x => { x.Embed = Panel.Build(); });
            }
        }
コード例 #6
0
        public async Task Module([Remainder] string name)
        {
            ModuleInfo module = services.GetModules().First(n => (n.Name.ToLower() == name.ToLower()));

            if (module != null)
            {
                EmbedBuilder       embed  = new EmbedBuilder();
                EmbedFooterBuilder footer = new EmbedFooterBuilder();

                //Make the footer the current UTC time
                footer.WithText(DateTime.UtcNow.ToString() + " UTC");
                embed.WithFooter(footer);
                embed.WithColor(new Color(0x4900ff));

                //Make the title the modules name + some info.
                embed.Title = $"Module {module.Name}'s commands. Contains {module.Commands.Count} out of 25 max commands.";

                //Add each command in the module into its own field.
                foreach (var cmd in module.Commands)
                {
                    embed.AddField(y =>
                    {
                        y.Name     = cmd.Name;
                        y.Value    = cmd.Summary;
                        y.IsInline = false;
                    });
                }

                await ReplyAsync("", embed : embed);
            }
            else
            {
                //The module was an invalid name, tell the user
                IUserMessage msg = await ReplyAsync("A module with the name '" + name + "' does not exist.");

                msg.DeleteAfterSeconds(20);
            }
        }
コード例 #7
0
ファイル: Profiling.cs プロジェクト: sermetk/Orikivo.Classic
        public async Task GetReportsAsync(OldGlobal g, int page = 1)
        {
            EmbedBuilder e = EmbedData.DefaultEmbed;

            EmbedFooterBuilder f = new EmbedFooterBuilder();

            f.WithText($"{EmojiIndex.Report} Reports");
            e.WithFooter(f);

            const int MAX_DESC = 1024;
            string    desc     = "";

            List <string> list         = new List <string>();
            List <string> descriptions = new List <string>();

            List <Report> reports  = g.Reports;
            List <Report> accepted = g.AcceptedReports;


            foreach (Report accept in accepted)
            {
                list.Add("**+** " + accept.ToString(Context.Account));
            }
            foreach (Report r in reports)
            {
                list.Add(r.ToString(Context.Account));
            }
            if (!list.Funct())
            {
                await ReplyAsync(embed : EmbedData.Throw(Context, "Empty collection.", "There are currently no reports.", false));

                return;
            }

            Embed q = EmbedData.GenerateEmbedList(list, page, e);

            await ReplyAsync(embed : q);
        }
コード例 #8
0
        private async Task WriteEnemies()
        {
            var e     = new EmbedBuilder();
            var tasks = new List <Task>();

            if (Battle.SizeTeamB > 0)
            {
                e.WithThumbnailUrl(Battle.GetTeam(ColossoBattle.Team.B).FirstOrDefault().imgUrl);
            }
            var msg = EnemyMsg;
            var i   = 1;

            foreach (ColossoFighter fighter in Battle.GetTeam(ColossoBattle.Team.B))
            {
                //e.AddField(numberEmotes[i], $"{fighter.name} {fighter.stats.HP}/{fighter.stats.maxHP}", true);
                e.AddField($"{numberEmotes[i]}{fighter.ConditionsToString()}", $"{fighter.name}", true);
                i++;
            }
            if (IsEndless)
            {
                EmbedFooterBuilder footerBuilder = new EmbedFooterBuilder();
                footerBuilder.WithText($"Battle {winsInARow + 1} - {Diff}");
                e.WithFooter(footerBuilder);
            }
            if (!msg.Embeds.FirstOrDefault().ToEmbedBuilder().AllFieldsEqual(e))
            {
                tasks.Add(msg.ModifyAsync(m => m.Embed = e.Build()));
            }

            var validReactions = reactions.Where(r => r.MessageId == EnemyMsg.Id).ToList();

            foreach (var r in validReactions)
            {
                tasks.Add(EnemyMsg.RemoveReactionAsync(r.Emote, r.User.Value));
                reactions.Remove(r);
            }
            await Task.WhenAll(tasks);
        }
コード例 #9
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());
    }
コード例 #10
0
ファイル: VoteLink.cs プロジェクト: bunnyslippers69/RustBot
    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());
    }
コード例 #11
0
        public static async Task ReportAsync(Color color, SocketTextChannel channel, string title, string content, SocketUser originUser, SocketUser targetUser = null, string footerText = null)
        {
            EmbedBuilder eb = new EmbedBuilder();

            EmbedAuthorBuilder authorBuilder = new EmbedAuthorBuilder();

            authorBuilder.WithName(title);
            //authorBuilder.WithUrl("Title URL");
            authorBuilder.WithIconUrl(originUser.GetAvatarUrl());

            eb.WithAuthor(authorBuilder);
            eb.WithColor(color);
            eb.WithDescription(content);

            eb.WithCurrentTimestamp();

            if (footerText != null)
            {
                EmbedFooterBuilder footer = new EmbedFooterBuilder();
                //footer.WithIconUrl("URL to footer image");
                footer.WithText(footerText);
                eb.WithFooter(footer);
            }

            //eb.WithTitle("Title");
            if (targetUser != null)
            {
                eb.WithThumbnailUrl(targetUser.GetAvatarUrl());
            }
            else
            {
                eb.WithThumbnailUrl(originUser.GetAvatarUrl());
            }
            //eb.WithUrl("http://EBUrlshow.com");

            await reportChannel.SendMessageAsync("", false, eb.Build());
        }
コード例 #12
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());
    }
コード例 #13
0
    public async Task SendGuildList(string guildID)
    {
        StringBuilder sb    = new StringBuilder();
        string        gName = "";


        foreach (var guild in Program._client.Guilds)
        {
            if (guild.Id.ToString() == guildID)
            {
                foreach (var member in guild.Users)
                {
                    sb.Append(member.Username + "\n");
                }
                gName = guild.Name;
            }
        }


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


        fb.WithText($"Called by {Context.Message.Author.Username}");
        fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

        eb.WithTitle($"Guild List");
        eb.AddField($"{gName}", sb.ToString());
        eb.WithColor(Color.Blue);
        eb.WithFooter(fb);



        await ReplyAsync("", false, eb.Build());

        await Utilities.StatusMessage("roll", Context);
    }
コード例 #14
0
    public async Task SendCaseSimulation(string casE, int amount = 1)
    {
        if (PermissionManager.GetPerms(Context.Message.Author.Id) < PermissionConfig.User)
        {
            await Context.Channel.SendMessageAsync("Not authorised to run this command."); return;
        }

        if (amount > 3000 || amount < 1)
        {
            await ReplyAsync("Amount can't be higher than 3000 or smaller than 1."); return;
        }

        List <string> wins = new List <string> {
        };
        int spins          = Convert.ToInt32(amount);

        SSRPItems.Case selectedCase = SelectCase(casE.ToLower());
        StringBuilder  sb           = new StringBuilder();

        sb.Clear();
        items.Clear();
        wins.Clear();

        if (selectedCase == null)
        {
            await ReplyAsync("Case not found. Try enclosing the case name in \"quotes\"");
        }
        else
        {
            for (int i = 0; i < spins; i++)
            {
                wins.Add(SelectItem(selectedCase));
            }

            var q = from x in wins
                    group x by x into g
                    let count = g.Count()
                                orderby count descending
                                select new { Value = g.Key, Count = count };
            foreach (var x in q)
            {
                sb.Append($"{x.Count} - {x.Value}\n");
            }

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


            fb.WithText($"Called by {Context.Message.Author.Username}");
            fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

            eb.WithTitle($"{selectedCase.caseName} Case");
            eb.AddField("Wins", $"{sb.ToString()}");
            eb.WithColor(Color.Blue);
            eb.WithFooter(fb);

            await ReplyAsync("", false, eb.Build());
        }

        await Utilities.StatusMessage("case simulation", Context);
    }
コード例 #15
0
ファイル: Paginator.cs プロジェクト: N0tAI/Energize
        private async Task Update()
        {
            if (this.Message == null)
            {
                return;
            }
            string display = this.DisplayCallback?.Invoke(this.Data[this.CurrentIndex]);

            await this.Message.ModifyAsync(prop =>
            {
                if (this.Embed != null)
                {
                    Embed oldEmbed       = this.Embed;
                    EmbedBuilder builder = new EmbedBuilder();
                    builder
                    .WithLimitedTitle(oldEmbed.Title)
                    .WithLimitedDescription(display);

                    if (oldEmbed.Color.HasValue)
                    {
                        builder.WithColor(oldEmbed.Color.Value);
                    }

                    if (oldEmbed.Timestamp.HasValue)
                    {
                        builder.WithTimestamp(oldEmbed.Timestamp.Value);
                    }

                    if (oldEmbed.Author.HasValue)
                    {
                        EmbedAuthor oldAuthor            = oldEmbed.Author.Value;
                        EmbedAuthorBuilder authorBuilder = new EmbedAuthorBuilder();
                        authorBuilder
                        .WithIconUrl(oldAuthor.IconUrl)
                        .WithName(oldAuthor.Name)
                        .WithUrl(oldAuthor.Url);
                        builder.WithAuthor(authorBuilder);
                    }

                    if (oldEmbed.Footer.HasValue)
                    {
                        EmbedFooter oldFooter            = oldEmbed.Footer.Value;
                        EmbedFooterBuilder footerBuilder = new EmbedFooterBuilder();
                        footerBuilder
                        .WithText(oldFooter.Text)
                        .WithIconUrl(oldFooter.IconUrl);
                        builder.WithFooter(footerBuilder);
                    }

                    this.DisplayEmbedCallback?.Invoke(this.Data[this.CurrentIndex], builder);

                    this.Embed = builder.Build();
                    prop.Embed = this.Embed;
                }
                else
                {
                    prop.Content = display;
                }
            });

            this.Refresh();
        }
コード例 #16
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());
    }
コード例 #17
0
    public async Task SendPrinter(string item, int boost = 1, int time = 1)
    {
        if (PermissionManager.GetPerms(Context.Message.Author.Id) < PermissionConfig.User)
        {
            await Context.Channel.SendMessageAsync("Not authorised to run this command."); return;
        }

        SSRPItems.Printer p = await SSRPItems.GetPrinter(item);

        Discord.Color c = new Discord.Color(ColorTranslator.FromHtml($"#{p.color}").R, ColorTranslator.FromHtml($"#{p.color}").G, ColorTranslator.FromHtml($"#{p.color}").B);

        if (p == null)
        {
            await Context.Channel.SendMessageAsync("Printer not found. Please enclose the printer name in quotes: `\"name\"`"); await Utilities.StatusMessage("printer", Context);
        }
        else
        {
            //If loot/gem/uranium
            if (p.printerName == "Uranium" || p.printerName == "Loot" || p.printerName == "Gem")
            {
                //If 1, don't print the plural
                if (time == 1)
                {
                    EmbedBuilder       eb = new EmbedBuilder();
                    EmbedFooterBuilder fb = new EmbedFooterBuilder();

                    fb.WithText($"Called by {Context.Message.Author.Username}");
                    fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

                    eb.WithTitle($"{p.printerName}");
                    eb.AddField("Per Second", $"{((p.perSecond * boost) * time).ToString("#,##0")}");
                    eb.AddField("Per Minute", $"{(((p.perSecond * 60) * boost) * time).ToString("#,##0")}");
                    eb.AddField("Per Hour", $"{(((p.perSecond * 60) * 60) * boost).ToString("#,##0")}");
                    eb.AddField("With Boost", $"x{boost}");
                    eb.WithColor(c);
                    eb.WithFooter(fb);

                    await ReplyAsync("", false, eb.Build());

                    await Utilities.StatusMessage("printer", Context);
                }
                else
                {
                    EmbedBuilder       eb = new EmbedBuilder();
                    EmbedFooterBuilder fb = new EmbedFooterBuilder();

                    fb.WithText($"Called by {Context.Message.Author.Username}");
                    fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

                    eb.WithTitle($"{p.printerName}");
                    eb.AddField($"Per {time} Seconds", $"{((p.perSecond * boost) * time).ToString("#,##0")}");
                    eb.AddField($"Per {time} Minutes", $"{(((p.perSecond * 60) * boost) * time).ToString("#,##0")}");
                    eb.AddField($"Per {time} Hours", $"{((((p.perSecond * 60) * 60) * boost) * time).ToString("#,##0")}");
                    eb.AddField($"With Boost", $"x{boost}");
                    eb.WithColor(c);
                    eb.WithFooter(fb);

                    await ReplyAsync("", false, eb.Build());

                    await Utilities.StatusMessage("printer", Context);
                }
            }
            //If normal printer
            else
            {
                //If 1, don't print the plural
                if (time == 1)
                {
                    EmbedBuilder       eb = new EmbedBuilder();
                    EmbedFooterBuilder fb = new EmbedFooterBuilder();

                    fb.WithText($"Called by {Context.Message.Author.Username}");
                    fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

                    eb.WithTitle($"{p.printerName}");
                    eb.AddField("Per Second", $"${((p.perSecond * boost) * time).ToString("#,##0")}");
                    eb.AddField("Per Minute", $"${(((p.perSecond * 60) * boost) * time).ToString("#,##0")}");
                    eb.AddField("Per Hour", $"${(((p.perSecond * 60) * 60) * boost).ToString("#,##0")}");
                    eb.AddField("With Boost", $"x{boost}");
                    eb.WithColor(c);
                    eb.WithFooter(fb);

                    await ReplyAsync("", false, eb.Build());

                    await Utilities.StatusMessage("printer", Context);
                }
                else
                {
                    EmbedBuilder       eb = new EmbedBuilder();
                    EmbedFooterBuilder fb = new EmbedFooterBuilder();

                    fb.WithText($"Called by {Context.Message.Author.Username}");
                    fb.WithIconUrl(Context.Message.Author.GetAvatarUrl());

                    eb.WithTitle($"{p.printerName}");
                    eb.AddField($"Per {time} Seconds", $"${((p.perSecond * boost) * time).ToString("#,##0")}");
                    eb.AddField($"Per {time} Minutes", $"${(((p.perSecond * 60) * boost) * time).ToString("#,##0")}");
                    eb.AddField($"Per {time} Hours", $"${((((p.perSecond * 60) * 60) * boost)* time).ToString("#,##0")}");
                    eb.AddField($"With Boost", $"x{boost}");
                    eb.WithColor(c);
                    eb.WithFooter(fb);

                    await ReplyAsync("", false, eb.Build());

                    await Utilities.StatusMessage("printer", Context);
                }
            }
        }
    }
コード例 #18
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());
    }
コード例 #19
0
        public static async Task ReceiveData(SerializedData.SerializedData data, TcpClient client)
        {
            try
            {
                if (data == null)
                {
                    Console.WriteLine("Network: Received data null");
                    return;
                }

                if (data.Data.Contains("REQUEST_DATA PLAYER_LIST SILENT"))
                {
                    return;
                }
                SocketGuild guild = Bot.Client.Guilds.FirstOrDefault();

                if (data.Data.StartsWith("checksync"))
                {
                    string[]   args = data.Data.Split(' ');
                    SyncedUser user = Program.Users.FirstOrDefault(u => u.UserId == args[1]);
                    if (user == null)
                    {
                        return;
                    }

                    foreach (SocketRole role in guild.GetUser(user.DiscordId).Roles)
                    {
                        if (Program.SyncedGroups.ContainsKey(role.Id))
                        {
                            SendData($"setgroup {user.UserId} {Program.SyncedGroups[role.Id]}", Config.Port, "RoleSync");
                        }
                    }
                }
                if (data.Data == "ping")
                {
                    if (!bag.ContainsKey(data.Port))
                    {
                        Console.WriteLine($"Network: Adding {data.Port}");
                        bag.TryAdd(data.Port, client);
                    }

                    if (!bag[data.Port].Connected || bag[data.Port] == null)
                    {
                        Console.WriteLine($"Network: Bag {data.Port} not connected or null, removing.");
                        if (bag.TryRemove(data.Port, out TcpClient cli))
                        {
                            cli?.Close();
                        }
                    }
                    Console.WriteLine($"Network: Received heartbeat for: {data.Port}");
                    if (!heartbeats.ContainsKey(data.Port))
                    {
                        Heartbeat(data.Port);
                        heartbeats.TryAdd(data.Port, 0);
                    }
                    else
                    {
                        heartbeats[data.Port]--;
                    }
                    return;
                }

                if (data.Data.StartsWith("updateStatus"))
                {
                    string status = data.Data.Replace("updateStatus ", "");
                    if (status.StartsWith("0"))
                    {
                        await Bot.Client.SetStatusAsync(UserStatus.Idle);
                    }
                    else
                    {
                        await Bot.Client.SetStatusAsync(UserStatus.Online);
                    }
                    await Bot.Client.SetActivityAsync(new Game(status));

                    return;
                }

                if (data.Data.StartsWith("embed"))
                {
                    try
                    {
                        Console.WriteLine($"Received embed: \"{data.Data.Replace("embed ", "")}\"");
                        Console.WriteLine("Splitting");
                        string[] embedData = data.Data.Replace("embed ", "").Split('+');
                        Console.WriteLine("Initializing EmbedBuilder");
                        EmbedBuilder embedBuilder = new EmbedBuilder();
                        Embed        embed;
                        Console.WriteLine("Setting color");
                        embedBuilder.WithColor(Color.Red);

                        if (!string.IsNullOrEmpty(embedData[0]) && embedData[0] != "none")
                        {
                            Console.WriteLine($"Setting title: {embedData[0]}");
                            embedBuilder.WithTitle(embedData[0]);
                        }

                        if (!string.IsNullOrEmpty(embedData[1]))
                        {
                            Console.WriteLine($"Setting description: {embedData[1]}");
                            embedBuilder.WithDescription(embedData[1]);
                        }

                        if (!string.IsNullOrEmpty(embedData[2]))
                        {
                            Console.WriteLine($"Setting footer: {embedData[2]}");
                            EmbedFooterBuilder embedFooterBuilder = new EmbedFooterBuilder();
                            embedFooterBuilder.WithText(embedData[2]);
                            embedBuilder.WithFooter(embedFooterBuilder);
                        }

                        Console.WriteLine("Building embed");
                        embed = embedBuilder.Build();
                        Console.WriteLine($"Sending embed to {data.Channel}");
                        await API.API.SendEmbed(embed, data.Channel);

                        return;
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.ToString());
                        return;
                    }
                }

                if (data.Data.StartsWith("cmdresp"))
                {
                    try
                    {
                        Console.WriteLine($"Received command embed response: \"{data.Data.Replace("embed ", "")}\"");
                        Console.WriteLine("Getting description");
                        string description = data.Data.Replace("cmdresp ", "");
                        description = $"```{description.Substring(description.IndexOf("#") + 1)}```";
                        Console.WriteLine("Initializing EmbedBuilder");
                        EmbedBuilder embedBuilder = new EmbedBuilder();
                        Embed        embed;
                        Console.WriteLine("Setting properties");
                        embedBuilder.WithColor(Color.Blue);
                        embedBuilder.WithDescription(description);
                        embedBuilder.WithCurrentTimestamp();
                        Console.WriteLine("Building embed");
                        embed = embedBuilder.Build();
                        Console.WriteLine($"Sending embed to {data.Channel}");
                        await API.API.SendEmbed(embed, data.Channel);

                        return;
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.ToString());
                        return;
                    }
                }

                data.Data = data.Data.Substring(data.Data.IndexOf('#') + 1);
                if (guild == null)
                {
                    return;
                }
                SocketTextChannel chan = null;
                chan = data.Channel.GetChannel();

                if (chan == null)
                {
                    return;
                }

                await chan.SendMessageAsync($"[{DateTime.Now.ToString("HH:mm:ss")}] {data.Data}");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #20
0
        public Embed Generate()
        {
            EmbedBuilder       e = EmbedData.DefaultEmbed;
            EmbedFooterBuilder f = new EmbedFooterBuilder();

            f.WithText(ToString());

            // Colors
            Color onEmptyColor = EmbedData.GetColor("steamerror");
            Color onLoseColor  = EmbedData.GetColor("error");
            Color onWinColor   = EmbedData.GetColor("origreen");

            // Titles
            string onWinTitle  = "+ {0}";
            string onLoseTitle = "- {0}";
            string onOORTitle  = "> {0}";

            // Money display
            string money = $"{EmojiIndex.Balance}" + "{0}".MarkdownBold();

            string defLoseDesc  = "You lost at chance at {0}.";
            string defWinDesc   = "You have earned " + "(x{0})".MarkdownBold() + " the initial bet!";
            string defEmptyDesc = "You do know you need money, right?";
            string defOORDesc   = "You asked to wager a bit too much.";

            // exceptions based on balance.
            if (Player.Balance == 0)
            {
                e.WithColor(onEmptyColor);
                e.WithTitle(string.Format(money, "null"));
                e.WithDescription(defEmptyDesc);

                return(e.Build());
            }
            if (Player.Balance - Wager < 0)
            {
                if (!Player.Config.Overflow)
                {
                    e.WithColor(onEmptyColor);
                    e.WithTitle(string.Format(onOORTitle, string.Format(money, Player.Balance.ToPlaceValue())));
                    e.WithDescription(defOORDesc);

                    return(e.Build());
                }
                Wager = Player.Balance;
            }

            Player.Take((ulong)Wager);
            e.WithFooter(f);

            if (Victory)
            {
                Player.Give((ulong)Reward);
                e.WithColor(onWinColor);
                e.WithTitle(string.Format(onWinTitle, string.Format(money, Reward.ToPlaceValue())));
                e.WithDescription(string.Format(defWinDesc, Risk.ToString("##,0.0#")));

                return(e.Build());
            }
            else
            {
                e.WithColor(onLoseColor);
                e.WithTitle(string.Format(onLoseTitle, string.Format(money, Wager.ToPlaceValue())));
                e.WithDescription(LosingSummary ?? string.Format(defLoseDesc, string.Format(money, Reward.ToPlaceValue())));

                return(e.Build());
            }
        }
コード例 #21
0
ファイル: ProfileModule.cs プロジェクト: radtek/DiscordBot
        public async Task UserAbout(IUser user = null)
        {
            var userSpecified = user as SocketGuildUser ?? Context.User as SocketGuildUser;

            if (userSpecified == null)
            {
                await ReplyAsync("User not found, please try again.");

                return;
            }

            EmbedAuthorBuilder eab = new EmbedAuthorBuilder();

            if (!String.IsNullOrEmpty(userSpecified.Nickname))
            {
                eab.WithName("About " + userSpecified.Nickname);
            }
            else
            {
                eab.WithName("About " + userSpecified.Username);
            }

            eab.WithUrl(Configuration.Load().PROFILE_URL_ID_TAGGED + userSpecified.Id);

            EmbedFooterBuilder efb = new EmbedFooterBuilder();

            if (userSpecified.IsTeamMember())
            {
                eab.WithIconUrl(userSpecified.GetEmbedAuthorBuilderIconUrl());
            }
            if (!String.IsNullOrEmpty(userSpecified.GetFooterText()))
            {
                efb.WithText(userSpecified.GetFooterText());
                efb.WithIconUrl(userSpecified.GetEmbedFooterBuilderIconUrl());
            }

            EmbedBuilder eb = new EmbedBuilder()
                              .WithAuthor(eab)
                              .WithFooter(efb)
                              .WithThumbnailUrl(userSpecified.GetAvatarUrl())
                              .WithDescription(User.Load(userSpecified.Id).About)
                              .WithColor(userSpecified.GetCustomRGB());

            if (!String.IsNullOrEmpty(userSpecified.GetName()))
            {
                eb.AddField("Name", userSpecified.GetName(), true);
            }

            if (!String.IsNullOrEmpty(userSpecified.GetGender()))
            {
                eb.AddField("Gender", userSpecified.GetGender(), true);
            }

            if (!String.IsNullOrEmpty(userSpecified.GetPronouns()))
            {
                eb.AddField("Pronouns", userSpecified.GetPronouns(), true);
            }

            eb.AddField("Level", userSpecified.GetLevel(), true);
            eb.AddField("EXP", userSpecified.GetEXP() + " (" + (Math.Round(userSpecified.EXPToLevelUp()) - userSpecified.GetEXP()) + " EXP to level up)", true);
            eb.AddField("Account Created", userSpecified.UserCreateDate(), true);
            eb.AddField("Joined Guild", userSpecified.GuildJoinDate(), true);

            if (!String.IsNullOrEmpty(userSpecified.GetMinecraftUsername()))
            {
                eb.AddField("Minecraft Username", userSpecified.GetMinecraftUsername(), true);
            }

            if (!String.IsNullOrEmpty(userSpecified.GetWebsiteUrl()))
            {
                eb.AddField(StringConfiguration.Load().DefaultWebsiteName,
                            "[" + (userSpecified.GetWebsiteName() ?? StringConfiguration.Load().DefaultWebsiteName) + "](" +
                            userSpecified.GetWebsiteUrl() + ")", true);
            }

            if (!String.IsNullOrEmpty(userSpecified.GetInstagramUsername()))
            {
                eb.AddField("Instagram",
                            "[" + userSpecified.GetInstagramUsername() + "](https://www.instagram.com/" +
                            userSpecified.GetInstagramUsername() + "/)", true);
            }

            if (!String.IsNullOrEmpty(userSpecified.GetSnapchatUsername()))
            {
                eb.AddField("Snapchat",
                            "[" + userSpecified.GetSnapchatUsername() + "](https://www.snapchat.com/add/" +
                            userSpecified.GetSnapchatUsername() + "/)", true);
            }

            if (!String.IsNullOrEmpty(userSpecified.GetGitHubUsername()))
            {
                eb.AddField("GitHub",
                            "[" + userSpecified.GetGitHubUsername() + "](https://github.com/" +
                            userSpecified.GetGitHubUsername() + "/)", true);
            }

            if (!String.IsNullOrEmpty(userSpecified.GetPokemonGoFriendCode()))
            {
                eb.AddField("Pokémon Go Friend Code",
                            "[" + userSpecified.GetPokemonGoFriendCode() +
                            "](https://chart.googleapis.com/chart?chs=300x300&cht=qr&" +
                            userSpecified.GetPokemonGoFriendCode().Replace(" ", "") + "&choe=UTF-8)", true);
            }

            if (!String.IsNullOrEmpty(userSpecified.GetCustomPrefix()))
            {
                eb.AddField("Custom Prefix", userSpecified.GetCustomPrefix(), true);
            }

            eb.AddField("Profile", "[Online Profile](" + Configuration.Load().PROFILE_URL_ID_TAGGED + userSpecified.Id + ")", true);

            await ReplyAsync("", false, eb.Build());
        }
コード例 #22
0
        private async Task HandleCommandAsync(SocketMessage s)
        {
            if (!(s is SocketUserMessage msg))
            {
                return;
            }

            SocketCommandContext context = new SocketCommandContext(_client, msg);

            int argPos = 0;

            if (!context.User.IsBot)
            {
                // Commands
                if (msg.HasCharPrefix(prefix, ref argPos))
                {
                    var result = await _commands.ExecuteAsync(context, argPos, _services);

                    if (!result.IsSuccess && result.Error != CommandError.UnknownCommand)
                    {
                        await context.Channel.SendMessageAsync($"Error: {result.ErrorReason}");
                    }
                }

                // InterServer Chat
                else if (Program.interServerChats.ContainsKey(context.Guild.Id) && Program.interServerChats[context.Guild.Id] == context.Channel.Id)
                {
                    string fileName = "";

                    EmbedBuilder embed = new EmbedBuilder();
                    embed.WithAuthor(msg.Author);
                    embed.WithDescription(msg.Content);
                    foreach (Attachment a in msg.Attachments)
                    {
                        if (a.Url.EndsWith(".png") || a.Url.EndsWith(".jpg"))
                        {
                            embed.WithImageUrl(a.Url);
                        }
                        else
                        {
                            WebClient wc  = new WebClient();
                            Uri       uri = new Uri(a.Url);

                            string[] extension = a.Url.Split('.', '/');
                            fileName = $"{extension[extension.Length - 2]}-(1).{extension[extension.Length - 1]}";

                            await wc.DownloadFileTaskAsync(uri, fileName);
                        }
                    }

                    EmbedBuilder embedGuild = new EmbedBuilder();
                    embedGuild.WithAuthor(msg.Author);
                    embedGuild.WithDescription(msg.Content);
                    foreach (Attachment a in msg.Attachments)
                    {
                        if (a.Url.EndsWith(".png") || a.Url.EndsWith(".jpg") || a.Url.EndsWith(".jpeg") || a.Url.EndsWith(".gif"))
                        {
                            embed.WithImageUrl(a.Url);
                        }
                    }
                    if (Program.broadcastServerName.Contains(context.Guild.Id))
                    {
                        EmbedFooterBuilder footer = new EmbedFooterBuilder();
                        footer.WithIconUrl(context.Guild.IconUrl);
                        footer.WithText($"{context.Guild.Name } [{context.Guild.Id}]");

                        embedGuild.WithFooter(footer);
                    }

                    List <Task> sendMessage = new List <Task>();
                    List <Task> sendFile    = new List <Task>();

                    foreach (ulong serverID in Program.interServerChats.Keys.ToList())
                    {
                        SocketGuild guild = context.Client.GetGuild(serverID);

                        if (guild != null)
                        {
                            SocketTextChannel chan = guild.GetTextChannel(Program.interServerChats[serverID]);

                            if (serverID != context.Guild.Id && chan != null && PermissionChecker.HasSend(guild, chan))
                            {
                                bool sendMsg = true;

                                bool wlEnabled = Program.wlEnable.Contains(context.Guild.Id);

                                // Host server-side
                                if (wlEnabled && Program.ischatWhitelist.ContainsKey(context.Guild.Id))
                                {
                                    if (!Program.ischatWhitelist[context.Guild.Id].Contains(serverID))
                                    {
                                        sendMsg = false;
                                    }
                                }
                                else if (wlEnabled)
                                {
                                    sendMsg = false;
                                }
                                else if (Program.ischatBlacklist.ContainsKey(context.Guild.Id))
                                {
                                    if (Program.ischatBlacklist[context.Guild.Id].Contains(serverID))
                                    {
                                        sendMsg = false;
                                    }
                                }

                                // Receiving server-side
                                if (sendMsg)
                                {
                                    wlEnabled = Program.wlEnable.Contains(serverID);

                                    if (wlEnabled && Program.ischatWhitelist.ContainsKey(serverID))
                                    {
                                        if (!Program.ischatWhitelist[serverID].Contains(context.Guild.Id))
                                        {
                                            sendMsg = false;
                                        }
                                    }
                                    else if (wlEnabled)
                                    {
                                        sendMsg = false;
                                    }
                                    else if (Program.ischatBlacklist.ContainsKey(serverID))
                                    {
                                        if (Program.ischatBlacklist[serverID].Contains(context.Guild.Id))
                                        {
                                            sendMsg = false;
                                        }
                                    }
                                }

                                if (sendMsg)
                                {
                                    if (Program.showUserServer.Contains(serverID))
                                    {
                                        sendMessage.Add(chan.SendMessageAsync("", false, embedGuild.Build()));

                                        if (fileName.Length == 0)
                                        {
                                            sendFile.Add(chan.SendFileAsync(fileName, ""));
                                        }
                                    }
                                    else
                                    {
                                        sendMessage.Add(chan.SendMessageAsync("", false, embed.Build()));

                                        if (fileName.Length == 0)
                                        {
                                            sendFile.Add(chan.SendFileAsync(fileName, ""));
                                        }
                                    }
                                }
                            }
                        }
                    }

                    await Task.WhenAll(sendMessage.ToArray()).ContinueWith(t => Task.WhenAll(sendFile.ToArray()).ContinueWith(r => Task.Run(() =>
                    {
                        if (fileName.Length == 0)
                        {
                            System.IO.File.Delete(fileName);
                        }
                    })));
                }
            }
        }
コード例 #23
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)));
            }
        }
    }
コード例 #24
0
ファイル: Profiling.cs プロジェクト: sermetk/Orikivo.Classic
        public async Task AccountResponseAsync(int page = 1)
        {
            SocketUser u     = Context.User;
            OldAccount a     = Context.Account;
            Server     s     = Context.Server;
            int        pages = 7;

            page = page.InRange(1, pages) - 1;

            EmbedFooterBuilder f = new EmbedFooterBuilder();

            f.WithIconUrl(u.GetAvatarUrl());
            f.WithText($"{a.GetName()} | Page {page + 1} of {pages}");

            EmbedBuilder e = new EmbedBuilder();

            e.WithColor(EmbedData.GetColor("origreen"));
            e.WithFooter(f);

            if (page.Equals(0)) // Introduction Page
            {
                StringBuilder sb = new StringBuilder();

                string title = "Account Panel";
                sb.AppendLine($"`{Context.Server.Config.Prefix}account 2` - Options");
                sb.AppendLine($"`{Context.Server.Config.Prefix}account 3` - Notifications");
                sb.AppendLine($"`{Context.Server.Config.Prefix}account 4` - Level Stats");
                sb.AppendLine($"`{Context.Server.Config.Prefix}account 5` - Wallet Stats");
                sb.AppendLine($"`{Context.Server.Config.Prefix}account 6` - Command Stats");
                sb.AppendLine($"`{Context.Server.Config.Prefix}account 7` - Give Or Take Stats");

                e.WithTitle(title);
                e.WithDescription(sb.ToString());

                await ReplyAsync(embed : e.Build());

                return;
            }
            if (page.Equals(1)) // Configuration
            {
                await GetConfigPanelAsync(a, s, e);

                return;
            }
            if (page.Equals(2)) // Notifiers
            {
                await GetNotifierPanelAsync(a, s, e);

                return;
            }
            if (page.Equals(3)) // Level Analytics
            {
                await GetLevelPanelAsync(a, s, e);

                return;
            }
            if (page.Equals(4)) // Wallet Analytics
            {
                await GetWalletPanelAsync(a, s, e);

                return;
            }
            if (page.Equals(6))
            {
                await GetGimmePanelAsync(a, s, e);

                return;
            }
        }
コード例 #25
0
ファイル: CalendarCommands.cs プロジェクト: cun83/EKRAN
        public async Task Calendar()
        {
            if (Context.Guild == null)
            {
                //Text was send by DM, not supported
                string helptext = "Please use this command in a text channel of your server, not via DM. This will be fixed in a later release.";

                var channel = await Context.User.GetOrCreateDMChannelAsync();

                await channel.SendMessageAsync(helptext);
            }
            else
            {
                EmbedBuilder MyEmbedBuilder = new EmbedBuilder();
                MyEmbedBuilder.WithColor(new Color(43, 234, 152));
                MyEmbedBuilder.WithTitle("Planned Events");

                MyEmbedBuilder.WithDescription("These are our upcoming events:");

                MyEmbedBuilder.WithThumbnailUrl("https://cdn4.iconfinder.com/data/icons/small-n-flat/24/calendar-512.png");
                //MyEmbedBuilder.WithImageUrl("https://cdn4.iconfinder.com/data/icons/small-n-flat/24/calendar-512.png");

                //Footer
                EmbedFooterBuilder MyFooterBuilder = new EmbedFooterBuilder();
                MyFooterBuilder.WithText("You can get more information on an event by using !event *eventid* -- DM the bot with !help to get a command overview.");
                MyFooterBuilder.WithIconUrl("https://vignette2.wikia.nocookie.net/mario/images/f/f6/Question_Block_Art_-_New_Super_Mario_Bros.png/revision/latest?cb=20120603213532");
                MyEmbedBuilder.WithFooter(MyFooterBuilder);

                //Author
                EmbedAuthorBuilder MyAuthorBuilder = new EmbedAuthorBuilder();
                MyAuthorBuilder.WithName($"{Context.Guild.Name}'s Schedule");
                //MyAuthorBuilder.WithUrl("http://www.google.com");
                MyEmbedBuilder.WithAuthor(MyAuthorBuilder);

                foreach (CalendarEvent Event in CalendarXMLManagement.arrEvents)
                {
                    if (Event.Active & (Context.Guild.Id == Event.EventGuild & (Event.EventDate.Date >= DateTime.UtcNow.Date) | Event.PublicEvent))
                    {
                        string sType = null;
                        if (Event.PublicEvent)
                        {
                            sType = "Public";
                        }
                        else
                        {
                            sType = "Internal";
                        }

                        //EmbedField
                        EmbedFieldBuilder MyEmbedField = new EmbedFieldBuilder();
                        MyEmbedField.WithIsInline(true);
                        MyEmbedField.WithName(Event.Eventname + $" ({sType})");
                        MyEmbedField.WithValue(
                            $"Date: **{Event.EventDate.ToShortDateString()} **\n" +
                            $"Time: **{Event.EventDate.ToShortTimeString()} UTC**\n" +
                            $"Attendees: **{Event.Attendees.Count}**\n" +
                            $"ID: **{Event.EventID}**\n");

                        //if (Event.MaxAttendees == 0)
                        //{
                        //    sEmbedDescription += $"Attendees: **{sAttendees}**\n";
                        //}
                        //else
                        //{
                        //    sEmbedDescription += $"Attendees: **{sAttendees}/{E}**\n";
                        //}

                        MyEmbedBuilder.AddField(MyEmbedField);
                    }
                }

                await ReplyAsync("", false, MyEmbedBuilder);
            }
        }
コード例 #26
0
        private async Task WriteEnemiesInit()
        {
            var tasks = new List <Task>();

            if (Battle.SizeTeamB == 0)
            {
                Console.WriteLine("Here!!");
            }
            var e = new EmbedBuilder();

            if (Battle.SizeTeamB > 0)
            {
                e.WithThumbnailUrl(Battle.GetTeam(ColossoBattle.Team.B).FirstOrDefault().imgUrl);
            }
            var msg = EnemyMsg;
            var i   = 1;

            foreach (ColossoFighter fighter in Battle.GetTeam(ColossoBattle.Team.B))
            {
                e.AddField($"{numberEmotes[i]} {fighter.ConditionsToString()}", $"{fighter.name}", true);
                i++;
            }
            if (IsEndless)
            {
                EmbedFooterBuilder footerBuilder = new EmbedFooterBuilder();
                footerBuilder.WithText($"Battle {winsInARow + 1} - {Diff}");
                e.WithFooter(footerBuilder);
            }
            tasks.Add(msg.ModifyAsync(m => { m.Content = ""; m.Embed = e.Build(); }));

            var oldReactionCount = EnemyMsg.Reactions.Where(k => numberEmotes.Contains(k.Key.Name)).Count();

            if (winsInARow == 0 && Battle.turn == 0)
            {
                await msg.RemoveAllReactionsAsync();
            }

            if (Battle.SizeTeamB == oldReactionCount)
            {
            }
            else if (Battle.SizeTeamB <= 1)
            {
                if (oldReactionCount > 0)
                {
                    tasks.Add(msg.RemoveAllReactionsAsync());
                }
            }
            else if (Battle.SizeTeamB > oldReactionCount)
            {
                tasks.Add(msg.AddReactionsAsync(
                              numberEmotes
                              .Skip(Math.Max(1, oldReactionCount))
                              .Take(Battle.SizeTeamB - Math.Max(0, oldReactionCount - 1))
                              .Select(s => new Emoji(s))
                              .ToArray()));
            }
            else if (oldReactionCount - Battle.SizeTeamB <= Battle.SizeTeamB + 1)
            {
                var reactionsToRemove = msg.Reactions.Where(k => numberEmotes.Skip(Battle.SizeTeamB + 1).Contains(k.Key.Name)).ToArray();
                tasks.Add(msg.RemoveReactionsAsync(msg.Author, reactionsToRemove.Select(d => d.Key).ToArray()));
            }
            else
            {
                if (oldReactionCount > 0)
                {
                    await msg.RemoveAllReactionsAsync();
                }

                tasks.Add(msg.AddReactionsAsync(
                              numberEmotes
                              .Skip(1)
                              .Take(Battle.SizeTeamB)
                              .Select(s => new Emoji(s))
                              .ToArray()));
            }

            if (Battle.SizeTeamB == 0)
            {
                Console.WriteLine("Here!!");
            }
            await Task.WhenAll(tasks);
        }
コード例 #27
0
ファイル: EmbedData.cs プロジェクト: sermetk/Orikivo.Classic
        public static Embed GenerateEmbedList(List <string> strings, int page = 1, EmbedBuilder e = null)
        {
            int PER_PAGE  = 20;
            int MAX_PAGES = (int)Math.Ceiling((double)strings.Count / PER_PAGE);

            page = page.InRange(1, MAX_PAGES);
            int skip = (page - 1) * PER_PAGE;

            e = e ?? DefaultEmbed;
            const int MAX_DESC = EmbedBuilder.MaxDescriptionLength;

            int len = 0;

            if (!string.IsNullOrWhiteSpace(e.Description))
            {
                len = e.Description.Length;
            }

            string desc = e.Description ?? "";

            StringBuilder sb = new StringBuilder();
            int           i  = 0;

            foreach (string s in strings.Skip(skip))
            {
                if (i >= PER_PAGE)
                {
                    break;
                }

                if (len + sb.Length + '\n' + s.Length > MAX_DESC)
                {
                    e.WithDescription($"{desc}{sb.ToString()}");
                    return(e.Build());
                }

                sb.AppendLine(s);
                i += 1;
            }

            e.WithDescription($"{desc}{sb.ToString()}");
            EmbedFooterBuilder f = e.Footer ?? new EmbedFooterBuilder();

            if (e.Footer.Exists())
            {
                if (MAX_PAGES > 1)
                {
                    f.WithText($"{e.Footer.Text} | Page {page} of {MAX_PAGES}");
                }
                else
                {
                    f.WithText(e.Footer.Text);
                }

                e.WithFooter(f);
            }
            else
            {
                if (MAX_PAGES > 1)
                {
                    f.WithText($"Page {page} of {MAX_PAGES}");
                    e.WithFooter(f);
                }
            }

            return(e.Build());
        }