Skip to content

Instantly share code, notes, and snippets.

@EasyThe
Created June 8, 2018 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EasyThe/9c1e3e84c29fd10e2d39d05a150f5cce to your computer and use it in GitHub Desktop.
Save EasyThe/9c1e3e84c29fd10e2d39d05a150f5cce to your computer and use it in GitHub Desktop.
[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