public async Task GetTime(CommandContext ctx,
                                  [Description("Location to retrieve time data from")][RemainingText] string location)
        {
            if (!BotServices.CheckUserInput(location))
            {
                return;
            }
            var results = GoogleService.GetTimeDataAsync(location).Result;

            if (results.status != "OK")
            {
                await BotServices.SendEmbedAsync(ctx, Resources.NOT_FOUND_GENERIC, EmbedType.Missing).ConfigureAwait(false);
            }
            else
            {
                var output = new DiscordEmbedBuilder()
                             .WithTitle(":clock1: Current time in " + results.Results[0].FormattedAddress)
                             .WithDescription(Formatter.Bold(results.Time.ToShortTimeString()) + " " + results.Timezone.timeZoneName)
                             .WithColor(SharedData.DefaultColor);
                await ctx.RespondAsync(embed : output.Build()).ConfigureAwait(false);
            }
        }
Example #2
0
 public void GetTimeData()
 {
     Assert.IsTrue(GoogleService.GetTimeDataAsync("Ottawa").Result.status == "OK");
     Assert.IsFalse(GoogleService.GetTimeDataAsync("Ottura").Result.status == "OK");
 }