public async Task BaseCalendarAdd(int month, int day, int year, string name) { if (name.Length > 100) { await ReplyAsync("Event message too long! Keep it under 100 characters."); return; } if (day > DateTime.DaysInMonth(year, month)) { await ReplyAsync("Invalid date!"); return; } DateTime now = DateTime.UtcNow; if ((now.Day > day && now.Month == month && now.Year == year) || (now.Month > month && now.Year == year) || now.Year > year) { await ReplyAsync("You can't create an event at a date that's in the past!"); return; } CalendarHelper.AddToCalendar(month, day, year, name); await CalendarHelper.UpdateCalendarMessage(Context.Client); await ReplyAsync("Added to calendar."); }
public async Task CalendarRemove(int month, int day, int year, [Remainder] string name) { if (!CalendarHelper.CalendarEventExists(month, day, year, name)) { await ReplyAsync("Calendar event not found! Make sure the month, day, year, and name are all exactly the same."); return; } CalendarHelper.RemoveCalendarEvent(month, day, year, name); await CalendarHelper.UpdateCalendarMessage(Context.Client); await ReplyAsync("Event deleted."); }
public async Task CalendarChannel(string name) { var channel = Context.Guild.Channels.FirstOrDefault(n => n.Name == name); if (channel is null) { await ReplyAsync("Channel not found! Make sure you typed in the name correctly."); return; } CalendarHelper.EditCalendarChannel(channel); await ReplyAsync("Channel changed."); }
async Task Loop() { do { await ReminderHelper.ScanForNewReminders(client); if ((DateTime.UtcNow.Hour == 0 && DateTime.UtcNow.Minute < 1) || firstRun) //if it is a new day { PollHelper.ScanForOldPolls(); await CalendarHelper.UpdateCalendarMessage(client); CalendarHelper.RemoveOldEvents(); firstRun = false; } await Task.Delay(60000); //every minute } while (true); }