예제 #1
0
        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.");
        }
예제 #2
0
        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.");
        }
예제 #3
0
        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.");
        }
예제 #4
0
        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);
        }