Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.06 KB | None | 0 0
  1. [Command("twitchuser")]
  2.         public async Task twitchAsync(string username = "")
  3.         {
  4.             using (var client = new HttpClient(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate }))
  5.             {
  6.                 string websiteurl = $"https://api.twitch.tv/kraken/channels/{username}?client_id=g8vz0dctlo417o6dz3gvol1ssws1ih";
  7.                 client.BaseAddress = new Uri(websiteurl);
  8.                 HttpResponseMessage response = client.GetAsync("").Result;
  9.                 response.EnsureSuccessStatusCode();
  10.                 string result = await response.Content.ReadAsStringAsync();
  11.                 var json = JObject.Parse(result);
  12.                
  13.                 string name = json["name"].ToString();
  14.                 string bio = json["bio"].ToString();
  15.                 string created_at = json["created_at"].ToString();
  16.                 string logo = json["logo"].ToString();
  17.                 string updated_at = json["updated_at"].ToString();
  18.                 string views = json["views"].ToString();
  19.                 string followers = json["followers"].ToString();
  20.  
  21.  
  22.                 var embed = new EmbedBuilder();
  23.                 embed.WithTitle($"{name}'s info")
  24.                     .WithDescription($"**Username:** {name}"
  25.                                     + "\n" +
  26.                                     $"**Bio:** {bio}"
  27.                                     + "\n" +
  28.                                     $"**Created at:** {created_at}"
  29.                                     + "\n" +
  30.                                     $"**Last updated at:** {updated_at}"
  31.                                     + "\n" +
  32.                                     $"**Total Views:** {views}"
  33.                                     + "\n" +
  34.                                     $"**Followers:** {followers}"
  35.                                   )
  36.                     .WithThumbnailUrl($"{logo}")
  37.                     .WithColor(Color.Gold);
  38.  
  39.                 await ReplyAsync("", false, embed.Build());
  40.  
  41.             }
  42.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement