Class DiscordRole
Represents a discord role, to which users can be assigned.
Namespace: DisCatSharp.Entities
Assembly: DisCatSharp.dll
Syntax
public class DiscordRole : SnowflakeObject, IEquatable<DiscordRole>
Properties
| Improve this Doc View SourceColor
Gets the color of this role.
Declaration
public DiscordColor Color { get; }
Property Value
Type | Description |
---|---|
DiscordColor |
Flags
Gets the role flags.
Declaration
public RoleFlags Flags { get; }
Property Value
Type | Description |
---|---|
RoleFlags |
IconHash
Gets the role icon's hash.
Declaration
public string IconHash { get; }
Property Value
Type | Description |
---|---|
System.String |
IconUrl
Gets the role icon's url.
Declaration
public string IconUrl { get; }
Property Value
Type | Description |
---|---|
System.String |
IsHoisted
Gets whether this role is hoisted.
Declaration
public bool IsHoisted { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsManaged
Gets whether this role is managed by an integration.
Declaration
public bool IsManaged { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsMentionable
Gets whether this role is mentionable.
Declaration
public bool IsMentionable { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Mention
Gets a mention string for this role. If the role is mentionable, this string will mention all the users that belong to this role.
Declaration
public string Mention { get; }
Property Value
Type | Description |
---|---|
System.String |
Name
Gets the name of this role.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
System.String |
Permissions
Gets the permissions set for this role.
Declaration
public Permissions Permissions { get; }
Property Value
Type | Description |
---|---|
Permissions |
Position
Gets the position of this role in the role hierarchy.
Declaration
public int Position { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Tags
Gets the tags this role has.
Declaration
public DiscordRoleTags Tags { get; }
Property Value
Type | Description |
---|---|
DiscordRoleTags |
UnicodeEmoji
Gets the unicode emoji.
Declaration
public DiscordEmoji UnicodeEmoji { get; }
Property Value
Type | Description |
---|---|
DiscordEmoji |
Methods
| Improve this Doc View SourceCheckPermission(Permissions)
Checks whether this role has specific permissions.
Declaration
public PermissionLevel CheckPermission(Permissions permission)
Parameters
Type | Name | Description |
---|---|---|
Permissions | permission | Permissions to check for. |
Returns
Type | Description |
---|---|
PermissionLevel | Whether the permissions are allowed or not. |
DeleteAsync(String)
Deletes this role.
Declaration
public Task DeleteAsync(string reason = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | reason | Reason as to why this role has been deleted. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ManageRoles permission. |
NotFoundException | Thrown when the role does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
Equals(DiscordRole)
Checks whether this DiscordRole is equal to another DiscordRole.
Declaration
public bool Equals(DiscordRole e)
Parameters
Type | Name | Description |
---|---|---|
DiscordRole | e | DiscordRole to compare to. |
Returns
Type | Description |
---|---|
System.Boolean | Whether the DiscordRole is equal to this DiscordRole. |
Equals(Object)
Checks whether this DiscordRole is equal to another object.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | Object to compare to. |
Returns
Type | Description |
---|---|
System.Boolean | Whether the object is equal to this DiscordRole. |
Overrides
GetHashCode()
Gets the hash code for this DiscordRole.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | The hash code for this DiscordRole. |
Overrides
ModifyAsync(Action<RoleEditModel>)
Updates this role.
Declaration
public Task ModifyAsync(Action<RoleEditModel> action)
Parameters
Type | Name | Description |
---|---|---|
System.Action<RoleEditModel> | action | The action. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have theManageRoles permission. |
NotFoundException | Thrown when the role does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
ModifyAsync(String, Nullable<Permissions>, Nullable<DiscordColor>, Nullable<Boolean>, Nullable<Boolean>, String)
Updates this role.
Declaration
public Task ModifyAsync(string name = null, Permissions? permissions = null, DiscordColor? color = null, bool? hoist = null, bool? mentionable = null, string reason = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | New role name. |
System.Nullable<Permissions> | permissions | New role permissions. |
System.Nullable<DiscordColor> | color | New role color. |
System.Nullable<System.Boolean> | hoist | New role hoist. |
System.Nullable<System.Boolean> | mentionable | Whether this role is mentionable. |
System.String | reason | Audit log reason. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ManageRoles permission. |
NotFoundException | Thrown when the role does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
ModifyPositionAsync(Int32, String)
Modifies this role's position.
Declaration
public Task ModifyPositionAsync(int position, string reason = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | position | New position |
System.String | reason | Reason why we moved it |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
UnauthorizedException | Thrown when the client does not have the ManageRoles permission. |
NotFoundException | Thrown when the role does not exist. |
BadRequestException | Thrown when an invalid parameter was provided. |
ServerErrorException | Thrown when Discord is unable to process the request. |
ToString()
Returns a string representation of this role.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | String representation of this role. |
Overrides
Operators
| Improve this Doc View SourceEquality(DiscordRole, DiscordRole)
Gets whether the two DiscordRole objects are equal.
Declaration
public static bool operator ==(DiscordRole e1, DiscordRole e2)
Parameters
Type | Name | Description |
---|---|---|
DiscordRole | e1 | First role to compare. |
DiscordRole | e2 | Second role to compare. |
Returns
Type | Description |
---|---|
System.Boolean | Whether the two roles are equal. |
Inequality(DiscordRole, DiscordRole)
Gets whether the two DiscordRole objects are not equal.
Declaration
public static bool operator !=(DiscordRole e1, DiscordRole e2)
Parameters
Type | Name | Description |
---|---|---|
DiscordRole | e1 | First role to compare. |
DiscordRole | e2 | Second role to compare. |
Returns
Type | Description |
---|---|
System.Boolean | Whether the two roles are not equal. |