I'm writing a bot, which should get a list of all users on a server, figure out if they are playing a game and displaying the user and the game in an embed for now. My problem is, that from everything I found there seems to be a way. But there is no thing like "user.Activity" or "user.Game.Name" available. Is there a way to do it?
My code:
[Command("playing")]
[Alias("p")]
public async Task GetUsersPlaying()
{
var users = Context.Guild.Users;
var embed = new EmbedBuilder { };
foreach (IGuildUser user in users)
{
if (user.Activity is CustomStatusGame statusGame)
{
embed.AddField("User", user, false);
embed.AddField("Game", user.Game.Name, true);
}
}
await ReplyAsync(embed: embed.Build());
}