Example #1
0
        private EmbedResponse GetSuccessResponse(string query, SearchResult result)
        {
            EmbedResponse.Builder builder = new EmbedResponse.Builder(EmbedResponseTemplate.Success);

            builder.SetTitle(result.Snippet.Title);

            string description = result.Snippet.Description;

            if (string.IsNullOrWhiteSpace(description))
            {
                description = NO_DESCRIPTION;
            }

            builder.AddMessage(result.Snippet.ChannelTitle, description);
            builder.SetThumbnailURL(result.Snippet.Thumbnails.Default__.Url);

            switch (result.Id.Kind)
            {
            case VIDEO_KIND:
                builder.SetURL(string.Format(VIDEO_URL_FORMAT, result.Id.VideoId));
                break;

            case CHANNEL_KIND:
                builder.SetURL(string.Format(CHANNEL_URL_FORMAT, result.Id.ChannelId));
                break;

            case PLAYLIST_KIND:
                builder.SetURL(string.Format(PLAYLIST_URL_FORMAT, result.Id.PlaylistId));
                break;
            }

            CoreModule.Logger.LogInfo($"Title: {result.Snippet.Title}\r\n" +
                                      $"Channel: {result.Snippet.ChannelTitle}\r\n" +
                                      $"Desc: {result.Snippet.Description}\r\n" +
                                      $"Thumb url: {result.Snippet.Thumbnails.Default__.Url}\r\n" +
                                      $"URL: {string.Format(PLAYLIST_URL_FORMAT, result.Id.PlaylistId)}");
            return(builder.Build());
        }