コード例 #1
0
        private static ILocalisable <EmbedBuilder> GetBuilder(Embed embed)
        {
            if (embed == null)
            {
                return(null);
            }
            var builder = new LocalisedEmbedBuilder()
            {
                Fields = embed.Fields.Select(f => (LocalisedFieldBuilder)(new EmbedFieldBuilder().WithIsInline(f.Inline).WithName(f.Name).WithValue(f.Value)))
                         .ToList()
            };

            if (embed.Author != null)
            {
                builder.WithAuthor(new EmbedAuthorBuilder
                {
                    IconUrl = embed.Author?.IconUrl,
                    Name    = embed.Author?.Name,
                    Url     = embed.Author?.Url
                });
            }
            if (embed.Color != null)
            {
                builder.WithColor(embed.Color.Value);
            }
            builder.WithRawDescription(embed.Description);
            if (embed.Footer != null)
            {
                builder.WithFooter(new EmbedFooterBuilder
                {
                    IconUrl = embed.Footer?.IconUrl,
                    Text    = embed.Footer?.Text
                });
            }
            if (embed.Image != null)
            {
                builder.WithRawImageUrl(embed.Image?.Url);
            }
            if (embed.Thumbnail != null)
            {
                builder.WithRawThumbnailUrl(embed.Thumbnail?.Url);
            }
            if (embed.Timestamp != null)
            {
                builder.WithTimestamp(embed.Timestamp.Value);
            }
            builder.WithRawTitle(embed.Title);
            builder.WithRawUrl(embed.Url);

            return(builder);
        }