Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Command("twitchuser")]
- public async Task twitchAsync(string username = "")
- {
- using (var client = new HttpClient(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate }))
- {
- string websiteurl = $"https://api.twitch.tv/kraken/channels/{username}?client_id=g8vz0dctlo417o6dz3gvol1ssws1ih";
- client.BaseAddress = new Uri(websiteurl);
- HttpResponseMessage response = client.GetAsync("").Result;
- response.EnsureSuccessStatusCode();
- string result = await response.Content.ReadAsStringAsync();
- var json = JObject.Parse(result);
- string name = json["name"].ToString();
- string bio = json["bio"].ToString();
- string created_at = json["created_at"].ToString();
- string logo = json["logo"].ToString();
- string updated_at = json["updated_at"].ToString();
- string views = json["views"].ToString();
- string followers = json["followers"].ToString();
- var embed = new EmbedBuilder();
- embed.WithTitle($"{name}'s info")
- .WithDescription($"**Username:** {name}"
- + "\n" +
- $"**Bio:** {bio}"
- + "\n" +
- $"**Created at:** {created_at}"
- + "\n" +
- $"**Last updated at:** {updated_at}"
- + "\n" +
- $"**Total Views:** {views}"
- + "\n" +
- $"**Followers:** {followers}"
- )
- .WithThumbnailUrl($"{logo}")
- .WithColor(Color.Gold);
- await ReplyAsync("", false, embed.Build());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement