Skip to content

Commit

Permalink
Add tag examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Still Hsu committed May 3, 2018
1 parent 57ea571 commit 157acc4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 15 deletions.
48 changes: 33 additions & 15 deletions src/Discord.Net.Core/Entities/Messages/TagHandling.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,39 @@
namespace Discord
{
/// <summary> Specifies the handling type the tag should use. </summary>
/// <summary>
/// Specifies the handling type the tag should use.
/// </summary>
/// <seealso cref="MentionUtils"/>
/// <seealso cref="IUserMessage.Resolve"/>
public enum TagHandling
{
/// <summary> Tag handling is ignored. </summary>
Ignore = 0, //<@53905483156684800> -> <@53905483156684800>
/// <summary> Removes the tag entirely. </summary>
Remove, //<@53905483156684800> ->
/// <summary> Resolves to username (e.g. @User). </summary>
Name, //<@53905483156684800> -> @Voltana
/// <summary> Resolves to username without mention prefix (e.g. User). </summary>
NameNoPrefix, //<@53905483156684800> -> Voltana
/// <summary> Resolves to username with discriminator value. (e.g. @User#0001). </summary>
FullName, //<@53905483156684800> -> @Voltana#8252
/// <summary> Resolves to username with discriminator value without mention prefix. (e.g. User#0001). </summary>
FullNameNoPrefix, //<@53905483156684800> -> Voltana#8252
/// <summary> Sanitizes the tag. </summary>
Sanitize //<@53905483156684800> -> <@53905483156684800> (w/ nbsp)
/// <summary>
/// Tag handling is ignored (e.g. &lt;@53905483156684800&gt; -&gt; &lt;@53905483156684800&gt;).
/// </summary>
Ignore = 0,
/// <summary>
/// Removes the tag entirely.
/// </summary>
Remove,
/// <summary>
/// Resolves to username (e.g. &lt;@53905483156684800&gt; -&gt; @Voltana).
/// </summary>
Name,
/// <summary>
/// Resolves to username without mention prefix (e.g. &lt;@53905483156684800&gt; -&gt; Voltana).
/// </summary>
NameNoPrefix,
/// <summary>
/// Resolves to username with discriminator value. (e.g. &lt;@53905483156684800&gt; -&gt; @Voltana#8252).
/// </summary>
FullName,
/// <summary>
/// Resolves to username with discriminator value without mention prefix. (e.g. &lt;@53905483156684800&gt; -&gt; Voltana#8252).
/// </summary>
FullNameNoPrefix,
/// <summary>
/// Sanitizes the tag (e.g. &lt;@53905483156684800&gt; -&gt; &lt;@53905483156684800&gt; (w/ nbsp)).
/// </summary>
Sanitize
}
}
9 changes: 9 additions & 0 deletions src/Discord.Net.Core/Utils/MentionUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,25 @@ public static class MentionUtils
/// <summary>
/// Returns a mention string based on the user ID.
/// </summary>
/// <returns>
/// A user mention string (e.g. &lt;@80351110224678912&gt;).
/// </returns>
public static string MentionUser(ulong id) => MentionUser(id.ToString(), true);
internal static string MentionChannel(string id) => $"<#{id}>";
/// <summary>
/// Returns a mention string based on the channel ID.
/// </summary>
/// <returns>
/// A channel mention string (e.g. &lt;#103735883630395392&gt;).
/// </returns>
public static string MentionChannel(ulong id) => MentionChannel(id.ToString());
internal static string MentionRole(string id) => $"<@&{id}>";
/// <summary>
/// Returns a mention string based on the role ID.
/// </summary>
/// <returns>
/// A role mention string (e.g. &lt;@&amp;165511591545143296&gt;).
/// </returns>
public static string MentionRole(ulong id) => MentionRole(id.ToString());

/// <summary>
Expand Down

0 comments on commit 157acc4

Please sign in to comment.