Example #1
0
        private DateTime setUpUser()
        {
            DateTime time = DateTime.Now.Add(timeToWait);

            RemindMeController.AddRemindMeHistory(time, note, userId);

            return(time);
        }
Example #2
0
        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);
            }
        }
Example #3
0
        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);
        }