Created
June 8, 2018 03:48
-
-
Save EasyThe/9c1e3e84c29fd10e2d39d05a150f5cce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Command("person")] | |
public async Task GetRandomPerson() | |
{ | |
string json = ""; | |
using (WebClient client = new WebClient()) | |
{ | |
json = client.DownloadString("https://randomuser.me/api/?gender=male&nat=US"); | |
} | |
var dataObject = JsonConvert.DeserializeObject<dynamic>(json); | |
string firstN = dataObject.results[0].name.first.ToString(); | |
string lastN = dataObject.results[0].name.last.ToString(); | |
string avatarURL = dataObject.results[0].picture.large.ToString(); | |
string firstName = firstN.Substring(0, 1).ToUpper() + firstN.Substring(1); | |
string lastName = lastN.Substring(0, 1).ToUpper() + lastN.Substring(1); | |
var embed = new EmbedBuilder(); | |
embed.WithThumbnailUrl(avatarURL); | |
embed.WithTitle("Generated Person"); | |
embed.AddField("First Name", firstName, inline: true); | |
embed.AddField("Last Name", lastName, inline: true); | |
await Context.Channel.SendMessageAsync("", embed: embed.Build()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment