Skip to content

Commit

Permalink
Embeds array for send message async (discord-net#181)
Browse files Browse the repository at this point in the history
* meta: bump version

* meta: bump vers

* Fix sticker args

* Grammer fix (discord-net#179)

* Added embeds for SendMessageAsync

* [JsonProperty("embed")] forgot to remove this

 public Optional<Embed> Embed { get; set; }

* It has been done as requested.

* Changed the old way of handeling single embeds

* Moved embeds param and added options param

* xmls

Co-authored-by: quin lynch <[email protected]>
  • Loading branch information
killerfrienddk and quinchs committed Sep 24, 2021
1 parent d0738d6 commit cfac5d5
Show file tree
Hide file tree
Showing 24 changed files with 186 additions and 80 deletions.
4 changes: 2 additions & 2 deletions src/Discord.Net.Commands/Discord.Net.Commands.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/Discord.Net.Commands/ModuleBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ public abstract class ModuleBase<T> : IModuleBase
/// Specifies if notifications are sent for mentioned users and roles in the <paramref name="message"/>.
/// If <c>null</c>, all mentioned roles and users will be notified.
/// </param>
/// <param name="options">The request options for this async request.</param>
/// <param name="messageReference">The message references to be included. Used to reply to specific messages.</param>
/// <param name="component">The message components to be included with this message. Used for interactions</param>
/// <param name="stickers">A collection of stickers to send with the file.</param>
protected virtual async Task<IUserMessage> ReplyAsync(string message = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null)
/// <param name="embeds">A array of <see cref="Embed"/>s to send with this response. Max 10</param>
protected virtual async Task<IUserMessage> ReplyAsync(string message = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null)
{
return await Context.Channel.SendMessageAsync(message, isTTS, embed, options, allowedMentions, messageReference, component, stickers).ConfigureAwait(false);
return await Context.Channel.SendMessageAsync(message, isTTS, embed, options, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false);
}
/// <summary>
/// The method to execute before executing the command.
Expand Down
10 changes: 7 additions & 3 deletions src/Discord.Net.Core/Discord.Net.Core.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1507,7 +1507,7 @@
Represents a generic channel that can send and receive messages.
</summary>
</member>
<member name="M:Discord.IMessageChannel.SendMessageAsync(System.String,System.Boolean,Discord.Embed,Discord.RequestOptions,Discord.AllowedMentions,Discord.MessageReference,Discord.MessageComponent,Discord.ISticker[])">
<member name="M:Discord.IMessageChannel.SendMessageAsync(System.String,System.Boolean,Discord.Embed,Discord.RequestOptions,Discord.AllowedMentions,Discord.MessageReference,Discord.MessageComponent,Discord.ISticker[],Discord.Embed[])">
<summary>
Sends a message to this message channel.
</summary>
Expand All @@ -1528,6 +1528,7 @@
<param name="messageReference">The message references to be included. Used to reply to specific messages.</param>
<param name="component">The message components to be included with this message. Used for interactions</param>
<param name="stickers">A collection of stickers to send with the message.</param>
<param name="embeds">A array of <see cref="T:Discord.Embed"/>s to send with this response. Max 10</param>
<returns>
A task that represents an asynchronous send operation for delivering the message. The task result
contains the sent message.
Expand Down Expand Up @@ -11087,13 +11088,14 @@
<seealso cref="M:Discord.IMessage.RemoveReactionAsync(Discord.IEmote,Discord.IUser,Discord.RequestOptions)"/>
<seealso cref="T:Discord.IEmote"/>
</member>
<member name="M:Discord.MessageExtensions.ReplyAsync(Discord.IUserMessage,System.String,System.Boolean,Discord.Embed,Discord.AllowedMentions,Discord.RequestOptions,Discord.MessageComponent,Discord.ISticker[])">
<member name="M:Discord.MessageExtensions.ReplyAsync(Discord.IUserMessage,System.String,System.Boolean,Discord.Embed,Discord.AllowedMentions,Discord.RequestOptions,Discord.MessageComponent,Discord.ISticker[],Discord.Embed[])">
<summary>
Sends an inline reply that references a message.
</summary>
<param name="text">The message to be sent.</param>
<param name="isTTS">Determines whether the message should be read aloud by Discord or not.</param>
<param name="embed">The <see cref="F:Discord.EmbedType.Rich"/> <see cref="T:Discord.Embed"/> to be sent.</param>
<param name="embeds">A array of <see cref="T:Discord.Embed"/>s to send with this response. Max 10</param>
<param name="allowedMentions">
Specifies if notifications are sent for mentioned users and roles in the message <paramref name="text"/>.
If <c>null</c>, all mentioned roles and users will be notified.
Expand All @@ -11107,7 +11109,7 @@
<member name="T:Discord.UserExtensions">
<summary> An extension class for various Discord user objects. </summary>
</member>
<member name="M:Discord.UserExtensions.SendMessageAsync(Discord.IUser,System.String,System.Boolean,Discord.Embed,Discord.RequestOptions,Discord.AllowedMentions,Discord.MessageComponent)">
<member name="M:Discord.UserExtensions.SendMessageAsync(Discord.IUser,System.String,System.Boolean,Discord.Embed,Discord.Embed[],Discord.RequestOptions,Discord.AllowedMentions,Discord.MessageComponent)">
<summary>
Sends a message via DM.
</summary>
Expand All @@ -11128,11 +11130,13 @@
<param name="text">The message to be sent.</param>
<param name="isTTS">Whether the message should be read aloud by Discord or not.</param>
<param name="embed">The <see cref="F:Discord.EmbedType.Rich"/> <see cref="T:Discord.Embed"/> to be sent.</param>
<param name="embeds">A array of <see cref="T:Discord.Embed"/>s to send with this response. Max 10</param>
<param name="options">The options to be used when sending the request.</param>
<param name="allowedMentions">
Specifies if notifications are sent for mentioned users and roles in the message <paramref name="text"/>.
If <c>null</c>, all mentioned roles and users will be notified.
</param>
<param name="component">The message components to be included with this message. Used for interactions</param>
<returns>
A task that represents the asynchronous send operation. The task result contains the sent message.
</returns>
Expand Down
3 changes: 2 additions & 1 deletion src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ public interface IMessageChannel : IChannel
/// <param name="messageReference">The message references to be included. Used to reply to specific messages.</param>
/// <param name="component">The message components to be included with this message. Used for interactions</param>
/// <param name="stickers">A collection of stickers to send with the message.</param>
/// <param name="embeds">A array of <see cref="Embed"/>s to send with this response. Max 10</param>
/// <returns>
/// A task that represents an asynchronous send operation for delivering the message. The task result
/// contains the sent message.
/// </returns>
Task<IUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null);
Task<IUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null);
/// <summary>
/// Sends a file to this message channel with an optional caption.
/// </summary>
Expand Down
5 changes: 3 additions & 2 deletions src/Discord.Net.Core/Extensions/MessageExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public static async Task RemoveReactionsAsync(this IUserMessage msg, IUser user,
/// <param name="text">The message to be sent.</param>
/// <param name="isTTS">Determines whether the message should be read aloud by Discord or not.</param>
/// <param name="embed">The <see cref="Discord.EmbedType.Rich"/> <see cref="Embed"/> to be sent.</param>
/// <param name="embeds">A array of <see cref="Embed"/>s to send with this response. Max 10</param>
/// <param name="allowedMentions">
/// Specifies if notifications are sent for mentioned users and roles in the message <paramref name="text"/>.
/// If <c>null</c>, all mentioned roles and users will be notified.
Expand All @@ -87,9 +88,9 @@ public static async Task RemoveReactionsAsync(this IUserMessage msg, IUser user,
/// A task that represents an asynchronous send operation for delivering the message. The task result
/// contains the sent message.
/// </returns>
public static async Task<IUserMessage> ReplyAsync(this IUserMessage msg, string text = null, bool isTTS = false, Embed embed = null, AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent components = null, ISticker[] stickers = null)
public static async Task<IUserMessage> ReplyAsync(this IUserMessage msg, string text = null, bool isTTS = false, Embed embed = null, AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null)
{
return await msg.Channel.SendMessageAsync(text, isTTS, embed, options, allowedMentions, new MessageReference(messageId: msg.Id), components, stickers).ConfigureAwait(false);
return await msg.Channel.SendMessageAsync(text, isTTS, embed, options, allowedMentions, new MessageReference(messageId: msg.Id), components, stickers, embeds).ConfigureAwait(false);
}
}
}
5 changes: 4 additions & 1 deletion src/Discord.Net.Core/Extensions/UserExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,26 @@ public static class UserExtensions
/// <param name="text">The message to be sent.</param>
/// <param name="isTTS">Whether the message should be read aloud by Discord or not.</param>
/// <param name="embed">The <see cref="EmbedType.Rich"/> <see cref="Embed"/> to be sent.</param>
/// <param name="embeds">A array of <see cref="Embed"/>s to send with this response. Max 10</param>
/// <param name="options">The options to be used when sending the request.</param>
/// <param name="allowedMentions">
/// Specifies if notifications are sent for mentioned users and roles in the message <paramref name="text"/>.
/// If <c>null</c>, all mentioned roles and users will be notified.
/// </param>
/// <param name="component">The message components to be included with this message. Used for interactions</param>
/// <returns>
/// A task that represents the asynchronous send operation. The task result contains the sent message.
/// </returns>
public static async Task<IUserMessage> SendMessageAsync(this IUser user,
string text = null,
bool isTTS = false,
Embed embed = null,
Embed[] embeds = null,
RequestOptions options = null,
AllowedMentions allowedMentions = null,
MessageComponent component = null)
{
return await (await user.CreateDMChannelAsync().ConfigureAwait(false)).SendMessageAsync(text, isTTS, embed, options, allowedMentions, component: component).ConfigureAwait(false);
return await (await user.CreateDMChannelAsync().ConfigureAwait(false)).SendMessageAsync(text, isTTS, embed, options, allowedMentions, component: component, embeds: embeds).ConfigureAwait(false);
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Discord.Net.Rest/API/Rest/CreateMessageParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ internal class CreateMessageParams
[JsonProperty("tts")]
public Optional<bool> IsTTS { get; set; }

[JsonProperty("embed")]
public Optional<Embed> Embed { get; set; }
[JsonProperty("embeds")]
public Optional<Embed[]> Embeds { get; set; }

[JsonProperty("allowed_mentions")]
public Optional<AllowedMentions> AllowedMentions { get; set; }
Expand Down
Loading

0 comments on commit cfac5d5

Please sign in to comment.