Exemple #1
0
        public async Task AuthAsync()
        {
            // before we begin, check if the pre-reqs are met
            if (!GoogleCalendarSyncService.DoesGoogleAPIClientIDFileExist())
            {
                await ReplyAsync(
                    $"We can't find some things we need for this to work. " +
                    $"Contact {Context.Guild.GetUser(ulong.Parse(Config["discordBotOwnerId"])).Mention} (client_id.json file missing). " +
                    $"When that's resolved, run the ```{Config["prefix"]}auth``` command to continue the process.");

                return;
            }

            await GoogleCalendarSyncService.GetAuthCode(Context);

            var response = await NextMessageAsync(true, true, TimeSpan.FromSeconds(60));

            if (response != null)
            {
                await GoogleCalendarSyncService.GetTokenAndLogin(response.Content, Context);
            }
            else
            {
                await ReplyAsync("I didn't get a response in time. Try again.");
            }
        }
Exemple #2
0
 public async Task CalendarIdSetAsync([Remainder] string input)
 {
     if (input != "")
     {
         await GoogleCalendarSyncService.SetCalendarId(input, Context);
         await ReplyAndDeleteAsync(
             $":white_check_mark: Calendar ID set. You can use ```{Config["prefix"]}sync``` to sync up your calendar now.", false, null, TimeSpan.FromMinutes(1));
     }
     else
     {
         await ReplyAsync("You need to provide a calendar ID after the command.");
     }
 }
        public async Task AuthAsync()
        {
            await GoogleCalendarSyncService.GetAuthCode(Context);

            var response = await NextMessageAsync(true, true, TimeSpan.FromSeconds(60));

            if (response != null)
            {
                await GoogleCalendarSyncService.GetTokenAndLogin(response.Content, Context);
            }
            else
            {
                await ReplyAsync("I didn't get a response in time. Try again.");
            }
        }
Exemple #4
0
        public async Task AdjustEventAsync(string function, int value = 0)
        {
            if (function != "start" && function != "end" && function != "clear" || function != "clear" && value == 0)
            {
                await ReplyAsync($"You didn't correctly fill out the command. Syntax is ```{Config["prefix"]}adjust start/end amount (in minutes)```");

                return;
            }

            var result = GoogleCalendarSyncService.AdjustUpcomingEvent(function, value, Context);

            if (result == true)
            {
                var server = DbDiscordServers.ServerList.Find(x => x.DiscordServerObject == Context.Guild);

                StringBuilder responseBuilder = new StringBuilder();
                responseBuilder.Append($"Event {server.Events[0].Name} adjusted - ");

                if (function == "start")
                {
                    responseBuilder.Append($" new start time: {server.Events[0].StartDate}");
                }
                if (function == "end")
                {
                    responseBuilder.Append($" new end time: {server.Events[0].EndDate}");
                }
                if (function == "clear")
                {
                    responseBuilder.Append($"adjustment cleared. Use the ```{Config["prefix"]}sync``` command to reload original values.");
                }

                await ReplyAsync(responseBuilder.ToString());
            }
            if (result == false)
            {
                await ReplyAsync("Adjust failed - you probably tried to make the event start after it was set to end or something.");
            }
            if (result == null)
            {
                await ReplyAsync("Adjust failed - this server doesn't have any events to adjust.");
            }
        }
Exemple #5
0
 public async Task CalendarSyncAsync()
 {
     await GoogleCalendarSyncService.ManualSync(null, Context);
 }