More fixes

This commit is contained in:
Kwoth 2017-01-02 12:09:52 +01:00
parent 908df9d773
commit f9e0f78c63

View File

@ -104,8 +104,6 @@ namespace NadekoBot.Modules.NSFW
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
public async Task HentaiBomb([Remainder] string tag = null) public async Task HentaiBomb([Remainder] string tag = null)
{ {
var channel = (ITextChannel)Context.Channel;
tag = tag?.Trim() ?? ""; tag = tag?.Trim() ?? "";
tag = "rating%3Aexplicit+" + tag; tag = "rating%3Aexplicit+" + tag;
@ -114,30 +112,28 @@ namespace NadekoBot.Modules.NSFW
GetKonachanImageLink(tag), GetKonachanImageLink(tag),
GetYandereImageLink(tag)).ConfigureAwait(false); GetYandereImageLink(tag)).ConfigureAwait(false);
var linksEnum = links.Where(l => l != null); var linksEnum = links?.Where(l => l != null);
if (!linksEnum.Any()) if (links == null || !linksEnum.Any())
{ {
await channel.SendErrorAsync("No results found.").ConfigureAwait(false); await Context.Channel.SendErrorAsync("No results found.").ConfigureAwait(false);
return; return;
} }
await channel.SendMessageAsync(String.Join("\n\n", linksEnum)).ConfigureAwait(false); await Context.Channel.SendMessageAsync(String.Join("\n\n", linksEnum)).ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
public async Task Danbooru([Remainder] string tag = null) public async Task Danbooru([Remainder] string tag = null)
{ {
var channel = (ITextChannel)Context.Channel;
tag = tag?.Trim() ?? ""; tag = tag?.Trim() ?? "";
var url = await GetDanbooruImageLink(tag).ConfigureAwait(false); var url = await GetDanbooruImageLink(tag).ConfigureAwait(false);
if (url == null) if (url == null)
await channel.SendErrorAsync(Context.User.Mention + " No results."); await Context.Channel.SendErrorAsync(Context.User.Mention + " No results.");
else else
await channel.EmbedAsync(new EmbedBuilder().WithOkColor() await Context.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
.WithDescription(Context.User.Mention + " " + tag) .WithDescription(Context.User.Mention + " " + tag)
.WithImageUrl(url) .WithImageUrl(url)
.WithFooter(efb => efb.WithText("Danbooru"))).ConfigureAwait(false); .WithFooter(efb => efb.WithText("Danbooru"))).ConfigureAwait(false);