public async Task IsLive(CommandContext ctx, string twitchUsername) { string[] userList = { twitchUsername }; // get twitch user's id var twitchUser = await twitchAdapter.GetTwitchUsers(userList); if (twitchUser != null && twitchUser.Total > 0) { bool isLive = await twitchAdapter.CheckIfStreamIsLive(twitchUser.Users[0].Id.ToString()); if (isLive) { await ctx.Channel.SendMessageAsync(twitchUser.Users[0].Name + " is live!").ConfigureAwait(false); } else { await ctx.Channel.SendMessageAsync($"{twitchUsername} is not live!").ConfigureAwait(false); } } else { await ctx.Channel.SendMessageAsync($"{twitchUsername} does not exist!").ConfigureAwait(false); } }
public async Task IsLive([Remainder] string twitchUsername) { string twitchPath = "https://www.twitch.tv/"; if (string.IsNullOrEmpty(twitchUsername)) { return; } string[] userList = { twitchUsername }; var twitchUser = await twitchAdapter.GetTwitchUsers(userList); if (twitchUser != null && twitchUser.Total > 0) { bool isLive = await twitchAdapter.CheckIfStreamIsLive(twitchUser.Users[0].Id.ToString()); if (isLive) { var embed = new EmbedBuilder { Title = twitchUser.Users[0].Name + " is live!", Description = $"{twitchPath}{twitchUser.Users[0].Name}" }; embed.WithColor(Color.Blue).Build(); await ReplyAsync(embed : embed.Build()); } else { await Context.Channel.SendMessageAsync($"{twitchUsername} is not live!").ConfigureAwait(false); } } else { await Context.Channel.SendMessageAsync($"{twitchUsername} does not exist!").ConfigureAwait(false); } }