예제 #1
0
        private async Task <Embed> GetTwitchStreamEmbedAsync(string twitchLoginName)
        {
            var stream = await _twitchClient.GetStreamAsync(twitchLoginName).ConfigureAwait(false);

            var game = await _twitchClient.GetGameTitleAsync(stream.GameId).ConfigureAwait(false);

            var embed = new EmbedBuilder
            {
                Title        = $"{twitchLoginName} is now streaming {game.Name}!",
                ImageUrl     = stream.ThumbnailUrl.Replace("{width}", "640").Replace("{height}", "480"),
                Url          = $"https://www.twitch.tv/{twitchLoginName}",
                ThumbnailUrl = game.BoxArtUrl.Replace("{width}", "128").Replace("{height}", "128"),
                Color        = new Color(100, 65, 164)
            };

            embed.AddField("Title", stream.Title, true)
            .AddField("Viewers", stream.ViewerCount);

            return(embed.Build());
        }