Class MessageExtensions
- Namespace
- Discord
- Assembly
- Discord.Net.Core.dll
Provides extension methods for IMessage.
public static class MessageExtensions
- Inheritance
-
MessageExtensions
- Inherited Members
Methods
AddReactionsAsync(IUserMessage, IEnumerable<IEmote>, RequestOptions)
Add multiple reactions to a message.
public static Task AddReactionsAsync(this IUserMessage msg, IEnumerable<IEmote> reactions, RequestOptions options = null)
Parameters
msg
IUserMessageThe message to add reactions to.
reactions
IEnumerable<IEmote>An array of reactions to add to the message.
options
RequestOptionsThe options to be used when sending the request.
Returns
- Task
A task that represents the asynchronous operation for adding a reaction to this message.
Examples
IEmote A = new Emoji("🅰");
IEmote B = new Emoji("🅱");
await msg.AddReactionsAsync(new[] { A, B });
Remarks
This method does not bulk add reactions! It will send a request for each reaction included.
- See Also
GetJumpUrl(IMessage)
Gets a URL that jumps to the message.
public static string GetJumpUrl(this IMessage msg)
Parameters
msg
IMessageThe message to jump to.
Returns
- string
A string that contains a URL for jumping to the message in chat.
RemoveReactionsAsync(IUserMessage, IUser, IEnumerable<IEmote>, RequestOptions)
Remove multiple reactions from a message.
public static Task RemoveReactionsAsync(this IUserMessage msg, IUser user, IEnumerable<IEmote> reactions, RequestOptions options = null)
Parameters
msg
IUserMessageThe message to remove reactions from.
user
IUserThe user who removed the reaction.
reactions
IEnumerable<IEmote>An array of reactions to remove from the message.
options
RequestOptionsThe options to be used when sending the request.
Returns
- Task
A task that represents the asynchronous operation for removing a reaction to this message.
Examples
await msg.RemoveReactionsAsync(currentUser, new[] { A, B });
Remarks
This method does not bulk remove reactions! If you want to clear reactions from a message, RemoveAllReactionsAsync(RequestOptions)
- See Also
ReplyAsync(IUserMessage, string, bool, Embed, AllowedMentions, RequestOptions, MessageComponent, ISticker[], Embed[], MessageFlags)
Sends an inline reply that references a message.
public static 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, MessageFlags flags = MessageFlags.None)
Parameters
msg
IUserMessageThe message that is being replied on.
text
stringThe message to be sent.
isTTS
boolDetermines whether the message should be read aloud by Discord or not.
embed
EmbedallowedMentions
AllowedMentionsSpecifies if notifications are sent for mentioned users and roles in the message
text
. If null, all mentioned roles and users will be notified.options
RequestOptionsThe options to be used when sending the request.
components
MessageComponentThe message components to be included with this message. Used for interactions.
stickers
ISticker[]A collection of stickers to send with the message.
embeds
Embed[]A array of Embeds to send with this response. Max 10.
flags
MessageFlagsMessage flags combined as a bitfield.
Returns
- Task<IUserMessage>
A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message.