public static EmbedAuthorBuilder WithUser(this EmbedAuthorBuilder builder, IUser user, bool includeId = false) { string id = includeId ? $" ({user.Id})" : ""; if (user is SocketGuildUser sUser) { builder.WithName($"{sUser.Nickname ?? sUser.Username}{id}"); } else { builder.WithName($"{user.Username}{id}"); } return(builder.WithIconUrl(user.GetAvatarUrl() ?? "https://i.imgur.com/xVIMQiB.jpg")); }
public async Task Tri(SocketGuildUser user = null) { user = user ?? (SocketGuildUser)Context.User; var account = UserAccounts.GetAccount(user); var embed = new EmbedBuilder(); var p = new PlayerFighter(user); embed.WithColor(Colors.Get(account.Element.ToString())); var author = new EmbedAuthorBuilder(); author.WithName(user.DisplayName()); author.WithIconUrl(user.GetAvatarUrl()); embed.WithAuthor(author); embed.WithThumbnailUrl(user.GetAvatarUrl()); embed.AddField("Server Stats", JsonConvert.SerializeObject(account.ServerStats, Formatting.Indented)); embed.AddField("Battle Stats", JsonConvert.SerializeObject(account.BattleStats, Formatting.Indented)); embed.AddField("Unlocked Classes", account.BonusClasses.Length == 0 ? "none" : string.Join(", ", account.BonusClasses)); var Footer = new EmbedFooterBuilder(); Footer.WithText("Joined this Server on " + user.JoinedAt.Value.Date.ToString("dd-MM-yyyy")); Footer.WithIconUrl(Sprites.GetImageFromName("Iodem")); embed.WithFooter(Footer); //await Context.User.SendMessageAsync("", false, embed.Build()); await Context.Channel.SendMessageAsync("", false, embed.Build()); }
private EmbedBuilder build_message(string usname, string text, string icon) //makes the embed for message { var auth_build = new EmbedAuthorBuilder(); auth_build.WithName(usname); auth_build.WithIconUrl(icon); var builder = new EmbedBuilder(); builder.WithAuthor(auth_build); builder.WithDescription(text); if (color_picked) { builder.WithColor(rnd_color); } else { Random rnd = new Random(); rnd_color = new Color(rnd.Next(256), rnd.Next(256), rnd.Next(256)); builder.WithColor(rnd_color); color_picked = true; } return(builder); }
public async Task GetAllGuildChannelsAsync() { var server = new EmbedAuthorBuilder(); var _embed = new EmbedBuilder(); var shard = Context.Client.Rest.GetGuildsAsync(); // await ReplyAsync(shard.Result.Count.ToString()); foreach (var conn in shard.Result) { server.WithName(conn.Name) .WithIconUrl((conn.IconUrl == null) ? Context.Client.CurrentUser.GetDefaultAvatarUrl() : conn.IconUrl); _embed.Author = server; var guildItem = await conn.GetChannelsAsync(); foreach (var ch in guildItem) { _embed.AddField("||" + ch.Id.ToString() + "||", "**" + ch.Name + "**"); } var users = conn.GetUsersAsync().FlattenAsync().Result.GetEnumerator(); int userCount = 0; while (users.MoveNext()) { if (!(users.Current.IsBot)) { userCount++; } } _embed.WithColor(Color.Blue) .WithFooter("Members: " + userCount.ToString()); await ReplyAsync(embed : _embed.Build()); } }
public async Task Tri([Remainder] SocketGuildUser user = null) { user ??= (SocketGuildUser)Context.User; var account = EntityConverter.ConvertUser(user); var embed = new EmbedBuilder(); embed.WithColor(Colors.Get(account.Element.ToString())); var author = new EmbedAuthorBuilder(); author.WithName(user.DisplayName()); author.WithIconUrl(user.GetAvatarUrl()); embed.WithAuthor(author); embed.WithThumbnailUrl(user.GetAvatarUrl()); embed.AddField("Server Stats", JsonConvert.SerializeObject(account.ServerStats, Formatting.Indented).Replace("{", "").Replace("}", "").Replace("\"", "")); embed.AddField("Battle Stats", JsonConvert.SerializeObject(account.BattleStats, Formatting.Indented).Replace("{", "").Replace("}", "").Replace("\"", "")); embed.AddField("Account Created:", user.CreatedAt); embed.AddField("Unlocked Classes", account.BonusClasses.Count == 0 ? "none" : string.Join(", ", account.BonusClasses)); var Footer = new EmbedFooterBuilder(); Footer.WithText("Joined this Server on " + user.JoinedAt.Value.Date.ToString("dd-MM-yyyy")); Footer.WithIconUrl(Sprites.GetImageFromName("Iodem")); embed.WithFooter(Footer); await Context.Channel.SendMessageAsync("", false, embed.Build()); Console.WriteLine(JsonConvert.SerializeObject(account, Formatting.Indented)); }
public async Task serverStatsAsync() { EmbedBuilder eb = new EmbedBuilder(); using (DiscordContext db = new DiscordContext()) { ulong authorId = Context.User.Id; User author = db.Users.Where(u => (ulong)u.DiscordId == authorId).FirstOrDefault(); if (author == null) { Logger.Warning("system", $"Cannot find user {Context.User.Username}"); return; } if (author.Privilege < User.Privileges.Moderator) { await ReplyAsync("Go bug someone else."); return; } EmbedAuthorBuilder authorBuilder = new EmbedAuthorBuilder(); authorBuilder.WithName(Context.Guild.Name); authorBuilder.WithIconUrl(Context.Guild.IconUrl); eb.WithAuthor(authorBuilder); eb.WithColor(Color.Teal); db.Users.Count(u => u.Gender == User.Genders.Male); eb.WithDescription( $"Users: {Context.Guild.Users.Count}\n" + $"Rooms: {Context.Guild.TextChannels.Count}\n" + $"Voice Channels: {Context.Guild.VoiceChannels.Count}\n" + $"5+ Levels: {db.Users.Count(u => u.Level >= 5)}" + $"18+ Users: {db.Users.Count(u => u.Age >= 18)}\n" + $"Monk Role: {db.Users.Count(u => u.Monk.Equals(true))}\n" + $"NSFW Role: {db.Users.Count(u => u.Nsfw.Equals(true))}" + $"Subscribed to Games: {db.Users.Count(u => u.Games.Equals(true))}\n" + $"Subscribed to Bot Updates: {db.Users.Count(u => u.BotUpdates.Equals(true))}\n" + $"Genders\n" + $"Male:{db.Users.Count(u => u.Gender == User.Genders.Male) + db.Users.Count(u => u.Gender == User.Genders.Trans_Male)}, " + $"Female: {db.Users.Count(u => u.Gender == User.Genders.Female) + db.Users.Count(u => u.Gender == User.Genders.Trans_Female)}" + $"Other: {db.Users.Count(u => u.Gender == User.Genders.Other)}\n" + $"Fluid: {db.Users.Count(u => u.Gender == User.Genders.Fluid)}" + $"None: {db.Users.Count(u => u.Gender == User.Genders.None)}"); eb.WithCurrentTimestamp(); EmbedFooterBuilder footer = new EmbedFooterBuilder(); footer.WithText($"Server ID: {Context.Guild.Id}"); eb.WithFooter(footer); eb.WithThumbnailUrl(Context.Guild.IconUrl); } await ReplyAsync("", false /*TTS*/, eb.Build()); }
public static Embed ActivityProfileEmbed(IUser user, Dictionary <string, DatabaseField> databaseFields) { var guildUser = (SocketGuildUser)user; var builder = new EmbedBuilder(); var description = CreateDescription(new List <DatabaseField> { databaseFields.GetValueOrDefault("Tier"), databaseFields.GetValueOrDefault("GA"), databaseFields.GetValueOrDefault("InactivityNotice") }); builder.WithDescription(description); var fields = CreateInlineFields(new List <DatabaseField> { databaseFields.GetValueOrDefault("GQ"), databaseFields.GetValueOrDefault("NW"), databaseFields.GetValueOrDefault("Villa"), databaseFields.GetValueOrDefault("Militia"), databaseFields.GetValueOrDefault("Seamonsters"), databaseFields.GetValueOrDefault("Placeholder") }); builder.Fields = fields; //builder.WithDescription($"" + // $"**Tier**: {memberActivity.Tier}\n" + // $"**Guild Activity:** {memberActivity.GA}\n" + // $"**Inactivity notice:** {memberActivity.InactivityNotice}"); //var gearScoreFields = new List<EmbedFieldBuilder>{ // new EmbedFieldBuilder{ Name = "GQ", Value = memberActivity.GQ, IsInline = true }, // new EmbedFieldBuilder{ Name = "NW", Value = memberActivity.NW, IsInline = true }, // new EmbedFieldBuilder{ Name = "Villa", Value = memberActivity.Villa, IsInline = true }, // new EmbedFieldBuilder{ Name = "Militia", Value = memberActivity.Militia, IsInline = true }, // new EmbedFieldBuilder{ Name = "Seamonsters", Value = memberActivity.Seamonsters, IsInline = true }, // new EmbedFieldBuilder{ Name = "Placeholder", Value = "N/A", IsInline = true }, //}; //builder.Fields = gearScoreFields; var footer = new EmbedFooterBuilder(); footer.WithText($"Last updated: {databaseFields.GetValueOrDefault("Activity last updated").CellValue}"); builder.WithFooter(footer); var author = new EmbedAuthorBuilder(); author.WithIconUrl(guildUser.GetAvatarUrl()); author.WithName(guildUser.Nickname); builder.WithAuthor(author); builder.WithColor(Color.Red); return(builder.Build()); }
public static EmbedAuthorBuilder ToEmbedAuthorBuilder(this IUser user) { var builder = new EmbedAuthorBuilder { IconUrl = user.GetEffectiveAvatarUrl() }; if (user is IGuildUser guildUser) { builder.WithName( $"{(guildUser.Nickname != null ? $"({guildUser.Nickname}) " : "")}{guildUser.Username}#{guildUser.Discriminator}"); } else { builder.WithName(user.ToString()); } return(builder); }
public static Embed GearProfileEmbed(IUser user, Dictionary <string, DatabaseField> databaseFields) { var guildUser = (SocketGuildUser)user; var classRole = MiscHelper.GetClassRoleOfUser(user); if (classRole == null) { classRole = "N/A"; } var builder = new EmbedBuilder(); var description = CreateDescription(new List <DatabaseField> { databaseFields.GetValueOrDefault("LVL"), databaseFields.GetValueOrDefault("Renown"), databaseFields.GetValueOrDefault("GearLink"), databaseFields.GetValueOrDefault("GearComment") }); builder.WithDescription(description); var fields = CreateInlineFields(new List <DatabaseField> { databaseFields.GetValueOrDefault("AP"), databaseFields.GetValueOrDefault("AAP"), databaseFields.GetValueOrDefault("DP"), databaseFields.GetValueOrDefault("Class"), databaseFields.GetValueOrDefault("AlchStone"), databaseFields.GetValueOrDefault("Axe") }); builder.Fields = fields; if (databaseFields.GetValueOrDefault("GearLink").CellValue == "N/A") { databaseFields.GetValueOrDefault("GearLink").CellValue = ""; } builder.WithImageUrl(databaseFields.GetValueOrDefault("GearLink").CellValue); var footer = new EmbedFooterBuilder(); footer.WithText($"Last updated: {databaseFields.GetValueOrDefault("Gear last updated").CellValue}"); builder.WithFooter(footer); var author = new EmbedAuthorBuilder(); author.WithIconUrl(guildUser.GetAvatarUrl()); author.WithName(guildUser.Nickname); builder.WithAuthor(author); builder.WithColor(Color.Red); return(builder.Build()); }
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); }
/// <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()); }
public async Task Xp() { var user = (SocketGuildUser)Context.User; var account = EntityConverter.ConvertUser(user); var embed = new EmbedBuilder(); embed.WithColor(Colors.Get(account.Element.ToString())); var author = new EmbedAuthorBuilder(); author.WithName(user.DisplayName()); author.WithIconUrl(user.GetAvatarUrl()); embed.WithAuthor(author); embed.AddField("Level", account.LevelNumber, true); embed.AddField("XP", account.XP, true); embed.AddField("XP to level up", account.XPneeded, true); await Context.Channel.SendMessageAsync("", false, embed.Build()); }
internal static Embed SignupProfileEmbed(IUser user, MemberSignupData memberSignupData) { var guildUser = (SocketGuildUser)user; var classRole = MiscHelper.GetClassRoleOfUser(user); if (classRole == null) { classRole = "N/A"; } var builder = new EmbedBuilder(); var description = CreateDescription(new List <DatabaseField> { memberSignupData.SignupComment }); builder.WithDescription(description); var fields = CreateInlineFields(new List <DatabaseField> { memberSignupData.FirstEvent, memberSignupData.SecondEvent, memberSignupData.ThirdEvent, memberSignupData.FourthEvent, }); builder.Fields = fields; //builder.WithImageUrl(memberSignupData.GearLink); //var footer = new EmbedFooterBuilder(); //footer.WithText($"Last updated: {memberSignupData.GearLastUpdated}"); //builder.WithFooter(footer); var author = new EmbedAuthorBuilder(); author.WithIconUrl(guildUser.GetAvatarUrl()); author.WithName(guildUser.Nickname); builder.WithAuthor(author); builder.WithColor(Color.Red); return(builder.Build()); }
public async Task Xp() { var user = (SocketGuildUser)Context.User; var account = UserAccounts.GetAccount(user); var embed = new EmbedBuilder(); var factory = new PlayerFighterFactory(); var p = factory.CreatePlayerFighter(user); embed.WithColor(Colors.Get(account.Element.ToString())); var author = new EmbedAuthorBuilder(); author.WithName(user.DisplayName()); author.WithIconUrl(user.GetAvatarUrl()); embed.WithAuthor(author); embed.AddField("Level", account.LevelNumber, true); embed.AddField("XP", account.XP, true); embed.AddField("XP to level up", Leveling.XPforNextLevel(account.XP), true); await Context.Channel.SendMessageAsync("", false, embed.Build()); }
public async Task Status([Remainder] SocketGuildUser user = null) { user = user ?? (SocketGuildUser)Context.User; var account = UserAccounts.GetAccount(user); var factory = new PlayerFighterFactory(); var p = factory.CreatePlayerFighter(user); var author = new EmbedAuthorBuilder(); author.WithName($"{user.DisplayName()}"); author.WithIconUrl(user.GetAvatarUrl()); //embed.WithThumbnailUrl(user.GetAvatarUrl()); //embed.WithDescription($"Status."); //embed.AddField("Element", account.element, true); var embed = new EmbedBuilder() .WithColor(Colors.Get(account.Element.ToString())) .WithAuthor(author) .AddField("Level", account.LevelNumber, true) .AddField("XP", $"{account.XP} - next in {Leveling.XPforNextLevel(account.XP)}", true) .AddField("Rank", UserAccounts.GetRank(user) + 1, true) .AddField("Class", account.GsClass, true) .AddField("Colosso wins | streak", $"{account.ServerStats.ColossoWins} | {account.ServerStats.ColossoHighestStreak} ", true) .AddField("Endless Streaks", $"Solo: {account.ServerStats.ColossoHighestRoundEndlessSolo} | Duo: {account.ServerStats.ColossoHighestRoundEndlessDuo} \nTrio: {account.ServerStats.ColossoHighestRoundEndlessTrio} | Quad: {account.ServerStats.ColossoHighestRoundEndlessQuad}", true) .AddField("Current Equip", account.Inv.GearToString(AdeptClassSeriesManager.GetClassSeries(account).Archtype), true) .AddField("Psynergy", p.GetMoves(false), false) .AddField("Stats", p.Stats.ToString(), true) .AddField("Elemental Stats", p.ElStats.ToString(), true) .AddField("Unlocked Classes", account.BonusClasses.Length == 0 ? "none" : string.Join(", ", account.BonusClasses)); var Footer = new EmbedFooterBuilder(); Footer.WithText("Joined this Server on " + user.JoinedAt.Value.Date.ToString("dd-MM-yyyy")); Footer.WithIconUrl(Sprites.GetImageFromName("Iodem")); embed.WithFooter(Footer); await Context.Channel.SendMessageAsync("", false, embed.Build()); }
public async Task w0nderAsync() { EmbedBuilder builder = new EmbedBuilder(); builder.WithTitle("__w0nder__") .WithDescription("*aka Santi*") .WithColor(Color.Green) .WithImageUrl("https://media.giphy.com/media/l0GRkzJhkMlJotMFq/giphy.gif"); // Social Media Field *BETA* builder.AddField("Watch w0nder play your favorite games LIVE! :)", "[Twitch](https://www.twitch.tv/w0nder_what)") .AddField("Discover w0nder's stream highlights and more! :)", "[YouTube](https://www.youtube.com/user/xSneakyFoxX)") .AddField("Get the lastest and greatest news, straight from w0nder! :)", "[Twitter](https://twitter.com/santirend0n)"); await ReplyAsync("", false, builder.Build()); // Social Media Links // builder.WithTitle("w0nder") // .WithColor(Color.Green) // .WithDescription("[Twitch](https://www.twitch.tv/w0nder_what) " + // "[YouTube](https://www.youtube.com/user/xSneakyFoxX) " + // "[Twitter](https://twitter.com/santirend0n)") // Images // builder.WithThumbnailUrl("https://cdn.discordapp.com/attachments/396131592591900672/409565974421962761/4803049a93e73306c59a627e5baacde1.png") //.WithImageUrl("https://media.giphy.com/media/l0GRkzJhkMlJotMFq/giphy.gif"); EmbedFooterBuilder footbuilder = new EmbedFooterBuilder(); footbuilder.WithText("Don't Forget to Like and Subscribe"); footbuilder.WithIconUrl("https://cdn.discordapp.com/attachments/396131592591900672/409565974421962761/4803049a93e73306c59a627e5baacde1.png"); builder.WithFooter(footbuilder); EmbedAuthorBuilder authorbuilder = new EmbedAuthorBuilder(); authorbuilder.WithName("w0nder"); authorbuilder.WithIconUrl("https://cdn.discordapp.com/attachments/396131592591900672/409565974421962761/4803049a93e73306c59a627e5baacde1.png"); }
public static EmbedAuthorBuilder SetAuthor(String icon = null, String name = null, String url = null) { var iconExists = !String.IsNullOrWhiteSpace(icon); var nameExists = !String.IsNullOrWhiteSpace(name); var urlExists = !String.IsNullOrWhiteSpace(url); EmbedAuthorBuilder author = new EmbedAuthorBuilder(); if (iconExists) { try { author.WithIconUrl(icon); } catch (Exception) { } } ; if (nameExists) { author.WithName(name); } if (urlExists) { try { author.WithUrl(url); } catch (Exception) { } } ; return(author); }
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()); }
public async Task Sihirdar([Remainder] string isim) { await Turkcemi(Context); try { Console.WriteLine(isim + "aranıyor"); if (l == 1) { await Context.Channel.SendMessageAsync(isim + " Aranıyor..."); } else { await Context.Channel.SendMessageAsync("Searching for " + isim + "..."); } kills = new string[5]; deaths = new string[5]; assists = new string[5]; result = new string[5]; isim.Replace(" ", "%20"); // 1 riot.summonerbul(isim); riot.macbilgi(riot.summonerid, riot.mac1id); kills[0] = riot.kill; deaths[0] = riot.death; assists[0] = riot.assist; result[0] = riot.macsonuc; // 2 riot.summonerbul(isim); riot.macbilgi(riot.summonerid, riot.mac2id); kills[1] = riot.kill; deaths[1] = riot.death; assists[1] = riot.assist; result[1] = riot.macsonuc; // 3 riot.summonerbul(isim); riot.macbilgi(riot.summonerid, riot.mac3id); kills[2] = riot.kill; deaths[2] = riot.death; assists[2] = riot.assist; result[2] = riot.macsonuc; // 4 riot.summonerbul(isim); riot.macbilgi(riot.summonerid, riot.mac4id); kills[3] = riot.kill; deaths[3] = riot.death; assists[3] = riot.assist; result[3] = riot.macsonuc; // 5 riot.summonerbul(isim); riot.macbilgi(riot.summonerid, riot.mac5id); kills[4] = riot.kill; deaths[4] = riot.death; assists[4] = riot.assist; result[4] = riot.macsonuc; var eb = new EmbedBuilder() { Title = "", Description = "**Maçlar**", Color = Color.Blue }; if (l == 0) { eb = new EmbedBuilder() { Title = "", Description = "**Matches**", Color = Color.Blue } } ; string newname = riot.summonername; newname.First().ToString().ToUpper(); EmbedAuthorBuilder MyAuthorBuilder = new EmbedAuthorBuilder(); if (l == 1) { MyAuthorBuilder.WithName(newname + " - Tüm profil için tıkla"); } else { MyAuthorBuilder.WithName(newname + " - Click for complete profile"); } MyAuthorBuilder.WithIconUrl("https://i.hizliresim.com/JlvA4B.jpg"); eb.WithAuthor(MyAuthorBuilder); for (int i = 0; i < 5; i++) { if (result[i] == "Zafer") { if (l == 1) { result[i] = ":white_check_mark: Zafer"; } else { result[i] = ":white_check_mark: Win"; } } if (result[i] == "Bozgun") { if (l == 1) { result[i] = ":no_entry_sign: Bozgun"; } else { result[i] = ":no_entry_sign: Loss"; } } } EmbedFieldBuilder MyEmbedField = new EmbedFieldBuilder(); MyEmbedField.WithIsInline(true); MyEmbedField.WithName(result[0]); MyEmbedField.WithValue(kills[0] + "/" + deaths[0] + "/" + assists[0]); eb.AddField(MyEmbedField); EmbedFieldBuilder MyEmbedField2 = new EmbedFieldBuilder(); MyEmbedField2.WithIsInline(true); MyEmbedField2.WithName(result[1]); MyEmbedField2.WithValue(kills[1] + "/" + deaths[1] + "/" + assists[1]); eb.AddField(MyEmbedField2); EmbedFieldBuilder MyEmbedField3 = new EmbedFieldBuilder(); MyEmbedField3.WithIsInline(true); MyEmbedField3.WithName(result[2]); MyEmbedField3.WithValue(kills[2] + "/" + deaths[2] + "/" + assists[2]); eb.AddField(MyEmbedField3); EmbedFieldBuilder MyEmbedField4 = new EmbedFieldBuilder(); MyEmbedField4.WithIsInline(true); MyEmbedField4.WithName(result[3]); MyEmbedField4.WithValue(kills[3] + "/" + deaths[3] + "/" + assists[3]); eb.AddField(MyEmbedField4); EmbedFieldBuilder MyEmbedField5 = new EmbedFieldBuilder(); MyEmbedField5.WithIsInline(true); MyEmbedField5.WithName(result[4]); MyEmbedField5.WithValue(kills[4] + "/" + deaths[4] + "/" + assists[4]); eb.AddField(MyEmbedField5); EmbedFieldBuilder MyEmbedField6 = new EmbedFieldBuilder(); MyEmbedField6.WithIsInline(true); MyEmbedField6.WithName("..."); MyEmbedField6.WithValue("..."); eb.AddField(MyEmbedField6); eb.WithUrl("http://www.lolking.net/summoner/tr/" + riot.summonerid2); await Context.Channel.SendMessageAsync("", false, eb); // Task.Delay(5000); } catch (Exception e) { if (l == 1) { await Context.Channel.SendMessageAsync("```İşlemi gerçekleştirirken bir hata meydana geldi.\n" + e.Message + "\nHatanın kaynağı büyük ihtimal ile güncellenmemiş API anahtarı. \ndeveloper.riotgames.com```"); } else { await Context.Channel.SendMessageAsync("```Error: \n" + e.Message + "" + "\nProbably it caused by non updated API key. \ndeveloper.riotgames.com```"); } } }
static void SendDiscordWebhook(IList <Changelist> changeListsToSend, bool bUseGeneratedHtml) { foreach (Changelist changeList in changeListsToSend) { // TODO: Fix this uglyness string authorStr = changeList.OwnerName; string user1 = Environment.GetEnvironmentVariable("USER1"); string user2 = Environment.GetEnvironmentVariable("USER2"); string user3 = Environment.GetEnvironmentVariable("USER3"); string user4 = Environment.GetEnvironmentVariable("USER4"); string user5 = Environment.GetEnvironmentVariable("USER5"); string icon; if (authorStr == user1) { icon = Environment.GetEnvironmentVariable("U1ICON"); } else if (authorStr == user2) { icon = Environment.GetEnvironmentVariable("U2ICON"); } else if (authorStr == user3) { icon = Environment.GetEnvironmentVariable("U3ICON"); } else if (authorStr == user4) { icon = Environment.GetEnvironmentVariable("U4ICON"); } else if (authorStr == user5) { icon = Environment.GetEnvironmentVariable("U5ICON"); } else { icon = "https://cdn.discordapp.com/embed/avatars/0.png"; } // Discord.net.webhook ulong webhookId = Convert.ToUInt64(Environment.GetEnvironmentVariable("WEBHOOKID")); string webhookToken = Environment.GetEnvironmentVariable("WEBHOOKTOKEN"); DiscordWebhookClient discordWebhookClient = new DiscordWebhookClient(webhookId, webhookToken); EmbedAuthorBuilder author = new EmbedAuthorBuilder(); author .WithName(authorStr) .WithIconUrl(icon) .Build(); EmbedFooterBuilder footer = new EmbedFooterBuilder(); footer .WithIconUrl("https://i.imgur.com/qixMjRV.png") .WithText("Helix Core") .Build(); EmbedBuilder embedBuilder = new EmbedBuilder(); embedBuilder .WithAuthor(author) .WithFooter(footer) .WithColor(Color.Blue) .WithTitle("**" + changeList.Description + "**") .WithDescription(changeList.ClientId) .WithUrl(Environment.GetEnvironmentVariable("EMBEDURL")) .WithTimestamp(changeList.ModifiedDate) .WithThumbnailUrl(Environment.GetEnvironmentVariable("EMBEDTHUMB")); string rooturl = Environment.GetEnvironmentVariable("ROOTURL"); foreach (var file in changeList.Files) { string title = file.Action.ToString() + ' ' + file.Type.ToString(); int start = file.DepotPath.Path.LastIndexOf('/') + 1; string strippedPath = file.DepotPath.Path.Substring(start); string value = "[" + file.DepotPath.Path + '#' + file.HeadRev.ToString() + "]" + "(" + rooturl + "Diffs/" + strippedPath + '#' + file.HeadRev.ToString() + ")"; embedBuilder.AddField(title, value); } Embed embed = embedBuilder.Build(); string content = "Perforce change " + changeList.Id; IEnumerable <Embed> embeds = Enumerable.Repeat(embed, 1); discordWebhookClient.SendMessageAsync(content, false, embeds); } }
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); } }
public async Task NowPlaying(ICommand command) { try { var(settings, user) = await GetLastFmSettings(command["User"], (IGuildUser)command.Author); var client = new LastFmClient(settings.LastFmUsername, _integrationOptions.Value.LastFmKey); var topTracksTask = client.GetTopTracks(LastFmDataPeriod.Month, 100); var tracks = (await client.GetRecentTracks(count: 1)).ToList(); if (!tracks.Any()) { await command.Reply(GetNoScrobblesMessage((await command["User"].AsGuildUserOrName)?.Item2)); return; } var nowPlaying = tracks[0].NowPlaying; var current = await client.GetTrackInfo(tracks[0].Artist.Name, tracks[0].Name); // Description var description = new StringBuilder(); description.AppendLine($"**{FormatTrackLink(current ?? tracks[0].ToTrack())}** by **{FormatArtistLink(current?.Artist ?? tracks[0].Artist)}**"); if (!string.IsNullOrEmpty(current?.Album?.Name)) { description.AppendLine($"On {DiscordHelpers.BuildMarkdownUri(current.Album.Name, current.Album.Url)}"); } else if (!string.IsNullOrEmpty(tracks[0].Album?.Name)) { description.AppendLine($"On {tracks[0].Album.Name}"); } var embed = new EmbedBuilder() .WithDescription(description.ToString()) .WithColor(0xd9, 0x23, 0x23); // Image var imageUri = current?.Album?.ImageUri ?? tracks[0]?.Album?.ImageUri; if (imageUri != null) { embed.WithThumbnailUrl(imageUri.AbsoluteUri); } // Title var author = new EmbedAuthorBuilder().WithIconUrl(_websiteWalker.LfIconUrl); if (!settings.Anonymous) { author.WithUrl($"https://www.last.fm/user/{settings.LastFmUsername}"); } if (nowPlaying) { author.WithName($"{user} is now listening to..."); } else { author.WithName($"{user} last listened to..."); } embed.WithAuthor(author); // Playcount var playCount = (current?.Playcount ?? 0) + (nowPlaying ? 1 : 0); if (playCount == 1 && current?.Playcount != null) { embed.WithFooter($"First listen"); } else if (playCount > 1) { embed.WithFooter($"{playCount.ToEnglishOrdinal()} listen"); } // Month placement { var topTracks = await topTracksTask; int counter = 0, placement = 0, placementPlaycount = int.MaxValue; foreach (var track in topTracks) { counter++; if (placementPlaycount > track.Playcount) { placementPlaycount = track.Playcount.Value; placement = counter; } if (string.Compare(track.Url, (string)(current?.Url ?? tracks[0].Url), true) == 0) { var footer = placement == 1 ? "Most played track this month" : $"{placement.ToEnglishOrdinal()} most played this month"; if (embed.Footer != null) { embed.Footer.Text += " • " + footer; } else { embed.WithFooter(footer); } break; } } } // Previous if (nowPlaying && tracks.Count > 1) { var previous = tracks[1]; embed.AddField(x => x.WithName("Previous").WithValue($"{FormatTrackLink(previous?.ToTrack())} by {FormatArtistLink(previous?.Artist)}")); } await command.Reply(embed.Build()); } catch (WebException e) when((e.Response as HttpWebResponse)?.StatusCode == HttpStatusCode.NotFound) { ThrowUserNotFound((await command["User"].AsGuildUserOrName)?.Item2); } catch (WebException e) when((e.Response as HttpWebResponse)?.StatusCode == HttpStatusCode.Forbidden) { throw new CommandException("The bot can't access your recently listened tracks. \n\nPlease make sure you don't have `Hide recent listening information` checked in your Last.fm settings (Settings -> Privacy -> Recent listening)."); } catch (WebException e) { await command.Reply($"Last.fm is down (error {(e.Response as HttpWebResponse)?.StatusCode.ToString() ?? e.Status.ToString()}). Please try again in a few seconds."); } }
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()); }