From 6437fb6f90701eb6b5d579f45b2c57b311feba1e Mon Sep 17 00:00:00 2001 From: Kwoth Date: Mon, 6 Mar 2017 18:43:03 +0100 Subject: [PATCH] Fixed .remind me --- .../Modules/Utility/Commands/Remind.cs | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/NadekoBot/Modules/Utility/Commands/Remind.cs b/src/NadekoBot/Modules/Utility/Commands/Remind.cs index 45406de9..092d1470 100644 --- a/src/NadekoBot/Modules/Utility/Commands/Remind.cs +++ b/src/NadekoBot/Modules/Utility/Commands/Remind.cs @@ -64,7 +64,10 @@ namespace NadekoBot.Modules.Utility IMessageChannel ch; if (r.IsPrivate) { - ch = await NadekoBot.Client.GetDMChannelAsync(r.ChannelId).ConfigureAwait(false); + var user = NadekoBot.Client.GetGuild(r.ServerId).GetUser(r.ChannelId); + if(user == null) + return; + ch = await user.CreateDMChannelAsync().ConfigureAwait(false); } else { @@ -100,23 +103,16 @@ namespace NadekoBot.Modules.Utility [Priority(1)] public async Task Remind(MeOrHere meorhere, string timeStr, [Remainder] string message) { - IMessageChannel target; - if (meorhere == MeOrHere.Me) - { - target = await ((IGuildUser)Context.User).CreateDMChannelAsync().ConfigureAwait(false); - } - else - { - target = Context.Channel; - } - await Remind(target, timeStr, message).ConfigureAwait(false); + ulong target; + target = meorhere == MeOrHere.Me ? Context.User.Id : Context.Channel.Id; + await Remind(target, meorhere == MeOrHere.Me, timeStr, message).ConfigureAwait(false); } [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] [RequireUserPermission(GuildPermission.ManageMessages)] [Priority(0)] - public async Task Remind(IMessageChannel ch, string timeStr, [Remainder] string message) + public async Task Remind(ulong targetId, bool isPrivate, string timeStr, [Remainder] string message) { var channel = (ITextChannel)Context.Channel; @@ -164,8 +160,8 @@ namespace NadekoBot.Modules.Utility var rem = new Reminder { - ChannelId = ch.Id, - IsPrivate = ch is IDMChannel, + ChannelId = targetId, + IsPrivate = isPrivate, When = time, Message = message, UserId = Context.User.Id, @@ -182,7 +178,7 @@ namespace NadekoBot.Modules.Utility { await channel.SendConfirmAsync( "⏰ " + GetText("remind", - Format.Bold(ch is ITextChannel ? ((ITextChannel) ch).Name : Context.User.Username), + Format.Bold(!isPrivate ? $"<#{targetId}>" : Context.User.Username), Format.Bold(message.SanitizeMentions()), Format.Bold(output), time, time)).ConfigureAwait(false);