diff --git a/src/Discord.Net.Commands/ModuleBase.cs b/src/Discord.Net.Commands/ModuleBase.cs index c5b6d7436..73770402e 100644 --- a/src/Discord.Net.Commands/ModuleBase.cs +++ b/src/Discord.Net.Commands/ModuleBase.cs @@ -6,9 +6,9 @@ namespace Discord.Commands { public CommandContext Context { get; internal set; } - protected virtual async Task ReplyAsync(string message, bool isTTS = false, RequestOptions options = null) + protected virtual async Task ReplyAsync(string message, bool isTTS = false, API.Embed embed = null, RequestOptions options = null) { - return await Context.Channel.SendMessageAsync(message, isTTS, options).ConfigureAwait(false); + return await Context.Channel.SendMessageAsync(message, isTTS, embed, options).ConfigureAwait(false); } } } diff --git a/src/Discord.Net.Core/API/Common/Embed.cs b/src/Discord.Net.Core/API/Common/Embed.cs index 9cea24313..ed4715237 100644 --- a/src/Discord.Net.Core/API/Common/Embed.cs +++ b/src/Discord.Net.Core/API/Common/Embed.cs @@ -13,9 +13,17 @@ namespace Discord.API public string Description { get; set; } [JsonProperty("url")] public string Url { get; set; } + [JsonProperty("color")] + public uint? Color { get; set; } + [JsonProperty("author")] + public Optional Author { get; set; } + [JsonProperty("footer")] + public Optional Footer { get; set; } [JsonProperty("thumbnail")] public Optional Thumbnail { get; set; } [JsonProperty("provider")] public Optional Provider { get; set; } + [JsonProperty("fields")] + public Optional Fields { get; set; } } } diff --git a/src/Discord.Net.Core/API/Common/EmbedAuthor.cs b/src/Discord.Net.Core/API/Common/EmbedAuthor.cs new file mode 100644 index 000000000..973f7d5ea --- /dev/null +++ b/src/Discord.Net.Core/API/Common/EmbedAuthor.cs @@ -0,0 +1,16 @@ +using Newtonsoft.Json; + +namespace Discord.API +{ + public class EmbedAuthor + { + [JsonProperty("name")] + public string Name { get; set; } + [JsonProperty("url")] + public string Url { get; set; } + [JsonProperty("icon_url")] + public string IconUrl { get; set; } + [JsonProperty("proxy_icon_url")] + public string ProxyIconUrl { get; set; } + } +} diff --git a/src/Discord.Net.Core/API/Common/EmbedField.cs b/src/Discord.Net.Core/API/Common/EmbedField.cs new file mode 100644 index 000000000..12aa0137a --- /dev/null +++ b/src/Discord.Net.Core/API/Common/EmbedField.cs @@ -0,0 +1,14 @@ +using Newtonsoft.Json; + +namespace Discord.API +{ + public class EmbedField + { + [JsonProperty("name")] + public string Name { get; set; } + [JsonProperty("value")] + public string Value { get; set; } + [JsonProperty("inline")] + public bool Inline { get; set; } + } +} diff --git a/src/Discord.Net.Core/API/Common/EmbedFooter.cs b/src/Discord.Net.Core/API/Common/EmbedFooter.cs new file mode 100644 index 000000000..2ad22cae7 --- /dev/null +++ b/src/Discord.Net.Core/API/Common/EmbedFooter.cs @@ -0,0 +1,14 @@ +using Newtonsoft.Json; + +namespace Discord.API +{ + public class EmbedFooter + { + [JsonProperty("text")] + public string Text { get; set; } + [JsonProperty("icon_url")] + public string IconUrl { get; set; } + [JsonProperty("proxy_icon_url")] + public string ProxyIconUrl { get; set; } + } +} diff --git a/src/Discord.Net.Core/API/DiscordRestApiClient.cs b/src/Discord.Net.Core/API/DiscordRestApiClient.cs index 1a5b5b2fd..8535fcf33 100644 --- a/src/Discord.Net.Core/API/DiscordRestApiClient.cs +++ b/src/Discord.Net.Core/API/DiscordRestApiClient.cs @@ -439,7 +439,9 @@ namespace Discord.API { Preconditions.NotEqual(channelId, 0, nameof(channelId)); Preconditions.NotNull(args, nameof(args)); - Preconditions.NotNullOrEmpty(args.Content, nameof(args.Content)); + if (!args.Embed.IsSpecified || args.Embed.Value == null) + Preconditions.NotNullOrEmpty(args.Content, nameof(args.Content)); + if (args.Content.Length > DiscordConfig.MaxMessageSize) throw new ArgumentException($"Message content is too long, length must be less or equal to {DiscordConfig.MaxMessageSize}.", nameof(args.Content)); options = RequestOptions.CreateOrClone(options); diff --git a/src/Discord.Net.Core/API/Rest/CreateMessageParams.cs b/src/Discord.Net.Core/API/Rest/CreateMessageParams.cs index 9577ab579..a0dbb59dd 100644 --- a/src/Discord.Net.Core/API/Rest/CreateMessageParams.cs +++ b/src/Discord.Net.Core/API/Rest/CreateMessageParams.cs @@ -1,4 +1,5 @@ #pragma warning disable CS1591 +using System; using Newtonsoft.Json; namespace Discord.API.Rest @@ -13,6 +14,8 @@ namespace Discord.API.Rest public Optional Nonce { get; set; } [JsonProperty("tts")] public Optional IsTTS { get; set; } + [JsonProperty("embed")] + public Optional Embed { get; set; } public CreateMessageParams(string content) { diff --git a/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs b/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs index 7c13e4a6f..30ca044bd 100644 --- a/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs +++ b/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs @@ -8,7 +8,7 @@ namespace Discord public interface IMessageChannel : IChannel { /// Sends a message to this message channel. - Task SendMessageAsync(string text, bool isTTS = false, RequestOptions options = null); + Task SendMessageAsync(string text, bool isTTS = false, API.Embed embed = null, RequestOptions options = null); /// Sends a file to this text channel, with an optional caption. Task SendFileAsync(string filePath, string text = null, bool isTTS = false, RequestOptions options = null); /// Sends a file to this text channel, with an optional caption. diff --git a/src/Discord.Net.Core/Entities/Messages/EmbedAuthor.cs b/src/Discord.Net.Core/Entities/Messages/EmbedAuthor.cs new file mode 100644 index 000000000..b0ed0f08f --- /dev/null +++ b/src/Discord.Net.Core/Entities/Messages/EmbedAuthor.cs @@ -0,0 +1,29 @@ +using System.Diagnostics; +using Model = Discord.API.EmbedAuthor; + +namespace Discord +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public struct EmbedAuthor + { + public string Name { get; set; } + public string Url { get; set; } + public string IconUrl { get; set; } + public string ProxyIconUrl { get; set; } + + private EmbedAuthor(string name, string url, string iconUrl, string proxyIconUrl) + { + Name = name; + Url = url; + IconUrl = iconUrl; + ProxyIconUrl = proxyIconUrl; + } + internal static EmbedAuthor Create(Model model) + { + return new EmbedAuthor(model.Name, model.Url, model.IconUrl, model.ProxyIconUrl); + } + + private string DebuggerDisplay => $"{Name} ({Url})"; + public override string ToString() => Name; + } +} diff --git a/src/Discord.Net.Core/Entities/Messages/EmbedField.cs b/src/Discord.Net.Core/Entities/Messages/EmbedField.cs new file mode 100644 index 000000000..257074e41 --- /dev/null +++ b/src/Discord.Net.Core/Entities/Messages/EmbedField.cs @@ -0,0 +1,27 @@ +using System.Diagnostics; +using Model = Discord.API.EmbedField; + +namespace Discord +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public struct EmbedField + { + public string Name { get; set; } + public string Value { get; set; } + public bool Inline { get; set; } + + private EmbedField(string name, string value, bool inline) + { + Name = name; + Value = value; + Inline = inline; + } + internal static EmbedField Create(Model model) + { + return new EmbedField(model.Name, model.Value, model.Inline); + } + + private string DebuggerDisplay => $"{Name} ({Value}"; + public override string ToString() => Name; + } +} diff --git a/src/Discord.Net.Core/Entities/Messages/EmbedFooter.cs b/src/Discord.Net.Core/Entities/Messages/EmbedFooter.cs new file mode 100644 index 000000000..a69e4b077 --- /dev/null +++ b/src/Discord.Net.Core/Entities/Messages/EmbedFooter.cs @@ -0,0 +1,27 @@ +using System.Diagnostics; +using Model = Discord.API.EmbedFooter; + +namespace Discord +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public struct EmbedFooter + { + public string Text { get; set; } + public string IconUrl { get; set; } + public string ProxyUrl { get; set; } + + private EmbedFooter(string text, string iconUrl, string proxyUrl) + { + Text = text; + IconUrl = iconUrl; + ProxyUrl = proxyUrl; + } + internal static EmbedFooter Create(Model model) + { + return new EmbedFooter(model.Text, model.IconUrl, model.ProxyIconUrl); + } + + private string DebuggerDisplay => $"{Text} ({IconUrl})"; + public override string ToString() => Text; + } +} diff --git a/src/Discord.Net.Core/Entities/Messages/IEmbed.cs b/src/Discord.Net.Core/Entities/Messages/IEmbed.cs index 3bca85fd0..c46b22d17 100644 --- a/src/Discord.Net.Core/Entities/Messages/IEmbed.cs +++ b/src/Discord.Net.Core/Entities/Messages/IEmbed.cs @@ -1,4 +1,6 @@ -namespace Discord +using System.Collections.Immutable; + +namespace Discord { public interface IEmbed { @@ -6,7 +8,11 @@ string Type { get; } string Title { get; } string Description { get; } + Color? Color { get; } + EmbedAuthor? Author { get; } + EmbedFooter? Footer { get; } EmbedProvider? Provider { get; } EmbedThumbnail? Thumbnail { get; } + ImmutableArray Fields { get; } } } diff --git a/src/Discord.Net.Core/Utils/EmbedBuilder.cs b/src/Discord.Net.Core/Utils/EmbedBuilder.cs new file mode 100644 index 000000000..42861709f --- /dev/null +++ b/src/Discord.Net.Core/Utils/EmbedBuilder.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using Embed = Discord.API.Embed; +using Field = Discord.API.EmbedField; +using Author = Discord.API.EmbedAuthor; +using Footer = Discord.API.EmbedFooter; + +namespace Discord +{ + public class EmbedBuilder + { + private Embed embed = new Embed(); + List fields = new List(); + + public EmbedBuilder() + { + embed.Type = "rich"; + } + + public EmbedBuilder Title(string title) + { + embed.Title = title; + return this; + } + public EmbedBuilder Description(string description) + { + embed.Description = description; + return this; + } + public EmbedBuilder Url(string url) + { + embed.Url = url; + return this; + } + public EmbedBuilder Color(Color color) + { + embed.Color = color.RawValue; + return this; + } + public EmbedBuilder Field(Func builder) + { + fields.Add(builder(new EmbedFieldBuilder()).Build()); + return this; + } + public EmbedBuilder Author(Func builder) + { + embed.Author = builder(new EmbedAuthorBuilder()).Build(); + return this; + } + public EmbedBuilder Footer(Func builder) + { + embed.Footer = builder(new EmbedFooterBuilder()).Build(); + return this; + } + public Embed Build() + { + embed.Fields = fields.ToArray(); + return embed; + } + + } + + public class EmbedFieldBuilder + { + private Field embedField = new Field(); + + public EmbedFieldBuilder Name(string name) + { + embedField.Name = name; + return this; + } + public EmbedFieldBuilder Value(string value) + { + embedField.Value = value; + return this; + } + public EmbedFieldBuilder Inline(bool inline) + { + embedField.Inline = inline; + return this; + } + public Field Build() + { + return embedField; + } + } + + public class EmbedAuthorBuilder + { + private Author author = new Author(); + + public EmbedAuthorBuilder Name(string name) + { + author.Name = name; + return this; + } + public EmbedAuthorBuilder Url(string url) + { + author.Url = url; + return this; + } + public EmbedAuthorBuilder IconUrl(string iconUrl) + { + author.IconUrl = iconUrl; + return this; + } + public Author Build() + { + return author; + } + } + + public class EmbedFooterBuilder + { + private Footer footer = new Footer(); + + public EmbedFooterBuilder Text(string text) + { + footer.Text = text; + return this; + } + public EmbedFooterBuilder IconUrl(string iconUrl) + { + footer.IconUrl = iconUrl; + return this; + } + public Footer Build() + { + return footer; + } + } +} diff --git a/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs b/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs index 858269366..aecdf292e 100644 --- a/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs +++ b/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs @@ -110,9 +110,9 @@ namespace Discord.Rest } public static async Task SendMessageAsync(IChannel channel, BaseDiscordClient client, - string text, bool isTTS, IGuild guild, RequestOptions options) + string text, bool isTTS, API.Embed embed, IGuild guild, RequestOptions options) { - var args = new CreateMessageParams(text) { IsTTS = isTTS }; + 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); } diff --git a/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs b/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs index 6d2b729dd..82783700e 100644 --- a/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs @@ -7,7 +7,7 @@ namespace Discord.Rest public interface IRestMessageChannel : IMessageChannel { /// Sends a message to this message channel. - new Task SendMessageAsync(string text, bool isTTS = false, RequestOptions options = null); + new Task SendMessageAsync(string text, bool isTTS = false, API.Embed embed = null, RequestOptions options = null); /// Sends a file to this text channel, with an optional caption. new Task SendFileAsync(string filePath, string text = null, bool isTTS = false, RequestOptions options = null); /// Sends a file to this text channel, with an optional caption. diff --git a/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs index 9d866220d..8c547ad80 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs @@ -63,8 +63,8 @@ namespace Discord.Rest public Task> GetPinnedMessagesAsync(RequestOptions options = null) => ChannelHelper.GetPinnedMessagesAsync(this, Discord, null, options); - public Task SendMessageAsync(string text, bool isTTS = false, RequestOptions options = null) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, null, options); + public Task SendMessageAsync(string text, bool isTTS = false, API.Embed embed = null, RequestOptions options = null) + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, null, options); public Task SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null) => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, null, options); public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, RequestOptions options = null) @@ -126,8 +126,8 @@ namespace Discord.Rest => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false); async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options) => await SendFileAsync(stream, filename, text, isTTS, options).ConfigureAwait(false); - async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options) - => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false); + async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, API.Embed embed, RequestOptions options) + => await SendMessageAsync(text, isTTS, embed, options).ConfigureAwait(false); IDisposable IMessageChannel.EnterTypingState(RequestOptions options) => EnterTypingState(options); diff --git a/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs index bb840ece4..eb29192c4 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs @@ -76,8 +76,8 @@ namespace Discord.Rest public Task> GetPinnedMessagesAsync(RequestOptions options = null) => ChannelHelper.GetPinnedMessagesAsync(this, Discord, null, options); - public Task SendMessageAsync(string text, bool isTTS = false, RequestOptions options = null) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, null, options); + public Task SendMessageAsync(string text, bool isTTS = false, API.Embed embed = null, RequestOptions options = null) + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, null, options); public Task SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null) => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, null, options); public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, RequestOptions options = null) @@ -136,8 +136,8 @@ namespace Discord.Rest => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false); async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options) => await SendFileAsync(stream, filename, text, isTTS, options).ConfigureAwait(false); - async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options) - => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false); + async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, API.Embed embed, RequestOptions options) + => await SendMessageAsync(text, isTTS, embed, options).ConfigureAwait(false); IDisposable IMessageChannel.EnterTypingState(RequestOptions options) => EnterTypingState(options); diff --git a/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs index 4a617517e..5c6fc371b 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs @@ -55,8 +55,8 @@ namespace Discord.Rest public Task> GetPinnedMessagesAsync(RequestOptions options = null) => ChannelHelper.GetPinnedMessagesAsync(this, Discord, null, options); - public Task SendMessageAsync(string text, bool isTTS = false, RequestOptions options = null) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, null, options); + public Task SendMessageAsync(string text, bool isTTS = false, API.Embed embed = null, RequestOptions options = null) + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, null, options); public Task SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null) => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, null, options); public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, RequestOptions options = null) @@ -108,8 +108,8 @@ namespace Discord.Rest => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false); async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options) => await SendFileAsync(stream, filename, text, isTTS, options).ConfigureAwait(false); - async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options) - => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false); + async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, API.Embed embed, RequestOptions options) + => await SendMessageAsync(text, isTTS, embed, options).ConfigureAwait(false); IDisposable IMessageChannel.EnterTypingState(RequestOptions options) => EnterTypingState(options); diff --git a/src/Discord.Net.Rest/Entities/Channels/RestVirtualMessageChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestVirtualMessageChannel.cs index 97a0a93e6..a99430a82 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestVirtualMessageChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestVirtualMessageChannel.cs @@ -33,8 +33,8 @@ namespace Discord.Rest public Task> GetPinnedMessagesAsync(RequestOptions options = null) => ChannelHelper.GetPinnedMessagesAsync(this, Discord, null, options); - public Task SendMessageAsync(string text, bool isTTS, RequestOptions options = null) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, null, options); + public Task SendMessageAsync(string text, bool isTTS, API.Embed embed = null, RequestOptions options = null) + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, null, options); public Task SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options = null) => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, null, options); public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options = null) @@ -86,8 +86,8 @@ namespace Discord.Rest => await SendFileAsync(filePath, text, isTTS, options); async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options) => await SendFileAsync(stream, filename, text, isTTS, options); - async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options) - => await SendMessageAsync(text, isTTS, options); + async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, API.Embed embed, RequestOptions options) + => await SendMessageAsync(text, isTTS, embed, options); IDisposable IMessageChannel.EnterTypingState(RequestOptions options) => EnterTypingState(options); diff --git a/src/Discord.Net.Rest/Entities/Messages/Embed.cs b/src/Discord.Net.Rest/Entities/Messages/Embed.cs index 20979534e..540a39ea2 100644 --- a/src/Discord.Net.Rest/Entities/Messages/Embed.cs +++ b/src/Discord.Net.Rest/Entities/Messages/Embed.cs @@ -1,4 +1,7 @@ -using System.Diagnostics; +using System; +using System.Collections.Immutable; +using System.Diagnostics; +using System.Linq; using Model = Discord.API.Embed; namespace Discord @@ -10,23 +13,44 @@ namespace Discord public string Url { get; } public string Title { get; } public string Type { get; } + public Color? Color { get; } + public EmbedAuthor? Author { get; } + public EmbedFooter? Footer { get; } public EmbedProvider? Provider { get; } public EmbedThumbnail? Thumbnail { get; } + public ImmutableArray Fields { get; } - internal Embed(string type, string title, string description, string url, EmbedProvider? provider, EmbedThumbnail? thumbnail) + internal Embed(string type, + string title, + string description, + string url, + Color? color, + EmbedAuthor? author, + EmbedFooter? footer, + EmbedProvider? provider, + EmbedThumbnail? thumbnail, + ImmutableArray fields) { Type = type; Title = title; Description = description; Url = url; + Color = color; + Author = author; + Footer = footer; Provider = provider; Thumbnail = thumbnail; + Fields = fields; } internal static Embed Create(Model model) { return new Embed(model.Type, model.Title, model.Description, model.Url, + model.Color.HasValue ? new Color(model.Color.Value) : (Color?)null, + model.Author.IsSpecified ? EmbedAuthor.Create(model.Author.Value) : (EmbedAuthor?)null, + model.Footer.IsSpecified ? EmbedFooter.Create(model.Footer.Value) : (EmbedFooter?)null, model.Provider.IsSpecified ? EmbedProvider.Create(model.Provider.Value) : (EmbedProvider?)null, - model.Thumbnail.IsSpecified ? EmbedThumbnail.Create(model.Thumbnail.Value) : (EmbedThumbnail?)null); + model.Thumbnail.IsSpecified ? EmbedThumbnail.Create(model.Thumbnail.Value) : (EmbedThumbnail?)null, + model.Fields.IsSpecified ? model.Fields.Value.Select(x => EmbedField.Create(x)).ToImmutableArray() : ImmutableArray.Create()); } public override string ToString() => Title; diff --git a/src/Discord.Net.Rpc/Entities/Channels/RpcDMChannel.cs b/src/Discord.Net.Rpc/Entities/Channels/RpcDMChannel.cs index 3df04b320..e9393b5f9 100644 --- a/src/Discord.Net.Rpc/Entities/Channels/RpcDMChannel.cs +++ b/src/Discord.Net.Rpc/Entities/Channels/RpcDMChannel.cs @@ -44,8 +44,8 @@ namespace Discord.Rpc public Task> GetPinnedMessagesAsync(RequestOptions options = null) => ChannelHelper.GetPinnedMessagesAsync(this, Discord, null, options); - public Task SendMessageAsync(string text, bool isTTS = false, RequestOptions options = null) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, null, options); + public Task SendMessageAsync(string text, bool isTTS = false, API.Embed embed = null, RequestOptions options = null) + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, null, options); public Task SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null) => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, null, options); public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, RequestOptions options = null) @@ -104,8 +104,8 @@ namespace Discord.Rpc => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false); async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options) => await SendFileAsync(stream, filename, text, isTTS, options).ConfigureAwait(false); - async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options) - => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false); + async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, API.Embed embed, RequestOptions options) + => await SendMessageAsync(text, isTTS, embed, options).ConfigureAwait(false); IDisposable IMessageChannel.EnterTypingState(RequestOptions options) => EnterTypingState(options); diff --git a/src/Discord.Net.Rpc/Entities/Channels/RpcGroupChannel.cs b/src/Discord.Net.Rpc/Entities/Channels/RpcGroupChannel.cs index d88847067..12fb91343 100644 --- a/src/Discord.Net.Rpc/Entities/Channels/RpcGroupChannel.cs +++ b/src/Discord.Net.Rpc/Entities/Channels/RpcGroupChannel.cs @@ -46,8 +46,8 @@ namespace Discord.Rpc public Task> GetPinnedMessagesAsync(RequestOptions options = null) => ChannelHelper.GetPinnedMessagesAsync(this, Discord, null, options); - public Task SendMessageAsync(string text, bool isTTS = false, RequestOptions options = null) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, null, options); + public Task SendMessageAsync(string text, bool isTTS = false, API.Embed embed = null, RequestOptions options = null) + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, null, options); public Task SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null) => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, null, options); public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, RequestOptions options = null) @@ -103,8 +103,8 @@ namespace Discord.Rpc => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false); async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options) => await SendFileAsync(stream, filename, text, isTTS, options).ConfigureAwait(false); - async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options) - => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false); + async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, API.Embed embed, RequestOptions options) + => await SendMessageAsync(text, isTTS, embed, options).ConfigureAwait(false); IDisposable IMessageChannel.EnterTypingState(RequestOptions options) => EnterTypingState(options); diff --git a/src/Discord.Net.Rpc/Entities/Channels/RpcTextChannel.cs b/src/Discord.Net.Rpc/Entities/Channels/RpcTextChannel.cs index e6e3d3e48..7b20660ab 100644 --- a/src/Discord.Net.Rpc/Entities/Channels/RpcTextChannel.cs +++ b/src/Discord.Net.Rpc/Entities/Channels/RpcTextChannel.cs @@ -49,8 +49,8 @@ namespace Discord.Rpc public Task> GetPinnedMessagesAsync(RequestOptions options = null) => ChannelHelper.GetPinnedMessagesAsync(this, Discord, null, options); - public Task SendMessageAsync(string text, bool isTTS = false, RequestOptions options = null) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, null, options); + public Task SendMessageAsync(string text, bool isTTS = false, API.Embed embed = null, RequestOptions options = null) + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, null, options); public Task SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null) => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, null, options); public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, RequestOptions options = null) @@ -105,8 +105,8 @@ namespace Discord.Rpc => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false); async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options) => await SendFileAsync(stream, filename, text, isTTS, options).ConfigureAwait(false); - async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options) - => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false); + async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, API.Embed embed, RequestOptions options) + => await SendMessageAsync(text, isTTS, embed, options).ConfigureAwait(false); IDisposable IMessageChannel.EnterTypingState(RequestOptions options) => EnterTypingState(options); } diff --git a/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs index 7ba08544b..ed22c78a8 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs @@ -11,7 +11,7 @@ namespace Discord.WebSocket IReadOnlyCollection CachedMessages { get; } /// Sends a message to this message channel. - new Task SendMessageAsync(string text, bool isTTS = false, RequestOptions options = null); + new Task SendMessageAsync(string text, bool isTTS = false, API.Embed embed = null, RequestOptions options = null); /// Sends a file to this text channel, with an optional caption. new Task SendFileAsync(string filePath, string text = null, bool isTTS = false, RequestOptions options = null); /// Sends a file to this text channel, with an optional caption. diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketDMChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketDMChannel.cs index 4da4139d0..e9d37cc9c 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketDMChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketDMChannel.cs @@ -66,8 +66,8 @@ namespace Discord.WebSocket public Task> GetPinnedMessagesAsync(RequestOptions options = null) => ChannelHelper.GetPinnedMessagesAsync(this, Discord, null, options); - public Task SendMessageAsync(string text, bool isTTS = false, RequestOptions options = null) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, null, options); + public Task SendMessageAsync(string text, bool isTTS = false, API.Embed embed = null, RequestOptions options = null) + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, null, options); public Task SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null) => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, null, options); public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, RequestOptions options = null) @@ -134,8 +134,8 @@ namespace Discord.WebSocket => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false); async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options) => await SendFileAsync(stream, filename, text, isTTS, options).ConfigureAwait(false); - async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options) - => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false); + async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, API.Embed embed, RequestOptions options) + => await SendMessageAsync(text, isTTS, embed, options).ConfigureAwait(false); IDisposable IMessageChannel.EnterTypingState(RequestOptions options) => EnterTypingState(options); diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs index 3b47a8452..723df5390 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs @@ -89,8 +89,8 @@ namespace Discord.WebSocket public Task> GetPinnedMessagesAsync(RequestOptions options = null) => ChannelHelper.GetPinnedMessagesAsync(this, Discord, null, options); - public Task SendMessageAsync(string text, bool isTTS = false, RequestOptions options = null) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, null, options); + public Task SendMessageAsync(string text, bool isTTS = false, API.Embed embed = null, RequestOptions options = null) + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, null, options); public Task SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null) => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, null, options); public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, RequestOptions options = null) @@ -197,8 +197,8 @@ namespace Discord.WebSocket => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false); async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options) => await SendFileAsync(stream, filename, text, isTTS, options).ConfigureAwait(false); - async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options) - => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false); + async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, API.Embed embed, RequestOptions options) + => await SendMessageAsync(text, isTTS, embed, options).ConfigureAwait(false); IDisposable IMessageChannel.EnterTypingState(RequestOptions options) => EnterTypingState(options); diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs index 8dff22232..693af4312 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs @@ -72,8 +72,8 @@ namespace Discord.WebSocket public Task> GetPinnedMessagesAsync(RequestOptions options = null) => ChannelHelper.GetPinnedMessagesAsync(this, Discord, Guild, options); - public Task SendMessageAsync(string text, bool isTTS = false, RequestOptions options = null) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, Guild, options); + public Task SendMessageAsync(string text, bool isTTS = false, API.Embed embed = null, RequestOptions options = null) + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, Guild, options); public Task SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null) => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, Guild, options); public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, RequestOptions options = null) @@ -135,8 +135,8 @@ namespace Discord.WebSocket => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false); async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, RequestOptions options) => await SendFileAsync(stream, filename, text, isTTS, options).ConfigureAwait(false); - async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, RequestOptions options) - => await SendMessageAsync(text, isTTS, options).ConfigureAwait(false); + async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, API.Embed embed, RequestOptions options) + => await SendMessageAsync(text, isTTS, embed, options).ConfigureAwait(false); IDisposable IMessageChannel.EnterTypingState(RequestOptions options) => EnterTypingState(options); }