Class MentionUtils
Provides a series of helper methods for parsing mentions.
Inheritance
System.Object
MentionUtils
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Discord
Assembly: Discord.Net.Core.dll
Syntax
public static class MentionUtils
Methods
| Improve this Doc View SourceMentionChannel(UInt64)
Returns a mention string based on the channel ID.
Declaration
public static string MentionChannel(ulong id)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt64 | id |
Returns
| Type | Description |
|---|---|
| System.String | A channel mention string (e.g. <#103735883630395392>). |
MentionRole(UInt64)
Returns a mention string based on the role ID.
Declaration
public static string MentionRole(ulong id)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt64 | id |
Returns
| Type | Description |
|---|---|
| System.String | A role mention string (e.g. <@&165511591545143296>). |
MentionUser(UInt64)
Returns a mention string based on the user ID.
Declaration
public static string MentionUser(ulong id)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt64 | id |
Returns
| Type | Description |
|---|---|
| System.String | A user mention string (e.g. <@80351110224678912>). |
ParseChannel(String)
Parses a provided channel mention string.
Declaration
public static ulong ParseChannel(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | text |
Returns
| Type | Description |
|---|---|
| System.UInt64 |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Invalid mention format. |
ParseRole(String)
Parses a provided role mention string.
Declaration
public static ulong ParseRole(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | text |
Returns
| Type | Description |
|---|---|
| System.UInt64 |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Invalid mention format. |
ParseUser(String)
Parses a provided user mention string.
Declaration
public static ulong ParseUser(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | text |
Returns
| Type | Description |
|---|---|
| System.UInt64 |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Invalid mention format. |
TryParseChannel(String, out UInt64)
Tries to parse a provided channel mention string.
Declaration
public static bool TryParseChannel(string text, out ulong channelId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | text | |
| System.UInt64 | channelId |
Returns
| Type | Description |
|---|---|
| System.Boolean |
TryParseRole(String, out UInt64)
Tries to parse a provided role mention string.
Declaration
public static bool TryParseRole(string text, out ulong roleId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | text | |
| System.UInt64 | roleId |
Returns
| Type | Description |
|---|---|
| System.Boolean |
TryParseUser(String, out UInt64)
Tries to parse a provided user mention string.
Declaration
public static bool TryParseUser(string text, out ulong userId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | text | |
| System.UInt64 | userId |
Returns
| Type | Description |
|---|---|
| System.Boolean |