async Task ExecuteReminderCommandAsync() { if (!IsReminderSet) { var result = await ReminderService.AddReminderAsync(SelectedWorkshop.Id, new Plugin.Calendars.Abstractions.CalendarEvent { AllDay = false, Description = SelectedWorkshop.Abstract, Location = SelectedWorkshop.Room?.Name ?? string.Empty, Name = SelectedWorkshop.Title, Start = SelectedWorkshop.StartTime.Value, End = SelectedWorkshop.EndTime.Value }); if (!result) { return; } Logger.Log($"{DevopenspaceLoggerKeys.ReminderAdded}, Title, {SelectedWorkshop.Title}", Prism.Logging.Category.Info, Priority.None); IsReminderSet = true; } else { var result = await ReminderService.RemoveReminderAsync(SelectedWorkshop.Id); if (!result) { return; } Logger.Log($"{DevopenspaceLoggerKeys.ReminderRemoved}, Title, {SelectedWorkshop.Title}", Prism.Logging.Category.Info, Priority.None); IsReminderSet = false; } }
public async Task <DiscordCommandResult> ReminderAsync([Remainder] Reminder reminder) { if (reminder.ExecutionTime <= DateTime.Now) { return(Response("Reminder cannot be set in the past.")); } await _reminderService.AddReminderAsync(reminder); return(Response($"Ok, I will remind you to {Markdown.Code(reminder.Value)} {GetTimestampWithArticle(reminder)} (Id:{reminder.Id})")); }
private async Task ExecuteReminderCommandAsync() { if (!IsReminderSet) { try { var result = await ReminderService.AddReminderAsync("event_" + SelectedEvent.Id, new Plugin.Calendars.Abstractions.CalendarEvent { Description = SelectedEvent.Description, Location = SelectedEvent.LocationName, AllDay = SelectedEvent.IsAllDay, Name = SelectedEvent.Title, Start = SelectedEvent.StartTime.Value, End = SelectedEvent.EndTime.Value }); if (!result) { return; } Logger.Log($"{DevopenspaceLoggerKeys.ReminderAdded}, Title, {SelectedEvent.Title}", Prism.Logging.Category.Info, Priority.None); IsReminderSet = true; } catch (Exception ex) { Logger.Log($"{DevopenspaceLoggerKeys.ReminderAdded}, Title, {SelectedEvent.Title}. {ex}", Prism.Logging.Category.Info, Priority.None); return; } } else { var result = await ReminderService.RemoveReminderAsync("event_" + SelectedEvent.Id); if (!result) { return; } Logger.Log($"{DevopenspaceLoggerKeys.ReminderRemoved}, Title, {SelectedEvent.Title}", Prism.Logging.Category.Info, Priority.None); IsReminderSet = false; } }
private async Task <RuntimeResult> RemindAsync(SocketUser user, DateTimeOffset dateTime, string remindContent) { if (DateTimeOffset.Now > dateTime) { return(CommandRuntimeResult.FromError($"{dateTime} has already passed!")); } var userTimeOffset = GetUserTimeOffset(user); await ReminderService.AddReminderAsync(user, Context.Channel, dateTime, remindContent).ConfigureAwait(false); await ReplyAsync(string.Empty, embed : EmbedHelper.FromSuccess() .WithAuthor(new EmbedAuthorBuilder { IconUrl = Context.Client.CurrentUser.GetAvatarUrlOrDefault(), Name = "New Reminder Set!" }) .AddField("Reminder", remindContent, true) .AddField("At", dateTime.ToOffset(userTimeOffset)).Build()).ConfigureAwait(false); return(CommandRuntimeResult.FromSuccess()); }