Remind fixed

This commit is contained in:
Kwoth 2016-10-24 07:58:18 +02:00
parent 273f5a29a2
commit d34a429c1c

View File

@ -93,28 +93,36 @@ namespace NadekoBot.Modules.Utility
} }
} }
public enum MeOrHere
{
Me,Here
}
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
public async Task Remind(IUserMessage umsg, string meorchannel, string timeStr, [Remainder] string message) [Priority(1)]
public async Task Remind(IUserMessage umsg, MeOrHere meorhere, string timeStr, [Remainder] string message)
{ {
var channel = (ITextChannel)umsg.Channel; var channel = (ITextChannel)umsg.Channel;
var meorchStr = meorchannel.ToUpperInvariant(); IMessageChannel target;
IMessageChannel ch; if (meorhere == MeOrHere.Me)
bool isPrivate = false;
if (meorchStr == "ME")
{ {
isPrivate = true; target = await ((IGuildUser)umsg.Author).CreateDMChannelAsync().ConfigureAwait(false);
ch = await ((IGuildUser)umsg.Author).CreateDMChannelAsync().ConfigureAwait(false);
}
else if (meorchStr == "HERE")
{
ch = channel;
} }
else else
{ {
ch = channel.Guild.GetTextChannels().FirstOrDefault(c => c.Name.ToUpperInvariant() == meorchStr || c.Id.ToString() == meorchStr); target = channel;
} }
await Remind(umsg, target, timeStr, message).ConfigureAwait(false);
}
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
[Priority(0)]
public async Task Remind(IUserMessage umsg, IMessageChannel ch, string timeStr, [Remainder] string message)
{
var channel = (ITextChannel)umsg.Channel;
if (ch == null) if (ch == null)
{ {
@ -168,7 +176,7 @@ namespace NadekoBot.Modules.Utility
var rem = new Reminder var rem = new Reminder
{ {
ChannelId = ch.Id, ChannelId = ch.Id,
IsPrivate = isPrivate, IsPrivate = ch is IDMChannel,
When = time, When = time,
Message = message, Message = message,
UserId = umsg.Author.Id, UserId = umsg.Author.Id,
@ -184,7 +192,7 @@ namespace NadekoBot.Modules.Utility
try { await channel.SendMessageAsync($"⏰ I will remind \"{(ch is ITextChannel ? ((ITextChannel)ch).Name : umsg.Author.Username)}\" to \"{message.SanitizeMentions()}\" in {output}. ({time:d.M.yyyy.} at {time:HH:mm})").ConfigureAwait(false); } catch { } try { await channel.SendMessageAsync($"⏰ I will remind \"{(ch is ITextChannel ? ((ITextChannel)ch).Name : umsg.Author.Username)}\" to \"{message.SanitizeMentions()}\" in {output}. ({time:d.M.yyyy.} at {time:HH:mm})").ConfigureAwait(false); } catch { }
await StartReminder(rem); await StartReminder(rem);
} }
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)] [RequireContext(ContextType.Guild)]
[OwnerOnly] [OwnerOnly]