private static EmbedFieldBuilder BettorDescription(Bet bet) { var builder = new EmbedFieldBuilder() .WithName("Bettors") .WithIsInline(false); if (bet == null || bet.Bettors.Count() == 0) { return(builder.WithValue("none")); } var groups = bet.Bettors .GroupBy(b => b.BetOptionId) .Select(g => { BetOption option = bet.Options.FirstOrDefault(o => o.Id == g.Key); IEnumerable <string> bettors = g .OrderByDescending(b => b.Amount) .Select(b => $"{MentionUtils.MentionUser(b.UserId)} bet {b.Amount} Attarcoins."); return($"[{option.Id}] ({option.Odds:F}) {option.Name}\n\n{string.Join("\n", bettors)}"); }); string message = string.Join("\n\n", groups); if (message.Length > EmbedFieldBuilder.MaxFieldValueLength) { return(null); } return(builder.WithValue(message)); }
public async Task Say10() { if (119019602574442497 != Context.User.Id) { // Secrurity check await ReplyAsync("This is a debug command, you cannot use it!"); return; } EmbedBuilder MyEmbedBuilder = new EmbedBuilder(); MyEmbedBuilder.WithColor(new Color(43, 234, 152)); MyEmbedBuilder.WithTitle("Your title"); MyEmbedBuilder.WithUrl("http://www.google.com"); //MyEmbedBuilder.WithDescription("My description"); MyEmbedBuilder.WithDescription("[Google](http://www.google.com)"); MyEmbedBuilder.WithThumbnailUrl("https://forum.codingwithstorm.com/Themes/Modern/images/vertex_image/social_twitter_icon.png"); MyEmbedBuilder.WithImageUrl("https://forum.codingwithstorm.com/Themes/Modern/images/vertex_image/social_facebook_icon.png"); //Footer EmbedFooterBuilder MyFooterBuilder = new EmbedFooterBuilder(); MyFooterBuilder.WithText("Your text"); MyFooterBuilder.WithIconUrl("https://forum.codingwithstorm.com/Smileys/Koloboks/wink3.gif"); MyEmbedBuilder.WithFooter(MyFooterBuilder); //Author EmbedAuthorBuilder MyAuthorBuilder = new EmbedAuthorBuilder(); MyAuthorBuilder.WithName("Your Name"); MyAuthorBuilder.WithUrl("http://www.google.com"); MyEmbedBuilder.WithAuthor(MyAuthorBuilder); //EmbedField EmbedFieldBuilder MyEmbedField = new EmbedFieldBuilder(); MyEmbedField.WithIsInline(true); MyEmbedField.WithName("Your Field Name"); MyEmbedField.WithValue("Your value"); MyEmbedField.WithValue("[Youtube](http://www.youtube.com)"); MyEmbedBuilder.AddField(MyEmbedField); MyEmbedBuilder.AddField(MyEmbedField); MyEmbedBuilder.AddField(MyEmbedField); MyEmbedBuilder.AddField(MyEmbedField); MyEmbedBuilder.AddField(MyEmbedField); MyEmbedBuilder.AddField(MyEmbedField); MyEmbedBuilder.AddField(MyEmbedField); await ReplyAsync("Swaaaag:", false, MyEmbedBuilder); }
private static async Task <Embed> CreateEquipEmbedOutput(string equipName) { EmbedBuilder builder = new EmbedBuilder(); EmbedFieldBuilder fieldBuilder = new EmbedFieldBuilder(); builder.WithImageUrl(CreateEquipLink(equipName)); fieldBuilder.WithIsInline(false); fieldBuilder.WithName(string.Format("{0}(Equipment)", equipName)); // get ah prices from the hexprice api SearchRequest searchQuery = new SearchRequest() { SearchQuery = equipName, }; HttpResponseMessage response = await Program.httpClient.PostAsJsonAsync("items/search", searchQuery); if (response.IsSuccessStatusCode) { SearchResult[] resultList = await response.Content.ReadAsAsync <SearchResult[]>(); int resultIndex; bool foundExactMatch = false; for (resultIndex = 0; resultIndex < resultList.Length; resultIndex++) { if (resultList[resultIndex].Item.LinkName.Equals(equipName, StringComparison.OrdinalIgnoreCase)) { foundExactMatch = true; break; } } if (foundExactMatch) { int platBuyout = resultList[resultIndex].CurrentCheapestPlat; int goldBuyout = resultList[resultIndex].CurrentCheapestGold; fieldBuilder.WithValue(string.Format("Lowest Buyout: [{0} | {1}]({2})", platBuyout == -1 ? "none" : string.Format("{0}p", platBuyout), goldBuyout == -1 ? "none" : string.Format("{0}g", goldBuyout), CreateHexPriceLink(resultList[resultIndex]))); } else { fieldBuilder.WithValue("Couldn't find AH data."); } } else { fieldBuilder.WithValue("Couldn't connect to hexprice.com."); } builder.AddField(fieldBuilder); return(builder.WithColor(new Color(112, 141, 241)).Build()); }
private static Embed CreateMultipleEquipEmbedOutput(List <string> equipNames) { EmbedBuilder builder = new EmbedBuilder(); EmbedFieldBuilder fieldBuilder = new EmbedFieldBuilder(); if (equipNames.Count <= 5) { fieldBuilder.WithName("Found multiple matching equipment:"); string value = string.Empty; for (int i = 0; i < 5 && i < equipNames.Count; i++) { value += equipNames[i] + "\n"; } fieldBuilder.WithValue(value); fieldBuilder.WithIsInline(false); builder.AddField(fieldBuilder); } else { fieldBuilder.WithName("Found multiple matching equipment:"); string value = string.Empty; for (int i = 0; i < 5; i++) { value += equipNames[i] + "\n"; } if (equipNames.Count > 10) { value += string.Format("\n*and {0} more matches*", equipNames.Count - 5); } fieldBuilder.WithValue(value); fieldBuilder.WithIsInline(true); builder.AddField(fieldBuilder); fieldBuilder = new EmbedFieldBuilder(); fieldBuilder.WithName("\u200b"); value = string.Empty; for (int i = 5; i < 10 && i < equipNames.Count; i++) { value += equipNames[i] + "\n"; } fieldBuilder.WithValue(value); fieldBuilder.WithIsInline(true); builder.AddField(fieldBuilder); } return(builder.WithColor(new Color(112, 141, 241)).Build()); }
public async Task TagAsync(string tagName) { var requestName = tagName; requestName.Replace(" ", "%20"); HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.barbershoptags.com/api.php?fldlist=Title,SungBy,SheetMusic&SheetMusic=Yes&q=" + tagName); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); request.Credentials = CredentialCache.DefaultCredentials; Stream receiveStream = response.GetResponseStream(); StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8); XmlSerializer serializer = new XmlSerializer(typeof(Tags)); Tags tags = (Tags)serializer.Deserialize(readStream); var embed = new EmbedBuilder(); embed.WithTitle("Found " + tags.TagList.Count + " results when searching for " + tagName); foreach (var item in tags.TagList) { var builder = new EmbedFieldBuilder(); builder.WithName(item.Title); string content = "[Sheet Music](" + item.SheetMusic + ")"; builder.WithValue(content); embed.WithFields(builder); } await ReplyAsync("", false, embed.Build()); response.Close(); readStream.Close(); }
public async Task <RestUserMessage> PrintStreams(ISocketMessageChannel channel) { Dictionary <string, List <string> > streams = new Dictionary <string, List <string> >(); foreach (Stream stream in database.GetStreams()) { if (!streams.ContainsKey(stream.Category.Title)) { streams.Add(stream.Category.Title, new List <string>()); } streams[stream.Category.Title].Add($"{stream.Id}: [{stream.Title}]({stream.WebsiteUrl})"); } List <EmbedFieldBuilder> fields = new List <EmbedFieldBuilder>(); foreach (var kvp in streams) { EmbedFieldBuilder builder = new EmbedFieldBuilder() { Name = kvp.Key }; StringBuilder sb = new StringBuilder(); kvp.Value.ForEach(f => sb.AppendLine(f)); fields.Add(builder.WithValue(sb.ToString())); } return(await channel.SendEmbedMessageAsync("Stream Player", "Please choose a stream to play:", Colors.BLACK, null, fields)); }
public async Task GameMessageTest([Remainder] string arg = "") { string[] gameInfos = arg.Split(','); EmbedBuilder embed = new EmbedBuilder(); embed.WithTitle(gameInfos[0]); if (gameInfos.Length > 1) { embed.WithThumbnailUrl(gameInfos[1]); } if (gameInfos.Length > 2) { embed.WithDescription(gameInfos[2]); } if (gameInfos.Length > 3) { embed.WithUrl(gameInfos[3]); } EmbedFieldBuilder fieldBuilder = new EmbedFieldBuilder(); fieldBuilder.WithName("Test Field"); fieldBuilder.WithValue(123456); embed.WithFields(fieldBuilder); await Context.Channel.SendMessageAsync("", false, embed.Build()); }
public static Embed BuildEmbed(string sBranch, double iDays, string sVersion) { //Build the embed EmbedBuilder MyEmbedBuilder = new EmbedBuilder(); MyEmbedBuilder.WithColor(new Color(43, 234, 152)); MyEmbedBuilder.WithTitle("New DCS Update released!"); MyEmbedBuilder.WithDescription("[DCS Update Page](http://updates.digitalcombatsimulator.com)"); MyEmbedBuilder.WithThumbnailUrl("http://is1.mzstatic.com/image/thumb/Purple49/v4/71/b8/bc/71b8bca9-dfc5-e040-4e0f-54488d6a913b/source/175x175bb.jpg"); EmbedFooterBuilder MyFooterBuilder = new EmbedFooterBuilder(); MyFooterBuilder.WithText("Days since last update: " + iDays); MyFooterBuilder.WithIconUrl("https://cdn4.iconfinder.com/data/icons/small-n-flat/24/calendar-512.png"); MyEmbedBuilder.WithFooter(MyFooterBuilder); EmbedFieldBuilder MyEmbedField = new EmbedFieldBuilder(); MyEmbedField.WithIsInline(true); MyEmbedField.WithName("New " + sBranch + " release!"); MyEmbedField.WithValue("Version: " + sVersion); MyEmbedBuilder.AddField(MyEmbedField); return(MyEmbedBuilder); }
public static async Task <bool> SetStateAsync(StateInfo info) { IUserMessage msg = await modLogsDatabase.ModLogs.GetModLogAsync(info.Guild, info.LogId); if (msg == null || msg.Embeds.Count == 0) { return(false); } EmbedBuilder e = msg.Embeds.ToList()[0].ToEmbedBuilder(); List <EmbedFieldBuilder> fields = e.Fields.ToList(); EmbedBuilder embed = new EmbedBuilder() .WithColor(e.Color ?? SecurityInfo.botColor) .WithTitle(e.Title) .WithCurrentTimestamp(); EmbedFieldBuilder field = e.Fields.FirstOrDefault(x => x.Name.Contains(info.StateName)); if (field == null) { return(false); } int index = fields.IndexOf(field); fields.Remove(field); field.WithValue(info.StateValue); fields.Insert(index, field); embed.WithFields(fields); await msg.ModifyAsync(x => x.Embed = embed.Build()); return(true); }
Embed CreateKeepStarEmebed(KeepStarProgress progress) { EmbedBuilder embedBuilder = new EmbedBuilder(); embedBuilder.WithColor(Color.Gold); embedBuilder.WithThumbnailUrl("https://imageserver.eveonline.com/Render/35834_128.png"); embedBuilder.WithAuthor($"Operation Golden Throne - {progress.Complete * 100}%", "https://imageserver.eveonline.com/Corporation/98270640_128.png", "https://goonfleet.com/index.php/topic/269069-operation-golden-throne/"); embedBuilder.WithFooter("Dontations can be made at 1DQ1-A, B-7DFU or JITA 4-4."); double totalAssets = Math.Round(progress.AssetHistory[0].Item1 / 1000000000, 1); double escrow = Math.Round(progress.BuyOrdersEscrow / 1000000000, 1); EmbedFieldBuilder fieldBuilder = new EmbedFieldBuilder(); fieldBuilder.WithName($"Total Assets: {totalAssets.ToString("N1")}b ISK"); fieldBuilder.WithValue($"Buy orders in escrow: {escrow.ToString("N1")}b ISK"); embedBuilder.AddField(fieldBuilder); fieldBuilder = new EmbedFieldBuilder(); fieldBuilder.WithName("Currently needed: PI"); fieldBuilder.WithValue("P2: Viral Agent, Rocket Fuel, Polyaramids...\n⌴"); embedBuilder.AddField(fieldBuilder); double totalPI = Math.Round(progress.TotalPI / 1000000000, 1); double p1 = Math.Round(progress.P1 / 1000000000, 1); double p2 = Math.Round(progress.P2 / 1000000000, 1); double p3 = Math.Round(progress.P3 / 1000000000, 1); double p4 = Math.Round(progress.P4 / 1000000000, 1); fieldBuilder = new EmbedFieldBuilder(); fieldBuilder.WithName($"PI: {totalPI.ToString("N1")}b ISK"); fieldBuilder.WithIsInline(true); fieldBuilder.WithValue($"P1: {p1.ToString("N1")}b ISK\n" + $"P2: {p2.ToString("N1")}b ISK\n" + $"P3: {p3.ToString("N1")}b ISK\n" + $"P4: {p4.ToString("N1")}b ISK\n"); embedBuilder.AddField(fieldBuilder); double wallet = Math.Round(progress.Wallet / 1000000000, 1); fieldBuilder = new EmbedFieldBuilder(); fieldBuilder.WithName($"Wallet: {wallet.ToString("N1")}b ISK"); fieldBuilder.WithIsInline(true); string output = ""; for (int i = 0; i < progress.AssetHistory.Count; i++) { float walletHistory = progress.AssetHistory[i].Item1; double formated = Math.Round(walletHistory / 1000000000, 1); output += $"{progress.AssetHistory[i].Item2}: {formated.ToString("N1")}b ISK\n"; } fieldBuilder.WithValue(output); embedBuilder.AddField(fieldBuilder); return(embedBuilder.Build()); }
public async Task joinHelp() { EmbedBuilder embed = getHelpEmbed("!join <role>"); EmbedFieldBuilder function = new EmbedFieldBuilder(); function.WithName("Function:"); function.WithValue("This command allows users to join roles in the server"); EmbedFieldBuilder usage = new EmbedFieldBuilder(); usage.WithName("Usage:"); usage.WithValue("!join <role>\nEx) `!join guests`"); EmbedFieldBuilder roles = new EmbedFieldBuilder(); roles.WithName("Available Roles:"); roles.WithValue("Students\nAlumni\nGuests"); embed.AddField(function); embed.AddField(usage); embed.AddField(roles); await send(embed); }
public async Task help() { EmbedBuilder embed = getHelpEmbed(); string message = ""; message += "!join <role>\n"; message += "!leave\n"; message += "!help <command>\n"; EmbedFieldBuilder field = new EmbedFieldBuilder(); field.WithName("Available Commands:"); field.WithValue(message); EmbedFieldBuilder additionalHelp = new EmbedFieldBuilder(); additionalHelp.WithName("For more help, type type the help command with a specific Command"); additionalHelp.WithValue("Ex) !help join"); embed.AddField(field); embed.AddField(additionalHelp); await send(embed); }
public static EmbedBuilder SettingsAsEmbed() { EmbedBuilder builder = new EmbedBuilder().SetDefaults(); EmbedFieldBuilder commandsField = new EmbedFieldBuilder().WithIsInline(false).WithName("Commands"); CommandModuleInfo settingsInfo = new(typeof(Bot.Modules.Settings)); string commandDescription = settingsInfo.Commands.First(command => command.Command.Name == "s").ToString(); commandsField.WithValue(commandDescription); builder.AddField(commandsField); EmbedFieldBuilder settingsField = new EmbedFieldBuilder().WithIsInline(false).WithName("Settings"); string settings = string.Empty; Settings defaultSettings = new(); settings = defaultSettings._settings.Values.Aggregate(settings, (current, defaultSetting) => current + defaultSetting.HelpText + "\n"); builder.AddField(settingsField.WithValue(settings)); EmbedFieldBuilder examplesField = new EmbedFieldBuilder().WithIsInline(false).WithName("Examples"); string examples = "set `prefix` server wide:\n" + "`k!s prefix \"kudos!\" - true`\n"; examples += "unset (to default) `prefix` personal:\n" + "`k!s prefix`\n"; examples += "set `autoreact` for messages ending with `haha` to `😂` personal:\n" + "`k!s autoreact \"😂\" \"*haha\"`\n"; examples += "unset `autoreact` for messages starting with `haha` server wide:\n" + "`k!s autoreact - \"haha*\" true`\n"; examplesField.WithValue(examples); return(builder.AddField(examplesField)); }
private static Embed CreateMultipleShardsCardEmbedOutput(List <ShardsCard> cards) { EmbedBuilder builder = new EmbedBuilder(); EmbedFieldBuilder fieldBuilder = new EmbedFieldBuilder(); if (cards.Count <= 5) { fieldBuilder.WithName("Found multiple matching cards:"); string value = string.Empty; for (int i = 0; i < 5 && i < cards.Count; i++) { value += cards[i].Name + "\n"; } fieldBuilder.WithValue(value); fieldBuilder.WithIsInline(false); builder.AddField(fieldBuilder); } else { fieldBuilder.WithName("Found multiple matching cards:"); string value = string.Empty; for (int i = 0; i < 5; i++) { value += cards[i].Name + "\n"; } if (cards.Count > 10) { value += string.Format("\n*and {0} more matches*", cards.Count - 10); } fieldBuilder.WithValue(value); fieldBuilder.WithIsInline(true); builder.AddField(fieldBuilder); fieldBuilder = new EmbedFieldBuilder(); fieldBuilder.WithName("\u200b"); value = string.Empty; for (int i = 5; i < 10 && i < cards.Count; i++) { value += cards[i].Name + "\n"; } fieldBuilder.WithValue(value); fieldBuilder.WithIsInline(true); builder.AddField(fieldBuilder); } return(builder.WithColor(new Color(112, 141, 241)).Build()); }
public static EmbedFieldBuilder SetField(String name, String value, Boolean inline = false) { EmbedFieldBuilder field = new EmbedFieldBuilder(); field.WithName(name); field.WithValue(value); field.WithIsInline(inline); return(field); }
public static EmbedFieldBuilder CreateEmbedField(string title, string discription, bool inline) { EmbedFieldBuilder ebf = new EmbedFieldBuilder(); ebf.WithName(title); ebf.WithValue(discription); ebf.WithIsInline(inline); return(ebf); }
private static EmbedFieldBuilder CreateEmbedField(bool inline, string name, object value) { EmbedFieldBuilder FieldBuilder = new EmbedFieldBuilder(); FieldBuilder.WithIsInline(inline); FieldBuilder.WithName(name); FieldBuilder.WithValue(value); return(FieldBuilder); }
public EmbedFieldBuilder CreateCommandInfoEmbedField([NotNull] CommandInfo command) { var fieldBuilder = new EmbedFieldBuilder(); fieldBuilder.WithName(command.GetFullCommand()); fieldBuilder.WithValue(command.Summary ?? "No summary available."); return(fieldBuilder); }
public async Task Character(params string[] inputs) { if (inputs.Length == 0) { await ReplyAsync("The input text has too few parameters."); return; } string name = inputs.BuildName(); CharacterScraper scraper = new CharacterScraper(); Character character = scraper.GetCharacter(name); if (character != null) { EmbedBuilder embed = new EmbedBuilder(); embed.WithTitle(character.Name); embed.WithUrl(character.obsidianURL); embed.WithDescription(character.Tagline); embed.WithImageUrl(character.ImageURL); EmbedFieldBuilder field = new EmbedFieldBuilder(); field.WithName("Bio"); if (character.Bio.Length > 1024) { field.WithValue(character.Bio.Substring(0, 1021) + "..."); } else { field.WithValue(character.Bio); } embed.AddField(field); await ReplyAsync("", false, embed.Build()); } else { await ReplyAsync("No character could be found with name: " + name); } }
public async Task <RuntimeResult> ListAvailableRolesAsync() { var getServerRolesResult = await _characterRoles.GetCharacterRolesAsync(this.Context.Guild); if (!getServerRolesResult.IsSuccess) { return(getServerRolesResult.ToRuntimeResult()); } var serverRoles = getServerRolesResult.Entity.ToList(); var eb = _feedback.CreateEmbedBase(); eb.WithTitle("Available character roles"); eb.WithDescription ( "These are the roles you can apply to your characters to automatically switch you to that role " + "when you assume the character.\n" + "\n" + "In order to avoid mentioning everyone that has the role, use the numerical ID or role name" + " instead of the actual mention. The ID is listed below along with the role name." ); if (!serverRoles.Any()) { eb.WithFooter("There aren't any character roles available in this server."); } else { foreach (var characterRole in serverRoles) { var discordRole = this.Context.Guild.GetRole((ulong)characterRole.DiscordID); if (discordRole is null) { continue; } var ef = new EmbedFieldBuilder(); ef.WithName($"{discordRole.Name} ({discordRole.Id})"); var roleStatus = characterRole.Access == RoleAccess.Open ? "open to everyone" : "restricted"; ef.WithValue($"*This role is {roleStatus}.*"); eb.AddField(ef); } } await _feedback.SendEmbedAsync(this.Context.Channel, eb.Build()); return(RuntimeCommandResult.FromSuccess()); }
public async Task Deck(string argument = null, params string[] deckNames) { GameContext context = GameContexts.getContext(Context.Guild.Id); switch (argument) { case "add": context.AddDecks(deckNames); context.SaveToJson(); break; case "remove": context.RemoveDecks(deckNames); context.SaveToJson(); break; default: if (context.UsedDecks.Count > 0) { EmbedBuilder embed = new EmbedBuilder(); EmbedFieldBuilder usedField = new EmbedFieldBuilder(); usedField.WithName("Current Decks"); string description = string.Empty; foreach (Deck deck in context.UsedDecks) { description += string.Format("{2} {0} - {1}" + Environment.NewLine, deck.Name, deck.Description, deck.Emoji); } usedField.WithValue(description); EmbedFieldBuilder unusedField = new EmbedFieldBuilder(); unusedField.WithName("Avaliable Decks"); description = string.Empty; List <Deck> unusedDecks = (List <Deck>)Decks.GetAllDecks(); unusedDecks.RemoveAll(s => context.UsedDecks.Contains(s)); foreach (Deck deck in unusedDecks) { description += string.Format("{2} {0} - {1}" + Environment.NewLine, deck.Name, deck.Description, deck.Emoji); } unusedField.WithValue(description); embed.AddField(usedField); embed.AddField(unusedField); await ReplyAsync("", false, embed.Build()); } else { await ReplyAsync("You currently have no decks."); } break; } }
public async Task ShowAvailablePronounFamiliesAsync() { EmbedFieldBuilder CreatePronounField(IPronounProvider pronounProvider) { var ef = new EmbedFieldBuilder(); ef.WithName(pronounProvider.Family); var value = $"{pronounProvider.GetSubjectForm()} ate {pronounProvider.GetPossessiveAdjectiveForm()} " + $"pie that {pronounProvider.GetSubjectForm()} brought with " + $"{pronounProvider.GetReflexiveForm()}."; value = value.Transform(To.SentenceCase); ef.WithValue($"*{value}*"); return(ef); } var pronounProviders = _pronouns.GetAvailablePronounProviders().ToList(); if (!pronounProviders.Any()) { await _feedback.SendErrorAsync(this.Context, "There doesn't seem to be any pronouns available."); return; } var fields = pronounProviders.Select(CreatePronounField); var description = "Each field below represents a pronoun that can be used with a character. The title of " + "each field is the pronoun family that you use when selecting the pronoun, and below it" + "is a short example of how it might be used."; var paginatedEmbedPages = PageFactory.FromFields ( fields, description: description ); var paginatedEmbed = new PaginatedEmbed(_feedback, _interactivity, this.Context.User).WithPages ( paginatedEmbedPages.Select ( p => p.WithColor(Color.DarkPurple).WithTitle("Available pronouns") ) ); await _interactivity.SendInteractiveMessageAndDeleteAsync ( this.Context.Channel, paginatedEmbed, TimeSpan.FromMinutes(5.0) ); }
public async Task Help(ModuleInfo module) { var pages = new List <PageBuilder>(); var pageFields = new List <EmbedFieldBuilder>(); foreach (CommandInfo command in module.Commands) { EmbedFieldBuilder embedField = new EmbedFieldBuilder(); embedField.WithName(HelpUtilities.GetCommandUsage(command)); embedField.WithValue(command.Summary ?? "no information given"); pageFields.Add(embedField); } if (pageFields.Count <= 25) { PageBuilder page = new PageBuilder(); page.WithTitle(module.Name); page.WithFields(pageFields); pages.Add(page); var builder = new EmbedBuilder(); builder.WithTitle(module.Name); builder.WithFields(pageFields); await ReplyAsync("", false, builder.Build()); } else { while (pageFields.Count > 0) { PageBuilder page = new PageBuilder(); page.WithTitle(module.Name); page.WithFields(pageFields.Take(25)); pages.Add(page); if (pageFields.Count > 25) { pageFields.RemoveRange(0, 24); } else { pageFields.Clear(); } } var paginator = new StaticPaginatorBuilder() .WithUsers(Context.User) .WithPages(pages) .WithFooter(PaginatorFooter.PageNumber | PaginatorFooter.Users) .WithDefaultEmotes() .Build(); await _interactivity.SendPaginatorAsync(paginator, Context.Channel, TimeSpan.FromMinutes(2)); } }
public EmbedFieldBuilder CommandListAsEmbedField(bool isBotAdmin) { if (Module.Accessibility == Accessibility.Hidden && !isBotAdmin) { return(null); } EmbedFieldBuilder fieldBuilder = new EmbedFieldBuilder().WithName(Module.Name).WithIsInline(false); string commands = Commands.Where(command => command.Command.Accessibility != Accessibility.Hidden || isBotAdmin) .Aggregate("", (current, command) => current + (command + "\n")); return(string.IsNullOrEmpty(commands) ? null : fieldBuilder.WithValue(commands)); }
/// <summary> Creates an embed with specified mod case information, used for a quick lookup about mod case info. </summary> /// <returns> The created embed. </returns> public static Embed LookupEmbed(ModCase modCase, string user, string mod) { var punishment = new EmbedFieldBuilder().WithName("Punishment Type"); switch (modCase.PunishmentType) { case PunishmentType.Mute: punishment.WithValue("Mute"); break; case PunishmentType.VMute: punishment.WithValue("Voice Mute"); break; case PunishmentType.Kick: punishment.WithValue("Kick"); break; case PunishmentType.Ban: punishment.WithValue("Ban"); break; } var userNameField = new EmbedFieldBuilder().WithName("User Name").WithValue(user) .WithIsInline(true); var userIdField = new EmbedFieldBuilder().WithName("User ID").WithValue(modCase.UserId) .WithIsInline(true); var responsibleModField = new EmbedFieldBuilder().WithName("Responsible Mod").WithValue(mod) .WithIsInline(true); var reasonField = new EmbedFieldBuilder().WithName("Reason").WithValue(modCase.Reason ?? "_No reason_") .WithIsInline(true); var embed = new EmbedBuilder() .WithTitle($"Case #{modCase.ModCaseId}") .WithFields(punishment, userNameField, userIdField, responsibleModField, reasonField) .WithColor(Color.LightGrey) .WithTimestamp(modCase.DateTime); return(embed.Build()); }
/// <summary> /// Generates a Discord Embed for the given <paramref name="stream"/> /// </summary> /// <param name="stream"></param> /// <returns>Discord Embed with Stream Information</returns> public static Embed GetStreamEmbed(ILiveBotStream stream, ILiveBotUser user, ILiveBotGame game) { // Build the Author of the Embed EmbedAuthorBuilder authorBuilder = new EmbedAuthorBuilder(); authorBuilder.WithName(user.DisplayName); authorBuilder.WithIconUrl(user.AvatarURL); authorBuilder.WithUrl(user.ProfileURL); // Build the Footer of the Embed EmbedFooterBuilder footerBuilder = new EmbedFooterBuilder(); footerBuilder.WithText("Stream start time"); // Add Basic information to EmbedBuilder EmbedBuilder builder = new EmbedBuilder(); builder.WithColor(Color.DarkPurple); builder.WithAuthor(authorBuilder); builder.WithFooter(footerBuilder); builder.WithTimestamp(stream.StartTime); builder.WithDescription(stream.Title); builder.WithUrl(stream.StreamURL); builder.WithThumbnailUrl(user.AvatarURL); // Add Status Field //EmbedFieldBuilder statusBuilder = new EmbedFieldBuilder(); //statusBuilder.WithIsInline(false); //statusBuilder.WithName("Status"); //statusBuilder.WithValue(""); //builder.AddField(statusBuilder); // Add Game field EmbedFieldBuilder gameBuilder = new EmbedFieldBuilder(); gameBuilder.WithIsInline(true); gameBuilder.WithName("Game"); gameBuilder.WithValue(game.Name); builder.AddField(gameBuilder); // Add Stream URL field EmbedFieldBuilder streamURLField = new EmbedFieldBuilder(); streamURLField.WithIsInline(true); streamURLField.WithName("Stream"); streamURLField.WithValue(stream.StreamURL); builder.AddField(streamURLField); return(builder.Build()); }
private void ShowCommandHelpInternal(Command command, IUser user, IMessageChannel channel, EmbedBuilder output) { var field = new EmbedFieldBuilder(); var cmd = command.Text; foreach (var param in command.Parameters) { switch (param.Type) { case ParameterType.Required: cmd += $" <{param.Name}>"; break; case ParameterType.Optional: cmd += $" [{param.Name}]"; break; case ParameterType.Multiple: case ParameterType.MultipleUnparsed: cmd += $" [{param.Name}]"; break; case ParameterType.Unparsed: cmd += $" {param.Name}"; break; } } field.WithName($"`{cmd}`"); field.WithValue($"{command.Description ?? "No description."}"); if (command.Aliases.Any()) { field.Value += $"\n**Aliases:** `" + string.Join("`, `", command.Aliases) + '`'; } if (command.NsfwFlag || command.MusicFlag) { string flags = "\n**Flags:** "; if (command.MusicFlag) { flags += "Music "; } if (command.NsfwFlag) { flags += "NSFW "; } field.Value += flags.TrimEnd(' '); } output.AddField(field); }
private async Task HandleResults(string url, IMessageChannel channel) { IIqdbClient api = new IqdbClient(); IqdbApi.Models.SearchResult res; try { res = await api.SearchUrl(url); } //Too lazy to implement separate exceptions this'll do catch (Exception) { await channel.SendErrorAsync("IQDB serarch error'd. Try a different image?"); return; } //Lets get the results maybe? if (res.Matches.Where(x => x.MatchType == IqdbApi.Enums.MatchType.Best).Count() == 0) { await channel.SendErrorAsync("No source found for that image, sadly."); return; } //SWEET MOTHER OF GOD WE GOT SOMETHING EmbedBuilder e = new EmbedBuilder().WithOkColour().WithTitle("Potential Match Found").WithDescription("This is the \"best\" match according to IQDB."); EmbedFieldBuilder efb = new EmbedFieldBuilder().WithName("URL"); //We only need the best Match bestmatch = res.Matches.Where(x => x.MatchType == IqdbApi.Enums.MatchType.Best).First(); //There's gotta be a better way to do this but I'm okay with this as is string urlFix = bestmatch.Url; if (!urlFix.StartsWith("http:") && urlFix.StartsWith("//")) { urlFix = "http:" + urlFix; } //combine shit efb.WithValue(urlFix); e.AddField(efb); //Finally await channel.BlankEmbedAsync(e.Build()); }
public async Task resetAllHelp() { EmbedBuilder embed = getHelpEmbed("!resetall"); EmbedFieldBuilder function = new EmbedFieldBuilder(); function.WithName("Function:"); function.WithValue("This command will reset all users in the server to the default rank of Unranked/New. This can take some time."); EmbedFieldBuilder usage = new EmbedFieldBuilder(); usage.WithName("Usage:"); usage.WithValue("!resetall"); embed.AddField(function); embed.AddField(usage); await send(embed); }
public EmbedFieldBuilder ShowCommandFieldAsync(CommandInfo command) { EmbedFieldBuilder fb = new EmbedFieldBuilder(); fb.WithName(WriteCommandReport(command) + GetCommandSyntax(command) + $"+{command.Priority}".DiscordLine()); StringBuilder sb = new StringBuilder(); List <string> aliases = command.Aliases.Funct() ? GetAliases(command) : null; if (aliases.Funct()) { sb.AppendLine($"({"AKA".ToSuperscript()}) {aliases.Conjoin(", ")}"); } if (command.Summary.Exists()) { sb.AppendLine(command.Summary); } fb.WithValue(string.IsNullOrWhiteSpace(sb.ToString()) ? "UNSPECIFIED" : sb.ToString()); return(fb); }