public void Add_Reminder_Check() { setUpUser(); Assert.That(RemindMeController.FindReminder(note), Is.EqualTo(true)); File.Delete(Constants.remindMePath); }
public void Delete_Reminder_Admin_Check() { setUpUser(); Assert.That(RemindMeController.DeleteReminder(1, "Admin2"), Is.EqualTo(true)); File.Delete(Constants.remindMePath); }
private DateTime setUpUser() { DateTime time = DateTime.Now.Add(timeToWait); RemindMeController.AddRemindMeHistory(time, note, userId); return(time); }
public void Get_My_Reminders_Check() { File.Delete(Constants.remindMePath); var time = setUpUser(); string answer2 = RemindMeController.GetMyReminders(userId); Assert.AreEqual($"1, {userId}, {time}, {note} \r\n", answer2); File.Delete(Constants.remindMePath); }
public void Get_Reminder_Check() { File.Delete(Constants.remindMePath); var time = setUpUser(); string answer = RemindMeController.GetReminders(); Assert.AreEqual(answer, $"1, {userId}, {time}, {note} \r\n"); File.Delete(Constants.remindMePath); }
public async Task GetReminders() { // Search the db for current reminders (active) string currentReminders = RemindMeController.GetReminders(); if (currentReminders == "") { await ReplyAsync("There are no active reminders!"); } else { await ReplyAsync(currentReminders); } }
public async Task DeleteReminder(string id) { //Gets your discord user id var msg = Context.Message; var discordId = msg.Author.Username; // Delete item from the db bool hasDeleted = RemindMeController.DeleteReminder(Convert.ToInt32(id), discordId); if (hasDeleted) { await ReplyAsync($"{id} was deleted"); } else { await ReplyAsync($"You cannot delete someone elses reminders! Not cool..."); } }
public async Task GetMyReminders() { //Gets your discord user id var msg = Context.Message; var discordId = msg.Author.Username; // Search the db for current reminders (active) string currentReminders = RemindMeController.GetMyReminders(discordId); if (currentReminders == "") { await ReplyAsync("There are no active reminders!"); } else { await ReplyAsync(currentReminders); } }
public async Task RemindDateTime(string date, [Remainder] string note) { // Discord user info var msg = Context.Message; var discordId = msg.Author.Username; try { //Set all the date time info var currentTime = DateTime.Now; var userTime = DateTime.Parse(date); var timeToWait = userTime.Subtract(currentTime); TimeSpan timeToGo = timeToWait; // Add the reminder to the db RemindMeController.AddRemindMeHistory(userTime, note, discordId); await ReplyAsync($"Don't worry {discordId}! I will remind you at {userTime}"); // Handle the timer if its in the past if (timeToGo < TimeSpan.Zero) { await ReplyAsync("Time Passed Fam"); } //EVENT HANDLER FOR THE TIMER REACHING THE TIME _timer = new System.Threading.Timer(x => { ReplyWithNote($"{msg.Author.Mention} Remember: {note} \r\n This test was set up at {userTime} it is currently {DateTime.Now.ToString()}", note); }, null, timeToGo, Timeout.InfiniteTimeSpan); } catch (FormatException e) { Console.WriteLine(e); await ReplyAsync("Date was in an incorrect format. Use the format 'DD/MM/YYYY HH:MM:SS'(Must be in inverted commas) \r\n Or just type a date for a day"); } catch (Exception e) { await ReplyAsync(e.Message); } }
// Method to run when the timer is finished public async void ReplyWithNote(string userNote, string note) { // Check if the timer is still in the db bool timerExists = RemindMeController.FindReminder(note); //If the timer is still in the db awesome if (timerExists) { await ReplyAsync(userNote); RemindMeController.DeleteReminderEnd(note); _timer.Dispose(); } else { //End the instance of the timer _timer.Dispose(); //await ReplyAsync("THIS MESSAGE MEANS IT FKING WORKS"); } }
public async Task RemindMe(int hours, int mins, int seconds, [Remainder] string note) { // Discord user info var msg = Context.Message; var discordId = msg.Author.Username; //Set all the date time info TimeSpan timeToWait = new TimeSpan(hours, mins, seconds); TimeSpan timeToGo = timeToWait; DateTime setTime = DateTime.Now.Add(timeToGo); // Add reminder to the db RemindMeController.AddRemindMeHistory(setTime, note, discordId); await ReplyAsync($"Don't worry {discordId}! I will remind you in {timeToWait}"); //EVENT HANDLER FOR THE TIMER REACHING THE TIME _timer = new System.Threading.Timer(x => { ReplyWithNote($"{msg.Author.Mention} Remember: {note}", note); }, null, timeToGo, Timeout.InfiniteTimeSpan); }
public async Task AdminDeleteReminder(string id) { // Delete item from the db RemindMeController.DeleteReminder(Convert.ToInt32(id), "Admin2"); await ReplyAsync($"{id} was deleted"); }
public void Delete_Reminder_Fails() { setUpUser(); Assert.That(RemindMeController.DeleteReminder(1, "Test"), Is.EqualTo(false)); File.Delete(Constants.remindMePath); }
public void Find_Reminder_Failed() { File.Delete(Constants.remindMePath); Assert.That(RemindMeController.FindReminder(note), Is.EqualTo(false)); }