using System.Threading.Tasks;
namespace Discord
{
///
/// Provides extension methods for .
///
public static class MessageExtensions
{
///
/// Gets a URL that jumps to the message.
///
/// The message to jump to.
///
/// A string that contains a URL for jumping to the message in chat.
///
public static string GetJumpUrl(this IMessage msg)
{
var channel = msg.Channel;
return $"https://discordapp.com/channels/{(channel is IDMChannel ? "@me" : $"{(channel as ITextChannel).GuildId}")}/{channel.Id}/{msg.Id}";
}
///
/// Add multiple reactions to a message.
///
///
/// This method does not bulk add reactions! It will send a request for each reaction inculded.
///
///
///
/// IEmote A = new Emoji("🅰");
/// IEmote B = new Emoji("🅱");
/// await msg.AddReactionsAsync(new[] { A, B });
///
///
/// The message to add reactions to.
/// An array of reactions to add to the message
/// The options to be used when sending the request.
///
/// A task that represents the asynchronous operation for adding a reaction to this message.
///
///
///
public static async Task AddReactionsAsync(this IUserMessage msg, IEmote[] reactions, RequestOptions options = null)
{
foreach (var rxn in reactions)
await msg.AddReactionAsync(rxn, options).ConfigureAwait(false);
}
///
/// Remove multiple reactions from a message.
///
///
/// This method does not bulk remove reactions! If you want to clear reactions from a message,
///
///
///
///
/// await msg.RemoveReactionsAsync(currentUser, new[] { A, B });
///
///
/// The message to remove reactions from.
/// An array of reactions to remove from the message
/// The options to be used when sending the request.
///
/// A task that represents the asynchronous operation for removing a reaction to this message.
///
///
///
public static async Task RemoveReactionsAsync(this IUserMessage msg, IUser user, IEmote[] reactions, RequestOptions options = null)
{
foreach (var rxn in reactions)
await msg.RemoveReactionAsync(rxn, user, options).ConfigureAwait(false);
}
}
}