Fixes to some commands which had IUserMesasge leftover

This commit is contained in:
Kwoth 2017-01-01 13:26:17 +01:00
parent 221e707963
commit 755a2c40b3
13 changed files with 85 additions and 84 deletions

View File

@ -207,9 +207,9 @@ namespace NadekoBot.Modules.Gambling
} }
private void Client_MessageReceived(IMessage imsg) private void Client_MessageReceived(SocketMessage imsg)
{ {
var msg = imsg as IUserMessage; var msg = imsg as SocketUserMessage;
if (msg == null) if (msg == null)
return; return;
if (msg.IsAuthor() || !(imsg.Channel is ITextChannel) || imsg.Channel != raceChannel) if (msg.IsAuthor() || !(imsg.Channel is ITextChannel) || imsg.Channel != raceChannel)

View File

@ -26,9 +26,9 @@ namespace NadekoBot.Modules.Gambling
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Roll(IUserMessage umsg) public async Task Roll()
{ {
var channel = (ITextChannel)umsg.Channel; var channel = (ITextChannel)Context.Channel;
if (channel == null) if (channel == null)
return; return;
var rng = new NadekoRandom(); var rng = new NadekoRandom();
@ -48,7 +48,7 @@ namespace NadekoBot.Modules.Gambling
catch { return new MemoryStream(); } catch { return new MemoryStream(); }
}); });
await channel.SendFileAsync(imageStream, "dice.png", $"{umsg.Author.Mention} rolled " + Format.Code(gen.ToString())).ConfigureAwait(false); await channel.SendFileAsync(imageStream, "dice.png", $"{Context.User.Mention} rolled " + Format.Code(gen.ToString())).ConfigureAwait(false);
} }
public enum RollOrderType public enum RollOrderType
@ -60,39 +60,39 @@ namespace NadekoBot.Modules.Gambling
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(0)] [Priority(0)]
public async Task Roll(IUserMessage umsg, int num) public async Task Roll(int num)
{ {
await InternalRoll(umsg, num, true).ConfigureAwait(false); await InternalRoll(num, true).ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(0)] [Priority(0)]
public async Task Rolluo(IUserMessage umsg, int num) public async Task Rolluo(int num)
{ {
await InternalRoll(umsg, num, false).ConfigureAwait(false); await InternalRoll(num, false).ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(1)] [Priority(1)]
public async Task Roll(IUserMessage umsg, string arg) public async Task Roll(string arg)
{ {
await InternallDndRoll(umsg, arg, true).ConfigureAwait(false); await InternallDndRoll(arg, true).ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[Priority(1)] [Priority(1)]
public async Task Rolluo(IUserMessage umsg, string arg) public async Task Rolluo(string arg)
{ {
await InternallDndRoll(umsg, arg, false).ConfigureAwait(false); await InternallDndRoll(arg, false).ConfigureAwait(false);
} }
private async Task InternalRoll(IUserMessage umsg, int num, bool ordered) private async Task InternalRoll( int num, bool ordered)
{ {
var channel = (ITextChannel)umsg.Channel; var channel = (ITextChannel)Context.Channel;
if (channel == null) if (channel == null)
return; return;
@ -136,12 +136,12 @@ namespace NadekoBot.Modules.Gambling
var ms = new MemoryStream(); var ms = new MemoryStream();
bitmap.SaveAsPng(ms); bitmap.SaveAsPng(ms);
ms.Position = 0; ms.Position = 0;
await channel.SendFileAsync(ms, "dice.png", $"{umsg.Author.Mention} rolled {values.Count} {(values.Count == 1 ? "die" : "dice")}. Total: **{values.Sum()}** Average: **{(values.Sum() / (1.0f * values.Count)).ToString("N2")}**").ConfigureAwait(false); await channel.SendFileAsync(ms, "dice.png", $"{Context.User.Mention} rolled {values.Count} {(values.Count == 1 ? "die" : "dice")}. Total: **{values.Sum()}** Average: **{(values.Sum() / (1.0f * values.Count)).ToString("N2")}**").ConfigureAwait(false);
} }
private async Task InternallDndRoll(IUserMessage umsg, string arg, bool ordered) private async Task InternallDndRoll(string arg, bool ordered)
{ {
var channel = (ITextChannel)umsg.Channel; var channel = (ITextChannel)Context.Channel;
if (channel == null) if (channel == null)
return; return;
@ -160,7 +160,7 @@ namespace NadekoBot.Modules.Gambling
{ {
rolls.Add(fateRolls[rng.Next(0, fateRolls.Length)]); rolls.Add(fateRolls[rng.Next(0, fateRolls.Length)]);
} }
var embed = new EmbedBuilder().WithOkColor().WithDescription($"{umsg.Author.Mention} rolled {n1} fate {(n1 == 1 ? "die" : "dice")}.") var embed = new EmbedBuilder().WithOkColor().WithDescription($"{Context.User.Mention} rolled {n1} fate {(n1 == 1 ? "die" : "dice")}.")
.AddField(efb => efb.WithName(Format.Bold("Result")) .AddField(efb => efb.WithName(Format.Bold("Result"))
.WithValue(string.Join(" ", rolls.Select(c => Format.Code($"[{c}]"))))); .WithValue(string.Join(" ", rolls.Select(c => Format.Code($"[{c}]")))));
await channel.EmbedAsync(embed).ConfigureAwait(false); await channel.EmbedAsync(embed).ConfigureAwait(false);
@ -183,7 +183,7 @@ namespace NadekoBot.Modules.Gambling
arr[i] = rng.Next(1, n2 + 1) + add - sub; arr[i] = rng.Next(1, n2 + 1) + add - sub;
} }
var embed = new EmbedBuilder().WithOkColor().WithDescription($"{umsg.Author.Mention} rolled {n1} {(n1 == 1 ? "die" : "dice")} `1 to {n2}` +`{add}` -`{sub}`") var embed = new EmbedBuilder().WithOkColor().WithDescription($"{Context.User.Mention} rolled {n1} {(n1 == 1 ? "die" : "dice")} `1 to {n2}` +`{add}` -`{sub}`")
.AddField(efb => efb.WithName(Format.Bold("Result")) .AddField(efb => efb.WithName(Format.Bold("Result"))
.WithValue(string.Join(" ", (ordered ? arr.OrderBy(x => x).AsEnumerable() : arr).Select(x => Format.Code(x.ToString()))))); .WithValue(string.Join(" ", (ordered ? arr.OrderBy(x => x).AsEnumerable() : arr).Select(x => Format.Code(x.ToString())))));
await channel.EmbedAsync(embed).ConfigureAwait(false); await channel.EmbedAsync(embed).ConfigureAwait(false);
@ -193,9 +193,9 @@ namespace NadekoBot.Modules.Gambling
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task NRoll(IUserMessage umsg, [Remainder] string range) public async Task NRoll([Remainder] string range)
{ {
var channel = (ITextChannel)umsg.Channel; var channel = (ITextChannel)Context.Channel;
try try
{ {
@ -215,7 +215,7 @@ namespace NadekoBot.Modules.Gambling
rolled = new NadekoRandom().Next(0, int.Parse(range) + 1); rolled = new NadekoRandom().Next(0, int.Parse(range) + 1);
} }
await channel.SendConfirmAsync($"{umsg.Author.Mention} rolled **{rolled}**.").ConfigureAwait(false); await channel.SendConfirmAsync($"{Context.User.Mention} rolled **{rolled}**.").ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -1,5 +1,6 @@
using Discord; using Discord;
using Discord.Commands; using Discord.Commands;
using Discord.WebSocket;
using NadekoBot.Attributes; using NadekoBot.Attributes;
using NadekoBot.Extensions; using NadekoBot.Extensions;
using NadekoBot.Services; using NadekoBot.Services;
@ -25,7 +26,7 @@ namespace NadekoBot.Modules.Games
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Acro(IUserMessage imsg, int time = 60) public async Task Acro(int time = 60)
{ {
var channel = (ITextChannel)imsg.Channel; var channel = (ITextChannel)imsg.Channel;
@ -167,11 +168,11 @@ namespace NadekoBot.Modules.Games
await End().ConfigureAwait(false); await End().ConfigureAwait(false);
} }
private async void PotentialAcro(IMessage arg) private async void PotentialAcro(SocketMessage arg)
{ {
try try
{ {
var msg = arg as IUserMessage; var msg = arg as SocketUserMessage;
if (msg == null || msg.Author.IsBot || msg.Channel.Id != channel.Id) if (msg == null || msg.Author.IsBot || msg.Channel.Id != channel.Id)
return; return;

View File

@ -1,5 +1,6 @@
using Discord; using Discord;
using Discord.Commands; using Discord.Commands;
using Discord.WebSocket;
using NadekoBot.Attributes; using NadekoBot.Attributes;
using NadekoBot.Extensions; using NadekoBot.Extensions;
using NadekoBot.Services; using NadekoBot.Services;
@ -46,7 +47,7 @@ namespace NadekoBot.Modules.Games
_log.Debug($"Loaded in {sw.Elapsed.TotalSeconds:F2}s"); _log.Debug($"Loaded in {sw.Elapsed.TotalSeconds:F2}s");
} }
public static async Task<bool> TryAsk(IUserMessage msg) public static async Task<bool> TryAsk(SocketUserMessage msg)
{ {
var channel = msg.Channel as ITextChannel; var channel = msg.Channel as ITextChannel;

View File

@ -1,4 +1,5 @@
using Discord; using Discord;
using Discord.WebSocket;
using NadekoBot.Extensions; using NadekoBot.Extensions;
using NadekoBot.Services; using NadekoBot.Services;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -128,11 +129,11 @@ namespace NadekoBot.Modules.Games.Commands.Hangman
await GameChannel.EmbedAsync(embed.WithOkColor()).ConfigureAwait(false); await GameChannel.EmbedAsync(embed.WithOkColor()).ConfigureAwait(false);
} }
private async void PotentialGuess(IMessage msg) private async void PotentialGuess(SocketMessage msg)
{ {
try try
{ {
if (!(msg is IUserMessage)) if (!(msg is SocketUserMessage))
return; return;
if (msg.Channel != GameChannel) if (msg.Channel != GameChannel)

View File

@ -1,5 +1,6 @@
using Discord; using Discord;
using Discord.Commands; using Discord.Commands;
using Discord.WebSocket;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using NadekoBot.Attributes; using NadekoBot.Attributes;
using NadekoBot.Extensions; using NadekoBot.Extensions;
@ -62,11 +63,11 @@ namespace NadekoBot.Modules.Games
_log.Debug($"Loaded in {sw.Elapsed.TotalSeconds:F2}s"); _log.Debug($"Loaded in {sw.Elapsed.TotalSeconds:F2}s");
} }
private static async void PotentialFlowerGeneration(IMessage imsg) private static async void PotentialFlowerGeneration(SocketMessage imsg)
{ {
try try
{ {
var msg = imsg as IUserMessage; var msg = imsg as SocketUserMessage;
if (msg == null || msg.IsAuthor() || msg.Author.IsBot) if (msg == null || msg.IsAuthor() || msg.Author.IsBot)
return; return;

View File

@ -128,12 +128,12 @@ namespace NadekoBot.Modules.Games
} }
} }
private async void Vote(IMessage imsg) private async void Vote(SocketMessage imsg)
{ {
try try
{ {
// has to be a user message // has to be a user message
var msg = imsg as IUserMessage; var msg = imsg as SocketUserMessage;
if (msg == null || msg.Author.IsBot) if (msg == null || msg.Author.IsBot)
return; return;

View File

@ -1,5 +1,6 @@
using Discord; using Discord;
using Discord.Commands; using Discord.Commands;
using Discord.WebSocket;
using NadekoBot.Attributes; using NadekoBot.Attributes;
using NadekoBot.Extensions; using NadekoBot.Extensions;
using NadekoBot.Modules.Games.Commands.Models; using NadekoBot.Modules.Games.Commands.Models;
@ -105,13 +106,13 @@ namespace NadekoBot.Modules.Games
NadekoBot.Client.MessageReceived += AnswerReceived; NadekoBot.Client.MessageReceived += AnswerReceived;
} }
private async void AnswerReceived(IMessage imsg) private async void AnswerReceived(SocketMessage imsg)
{ {
try try
{ {
if (imsg.Author.IsBot) if (imsg.Author.IsBot)
return; return;
var msg = imsg as IUserMessage; var msg = imsg as SocketUserMessage;
if (msg == null) if (msg == null)
return; return;

View File

@ -1,5 +1,6 @@
using Discord; using Discord;
using Discord.Net; using Discord.Net;
using Discord.WebSocket;
using NadekoBot.Extensions; using NadekoBot.Extensions;
using NLog; using NLog;
using System; using System;
@ -141,14 +142,14 @@ namespace NadekoBot.Modules.Games.Trivia
try { await channel.SendConfirmAsync("Trivia Game", "Stopping after this question.").ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); } try { await channel.SendConfirmAsync("Trivia Game", "Stopping after this question.").ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); }
} }
private async void PotentialGuess(IMessage imsg) private async void PotentialGuess(SocketMessage imsg)
{ {
try try
{ {
if (imsg.Author.IsBot) if (imsg.Author.IsBot)
return; return;
var umsg = imsg as IUserMessage; var umsg = imsg as SocketUserMessage;
if (umsg == null) if (umsg == null)
return; return;

View File

@ -21,13 +21,13 @@ namespace NadekoBot.Modules.Games
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public Task Trivia([Remainder] string additionalArgs = "") public Task Trivia([Remainder] string additionalArgs = "")
=> Trivia(Context.Message, 10, additionalArgs); => Trivia(10, additionalArgs);
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Trivia(IUserMessage umsg, int winReq = 10, [Remainder] string additionalArgs = "") public async Task Trivia(int winReq = 10, [Remainder] string additionalArgs = "")
{ {
var channel = (ITextChannel)umsg.Channel; var channel = (ITextChannel)Context.Channel;
var showHints = !additionalArgs.Contains("nohint"); var showHints = !additionalArgs.Contains("nohint");

View File

@ -580,7 +580,7 @@ $"{("tracks".SnPl(musicPlayer.Playlist.Count))} | {(int)total.TotalHours}h {tota
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task ReptCurSong(IUserMessage umsg) public async Task ReptCurSong()
{ {
MusicPlayer musicPlayer; MusicPlayer musicPlayer;
@ -782,7 +782,7 @@ $"{("tracks".SnPl(musicPlayer.Playlist.Count))} | {(int)total.TotalHours}h {tota
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Autoplay(IUserMessage umsg) public async Task Autoplay()
{ {
MusicPlayer musicPlayer; MusicPlayer musicPlayer;
if (!MusicPlayers.TryGetValue(Context.Guild.Id, out musicPlayer)) if (!MusicPlayers.TryGetValue(Context.Guild.Id, out musicPlayer))

View File

@ -28,9 +28,9 @@ namespace NadekoBot.Modules.NSFW
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Hentai(IUserMessage umsg, [Remainder] string tag = null) public async Task Hentai([Remainder] string tag = null)
{ {
var channel = (ITextChannel)umsg.Channel; var channel = (ITextChannel)Context.Channel;
tag = tag?.Trim() ?? ""; tag = tag?.Trim() ?? "";
@ -66,16 +66,16 @@ namespace NadekoBot.Modules.NSFW
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task AutoHentai(IUserMessage umsg, int interval = 0, string tags = null) public async Task AutoHentai(int interval = 0, string tags = null)
{ {
Timer t; Timer t;
if (interval == 0) if (interval == 0)
{ {
if (AutoHentaiTimers.TryRemove(umsg.Channel.Id, out t)) if (AutoHentaiTimers.TryRemove(Context.Channel.Id, out t))
{ {
t.Change(Timeout.Infinite, Timeout.Infinite); //proper way to disable the timer t.Change(Timeout.Infinite, Timeout.Infinite); //proper way to disable the timer
await umsg.Channel.SendConfirmAsync("Autohentai stopped.").ConfigureAwait(false); await Context.Channel.SendConfirmAsync("Autohentai stopped.").ConfigureAwait(false);
} }
return; return;
} }
@ -90,28 +90,28 @@ namespace NadekoBot.Modules.NSFW
try try
{ {
if (tagsArr == null || tagsArr.Length == 0) if (tagsArr == null || tagsArr.Length == 0)
await Hentai(umsg, null).ConfigureAwait(false); await Hentai(null).ConfigureAwait(false);
else else
await Hentai(umsg, tagsArr[new NadekoRandom().Next(0, tagsArr.Length)]); await Hentai(tagsArr[new NadekoRandom().Next(0, tagsArr.Length)]);
} }
catch { } catch { }
}, null, interval * 1000, interval * 1000); }, null, interval * 1000, interval * 1000);
AutoHentaiTimers.AddOrUpdate(umsg.Channel.Id, t, (key, old) => AutoHentaiTimers.AddOrUpdate(Context.Channel.Id, t, (key, old) =>
{ {
old.Change(Timeout.Infinite, Timeout.Infinite); old.Change(Timeout.Infinite, Timeout.Infinite);
return t; return t;
}); });
await umsg.Channel.SendConfirmAsync($"Autohentai started. Reposting every {interval}s with one of the following tags:\n{string.Join(", ", tagsArr)}").ConfigureAwait(false); await Context.Channel.SendConfirmAsync($"Autohentai started. Reposting every {interval}s with one of the following tags:\n{string.Join(", ", tagsArr)}").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task HentaiBomb(IUserMessage umsg, [Remainder] string tag = null) public async Task HentaiBomb([Remainder] string tag = null)
{ {
var channel = (ITextChannel)umsg.Channel; var channel = (ITextChannel)Context.Channel;
tag = tag?.Trim() ?? ""; tag = tag?.Trim() ?? "";
tag = "rating%3Aexplicit+" + tag; tag = "rating%3Aexplicit+" + tag;
@ -133,76 +133,73 @@ namespace NadekoBot.Modules.NSFW
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Danbooru(IUserMessage umsg, [Remainder] string tag = null) public async Task Danbooru([Remainder] string tag = null)
{ {
var channel = (ITextChannel)umsg.Channel; 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(umsg.Author.Mention + " No results."); await channel.SendErrorAsync(Context.User.Mention + " No results.");
else else
await channel.EmbedAsync(new EmbedBuilder().WithOkColor() await channel.EmbedAsync(new EmbedBuilder().WithOkColor()
.WithDescription(umsg.Author.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);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public Task Yandere(IUserMessage umsg, [Remainder] string tag = null) public Task Yandere([Remainder] string tag = null)
=> Searches.Searches.InternalDapiCommand(umsg, tag, Searches.Searches.DapiSearchType.Yandere); => Searches.Searches.InternalDapiCommand(Context.Message, tag, Searches.Searches.DapiSearchType.Yandere);
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public Task Konachan(IUserMessage umsg, [Remainder] string tag = null) public Task Konachan([Remainder] string tag = null)
=> Searches.Searches.InternalDapiCommand(umsg, tag, Searches.Searches.DapiSearchType.Konachan); => Searches.Searches.InternalDapiCommand(Context.Message, tag, Searches.Searches.DapiSearchType.Konachan);
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public Task Gelbooru(IUserMessage umsg, [Remainder] string tag = null) public Task Gelbooru([Remainder] string tag = null)
=> Searches.Searches.InternalDapiCommand(umsg, tag, Searches.Searches.DapiSearchType.Gelbooru); => Searches.Searches.InternalDapiCommand(Context.Message, tag, Searches.Searches.DapiSearchType.Gelbooru);
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public Task Rule34(IUserMessage umsg, [Remainder] string tag = null) public Task Rule34([Remainder] string tag = null)
=> Searches.Searches.InternalDapiCommand(umsg, tag, Searches.Searches.DapiSearchType.Rule34); => Searches.Searches.InternalDapiCommand(Context.Message, tag, Searches.Searches.DapiSearchType.Rule34);
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task E621(IUserMessage umsg, [Remainder] string tag = null) public async Task E621([Remainder] string tag = null)
{ {
var channel = (ITextChannel)umsg.Channel; var channel = (ITextChannel)Context.Channel;
tag = tag?.Trim() ?? ""; tag = tag?.Trim() ?? "";
var url = await GetE621ImageLink(tag).ConfigureAwait(false); var url = await GetE621ImageLink(tag).ConfigureAwait(false);
if (url == null) if (url == null)
await channel.SendErrorAsync(umsg.Author.Mention + " No results."); await channel.SendErrorAsync(Context.User.Mention + " No results.");
else else
await channel.EmbedAsync(new EmbedBuilder().WithOkColor() await channel.EmbedAsync(new EmbedBuilder().WithOkColor()
.WithDescription(umsg.Author.Mention + " " + tag) .WithDescription(Context.User.Mention + " " + tag)
.WithImageUrl(url) .WithImageUrl(url)
.WithFooter(efb => efb.WithText("e621"))).ConfigureAwait(false); .WithFooter(efb => efb.WithText("e621"))).ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Cp(IUserMessage umsg) public async Task Cp()
{ {
var channel = (ITextChannel)umsg.Channel; await Context.Channel.SendMessageAsync("http://i.imgur.com/MZkY1md.jpg").ConfigureAwait(false);
await channel.SendMessageAsync("http://i.imgur.com/MZkY1md.jpg").ConfigureAwait(false);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Boobs(IUserMessage umsg) public async Task Boobs()
{ {
var channel = (ITextChannel)umsg.Channel;
try try
{ {
JToken obj; JToken obj;
@ -210,20 +207,18 @@ namespace NadekoBot.Modules.NSFW
{ {
obj = JArray.Parse(await http.GetStringAsync($"http://api.oboobs.ru/boobs/{ new NadekoRandom().Next(0, 10229) }").ConfigureAwait(false))[0]; obj = JArray.Parse(await http.GetStringAsync($"http://api.oboobs.ru/boobs/{ new NadekoRandom().Next(0, 10229) }").ConfigureAwait(false))[0];
} }
await channel.SendMessageAsync($"http://media.oboobs.ru/{ obj["preview"].ToString() }").ConfigureAwait(false); await Context.Channel.SendMessageAsync($"http://media.oboobs.ru/{ obj["preview"].ToString() }").ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
await channel.SendErrorAsync(ex.Message).ConfigureAwait(false); await Context.Channel.SendErrorAsync(ex.Message).ConfigureAwait(false);
} }
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Butts(IUserMessage umsg) public async Task Butts()
{ {
var channel = (ITextChannel)umsg.Channel;
try try
{ {
JToken obj; JToken obj;
@ -231,11 +226,11 @@ namespace NadekoBot.Modules.NSFW
{ {
obj = JArray.Parse(await http.GetStringAsync($"http://api.obutts.ru/butts/{ new NadekoRandom().Next(0, 4222) }").ConfigureAwait(false))[0]; obj = JArray.Parse(await http.GetStringAsync($"http://api.obutts.ru/butts/{ new NadekoRandom().Next(0, 4222) }").ConfigureAwait(false))[0];
} }
await channel.SendMessageAsync($"http://media.obutts.ru/{ obj["preview"].ToString() }").ConfigureAwait(false); await Context.Channel.SendMessageAsync($"http://media.obutts.ru/{ obj["preview"].ToString() }").ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
await channel.SendErrorAsync(ex.Message).ConfigureAwait(false); await Context.Channel.SendErrorAsync(ex.Message).ConfigureAwait(false);
} }
} }

View File

@ -475,7 +475,7 @@ namespace NadekoBot.Modules.Searches
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Hashtag(IUserMessage umsg, [Remainder] string query = null) public async Task Hashtag([Remainder] string query = null)
{ {
var arg = query; var arg = query;
if (string.IsNullOrWhiteSpace(arg)) if (string.IsNullOrWhiteSpace(arg))
@ -551,7 +551,7 @@ namespace NadekoBot.Modules.Searches
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public Task Safebooru(IUserMessage umsg, [Remainder] string tag = null) public Task Safebooru([Remainder] string tag = null)
=> InternalDapiCommand(umsg, tag, DapiSearchType.Safebooru); => InternalDapiCommand(umsg, tag, DapiSearchType.Safebooru);
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]