コード例 #1
0
 public static Embed ToEntity(this API.Embed model)
 {
     return(new Embed(model.Type, model.Title, model.Description, model.Url, model.Timestamp,
                      model.Color.HasValue ? new Color(model.Color.Value) : (Color?)null,
                      model.Image.IsSpecified ? model.Image.Value.ToEntity() : (EmbedImage?)null,
                      model.Video.IsSpecified ? model.Video.Value.ToEntity() : (EmbedVideo?)null,
                      model.Author.IsSpecified ? model.Author.Value.ToEntity() : (EmbedAuthor?)null,
                      model.Footer.IsSpecified ? model.Footer.Value.ToEntity() : (EmbedFooter?)null,
                      model.Provider.IsSpecified ? model.Provider.Value.ToEntity() : (EmbedProvider?)null,
                      model.Thumbnail.IsSpecified ? model.Thumbnail.Value.ToEntity() : (EmbedThumbnail?)null,
                      model.Fields.IsSpecified ? model.Fields.Value.Select(x => x.ToEntity()).ToImmutableArray() : ImmutableArray.Create <EmbedField>()));
 }
コード例 #2
0
        public static API.Embed ToModel(this Embed entity)
        {
            if (entity == null)
            {
                return(null);
            }
            var model = new API.Embed
            {
                Type        = entity.Type,
                Title       = entity.Title,
                Description = entity.Description,
                Url         = entity.Url,
                Timestamp   = entity.Timestamp,
                Color       = entity.Color?.RawValue
            };

            if (entity.Author != null)
            {
                model.Author = entity.Author.Value.ToModel();
            }
            model.Fields = entity.Fields.Select(x => x.ToModel()).ToArray();
            if (entity.Footer != null)
            {
                model.Footer = entity.Footer.Value.ToModel();
            }
            if (entity.Image != null)
            {
                model.Image = entity.Image.Value.ToModel();
            }
            if (entity.Provider != null)
            {
                model.Provider = entity.Provider.Value.ToModel();
            }
            if (entity.Thumbnail != null)
            {
                model.Thumbnail = entity.Thumbnail.Value.ToModel();
            }
            if (entity.Video != null)
            {
                model.Video = entity.Video.Value.ToModel();
            }
            return(model);
        }
コード例 #3
0
        public static async Task <RestUserMessage> SendRichMessageAsync(IChannel channel, BaseDiscordClient client,
                                                                        string text, bool isTTS, API.Embed embed, IGuild guild, RequestOptions options)
        {
            var args = new CreateMessageParams(text)
            {
                IsTTS = isTTS, Embed = embed
            };
            var model = await client.ApiClient.CreateMessageAsync(channel.Id, args, options).ConfigureAwait(false);

            return(RestUserMessage.Create(client, guild, model));
        }