Beispiel #1
0
        public async Task PostponeReminderAsync(IUserMessage message, SocketReaction reaction)
        {
            if (!(message.Channel is IPrivateChannel))
            {
                return;
            }

            if (!await CanPostponeRemindAsync(message, reaction))
            {
                var logMessage = $"Embeds: {message.Embeds.Count}, IsEmoji: {reaction.Emote is Emoji}, Time: {DateTime.UtcNow - message.CreatedAt}";
                Logger.LogInformation($"Skipped postpone remind for {(reaction.User.IsSpecified ? $"UnknownUser({reaction.UserId})" : reaction.User.Value.Username)}\n{logMessage}");

                return;
            }

            var remind = await GrillBotRepository.ReminderRepository.FindReminderByMessageIdAsync(message.Id);

            if (remind == null)
            {
                return;
            }

            var hours = ReminderDefinitions.EmojiToHourNumberMapping[reaction.Emote as Emoji];

            remind.RemindMessageIDSnowflake = null;
            remind.At = DateTime.Now.AddHours(hours);
            remind.PostponeCounter++;

            await message.DeleteMessageAsync();

            await GrillBotRepository.CommitAsync();

            Queue.Add(new ReminderBackgroundTask(remind));
        }