public ReminderEmbed(SocketCommandContext ctx) { SetCtx(ctx); User = BotUtils.GetGUser(ctx); UserTimeZone = UserDataManager.GetUserData(User).TimeZone; Timeout = new TimeSpan(0, 30, 0); RefreshList(); AddMenuOptions(ReactionHandler.SELECT, new MenuOptionNode(ASTERISK_NEW, "Add"), ReactionHandler.UP, ReactionHandler.DOWN, new MenuOptionNode(ReactionHandler.DECLINE_STR, "Delete"), new MenuOptionNode(PENCIL, "Edit"), ReactionHandler.BACK); RegisterMenuFields(); }
public override async Task ButtonAction(SocketReaction action) { if (action.Emote.ToString() == ReactionHandler.CHECK_STR) { TimeZone.Replace(" ", ""); if (Regex.IsMatch(TimeZone, PATTERN)) { TimeZoneNode node = new TimeZoneNode(Regex.Match(TimeZone, PATTERN).Value); UserDataManager.GetUserData(BotUtils.GetGUser(Context)).TimeZone = node; UserDataManager.SaveUserData(); EventQueueManager.RemoveMessageEvent(this); await Message.DeleteAsync(); await Context.Channel.SendMessageAsync(BotUtils.KamtroText("Time zone set successfuly!")); } else { BadFormat = true; await UpdateEmbed(); } } }
public override Embed GetEmbed() { EmbedBuilder eb = new EmbedBuilder(); eb.WithTitle("Reminders"); eb.WithColor(BotUtils.Kamtro); switch (PageNum) { case 1: string names = ""; string descs = ""; string dates = ""; for (int i = 0; i < ReminderList.Count; i++) { ReminderPointer rp = ReminderList[i]; ReminderNode node = ReminderManager.GetReminder(rp); names += $"{(CursorPos == i + 1 ? CustomEmotes.CursorAnimated:"")}{MakeBold(node.Name, CursorPos == i + 1)}\n"; descs += MakeBold(BotUtils.ShortenLongString(node.Description, 20), CursorPos == i + 1) + "\n"; dates += MakeBold(GetDateString(rp), CursorPos == i + 1) + "\n"; } if (ReminderList.Count == 0) { eb.AddField("Reminders", "You don't have any reminders set! Click the add reminder button to add one!"); } else { eb.AddField("Name", names, true); eb.AddField("Description", descs, true); eb.AddField("Date M/D/Y", dates, true); } break; case 2: string name, desc, dt; if (CurrentReminder == null) { name = "ERROR"; desc = "Something went wrong! Please contact arcy or carbon!\nTry clicking the back button!"; dt = "NONE"; } else { name = ReminderManager.GetReminder(CurrentReminder).Name; desc = ReminderManager.GetReminder(CurrentReminder).Description; DateTime d = DateTime.Parse(CurrentReminder.Date); TimeZoneNode node = UserDataManager.GetUserData(BotUtils.GetGUser(CurrentReminder.User)).TimeZone; d.AddHours(node.Hour); d.AddMinutes(node.Minute); dt = d.ToString("dd/MM/yyyy") + " at " + d.ToString("hh:mm tt"); } eb.AddField("Name", name); eb.AddField("Time", dt); eb.AddField("Description", desc); break; case 3: eb.WithTitle("Add Reminder"); eb.WithDescription("When adding a reminder, make sure that you add a space in between the time, and the AM/PM if you are using a 12 hour clock. AM/PM are not nessecary in a 24 hour clock.\nDates MUST be in MM/DD/YYYY format. Months are in number form, January is 1 (or 01, single digit numbers can have a single zero in front if you want), December is 12."); break; case 4: eb.WithTitle("Edit Remidner"); string options = $"{(CursorPos == 1 ? CustomEmotes.CursorAnimated : CustomEmotes.CursorBlankSpace)}Edit Name\n"; options += $"{(CursorPos == 2 ? CustomEmotes.CursorAnimated : CustomEmotes.CursorBlankSpace)}Edit Description\n"; options += $"{(CursorPos == 3 ? CustomEmotes.CursorAnimated : CustomEmotes.CursorBlankSpace)}Edit Date/Time"; eb.AddField("Options", options); break; case 5: case 6: case 7: eb.WithTitle("Edit Remidner"); break; } AddEmbedFields(eb); AddMenu(eb); if (ModifySuccess) { eb.AddField("Success", SuccessMessage); ModifySuccess = false; SuccessMessage = BotUtils.ZeroSpace; } if (ErrorHappened) { eb.AddField("ERROR", ErrorMessage); ErrorHappened = false; ErrorMessage = BotUtils.ZeroSpace; } return(eb.Build()); }