Autohentai no longer posts errors
This commit is contained in:
parent
2d2a7f765f
commit
cc6798496c
@ -19,15 +19,10 @@ namespace NadekoBot.Modules.NSFW
|
||||
[NadekoModule("NSFW", "~")]
|
||||
public class NSFW : DiscordModule
|
||||
{
|
||||
//ulong/cancel
|
||||
private static ConcurrentDictionary<ulong, Timer> AutoHentaiTimers { get; } = new ConcurrentDictionary<ulong, Timer>();
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Hentai([Remainder] string tag = null)
|
||||
private async Task InternalHentai(IMessageChannel channel, string tag, bool noError)
|
||||
{
|
||||
var channel = (ITextChannel)Context.Channel;
|
||||
|
||||
tag = tag?.Trim() ?? "";
|
||||
|
||||
tag = "rating%3Aexplicit+" + tag;
|
||||
@ -54,12 +49,17 @@ namespace NadekoBot.Modules.NSFW
|
||||
var link = await provider.ConfigureAwait(false);
|
||||
if (string.IsNullOrWhiteSpace(link))
|
||||
await channel.SendErrorAsync("No results found.").ConfigureAwait(false);
|
||||
else
|
||||
else if (!noError)
|
||||
await channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
||||
.WithImageUrl(link)
|
||||
.WithDescription("Tag: " + tag)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public Task Hentai([Remainder] string tag = null) =>
|
||||
InternalHentai(Context.Channel, tag, false);
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task AutoHentai(int interval = 0, string tags = null)
|
||||
@ -86,9 +86,9 @@ namespace NadekoBot.Modules.NSFW
|
||||
try
|
||||
{
|
||||
if (tagsArr == null || tagsArr.Length == 0)
|
||||
await Hentai(null).ConfigureAwait(false);
|
||||
await InternalHentai(Context.Channel, null, true).ConfigureAwait(false);
|
||||
else
|
||||
await Hentai(tagsArr[new NadekoRandom().Next(0, tagsArr.Length)]);
|
||||
await InternalHentai(Context.Channel, tagsArr[new NadekoRandom().Next(0, tagsArr.Length)], true);
|
||||
}
|
||||
catch { }
|
||||
}, null, interval * 1000, interval * 1000);
|
||||
|
Loading…
Reference in New Issue
Block a user