public async Task DeleteChannel(CommandContext ctx, [Description("Channel to delete.")][RemainingText] DiscordChannel channel = null) { // Set the current channel for deletion if one isn't provided by the user channel ??= ctx.Channel; var prompt = await ctx .RespondAsync("You're about to delete the " + Formatter.Bold(channel.ToString()) + "\nRespond with **yes** if you want to proceed or wait 10 seconds to cancel the operation.") .ConfigureAwait(false); var interactivity = await BotServices.GetUserInteractivity(ctx, "yes", 10).ConfigureAwait(false); if (interactivity.Result is null) { await ctx.RespondAsync(Resources.INFO_REQ_TIMEOUT).ConfigureAwait(false); return; } await BotServices.RemoveMessage(interactivity.Result).ConfigureAwait(false); await BotServices.RemoveMessage(prompt).ConfigureAwait(false); await ctx.RespondAsync("Successfully deleted " + Formatter.Bold(channel.Name)).ConfigureAwait(false); await channel.DeleteAsync().ConfigureAwait(false); }
public async Task PruneUsers(CommandContext ctx, [Description("Number of days the user had to be inactive to get pruned")][RemainingText] int days = 7) { if (days < 1 || days > 30) { await BotServices.SendEmbedAsync(ctx, "Number of days must be between 1 and 30", EmbedType.Warning).ConfigureAwait(false); } int count = await ctx.Guild.GetPruneCountAsync(days).ConfigureAwait(false); if (count == 0) { await ctx.RespondAsync("No inactive members found to prune").ConfigureAwait(false); return; } var prompt = await ctx.RespondAsync($"Pruning will remove {Formatter.Bold(count.ToString())} member(s).\nRespond with **yes** to continue.").ConfigureAwait(false); var interactivity = await BotServices.GetUserInteractivity(ctx, "yes", 10).ConfigureAwait(false); if (interactivity.Result is null) { return; } await BotServices.RemoveMessage(interactivity.Result).ConfigureAwait(false); await BotServices.RemoveMessage(prompt).ConfigureAwait(false); await ctx.Guild.PruneAsync(days).ConfigureAwait(false); }
public async Task Say(CommandContext ctx, [Description("Message for the bot to repeat")][RemainingText] string message) { await BotServices.RemoveMessage(ctx.Message).ConfigureAwait(false); await ctx.RespondAsync(message ?? ":thinking:").ConfigureAwait(false); }
public async Task UrbanDictionary(CommandContext ctx, [Description("Word or phrase to find on Urban Dictionary.")][RemainingText] string query) { if (string.IsNullOrWhiteSpace(query)) { return; } await ctx.TriggerTypingAsync(); var results = await DictionaryService.GetDictionaryDefinitionAsync(query).ConfigureAwait(false); if (results.ResultType == "no_results" || results.List.Count == 0) { await BotServices.SendResponseAsync(ctx, Resources.NOT_FOUND_COMMON, ResponseType.Missing) .ConfigureAwait(false); return; } foreach (var definition in results.List) { var output = new DiscordEmbedBuilder() .WithTitle("Urban Dictionary definition for " + Formatter.Bold(query)) .WithDescription(!string.IsNullOrWhiteSpace(definition.Author) ? "Submitted by: " + definition.Author : string.Empty) .AddField("Definition", definition.Definition.Length < 500 ? definition.Definition : definition.Definition.Take(500) + "...") .AddField("Example", definition.Example ?? "None") .AddField(":thumbsup:", definition.ThumbsUp.ToString(), true) .AddField(":thumbsdown:", definition.ThumbsDown.ToString(), true) .WithUrl(definition.Permalink) .WithFooter(!definition.Equals(results.List.Last()) ? "Type 'next' within 10 seconds for the next definition." : "This is the last found definition on the list.") .WithColor(new DiscordColor("#1F2439")); var message = await ctx.RespondAsync(output.Build()).ConfigureAwait(false); if (results.List.Count == 1) { continue; } var interactivity = await BotServices.GetUserInteractivity(ctx, "next", 10).ConfigureAwait(false); if (interactivity.Result is null) { break; } await BotServices.RemoveMessage(interactivity.Result).ConfigureAwait(false); if (!definition.Equals(results.List.Last())) { await BotServices.RemoveMessage(message).ConfigureAwait(false); } } }
public async Task Pokemon(CommandContext ctx, [Description("Name of the Pokémon")][RemainingText] string query) { var results = await PokemonService.GetPokemonCardsAsync(query).ConfigureAwait(false); if (results.Cards.Count == 0) { await BotServices.SendEmbedAsync(ctx, Resources.NOT_FOUND_GENERIC, EmbedType.Missing).ConfigureAwait(false); } else { foreach (var dex in results.Cards) { var card = PokemonService.GetExactPokemon(dex.ID); var output = new DiscordEmbedBuilder() .WithTitle(card.Name) .WithDescription("Pokédex ID: " + card.NationalPokedexNumber.ToString() ?? "Unknown") .AddField("Series", card.Series ?? "Unknown", true) .AddField("Rarity", card.Rarity ?? "Unknown", true) .AddField("HP", card.Hp ?? "Unknown", true) .AddField("Ability", (card.Ability != null) ? card.Ability.Name : "Unknown", true) .WithImageUrl(card.ImageUrlHiRes ?? card.ImageUrl) .WithFooter(!card.Equals(results.Cards.Last()) ? "Type 'next' within 10 seconds for the next Pokémon" : "This is the last found Pokémon on the list.") .WithColor(DiscordColor.Gold); var types = new StringBuilder(); foreach (var type in card.Types) { types.Append(type); } output.AddField("Types", types.ToString() ?? "Unknown", true); var weaknesses = new StringBuilder(); foreach (var weakness in card.Weaknesses) { weaknesses.Append(weakness.Type); } output.AddField("Weaknesses", weaknesses.ToString() ?? "Unknown", true); await ctx.RespondAsync(embed : output.Build()).ConfigureAwait(false); if (results.Cards.Count == 1) { continue; } var interactivity = await BotServices.GetUserInteractivity(ctx, "next", 10).ConfigureAwait(false); if (interactivity.Result is null) { break; } if (!card.Equals(results.Cards.Last())) { await BotServices.RemoveMessage(interactivity.Result).ConfigureAwait(false); } } } }
public async Task Twitch(CommandContext ctx, [Description("Channel to find on Twitch.")][RemainingText] string query) { if (string.IsNullOrWhiteSpace(query)) { return; } await ctx.TriggerTypingAsync(); var results = await TwitchService.GetTwitchDataAsync(Program.Settings.Tokens.TwitchToken, query) .ConfigureAwait(false); if (results.Total == 0) { await BotServices.SendResponseAsync(ctx, Resources.NOT_FOUND_TWITCH, ResponseType.Missing) .ConfigureAwait(false); return; } foreach (var streamer in results.Streams) { var output = new DiscordEmbedBuilder() .WithTitle(streamer.Channel.DisplayName) .WithDescription("[LIVE] Now Playing: " + streamer.Channel.Game) .AddField("Broadcaster", streamer.Channel.BroadcasterType.ToUpperInvariant(), true) .AddField("Viewers", streamer.Viewers.ToString(), true) .AddField("Followers", streamer.Channel.Followers.ToString(), true) .AddField("Status", streamer.Channel.Status) .WithThumbnail(streamer.Channel.Logo) .WithImageUrl(streamer.Preview.Large) .WithUrl(streamer.Channel.Url) .WithFooter(!streamer.Id.Equals(results.Streams.Last().Id) ? "Type 'next' within 10 seconds for the next streamer." : "This is the last found streamer on the list.") .WithColor(new DiscordColor("#6441A5")); var message = await ctx.RespondAsync(output.Build()).ConfigureAwait(false); if (results.Total == 1) { continue; } var interactivity = await BotServices.GetUserInteractivity(ctx, "next", 10).ConfigureAwait(false); if (interactivity.Result is null) { break; } await BotServices.RemoveMessage(interactivity.Result).ConfigureAwait(false); if (!streamer.Id.Equals(results.Streams.Last().Id)) { await BotServices.RemoveMessage(message).ConfigureAwait(false); } } }
public async Task Unmute(CommandContext ctx, [Description("Server user to unmute")][RemainingText] DiscordMember member, [Description("Reason for the deafen")][RemainingText] string reason = null) { await member.SetMuteAsync(false, reason).ConfigureAwait(false); await BotServices.RemoveMessage(ctx.Message).ConfigureAwait(false); await BotServices.SendUserStateChangeAsync(ctx, UserStateChange.Unmute, member, reason ?? "No reason provided"); }
public async Task GetAmiibo(CommandContext ctx, [Description("Name of the Amiibo figurine.")][RemainingText] string query) { if (string.IsNullOrWhiteSpace(query)) { return; } await ctx.TriggerTypingAsync(); var results = await NintendoService.GetAmiiboDataAsync(query).ConfigureAwait(false); if (results is null) { await BotServices.SendResponseAsync(ctx, Resources.NOT_FOUND_COMMON, ResponseType.Missing) .ConfigureAwait(false); return; } foreach (var amiibo in results.Amiibo) { var output = new DiscordEmbedBuilder() .WithTitle(amiibo.Name) .AddField("Amiibo Series", amiibo.AmiiboSeries, true) .AddField("Game Series", amiibo.GameSeries, true) .AddField(":flag_us: Release:", amiibo.ReleaseDate.American, true) .AddField(":flag_jp: Release:", amiibo.ReleaseDate.Japanese, true) .AddField(":flag_eu: Release:", amiibo.ReleaseDate.European, true) .AddField(":flag_au: Release:", amiibo.ReleaseDate.Australian, true) .WithImageUrl(amiibo.Image) .WithFooter(!amiibo.Equals(results.Amiibo.Last()) ? "Type 'next' within 10 seconds for the next amiibo." : "This is the last found amiibo on the list.") .WithColor(new DiscordColor("#E70009")); var message = await ctx.RespondAsync(output.Build()).ConfigureAwait(false); if (results.Amiibo.Count == 1) { continue; } var interactivity = await BotServices.GetUserInteractivity(ctx, "next", 10).ConfigureAwait(false); if (interactivity.Result is null) { break; } await BotServices.RemoveMessage(interactivity.Result).ConfigureAwait(false); if (!amiibo.Equals(results.Amiibo.Last())) { await BotServices.RemoveMessage(message).ConfigureAwait(false); } } }
public async Task Remove(CommandContext ctx, [Description("Discord user ID to unban from the server")] ulong userID, [Description("Reason for the deafen")][RemainingText] string reason = null) { var member = await ctx.Client.GetUserAsync(userID).ConfigureAwait(false); await ctx.Guild.UnbanMemberAsync(member, reason ?? "No reason provided.").ConfigureAwait(false); await BotServices.RemoveMessage(ctx.Message).ConfigureAwait(false); await ctx.RespondAsync($"Unbanned Discord User #{member} from the server.").ConfigureAwait(false); }
public async Task Tf2News(CommandContext ctx, [Description("Page number from which to retrieve the news")] int query = 0) { await ctx.TriggerTypingAsync(); var results = await TeamFortressService.GetNewsArticlesAsync(Program.Settings.Tokens.TeamworkToken, query) .ConfigureAwait(false); if (results is null || results.Count == 0) { await BotServices.SendResponseAsync(ctx, Resources.NOT_FOUND_COMMON, ResponseType.Missing) .ConfigureAwait(false); return; } while (results.Count > 0) { var output = new DiscordEmbedBuilder() .WithColor(new DiscordColor("#E7B53B")) .WithFooter(results.Count - 5 >= 5 ? "Type 'next' within 10 seconds for the next five posts." : "These are all the latest posts at this time."); foreach (var result in results.Take(5)) { output.AddField(result.CreatedAt.Date.ToString(), $"{result.Provider ?? result.Type}: [{result.Title}]({result.Link.AbsoluteUri})"); results.Remove(result); } var message = await ctx.RespondAsync("Latest news articles from teamwork.tf", output) .ConfigureAwait(false); if (results.Count < 5) { break; } var interactivity = await BotServices.GetUserInteractivity(ctx, "next", 10).ConfigureAwait(false); if (interactivity.Result is null) { break; } await BotServices.RemoveMessage(interactivity.Result).ConfigureAwait(false); await BotServices.RemoveMessage(message).ConfigureAwait(false); } }
public async Task News(CommandContext ctx, [Description("Article topic to find on NewsAPI.org.")][RemainingText] string query) { await ctx.TriggerTypingAsync(); var results = await NewsService.GetNewsDataAsync(Program.Settings.Tokens.NewsToken, query) .ConfigureAwait(false); if (results.Status != "ok") { await BotServices.SendResponseAsync(ctx, Resources.NOT_FOUND_COMMON, ResponseType.Missing) .ConfigureAwait(false); return; } while (results.Articles.Count > 0) { var output = new DiscordEmbedBuilder() .WithFooter("Type 'next' within 10 seconds for the next five articles.") .WithColor(new DiscordColor("#253B80")); foreach (var result in results.Articles.Take(5)) { output.AddField(result.PublishDate.ToString(CultureInfo.InvariantCulture), $"[{result.Title}]({result.Url})"); results.Articles.Remove(result); } var message = await ctx .RespondAsync("Latest Google News articles from News API", output.Build()) .ConfigureAwait(false); if (results.Articles.Count == 5) { continue; } var interactivity = await BotServices.GetUserInteractivity(ctx, "next", 10).ConfigureAwait(false); if (interactivity.Result is null) { break; } await BotServices.RemoveMessage(interactivity.Result).ConfigureAwait(false); await BotServices.RemoveMessage(message).ConfigureAwait(false); } }
private static async Task RedditPost(CommandContext ctx, string query, RedditCategory category) { if (string.IsNullOrWhiteSpace(query)) { return; } await ctx.TriggerTypingAsync(); var results = RedditService.GetResults(query, category); if (results is null || results.Count == 0) { await BotServices.SendResponseAsync(ctx, Resources.NOT_FOUND_COMMON, ResponseType.Missing) .ConfigureAwait(false); return; } while (results.Count > 0) { var output = new DiscordEmbedBuilder() .WithFooter("Type 'next' within 10 seconds for the next five posts.") .WithColor(new DiscordColor("#FF4500")); foreach (var result in results.Take(5)) { output.AddField(result.Authors.FirstOrDefault()?.Name, $"[{(result.Title.Text.Length < 500 ? result.Title.Text : result.Title.Text.Take(500) + "...")}]({result.Links.First().Uri})"); results.Remove(result); } var message = await ctx.RespondAsync("Search results for r/" + query + " on Reddit", output) .ConfigureAwait(false); if (results.Count == 5) { continue; } var interactivity = await BotServices.GetUserInteractivity(ctx, "next", 10).ConfigureAwait(false); if (interactivity.Result is null) { break; } await BotServices.RemoveMessage(interactivity.Result).ConfigureAwait(false); await BotServices.RemoveMessage(message).ConfigureAwait(false); } }
public async Task Books(CommandContext ctx, [Description("Book title to find on GoodReads")][RemainingText] string query) { if (!BotServices.CheckUserInput(query)) { return; } var results = GoodReadsService.GetBookDataAsync(query).Result.Search; if (results.ResultCount <= 0) { await BotServices.SendEmbedAsync(ctx, Resources.NOT_FOUND_GENERIC, EmbedType.Missing).ConfigureAwait(false); } else { foreach (var book in results.Results) { // TODO: Add page count, publication, ISBN, URLs var output = new DiscordEmbedBuilder() .WithTitle(book.Book.Title) .AddField("Written by", book.Book.Author.Name ?? "Unknown", true) .AddField("Publication Date", (book.PublicationMonth.Text ?? "01") + "-" + (book.PublicationDay.Text ?? "01") + "-" + book.PublicationYear.Text, true) .AddField("Avg. Rating", book.RatingAverage ?? "Unknown", true) .WithThumbnailUrl(book.Book.ImageUrl ?? book.Book.ImageUrlSmall) .WithFooter(!book.Equals(results.Results.Last()) ? "Type 'next' within 10 seconds for the next book." : "This is the last found book on the list.") .WithColor(new DiscordColor("#372213")); var message = await ctx.RespondAsync(embed : output.Build()).ConfigureAwait(false); if (results.Results.Count == 1) { continue; } var interactivity = await BotServices.GetUserInteractivity(ctx, "next", 10).ConfigureAwait(false); if (interactivity.Result is null) { break; } await BotServices.RemoveMessage(interactivity.Result).ConfigureAwait(false); if (!book.Equals(results.Results.Last())) { await BotServices.RemoveMessage(message).ConfigureAwait(false); } } } }
public async Task Ban(CommandContext ctx, [Description("Server user to ban")] DiscordMember member, [Description("Reason for the ban")][RemainingText] string reason = null) { if (ctx.Member.Id == member.Id) { await ctx.RespondAsync("You cannot ban yourself.").ConfigureAwait(false); } else { await ctx.Guild.BanMemberAsync(member, 7, reason).ConfigureAwait(false); await BotServices.RemoveMessage(ctx.Message).ConfigureAwait(false); await BotServices.SendUserStateChangeAsync(ctx, UserStateChange.Ban, member, reason ?? "No reason provided."); } }
public async Task Deafen(CommandContext ctx, [Description("Server user to deafen")] DiscordMember member, [Description("Reason for the deafen")][RemainingText] string reason = null) { if (member.IsDeafened) { await ctx.RespondAsync($"{member.DisplayName}#{member.Discriminator} is already **deafened**.").ConfigureAwait(false); } else { await member.SetDeafAsync(true, reason).ConfigureAwait(false); await BotServices.RemoveMessage(ctx.Message).ConfigureAwait(false); await BotServices.SendUserStateChangeAsync(ctx, UserStateChange.Deafen, member, reason ?? "No reason provided."); } }
public async Task Tf2ServerList(CommandContext ctx) { await ctx.TriggerTypingAsync(); var results = await TeamFortressService.GetCustomServerListsAsync(Program.Settings.Tokens.TeamworkToken) .ConfigureAwait(false); results = results.OrderBy(_ => new Random().Next()).ToList(); while (results.Count > 0) { var output = new DiscordEmbedBuilder() .WithFooter("Type 'next' within 10 seconds for the next set of server lists.") .WithColor(new DiscordColor("#E7B53B")); foreach (var list in results.Take(4)) { var desc = Regex.Replace( list.DescriptionLarge.Length <= 400 ? list.DescriptionLarge : list.DescriptionLarge.Substring(0, 200) + "...", "<[^>]*>", ""); output.AddField($"Created By: {list.Creator.Name ?? "Unknown"} \t Subscribers: {list.Subscribed}", $"[{list.Name}]({Resources.URL_TeamworkTF + list.Id}) - {desc}"); results.Remove(list); } var message = await ctx .RespondAsync("Community-Curated Server Lists from teamwork.tf", output.Build()) .ConfigureAwait(false); if (results.Count == 4) { continue; } var interactivity = await BotServices.GetUserInteractivity(ctx, "next", 10).ConfigureAwait(false); if (interactivity.Result is null) { break; } await BotServices.RemoveMessage(interactivity.Result).ConfigureAwait(false); await BotServices.RemoveMessage(message).ConfigureAwait(false); } }
public async Task Poll(CommandContext ctx, [Description("Question to be asked in the poll.")][RemainingText] string question) { if (string.IsNullOrWhiteSpace(question)) { await BotServices.SendResponseAsync(ctx, Resources.ERR_POLL_QUESTION, ResponseType.Warning) .ConfigureAwait(false); return; } // Build the poll question, duration and options. await ctx.TriggerTypingAsync(); question = ctx.User.Mention + " asked: " + question; var interactivity = ctx.Client.GetInteractivity(); var pollOptions = new List <DiscordEmoji> { DiscordEmoji.FromName(ctx.Client, ":thumbsup:"), DiscordEmoji.FromName(ctx.Client, ":thumbsdown:") }; var duration = new TimeSpan(0, 3, 10); var message = await ctx .RespondAsync(new DiscordEmbedBuilder() .WithDescription(question + $"\nThis poll ends in {duration.Minutes} minutes.").Build()) .ConfigureAwait(false); var results = await interactivity.DoPollAsync(message, pollOptions, PollBehaviour.DeleteEmojis, duration) .ConfigureAwait(false); // Removed the initial poll and return the calculated results await BotServices.RemoveMessage(message).ConfigureAwait(false); var output = new DiscordEmbedBuilder() .WithDescription(question) .WithFooter("The voting has ended."); foreach (var vote in results) { output.AddField(vote.Emoji.Name, vote.Voted.Count.ToString(), true); } await ctx.RespondAsync(output.Build()).ConfigureAwait(false); }
public async Task Kick(CommandContext ctx, [Description("Server user to kick.")] DiscordMember member, [Description("Reason for the kick.")][RemainingText] string reason = null) { if (ctx.Member.Id == member.Id) { await ctx.RespondAsync("You cannot kick yourself.").ConfigureAwait(false); return; } await member.RemoveAsync(reason).ConfigureAwait(false); await BotServices.RemoveMessage(ctx.Message).ConfigureAwait(false); await BotServices.SendUserStateChangeAsync(ctx, UserStateChange.Kick, member, reason ?? "No reason provided.").ConfigureAwait(false); }
public async Task News(CommandContext ctx, [Description("Article topic to find on Google News")][RemainingText] string query) { var results = await GoogleService.GetNewsDataAsync(query).ConfigureAwait(false); if (results.Status != "ok") { await BotServices.SendEmbedAsync(ctx, Resources.NOT_FOUND_GENERIC, EmbedType.Missing).ConfigureAwait(false); } else { while (results.Articles.Count > 0) { var output = new DiscordEmbedBuilder() .WithFooter("Type 'next' within 10 seconds for the next five articles.") .WithColor(new DiscordColor("#253B80")); foreach (var result in results.Articles.Take(5)) { output.AddField(result.Title, result.Url); results.Articles.Remove(result); } var message = await ctx.RespondAsync("Latest Google News articles from News API", embed : output.Build()).ConfigureAwait(false); if (results.Articles.Count == 5) { continue; } var interactivity = await BotServices.GetUserInteractivity(ctx, "next", 10).ConfigureAwait(false); if (interactivity.Result is null) { break; } await BotServices.RemoveMessage(interactivity.Result).ConfigureAwait(false); await BotServices.RemoveMessage(message).ConfigureAwait(false); } } }
public async Task Tf2ServerByMode(CommandContext ctx, [Description("Name of the game-mode, like payload.")][RemainingText] string query) { if (string.IsNullOrWhiteSpace(query)) { return; } await ctx.TriggerTypingAsync(); var results = await TeamFortressService .GetServersByGameModeAsync(Program.Settings.Tokens.TeamworkToken, query.Trim().Replace(' ', '-')) .ConfigureAwait(false); if (results is null) { await BotServices.SendResponseAsync(ctx, Resources.NOT_FOUND_COMMON, ResponseType.Missing) .ConfigureAwait(false); return; } foreach (var server in results.OrderBy(_ => new Random().Next()).ToList()) { var output = new DiscordEmbedBuilder() .WithTitle(server.Name) .WithDescription("steam://connect/" + server.Ip + ":" + server.Port) .AddField("Provider", server.Provider != null ? server.Provider.Name : "Unknown", true) .AddField("Player Count", (server.Players.ToString() ?? "Unknown") + "/" + (server.MaxPlayers.ToString() ?? "Unknown"), true) .AddField("Password Lock", server.HasPassword ? "Yes" : "No", true) .AddField("Random Crits", server.HasRandomCrits == true ? "Yes" : "No", true) .AddField("Instant Respawn", server.HasNoRespawnTime ? "Yes" : "No", true) .AddField("All Talk", server.HasAllTalk ? "Yes" : "No", true) .AddField("Current Map", server.MapName ?? "Unknown", true) .AddField("Next Map", server.MapNameNext ?? "Unknown", true) .WithFooter("Type 'next' within 10 seconds for the next server.") .WithColor(new DiscordColor("#E7B53B")); var thumbnailUrl = await TeamFortressService .GetMapThumbnailAsync(Program.Settings.Tokens.TeamworkToken, server.MapName).ConfigureAwait(false); output.WithImageUrl(thumbnailUrl.Name); var message = await ctx.RespondAsync(output.Build()).ConfigureAwait(false); if (results.Count == 1) { continue; } var interactivity = await BotServices.GetUserInteractivity(ctx, "next", 10).ConfigureAwait(false); if (interactivity.Result is null) { break; } if (!server.Equals(results.Last())) { await BotServices.RemoveMessage(message).ConfigureAwait(false); } await BotServices.RemoveMessage(interactivity.Result).ConfigureAwait(false); } }
public async Task Speedrun(CommandContext ctx, [Description("Game to find on Speedrun.com")][RemainingText] string query) { if (string.IsNullOrWhiteSpace(query)) { return; } await ctx.TriggerTypingAsync(); var results = SpeedrunService.GetSpeedrunGameAsync(query).Result; if (results is null || results.Data.Count == 0) { await BotServices.SendResponseAsync(ctx, Resources.NOT_FOUND_COMMON, ResponseType.Missing) .ConfigureAwait(false); return; } foreach (var game in results.Data) { var output = new DiscordEmbedBuilder() .WithTitle(game.Names.International) .AddField("Developers", SpeedrunService.GetSpeedrunExtraAsync(game.Developers, SpeedrunExtras.Developers).Result ?? "Unknown", true) .AddField("Publishers", SpeedrunService.GetSpeedrunExtraAsync(game.Publishers, SpeedrunExtras.Publishers).Result ?? "Unknown", true) .AddField("Release Date", game.ReleaseDate ?? "Unknown") .AddField("Platforms", SpeedrunService.GetSpeedrunExtraAsync(game.Platforms, SpeedrunExtras.Platforms).Result ?? "Unknown") .WithFooter($"ID: {game.Id} - Abbreviation: {game.Abbreviation}") .WithThumbnail(game.Assets.CoverLarge.Url ?? game.Assets.Icon.Url) .WithUrl(game.WebLink) .WithColor(new DiscordColor("#0F7A4D")); var link = game.Links.First(x => x.Rel == "categories").Url; var categories = SpeedrunService.GetSpeedrunCategoryAsync(link).Result; var category = new StringBuilder(); if (categories != null || categories.Data.Count > 0) { foreach (var x in categories.Data) { category.Append($"[{x.Name}]({x.Weblink}) **|** "); } } output.AddField("Categories", category.ToString()); await ctx.RespondAsync(output.Build()).ConfigureAwait(false); if (results.Data.Count == 1) { continue; } var interactivity = await BotServices.GetUserInteractivity(ctx, "next", 10).ConfigureAwait(false); if (interactivity.Result is null) { break; } if (!game.Equals(results.Data.Last())) { await BotServices.RemoveMessage(interactivity.Result).ConfigureAwait(false); } } }
public async Task Omdb(CommandContext ctx, [Description("Movie or TV show to find on OMDB.")][RemainingText] string query) { if (string.IsNullOrWhiteSpace(query)) { return; } await ctx.TriggerTypingAsync(); var results = OmdbService.GetMovieListAsync(Program.Settings.Tokens.OmdbToken, query.Replace(" ", "+")) .Result; if (!results.Search.Any()) { await BotServices.SendResponseAsync(ctx, Resources.NOT_FOUND_COMMON, ResponseType.Missing) .ConfigureAwait(false); return; } foreach (var title in results.Search) { var movie = OmdbService .GetMovieDataAsync(Program.Settings.Tokens.OmdbToken, title.Title.Replace(" ", "+")).Result; var output = new DiscordEmbedBuilder() .WithTitle(movie.Title) .WithDescription(movie.Plot.Length < 500 ? movie.Plot : movie.Plot.Take(500) + "...") .AddField("Released", movie.Released, true) .AddField("Runtime", movie.Runtime, true) .AddField("Genre", movie.Genre, true) .AddField("Rating", movie.Rated, true) .AddField("IMDb Rating", movie.IMDbRating, true) .AddField("Box Office", movie.BoxOffice, true) .AddField("Directors", movie.Director) .AddField("Actors", movie.Actors) .WithFooter(!movie.Title.Equals(results.Search.Last().Title) ? "Type 'next' within 10 seconds for the next movie." : "This is the last found movie on OMDB.") .WithColor(DiscordColor.Goldenrod); if (movie.Poster != "N/A") { output.WithImageUrl(movie.Poster); } var message = await ctx.RespondAsync(output.Build()).ConfigureAwait(false); if (results.Search.Length == 1) { continue; } var interactivity = await BotServices.GetUserInteractivity(ctx, "next", 10).ConfigureAwait(false); if (interactivity.Result is null) { break; } await BotServices.RemoveMessage(interactivity.Result).ConfigureAwait(false); if (!movie.Title.Equals(results.Search.Last().Title)) { await BotServices.RemoveMessage(message).ConfigureAwait(false); } } }
public async Task Tf2Creators(CommandContext ctx, [Description("Name of the community creator to find.")][RemainingText] string query) { if (string.IsNullOrWhiteSpace(query)) { return; } await ctx.TriggerTypingAsync(); var steamId = SteamService.GetSteamUserId(query).Result; if (steamId is null) { await BotServices.SendResponseAsync(ctx, Resources.NOT_FOUND_COMMON, ResponseType.Missing) .ConfigureAwait(false); return; } var results = await TeamFortressService .GetContentCreatorAsync(Program.Settings.Tokens.TeamworkToken, steamId.Data).ConfigureAwait(false); if (results.Count == 0) { await BotServices.SendResponseAsync(ctx, Resources.NOT_FOUND_COMMON, ResponseType.Missing) .ConfigureAwait(false); return; } foreach (var creator in results) { var user = results.FirstOrDefault(); var output = new DiscordEmbedBuilder() .WithTitle(user?.Name) .WithDescription("Main Class: " + user?.Main?.ToString()?.ToUpper()) .WithThumbnail(user?.ThumbnailUrl) .WithUrl(user?.Link) .WithColor(new DiscordColor("#E7B53B")) .WithFooter(!creator.Equals(results.Last()) ? "Type 'next' within 10 seconds for the next creator" : "Data retrieved from teamwork.tf"); var links = new StringBuilder(); if (creator.DiscordGroup != null) { links.Append($"[Discord]({Resources.URL_Discord}{creator.DiscordGroup}) **|** "); } if (!string.IsNullOrWhiteSpace(creator.Steam)) { links.Append($"[Steam]({Resources.URL_Steam_User}{creator.Steam}) **|** "); } if (creator.SteamGroup != null) { links.Append($"[Steam Group]({Resources.URL_Steam_Group}{creator.SteamGroup}) **|** "); } if (creator.Twitch != null) { links.Append($"[Twitch]({Resources.URL_Twitch}{creator.Twitch}) **|** "); } if (!string.IsNullOrWhiteSpace(creator.Twitter)) { links.Append($"[Twitter]({Resources.URL_Twitter}{creator.Twitter}) **|** "); } if (!string.IsNullOrWhiteSpace(creator.Youtube)) { links.Append($"[YouTube]({string.Format(Resources.URL_YouTube_Channel, creator.Youtube)})"); } output.AddField("Links", links.ToString(), true); var message = await ctx.RespondAsync(output.Build()).ConfigureAwait(false); if (results.Count == 1) { continue; } var interactivity = await BotServices.GetUserInteractivity(ctx, "next", 10).ConfigureAwait(false); if (interactivity.Result is null) { break; } await BotServices.RemoveMessage(interactivity.Result).ConfigureAwait(false); if (!creator.Equals(results.Last())) { await BotServices.RemoveMessage(message).ConfigureAwait(false); } } }