예제 #1
0
        private async Task YtSearch(string search, ISocketMessageChannel channel)
        {
            EmbedBuilder embed = new EmbedBuilder();

            embed.WithTitle($"YouTube Search '{search}'");
            embed.WithDescription("Searching YouTube...");
            embed.WithFooter($"Search by {Context.User}", Context.User.GetAvatarUrl());
            embed.WithCurrentTimestamp();
            embed.WithColor(FunCmdsConfig.youtubeColor);

            RestUserMessage message = await channel.SendMessageAsync("", false, embed.Build());

            //Search Youtube
            IList <YouTubeVideo> searchResponse = await youtubeService.SearchForYouTube(search);

            StringBuilder videos = new StringBuilder();

            if (searchResponse != null)
            {
                foreach (YouTubeVideo video in searchResponse)
                {
                    videos.Append(
                        $"**[{video.VideoTitle.RemoveIllegalChars()}]({FunCmdsConfig.ytChannelStart}{video.VideoId})**\n{video.VideoDescription}\n\n");
                }
            }

            embed.WithDescription($"**Videos**\n{videos}");
            embed.WithCurrentTimestamp();

            await MessageUtils.ModifyMessage(message, embed);
        }