public async Task DoSafe(EventContext e) { Locale locale = Locale.GetEntity(e.Guild.Id.ToDbLong()); IPost s = null; if (e.arguments.ToLower().StartsWith("use")) { string[] a = e.arguments.Split(' '); e.arguments = e.arguments.Substring(a[0].Length); switch (a[0].Split(':')[1].ToLower()) { case "safebooru": { s = SafebooruPost.Create(e.arguments, ImageRating.SAFE); } break; case "gelbooru": { s = GelbooruPost.Create(e.arguments, ImageRating.SAFE); } break; case "konachan": { s = KonachanPost.Create(e.arguments, ImageRating.SAFE); } break; case "e621": { s = E621Post.Create(e.arguments, ImageRating.SAFE); } break; default: { await e.Channel.SendMessage("I do not support this image host :("); } break; } } else { s = SafebooruPost.Create(e.arguments, ImageRating.SAFE); } if (s == null) { await e.Channel.SendMessage(Utils.ErrorEmbed(locale, "We couldn't find an image with these tags!")); return; } await e.Channel.SendMessage(s.ImageUrl); }
public static Embed ToEmbed(this E621Post post) { var author = post.Artists.Any() ? post.Artists.Humanize() : post.Author; var builder = new EmbedBuilder() .WithTitle($"id: {post.Id} • score: {post.Score}") .WithAuthor(author) .WithDescription(post.Description.Truncate(EmbedBuilder.MaxDescriptionLength)) .WithImageUrl(post.FileUrl) .WithUrl($"https://e621.net/post/show/{post.Id}"); return(builder.Build()); }
public async Task RunE621(EventContext e) { IPost s = E621Post.Create(e.arguments, ImageRating.EXPLICIT); if (s == null) { await Utils.ErrorEmbed(Locale.GetEntity(e.Channel.Id), "Couldn't find anything with these tags!") .SendToChannel(e.Channel); } await Utils.Embed .SetTitle("E621") .SetImageUrl(s.ImageUrl) .SendToChannel(e.Channel.Id); }