Browse Source

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.
pull/1455/head
Chris Johnston 5 years ago
parent
commit
af14b7cffe
1 changed files with 28 additions and 0 deletions
  1. +28
    -0
      src/Discord.Net.Core/Entities/Messages/AllowedMentions.cs

+ 28
- 0
src/Discord.Net.Core/Entities/Messages/AllowedMentions.cs View File

@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;

namespace Discord
@@ -7,11 +8,26 @@ namespace Discord
/// </summary>
public class AllowedMentions
{
private static readonly Lazy<AllowedMentions> none = new Lazy<AllowedMentions>(() => new AllowedMentions());
private static readonly Lazy<AllowedMentions> all = new Lazy<AllowedMentions>(() =>
new AllowedMentions(AllowedMentionTypes.Everyone | AllowedMentionTypes.Users | AllowedMentionTypes.Roles));

/// <summary>
/// Gets a value which indicates that no mentions in the message content should notify users.
/// </summary>
public static AllowedMentions None => none.Value;

/// <summary>
/// Gets a value which indicates that all mentions in the message content should notify users.
/// </summary>
public static AllowedMentions All => all.Value;

/// <summary>
/// Gets or sets the type of mentions that will be parsed from the message content.
/// The <see cref="AllowedMentionTypes.Users"/> flag is mutually exclusive with the <see cref="UserIds"/>
/// property, and the <see cref="AllowedMentionTypes.Roles"/> flag is mutually exclusive with the
/// <see cref="RoleIds"/> property.
/// If <c>null</c>, only the Ids specified in <see cref="UserIds"/> and <see cref="RoleIds"/> will be mentioned.
/// </summary>
public AllowedMentionTypes? AllowedTypes { get; set; }

@@ -30,5 +46,17 @@ namespace Discord
/// must be <c>null</c> or empty.
/// </summary>
public List<ulong> UserIds { get; set; }

/// <summary>
/// Initializes a new instance of the <see cref="AllowedMentions"/> class.
/// </summary>
/// <param name="allowedTypes">
/// The types of mentions to parse from the message content.
/// If <c>null</c>, only the Ids specified in <see cref="UserIds"/> and <see cref="RoleIds"/> will be mentioned.
/// </param>
public AllowedMentions(AllowedMentionTypes? allowedTypes = null)
{
AllowedTypes = allowedTypes;
}
}
}

Loading…
Cancel
Save