Reminder fixed

This commit is contained in:
Kwoth 2016-08-26 03:35:10 +02:00
parent b48bd16bd0
commit e47a9ca99c

View File

@ -48,10 +48,8 @@ namespace NadekoBot.Modules.Utility
{ {
var now = DateTime.Now; var now = DateTime.Now;
var twoMins = new TimeSpan(0, 2, 0); var twoMins = new TimeSpan(0, 2, 0);
TimeSpan time = (r.When - now) < twoMins TimeSpan time = r.When - now;
? twoMins //if the time is less than 2 minutes,
: r.When - now; //it will send the message 2 minutes after start
//To account for high bot startup times
if (time.TotalMilliseconds > int.MaxValue) if (time.TotalMilliseconds > int.MaxValue)
return; return;
@ -180,9 +178,11 @@ namespace NadekoBot.Modules.Utility
using (var uow = DbHandler.UnitOfWork()) using (var uow = DbHandler.UnitOfWork())
{ {
uow.Reminders.Add(rem); uow.Reminders.Add(rem);
await uow.CompleteAsync();
} }
await channel.SendMessageAsync($"⏰ I will remind \"{(ch is ITextChannel ? ((ITextChannel)ch).Name : imsg.Author.Username)}\" to \"{message.ToString()}\" in {output}. ({time:d.M.yyyy.} at {time:HH:mm})").ConfigureAwait(false); await channel.SendMessageAsync($"⏰ I will remind \"{(ch is ITextChannel ? ((ITextChannel)ch).Name : imsg.Author.Username)}\" to \"{message.ToString()}\" in {output}. ({time:d.M.yyyy.} at {time:HH:mm})").ConfigureAwait(false);
await StartReminder(rem);
} }
////todo owner only ////todo owner only