diff --git a/src/Discord.Net.Commands/ModuleBase.cs b/src/Discord.Net.Commands/ModuleBase.cs
index 9cd4ea15d..ec1722c70 100644
--- a/src/Discord.Net.Commands/ModuleBase.cs
+++ b/src/Discord.Net.Commands/ModuleBase.cs
@@ -31,9 +31,13 @@ namespace Discord.Commands
///
/// Specifies if Discord should read this aloud using text-to-speech.
/// An embed to be displayed alongside the .
- protected virtual async Task ReplyAsync(string message = null, bool isTTS = false, Embed embed = null, RequestOptions options = null)
+ ///
+ /// Specifies if notifications are sent for mentioned users and roles in the .
+ /// If null, all mentioned roles and users will be notified.
+ ///
+ protected virtual async Task ReplyAsync(string message = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null)
{
- return await Context.Channel.SendMessageAsync(message, isTTS, embed, options).ConfigureAwait(false);
+ return await Context.Channel.SendMessageAsync(message, isTTS, embed, options, allowedMentions).ConfigureAwait(false);
}
///
/// The method to execute before executing the command.
diff --git a/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs b/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs
index b5aa69d55..f5b986295 100644
--- a/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs
+++ b/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs
@@ -23,11 +23,15 @@ namespace Discord
/// Determines whether the message should be read aloud by Discord or not.
/// The to be sent.
/// The options to be used when sending the request.
+ ///
+ /// Specifies if notifications are sent for mentioned users and roles in the message .
+ /// If null, all mentioned roles and users will be notified.
+ ///
///
/// A task that represents an asynchronous send operation for delivering the message. The task result
/// contains the sent message.
///
- Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null);
+ Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null);
///
/// Sends a file to this message channel with an optional caption.
///
diff --git a/src/Discord.Net.Core/Entities/Messages/AllowedMentionTypes.cs b/src/Discord.Net.Core/Entities/Messages/AllowedMentionTypes.cs
new file mode 100644
index 000000000..3ce6531b7
--- /dev/null
+++ b/src/Discord.Net.Core/Entities/Messages/AllowedMentionTypes.cs
@@ -0,0 +1,24 @@
+using System;
+
+namespace Discord
+{
+ ///
+ /// Specifies the type of mentions that will be notified from the message content.
+ ///
+ [Flags]
+ public enum AllowedMentionTypes
+ {
+ ///
+ /// Controls role mentions.
+ ///
+ Roles,
+ ///
+ /// Controls user mentions.
+ ///
+ Users,
+ ///
+ /// Controls @everyone
and @here
mentions.
+ ///
+ Everyone,
+ }
+}
diff --git a/src/Discord.Net.Core/Entities/Messages/AllowedMentions.cs b/src/Discord.Net.Core/Entities/Messages/AllowedMentions.cs
new file mode 100644
index 000000000..9b168bbd0
--- /dev/null
+++ b/src/Discord.Net.Core/Entities/Messages/AllowedMentions.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+
+namespace Discord
+{
+ ///
+ /// Defines which mentions and types of mentions that will notify users from the message content.
+ ///
+ public class AllowedMentions
+ {
+ private static readonly Lazy none = new Lazy(() => new AllowedMentions());
+ private static readonly Lazy all = new Lazy(() =>
+ new AllowedMentions(AllowedMentionTypes.Everyone | AllowedMentionTypes.Users | AllowedMentionTypes.Roles));
+
+ ///
+ /// Gets a value which indicates that no mentions in the message content should notify users.
+ ///
+ public static AllowedMentions None => none.Value;
+
+ ///
+ /// Gets a value which indicates that all mentions in the message content should notify users.
+ ///
+ public static AllowedMentions All => all.Value;
+
+ ///
+ /// Gets or sets the type of mentions that will be parsed from the message content.
+ ///
+ ///
+ /// The flag is mutually exclusive with the
+ /// property, and the flag is mutually exclusive with the
+ /// property.
+ /// If null, only the ids specified in and will be mentioned.
+ ///
+ public AllowedMentionTypes? AllowedTypes { get; set; }
+
+ ///
+ /// Gets or sets the list of all role ids that will be mentioned.
+ /// This property is mutually exclusive with the
+ /// flag of the property. If the flag is set, the value of this property
+ /// must be null or empty.
+ ///
+ public List RoleIds { get; set; }
+
+ ///
+ /// Gets or sets the list of all user ids that will be mentioned.
+ /// This property is mutually exclusive with the
+ /// flag of the property. If the flag is set, the value of this property
+ /// must be null or empty.
+ ///
+ public List UserIds { get; set; }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
+ /// The types of mentions to parse from the message content.
+ /// If null, only the ids specified in and will be mentioned.
+ ///
+ public AllowedMentions(AllowedMentionTypes? allowedTypes = null)
+ {
+ AllowedTypes = allowedTypes;
+ }
+ }
+}
diff --git a/src/Discord.Net.Core/Extensions/UserExtensions.cs b/src/Discord.Net.Core/Extensions/UserExtensions.cs
index 58c762090..90f26828a 100644
--- a/src/Discord.Net.Core/Extensions/UserExtensions.cs
+++ b/src/Discord.Net.Core/Extensions/UserExtensions.cs
@@ -28,6 +28,10 @@ namespace Discord
/// Whether the message should be read aloud by Discord or not.
/// The to be sent.
/// The options to be used when sending the request.
+ ///
+ /// Specifies if notifications are sent for mentioned users and roles in the message .
+ /// If null, all mentioned roles and users will be notified.
+ ///
///
/// A task that represents the asynchronous send operation. The task result contains the sent message.
///
@@ -35,9 +39,10 @@ namespace Discord
string text = null,
bool isTTS = false,
Embed embed = null,
- RequestOptions options = null)
+ RequestOptions options = null,
+ AllowedMentions allowedMentions = null)
{
- return await (await user.GetOrCreateDMChannelAsync().ConfigureAwait(false)).SendMessageAsync(text, isTTS, embed, options).ConfigureAwait(false);
+ return await (await user.GetOrCreateDMChannelAsync().ConfigureAwait(false)).SendMessageAsync(text, isTTS, embed, options, allowedMentions).ConfigureAwait(false);
}
///
diff --git a/src/Discord.Net.Rest/API/Common/Message.cs b/src/Discord.Net.Rest/API/Common/Message.cs
index f20035685..b4529d457 100644
--- a/src/Discord.Net.Rest/API/Common/Message.cs
+++ b/src/Discord.Net.Rest/API/Common/Message.cs
@@ -54,5 +54,7 @@ namespace Discord.API
public Optional Reference { get; set; }
[JsonProperty("flags")]
public Optional Flags { get; set; }
+ [JsonProperty("allowed_mentions")]
+ public Optional AllowedMentions { get; set; }
}
}
diff --git a/src/Discord.Net.Rest/API/Rest/CreateMessageParams.cs b/src/Discord.Net.Rest/API/Rest/CreateMessageParams.cs
index d77bff8ca..4b56658d6 100644
--- a/src/Discord.Net.Rest/API/Rest/CreateMessageParams.cs
+++ b/src/Discord.Net.Rest/API/Rest/CreateMessageParams.cs
@@ -1,4 +1,4 @@
-#pragma warning disable CS1591
+#pragma warning disable CS1591
using Newtonsoft.Json;
namespace Discord.API.Rest
@@ -15,6 +15,8 @@ namespace Discord.API.Rest
public Optional IsTTS { get; set; }
[JsonProperty("embed")]
public Optional