예제 #1
0
        public async Task PlayerStats(CommandContext ctx, string platform, [RemainingText] string username)
        {
            await ctx.TriggerTypingAsync();

            string result;

            try
            {
                result = await Httpclient.GetStringAsync($"https://api.mozambiquehe.re/bridge?version=5&platform={platform}&player={username}&auth={Configuration.ApiTrackerKey}");
            }
            catch (Exception)
            {
                await ctx.Channel.SendMessageAsync("Couldn't fetch user data");

                return;
            }

            var stats  = ApexService.GetPlayerStats(result);
            var embeds = ApexService.BuildStatEmbeds(stats);

            var statEmbed = embeds[0];
            var rankEmbed = embeds[1];

            await ctx.RespondAsync(statEmbed);

            await ctx.RespondAsync(rankEmbed);
        }
예제 #2
0
        /// <summary>
        /// Nazim
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="apiUrl"></param>
        /// <returns></returns>
        public static IList <T> GetResponseForAPIServices <T>(string apiUrl)
        {
            try
            {
                HttpStatusCode Status = Httpclient.GetRequestApiStatus(apiUrl);

                Assert.AreEqual(HttpStatusCode.OK, Status, "Api Not Responding.");

                IList <T> vpodResponse =
                    CommonUtilities.DeserializeJSONResponse <T>(
                        (Httpclient.GetRequest <T>(apiUrl)).Result);


                return(vpodResponse);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
예제 #3
0
        public async Task MapRotation(CommandContext ctx)
        {
            await ctx.TriggerTypingAsync();

            string result;

            try
            {
                result = await Httpclient.GetStringAsync($"https://api.mozambiquehe.re/maprotation?auth={Configuration.ApiTrackerKey}");
            }
            catch (Exception)
            {
                await ctx.Channel.SendMessageAsync("Couldn't fetch data");

                return;
            }

            var rotation      = ApexService.GetRotation(result);
            var rotationEmbed = ApexService.BuildRotationEmbed(rotation);

            await ctx.RespondAsync(rotationEmbed);
        }
 public BooksController()
 {
     // Use this client handler to bypass ssl policy errors
     clientHandler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => { return(true); };
     client = new Httpclient(clientHandler);
 }