public async Task UrbanAsync(EventContext e) { if (string.IsNullOrEmpty(e.arguments)) { return; } Locale locale = new Locale(e.Channel.Id); UrbanDictionaryApi api = new UrbanDictionaryApi(Global.Config.UrbanKey); UrbanDictionaryEntry entry = await api.GetEntryAsync(e.arguments); if (entry != null) { IDiscordEmbed embed = Utils.Embed .SetAuthor(entry.Term, "http://cdn9.staztic.com/app/a/291/291148/urban-dictionary-647813-l-140x140.png", "http://www.urbandictionary.com/define.php?term=" + e.arguments) .SetDescription(locale.GetString("miki_module_general_urban_author", entry.Author)); embed.AddInlineField(locale.GetString("miki_module_general_urban_definition"), entry.Definition); embed.AddInlineField(locale.GetString("miki_module_general_urban_example"), entry.Example); embed.AddInlineField(locale.GetString("miki_module_general_urban_rating"), "π " + entry.ThumbsUp + " π " + entry.ThumbsDown); embed.QueueToChannel(e.Channel); } else { e.ErrorEmbed(e.GetResource("error_term_invalid")) .QueueToChannel(e.Channel.Id); } }
public async Task UrbanAsync(EventContext e) { if (string.IsNullOrEmpty(e.arguments)) { return; } Locale locale = Locale.GetEntity(e.Channel.Id.ToDbLong()); UrbanDictionaryApi api = new UrbanDictionaryApi(Global.UrbanKey); UrbanDictionaryEntry entry = api.GetEntry(e.arguments); if (entry != null) { IDiscordEmbed embed = Utils.Embed .SetAuthor(entry.Term, "http://cdn9.staztic.com/app/a/291/291148/urban-dictionary-647813-l-140x140.png", "http://www.urbandictionary.com/define.php?term=" + e.arguments) .SetDescription(locale.GetString("miki_module_general_urban_author", entry.Author)); embed.AddInlineField(locale.GetString("miki_module_general_urban_definition"), entry.Definition); embed.AddInlineField(locale.GetString("miki_module_general_urban_example"), entry.Example); embed.AddInlineField(locale.GetString("miki_module_general_urban_rating"), "π " + entry.ThumbsUp + " π " + entry.ThumbsDown); await embed.SendToChannel(e.Channel); } else { await Utils.ErrorEmbed(locale, "This term couldn't been found!") .SendToChannel(e.Channel.Id); } }
public async Task ConfigAsync(EventContext e) { IModule module = e.commandHandler.GetModule(e.arguments); if (module != null) { IDiscordEmbed embed = Utils.Embed.SetTitle(e.arguments.ToUpper()); string content = ""; foreach (RuntimeCommandEvent ev in module.Events.OrderBy((x) => x.Name)) { content += (await ev.IsEnabled(e.Channel.Id) ? "<:iconenabled:341251534522286080>" : "<:icondisabled:341251533754728458>") + " " + ev.Name + "\n"; } embed.AddInlineField("Events", content); content = ""; foreach (IService ev in module.Services.OrderBy((x) => x.Name)) { content += (await ev.IsEnabled(e.Channel.Id) ? "<:iconenabled:341251534522286080>" : "<:icondisabled:341251533754728458>") + " " + ev.Name + "\n"; } if (!string.IsNullOrEmpty(content)) { embed.AddInlineField("Services", content); } embed.QueueToChannel(e.Channel); } }
public async Task IdentifyPasta(EventContext e) { Locale locale = Locale.GetEntity(e.Channel.Id.ToDbLong()); if (string.IsNullOrWhiteSpace(e.arguments)) { await Utils.ErrorEmbed(locale, e.GetResource("infopasta_error_no_arg")) .SendToChannel(e.Channel.Id); return; } using (var context = MikiContext.CreateNoCache()) { context.Set <GlobalPasta>().AsNoTracking(); try { GlobalPasta pasta = await context.Pastas.FindAsync(e.arguments); if (pasta == null) { await Utils.ErrorEmbed(locale, e.GetResource("miki_module_pasta_error_null")).SendToChannel(e.Channel); return; } User creator = await context.Users.FindAsync(pasta.creator_id); IDiscordEmbed b = Utils.Embed; b.SetAuthor(pasta.Id.ToUpper(), "", ""); b.Color = new IA.SDK.Color(47, 208, 192); if (creator != null) { b.AddInlineField(e.GetResource("miki_module_pasta_identify_created_by"), $"{ creator.Name} [{creator.Id}]"); } b.AddInlineField(e.GetResource("miki_module_pasta_identify_date_created"), pasta.date_created.ToShortDateString()); b.AddInlineField(e.GetResource("miki_module_pasta_identify_times_used"), pasta.TimesUsed.ToString()); VoteCount v = pasta.GetVotes(context); b.AddInlineField(e.GetResource("infopasta_rating"), $"β¬οΈ { v.Upvotes} β¬οΈ {v.Downvotes}"); await b.SendToChannel(e.Channel); } catch (Exception ex) { Log.ErrorAt("IdentifyPasta", ex.Message); } } }
public async Task AchievementsAsync(EventContext e) { using (var context = new MikiContext()) { Args args = new Args(e.arguments); ArgObject argument = args.First(); long id = (long)e.Author.Id; if (argument != null) { IDiscordUser user = await args.Join().GetUserAsync(e.Guild); if (user != null) { id = (long)user.Id; } } IDiscordUser discordUser = await e.Guild.GetUserAsync(id.FromDbLong()); User u = await User.GetAsync(context, discordUser); List <Achievement> achievements = await context.Achievements .Where(x => x.Id == id) .ToListAsync(); IDiscordEmbed embed = Utils.Embed .SetColor(255, 255, 255) .SetAuthor($"{u.Name} | " + "Achievements", discordUser.AvatarUrl, "https://miki.ai/profiles/ID/achievements"); StringBuilder leftBuilder = new StringBuilder(); int totalScore = 0; foreach (var a in achievements) { BaseAchievement metadata = AchievementManager.Instance.GetContainerById(a.Name).Achievements[a.Rank]; leftBuilder.AppendLine(metadata.Icon + " | `" + metadata.Name.PadRight(15) + $"{metadata.Points.ToString().PadLeft(3)} pts` | Γ°ΕΈββ¦ {a.UnlockedAt.ToShortDateString()}"); totalScore += metadata.Points; } if (string.IsNullOrEmpty(leftBuilder.ToString())) { embed.AddInlineField("Total Pts: " + totalScore, "None, yet."); } else { embed.AddInlineField("Total Pts: " + totalScore, leftBuilder.ToString()); } embed.QueueToChannel(e.Channel); } }
public async Task GuildProfile(EventContext context) { using (MikiContext database = new MikiContext()) { GuildUser g = await database.GuildUsers.FindAsync(context.Guild.Id.ToDbLong()); if (g == null) { await GuildUser.Create(context.Guild); g = await database.GuildUsers.FindAsync(context.Guild.Id.ToDbLong()); } int rank = g.GetGlobalRank(); int level = g.CalculateLevel(g.Experience); EmojiBarSet onBarSet = new EmojiBarSet("<:mbaronright:334479818924228608>", "<:mbaronmid:334479818848468992>", "<:mbaronleft:334479819003789312>"); EmojiBarSet offBarSet = new EmojiBarSet("<:mbaroffright:334479818714513430>", "<:mbaroffmid:334479818504536066>", "<:mbaroffleft:334479818949394442>"); EmojiBar expBar = new EmojiBar(g.CalculateMaxExperience(g.Experience), onBarSet, offBarSet, 6); IDiscordEmbed embed = Utils.Embed .SetAuthor(g.Name, context.Guild.AvatarUrl, "https://miki.veld.one") .SetColor(0.1f, 0.6f, 1) .SetThumbnailUrl("http://veld.one/assets/img/transparentfuckingimage.png") .AddInlineField(context.GetResource("miki_terms_level"), level.ToString()); string expBarString = await expBar.Print(g.Experience, context.Channel); if (string.IsNullOrWhiteSpace(expBarString)) { embed.AddInlineField(context.GetResource("miki_terms_experience"), "[" + g.Experience + " / " + g.CalculateMaxExperience(g.Experience) + "]"); } else { embed.AddInlineField(context.GetResource("miki_terms_experience") + $" [{g.Experience} / {g.CalculateMaxExperience(g.Experience)}]", expBarString); } embed.AddInlineField(context.GetResource("miki_terms_rank"), "#" + ((rank <= 10) ? $"**{rank}**" : rank.ToString())) .AddInlineField(context.GetResource("miki_module_general_guildinfo_users"), g.UserCount.ToString()); if (g.RivalId != 0) { GuildUser rival = await g.GetRival(); embed.AddInlineField(context.GetResource("miki_terms_rival"), $"{rival.Name} [{rival.Experience}]"); } await embed.SendToChannel(context.Channel); } }
public async Task GuildTop(EventContext e) { int amountToSkip = 0; int amountToTake = 12; int.TryParse(e.arguments, out amountToSkip); using (var context = new MikiContext()) { List <GuildUser> leaderboards = context.GuildUsers.OrderByDescending(x => x.Experience) .Skip(amountToSkip * amountToTake) .Take(amountToTake) .ToList(); IDiscordEmbed embed = Utils.Embed .SetTitle(e.GetResource("guildtop_title")); foreach (GuildUser i in leaderboards) { embed.AddInlineField(i.Name, i.Experience.ToString()); } embed.SetFooter(e.GetResource("pasta_page_index", amountToSkip, "#"), null); await embed.SendToChannel(e.Channel); } }
public async Task WhoIsAsync(EventContext e) { ulong id = 0; if (string.IsNullOrEmpty(e.arguments)) { id = e.Author.Id; } else if (e.message.MentionedUserIds.Count == 0) { id = ulong.Parse(e.arguments); } else { id = e.message.MentionedUserIds.First(); } IDiscordUser user = await e.Guild.GetUserAsync(id); Locale l = Locale.GetEntity(e.Channel.Id.ToDbLong()); IDiscordEmbed embed = Utils.Embed; embed.Title = $"Who is {(string.IsNullOrEmpty(user.Nickname) ? user.Username : user.Nickname)}!?"; embed.Color = new Color(0.5f, 0, 1); embed.ImageUrl = (await e.Guild.GetUserAsync(id)).AvatarUrl; embed.AddInlineField( l.GetString("miki_module_whois_tag_personal"), $"User Id : **{user.Id}**\nUsername: **{user.Username}#{user.Discriminator} {(string.IsNullOrEmpty(user.Nickname) ? "" : $"({user.Nickname})")}**\nCreated at: **{user.CreatedAt.ToString()}**\nJoined at : **{user.JoinedAt.ToString()}**\n");
public async Task AchievementsAsync(EventContext e) { using (var context = new MikiContext()) { long id = (e.message.MentionedUserIds.Count > 0) ? e.message.MentionedUserIds.First().ToDbLong() : e.Author.Id.ToDbLong(); User u = await context.Users.FindAsync(id); IDiscordUser discordUser = await e.Guild.GetUserAsync(id.FromDbLong()); List <Achievement> achievements = await context.Achievements .Where(x => x.Id == id) .ToListAsync(); IDiscordEmbed embed = Utils.Embed; embed.SetAuthor(u.Name + " | " + "Achievements", discordUser.AvatarUrl, "https://miki.ai/profiles/ID/achievements"); StringBuilder leftBuilder = new StringBuilder(); int totalScore = 0; foreach (var a in achievements) { BaseAchievement metadata = AchievementManager.Instance.GetContainerById(a.Name).Achievements[a.Rank]; leftBuilder.AppendLine(metadata.Icon + " | `" + metadata.Name.PadRight(15) + $"{metadata.Points.ToString().PadLeft(3)} pts` | Γ°ΕΈββ¦ {a.UnlockedAt.ToShortDateString()}"); totalScore += metadata.Points; } await embed.AddInlineField("Total Pts: " + totalScore, leftBuilder.ToString()) .SendToChannel(e.Channel); } }
public async Task SpellCheckAsync(EventContext context) { IDiscordEmbed embed = Utils.Embed; embed.SetTitle("Spellcheck - top results"); API.StringComparison.StringComparer sc = new API.StringComparison.StringComparer(context.commandHandler.GetAllEventNames()); List <API.StringComparison.StringComparison> best = sc.CompareToAll(context.arguments) .OrderBy(z => z.score) .ToList(); int x = 1; foreach (API.StringComparison.StringComparison c in best) { embed.AddInlineField($"#{x}", c); x++; if (x > 16) { break; } } embed.QueueToChannel(context.Channel); await Task.Yield(); }
public async Task StatsAsync(EventContext e) { TimeSpan timeSinceStart = DateTime.Now.Subtract(Program.timeSinceStartup); IDiscordEmbed embed = Utils.Embed; embed.Title = "βοΈ Miki stats"; embed.Description = e.GetResource("stats_description"); embed.Color = new IA.SDK.Color(0.3f, 0.8f, 1); embed.AddInlineField($"π₯οΈ {e.GetResource("discord_servers")}", Bot.instance.Client.Guilds.Count.ToString()); embed.AddInlineField("π¬ Commands", Bot.instance.Events.CommandsUsed().ToString()); embed.AddInlineField("β° Uptime", timeSinceStart.ToTimeString(e.Channel.GetLocale())); await embed.SendToChannel(e.Channel); }
public async Task GuildTop(EventContext e) { int amountToTake = 12; int.TryParse(e.arguments, out int amountToSkip); using (var context = new MikiContext()) { int totalGuilds = (int)Math.Ceiling((double)await context.GuildUsers.CountAsync() / amountToTake); List <GuildUser> leaderboards = await context.GuildUsers.OrderByDescending(x => x.Experience) .Skip(amountToSkip * amountToTake) .Take(amountToTake) .ToListAsync(); IDiscordEmbed embed = Utils.Embed .SetTitle(e.GetResource("guildtop_title")); foreach (GuildUser i in leaderboards) { embed.AddInlineField(i.Name, i.Experience.ToString()); } embed.SetFooter(e.GetResource("page_index", amountToSkip + 1, totalGuilds), null); await embed.QueueToChannel(e.Channel); } }
public async Task StatsAsync(EventContext e) { TimeSpan timeSinceStart = DateTime.Now.Subtract(Program.timeSinceStartup); IDiscordEmbed embed = Utils.Embed; embed.Title = "βοΈ Miki stats"; embed.Description = e.GetResource("stats_description"); embed.Color = new IA.SDK.Color(0.3f, 0.8f, 1); embed.AddInlineField($"π₯οΈ {e.GetResource("discord_servers")}", Bot.instance.Client.Guilds.Count.ToString()); embed.AddInlineField("π¬ " + e.GetResource("term_commands"), Bot.instance.Events.CommandsUsed().ToString()); embed.AddInlineField("β° Uptime", timeSinceStart.ToTimeString(e.Channel.GetLocale())); embed.AddInlineField("More info", "https://p.datadoghq.com/sb/01d4dd097-08d1558da4"); await embed.QueueToChannel(e.Channel); }
public static IDiscordEmbed RenderLeaderboards(IDiscordEmbed embed, List <LeaderboardsItem> items) { for (int i = 0; i < (items.Count > 12 ? 12 : items.Count); i++) { embed.AddInlineField($"#{i+1}: " + items[i].Name, items[i].Value); } return(embed); }
public static IDiscordEmbed RenderLeaderboards(IDiscordEmbed embed, List <LeaderboardsItem> items, int offset) { for (int i = 0; i < Math.Min(items.Count, 12); i++) { embed.AddInlineField($"#{offset + i + 1}: " + items[i].Name, string.Format("{0:n0}", items[i].Value)); } return(embed); }
public async Task IdentifyPasta(EventContext e) { Locale locale = Locale.GetEntity(e.Channel.Id.ToDbLong()); if (string.IsNullOrWhiteSpace(e.arguments)) { await Utils.ErrorEmbed(locale, e.GetResource("infopasta_error_no_arg")) .QueueToChannel(e.Channel.Id); return; } using (var context = new MikiContext()) { GlobalPasta pasta = await context.Pastas.FindAsync(e.arguments); if (pasta == null) { await Utils.ErrorEmbed(locale, e.GetResource("miki_module_pasta_error_null")).QueueToChannel(e.Channel); return; } User creator = await context.Users.FindAsync(pasta.CreatorId); IDiscordEmbed b = Utils.Embed; b.SetAuthor(pasta.Id.ToUpper(), "", ""); b.Color = new Color(47, 208, 192); if (creator != null) { b.AddInlineField(e.GetResource("miki_module_pasta_identify_created_by"), $"{ creator.Name} [{creator.Id}]"); } b.AddInlineField(e.GetResource("miki_module_pasta_identify_date_created"), pasta.CreatedAt.ToShortDateString()); b.AddInlineField(e.GetResource("miki_module_pasta_identify_times_used"), pasta.TimesUsed.ToString()); VoteCount v = await pasta.GetVotesAsync(context); b.AddInlineField(e.GetResource("infopasta_rating"), $"β¬οΈ { v.Upvotes} β¬οΈ {v.Downvotes}"); await b.QueueToChannel(e.Channel); } }
public async Task GuildInfoAsync(EventContext e) { IDiscordEmbed embed = Utils.Embed; Locale l = Locale.GetEntity(e.Channel.Id.ToDbLong()); embed.SetAuthor(e.Guild.Name, e.Guild.AvatarUrl, e.Guild.AvatarUrl); IDiscordUser owner = await e.Guild.GetOwnerAsync(); embed.AddInlineField( "π" + l.GetString("miki_module_general_guildinfo_owned_by"), owner.Username + "#" + owner.Discriminator); embed.AddInlineField( "π" + l.GetString("miki_label_prefix"), await PrefixInstance.Default.GetForGuildAsync(e.Guild.Id)); embed.AddInlineField( "πΊ" + l.GetString("miki_module_general_guildinfo_channels"), (await e.Guild.GetChannelCountAsync()).ToString()); embed.AddInlineField( "π" + l.GetString("miki_module_general_guildinfo_voicechannels"), (await e.Guild.GetVoiceChannelCountAsync()).ToString()); embed.AddInlineField( "π" + l.GetString("miki_module_general_guildinfo_users"), (await e.Guild.GetUserCountAsync()).ToString()); embed.AddInlineField( "π€" + l.GetString("term_shard"), Bot.instance.Client.GetShardIdFor((e.Guild as IProxy <IGuild>).ToNativeObject())); List <string> roleNames = new List <string>(); foreach (IDiscordRole r in e.Guild.Roles) { roleNames.Add($"`{r.Name}`"); } embed.AddInlineField( "#β£" + l.GetString("miki_module_general_guildinfo_roles_count"), e.Guild.Roles.Count.ToString()); string roles = string.Join(", ", roleNames); if (roles.Length <= 1000) { embed.AddInlineField( "π" + l.GetString("miki_module_general_guildinfo_roles"), roles); } await embed.QueueToChannel(e.Channel); }
[Command(Name = "steamhelp")] // TODO: Kill this command. >help steam should be used instead. public async Task SteamHelpAsync(EventContext context) { IDiscordEmbed embed = Utils.Embed; embed.SetAuthor(steamAuthorName, steamAuthorIcon, ""); embed.Description = "Steam API at your fingertips."; embed.AddInlineField("Commands", "`>steam` \n`>steam user <vanity/steam64>`"); embed.QueueToChannel(context.Channel); }
public async Task GuildProfile(EventContext e) { using (MikiContext context = new MikiContext()) { GuildUser g = await GuildUser.GetAsync(context, e.Guild); int rank = g.GetGlobalRank(); int level = g.CalculateLevel(g.Experience); EmojiBarSet onBarSet = new EmojiBarSet("<:mbarlefton:391971424442646534>", "<:mbarmidon:391971424920797185>", "<:mbarrighton:391971424488783875>"); EmojiBarSet offBarSet = new EmojiBarSet("<:mbarleftoff:391971424824459265>", "<:mbarmidoff:391971424824197123>", "<:mbarrightoff:391971424862208000>"); EmojiBar expBar = new EmojiBar(g.CalculateMaxExperience(g.Experience), onBarSet, offBarSet, 6); IDiscordEmbed embed = Utils.Embed .SetAuthor(g.Name, e.Guild.AvatarUrl, "https://miki.veld.one") .SetColor(0.1f, 0.6f, 1) .SetThumbnailUrl("http://veld.one/assets/img/transparentfuckingimage.png") .AddInlineField(e.GetResource("miki_terms_level"), level.ToString()); string expBarString = await expBar.Print(g.Experience, e.Channel); if (string.IsNullOrWhiteSpace(expBarString)) { embed.AddInlineField(e.GetResource("miki_terms_experience"), "[" + g.Experience + " / " + g.CalculateMaxExperience(g.Experience) + "]"); } else { embed.AddInlineField(e.GetResource("miki_terms_experience") + $" [{g.Experience} / {g.CalculateMaxExperience(g.Experience)}]", expBarString); } embed.AddInlineField(e.GetResource("miki_terms_rank"), "#" + ((rank <= 10) ? $"**{rank}**" : rank.ToString())) .AddInlineField(e.GetResource("miki_module_general_guildinfo_users"), g.UserCount.ToString()); if (g.RivalId != 0) { GuildUser rival = await g.GetRival(); embed.AddInlineField(e.GetResource("miki_terms_rival"), $"{rival.Name} [{rival.Experience}]"); } await embed.QueueToChannel(e.Channel); } }
public async Task GetUserSeason(EventContext e) { int platform = 1; string[] arg = e.arguments.Split(' '); int seasonId = int.Parse(arg[1]); if (arg.Length > 2) { platform = GetPlatform(arg[2]); } IDiscordEmbed embed = Utils.Embed; RocketLeagueUser user = await TryGetUser(arg[0], platform); if (user == null) { embed.Title = "Uh oh!"; embed.Description = $"We couldn't find a user with the name `{arg[0]}`. Please look up yourself on https://rlstats.com/ to create your profile!"; embed.ThumbnailUrl = "http://miki.veld.one/assets/img/rlstats-logo.png"; await embed.QueueToChannel(e.Channel); return; } embed.Title = $"{user.DisplayName}'s Season {arg[1]}"; if (user.RankedSeasons.ContainsKey(seasonId)) { Dictionary <int, RocketLeagueRankedStats> rankedseason = user.RankedSeasons[seasonId]; foreach (RocketLeaguePlaylist playlist in api.playlists.Data) { if (rankedseason.ContainsKey(playlist.Id)) { if (playlist.PlatformId == platform) { RocketLeagueRankedStats stats = rankedseason[playlist.Id]; string rank = ""; RocketLeagueTier t = api.tiers.Data.Find(z => { return(z.Id == stats.Tier); }); if (t != null) { rank = t.Name + " " + stats.Division; embed.AddInlineField(playlist.Name.Substring(7), $"Rank: {rank}\n\nMMR: {stats.RankPoints}\nMatches Played: {stats.MatchesPlayed}"); } } } } } await embed.QueueToChannel(e.Channel); }
public AccountManager(IBot bot) { OnGlobalLevelUp += async(a, e, l) => { await Task.Yield(); DogStatsd.Counter("levels.global", l); }; OnLocalLevelUp += async(a, e, l) => { DogStatsd.Counter("levels.local", l); long guildId = (long)e.Guild.Id; Locale locale = new Locale(e.Id); List <LevelRole> rolesObtained = new List <LevelRole>(); using (var context = new MikiContext()) { rolesObtained = await context.LevelRoles .Where(p => p.GuildId == guildId && p.RequiredLevel == l && p.Automatic) .ToListAsync(); } await a.AddRolesAsync(rolesObtained.Select(x => x.Role).ToArray()); var setting = await Setting.GetAsync <LevelNotificationsSetting>(e.Id, DatabaseSettingId.LEVEL_NOTIFICATIONS); if (setting == LevelNotificationsSetting.NONE) { return; } if (setting == LevelNotificationsSetting.REWARDS_ONLY && rolesObtained.Count == 0) { return; } IDiscordEmbed embed = Utils.Embed .SetTitle(locale.GetString("miki_accounts_level_up_header")) .SetDescription(locale.GetString("miki_accounts_level_up_content", $"{a.Username}#{a.Discriminator}", l)) .SetColor(1, 0.7f, 0.2f); if (rolesObtained.Count > 0) { embed.AddInlineField("Rewards", string.Join("\n", rolesObtained.Select(x => $"New Role: **{x.Role.Name}**"))); } embed.QueueToChannel(e); }; bot.GuildUpdate += Client_GuildUpdated; bot.GuildJoin += Client_UserJoined; bot.GuildLeave += Client_UserLeft; }
public async Task GetUser(EventContext e) { string[] arg = e.arguments.Split(' '); int platform = 1; if (arg.Length > 1) { platform = GetPlatform(arg[1]); } IDiscordEmbed embed = Utils.Embed; RocketLeagueUser user = await TryGetUser(arg[0], platform); if (user == null) { embed.Title = "Uh oh!"; embed.Description = $"We couldn't find a user with the name `{arg[0]}`. Please look up yourself on https://rlstats.com/ to create your profile!"; embed.ThumbnailUrl = "http://miki.veld.one/assets/img/rlstats-logo.png"; await embed.QueueToChannel(e.Channel); return; } embed.Title = user.DisplayName; foreach (RocketLeagueSeason season in api.seasons.Data) { if (user.RankedSeasons.ContainsKey(season.Id)) { Dictionary <int, RocketLeagueRankedStats> rankedseason = user.RankedSeasons[season.Id]; string s = ""; foreach (RocketLeaguePlaylist playlist in api.playlists.Data) { if (rankedseason.ContainsKey(playlist.Id)) { if (playlist.PlatformId == platform) { RocketLeagueRankedStats stats = rankedseason[playlist.Id]; s += "`" + playlist.Name.Substring(7).PadRight(13) + ":` " + stats.RankPoints.ToString() + " MMR\n"; } } } embed.AddInlineField("Season" + season.Id, s); } } embed.ThumbnailUrl = user.AvatarUrl; embed.ImageUrl = user.SignatureUrl; await embed.QueueToChannel(e.Channel); }
public async Task DumpShards(EventContext context) { IDiscordEmbed embed = Utils.Embed; embed.Title = "Shards"; foreach (DiscordSocketClient c in Bot.instance.Client.Shards) { embed.AddInlineField("Shard " + c.ShardId, $"State: {c.ConnectionState}\nPing: {c.Latency}\nGuilds: {c.Guilds.Count}"); } await embed.SendToChannel(context.Channel); }
public async Task DoPastaLeaderboardsLove(EventContext context) { using (var d = new MikiContext()) { List <LeaderboardsItem> leaderboards = d.Database.SqlQuery <LeaderboardsItem>("select TOP 12 Id as Name, ((SELECT Count(*) from Votes where Id = c.Id AND PositiveVote = 1) - (SELECT Count(*) from Votes where Id = c.Id AND PositiveVote = 0)) as Value from dbo.GlobalPastas as c order by Value DESC").ToList(); IDiscordEmbed e = Utils.Embed .SetTitle("Top pastas") .SetColor(new IA.SDK.Color(1, 0, 0)); foreach (LeaderboardsItem t in leaderboards) { e.AddInlineField(t.Name, (t == leaderboards.First() ? "π " + t.Value.ToString() : (t.Value < 0 ? "π " : "β€ ") + t.Value.ToString())); } await e.SendToChannel(context.Channel.Id); } }
public async Task DoPastaLeaderboardsPopular(EventContext context) { using (var d = new MikiContext()) { List <LeaderboardsItem> leaderboards = d.Database.SqlQuery <LeaderboardsItem>("select TOP 12 Id as Name, TimesUsed as Value from dbo.GlobalPastas as c order by Value DESC").ToList(); IDiscordEmbed e = Utils.Embed .SetTitle("Most popular pastas") .SetColor(new IA.SDK.Color(1, 0.6f, 0.2f)); foreach (LeaderboardsItem t in leaderboards) { e.AddInlineField(t.Name, (t == leaderboards.First() ? "π " + t.Value.ToString() : "β¨ " + t.Value.ToString())); } await e.SendToChannel(context.Channel.Id); } }
public async Task DoPastaLeaderboardsPopular(EventContext context) { using (var d = new MikiContext()) { List <GlobalPasta> leaderboards = d.Pastas.OrderByDescending(x => x.TimesUsed) .Take(12) .ToList(); IDiscordEmbed e = Utils.Embed .SetTitle(context.GetResource("poppasta_title")) .SetColor(new IA.SDK.Color(1, 0.6f, 0.2f)); foreach (GlobalPasta t in leaderboards) { e.AddInlineField(t.Id, (t == leaderboards.First() ? "π " + t.TimesUsed.ToString() : "β¨ " + t.TimesUsed.ToString())); } await e.SendToChannel(context.Channel.Id); } }
public async Task GuildInfoAsync(EventContext e) { IDiscordEmbed embed = Utils.Embed; Locale l = Locale.GetEntity(e.Channel.Id.ToDbLong()); embed.SetAuthor(e.Guild.Name, e.Guild.AvatarUrl, e.Guild.AvatarUrl); embed.AddInlineField( "π" + l.GetString("miki_module_general_guildinfo_owned_by"), e.Guild.Owner.Username + "#" + e.Guild.Owner.Discriminator); embed.AddInlineField( "π" + l.GetString("miki_label_prefix"), await PrefixInstance.Default.GetForGuildAsync(e.Guild.Id)); embed.AddInlineField( "πΊ" + l.GetString("miki_module_general_guildinfo_channels"), e.Guild.ChannelCount.ToString()); embed.AddInlineField( "π" + l.GetString("miki_module_general_guildinfo_voicechannels"), e.Guild.VoiceChannelCount.ToString()); embed.AddInlineField( "π" + l.GetString("miki_module_general_guildinfo_users"), e.Guild.UserCount.ToString()); List <string> roleNames = new List <string>(); foreach (IDiscordRole r in e.Guild.Roles) { roleNames.Add($"`{r.Name}`"); } embed.AddInlineField( "#β£" + l.GetString("miki_module_general_guildinfo_roles_count"), e.Guild.Roles.Count.ToString()); embed.AddInlineField( "π" + l.GetString("miki_module_general_guildinfo_roles"), string.Join(", ", roleNames)); await embed.SendToChannel(e.Channel); }
public async Task DoPastaLeaderboardsLove(EventContext context) { using (var d = new MikiContext()) { List <GlobalPasta> leaderboards = d.Pastas.OrderByDescending(x => d.Votes.Where(p => p.Id == x.Id).Count()) .Take(12) .ToList(); IDiscordEmbed e = Utils.Embed .SetTitle(context.GetResource("toppasta_title")) .SetColor(new IA.SDK.Color(1, 0, 0)); foreach (GlobalPasta t in leaderboards) { int amount = d.Votes.Where(p => p.Id == t.Id).Count(); e.AddInlineField(t.Id, (t == leaderboards.First() ? "π " + amount : (amount < 0 ? "π " : "β€ ") + amount)); } await e.SendToChannel(context.Channel.Id); } }
public async Task HelpAsync(EventContext e) { Locale locale = Locale.GetEntity(e.Channel.Id.ToDbLong()); if (!string.IsNullOrEmpty(e.arguments)) { ICommandEvent ev = Bot.instance.Events.CommandHandler.GetCommandEvent(e.arguments); if (ev == null) { IDiscordEmbed helpListEmbed = Utils.Embed; helpListEmbed.Title = locale.GetString("miki_module_help_error_null_header"); helpListEmbed.Description = locale.GetString("miki_module_help_error_null_message", await Bot.instance.Events.GetPrefixInstance(">").GetForGuildAsync(e.Guild.Id)); helpListEmbed.Color = new Color(1.0f, 0, 0); API.StringComparison.StringComparer comparer = new API.StringComparison.StringComparer(e.commandHandler.GetAllEventNames()); API.StringComparison.StringComparison best = comparer.GetBest(e.arguments); helpListEmbed.AddField(locale.GetString("miki_module_help_didyoumean"), best.text); await helpListEmbed.SendToChannel(e.Channel); } else { if (Bot.instance.Events.CommandHandler.GetUserAccessibility(e.message) < ev.Accessibility) { return; } IDiscordEmbed explainedHelpEmbed = Utils.Embed .SetTitle(ev.Name.ToUpper()); if (ev.Aliases.Length > 0) { explainedHelpEmbed.AddInlineField( locale.GetString("miki_module_general_help_aliases"), string.Join(", ", ev.Aliases)); } explainedHelpEmbed.AddField( locale.GetString("miki_module_general_help_description"), (locale.HasString("miki_command_description_" + ev.Name.ToLower())) ? locale.GetString("miki_command_description_" + ev.Name.ToLower()) : locale.GetString("miki_placeholder_null")); explainedHelpEmbed.AddField( locale.GetString("miki_module_general_help_usage"), (locale.HasString("miki_command_usage_" + ev.Name.ToLower())) ? locale.GetString("miki_command_usage_" + ev.Name.ToLower()) : locale.GetString("miki_placeholder_null")); await explainedHelpEmbed.SendToChannel(e.Channel); } return; } IDiscordEmbed embed = Utils.Embed; embed.Description = locale.GetString("miki_module_general_help_dm"); embed.Color = new Color(0, 0.5f, 1); await embed.SendToChannel(e.Channel); await(await Bot.instance.Events.ListCommandsInEmbedAsync(e.message)).SendToUser(e.Author); }
public async Task ShowLeaderboardsAsync(IDiscordMessage e, LeaderboardsType t = LeaderboardsType.Experience) { using (var context = new MikiContext()) { IDiscordEmbed embed = Utils.Embed; Locale locale = Locale.GetEntity(e.Channel.Id.ToDbLong()); switch (t) { case LeaderboardsType.Commands: { embed.Title = locale.GetString("miki_module_accounts_leaderboards_commands_header"); embed.Color = new IA.SDK.Color(0.4f, 1.0f, 0.6f); List <User> output = context.Users.OrderByDescending(x => x.Total_Commands) .Take(12) .ToList(); int i = 1; foreach (User user in output) { embed.AddInlineField($"#{i}: {string.Join("", user.Name.Take(16))}", $"{user.Total_Commands} commands used!"); i++; } await embed.SendToChannel(e.Channel); } break; case LeaderboardsType.Currency: { embed.Title = locale.GetString("miki_module_accounts_leaderboards_mekos_header"); embed.Color = new IA.SDK.Color(1.0f, 0.6f, 0.4f); List <User> output = context.Users.OrderByDescending(x => x.Currency) .Take(12) .ToList(); int i = 1; foreach (User user in output) { embed.AddInlineField($"#{i}: {string.Join("", user.Name.Take(16))}", $"{user.Currency} mekos!"); i++; } await embed.SendToChannel(e.Channel); } break; case LeaderboardsType.LocalExperience: { embed.Title = locale.GetString("miki_module_accounts_leaderboards_local_header"); embed.Color = new IA.SDK.Color(1.0f, 0.6f, 0.4f); long guildId = e.Guild.Id.ToDbLong(); List <LocalExperience> output = context.Experience.Where(x => x.ServerId == guildId).OrderByDescending(x => x.Experience).ToList(); List <User> users = context.Users.Where(x => output.Any(y => y.UserId == x.Id)).ToList(); int i = 1; foreach (User user in users) { embed.AddInlineField($"#{i}: {string.Join("", user.Name.Take(16))}", $"{output.Find(x => x.UserId == user.Id).Experience} experience!"); i++; } await embed.SendToChannel(e.Channel); } break; case LeaderboardsType.Experience: { embed.Title = locale.GetString("miki_module_accounts_leaderboards_header"); embed.Color = new IA.SDK.Color(1.0f, 0.6f, 0.4f); List <User> output = context.Users.OrderByDescending(x => x.Total_Experience) .Take(12) .ToList(); int i = 1; foreach (User user in output) { embed.AddInlineField($"#{i}: {string.Join("", user.Name.Take(16))}", $"{user.Total_Experience} experience!"); i++; } await embed.SendToChannel(e.Channel); } break; } } }