From af14b7cffe1921776f68691d50e3b3e9c1d50076 Mon Sep 17 00:00:00 2001 From: Chris Johnston Date: Wed, 4 Mar 2020 23:01:52 -0800 Subject: [PATCH] Add util properties for specifying all or no mentions Adds read only properties which specify that all mentions or no mentions will notify users. These settings might be more common than others, so this would make them easier to use. --- .../Entities/Messages/AllowedMentions.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/Discord.Net.Core/Entities/Messages/AllowedMentions.cs b/src/Discord.Net.Core/Entities/Messages/AllowedMentions.cs index cb18cae90..27ec99845 100644 --- a/src/Discord.Net.Core/Entities/Messages/AllowedMentions.cs +++ b/src/Discord.Net.Core/Entities/Messages/AllowedMentions.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; namespace Discord @@ -7,11 +8,26 @@ namespace Discord /// 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; } @@ -30,5 +46,17 @@ namespace Discord /// 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; + } } }