@@ -17,7 +17,7 @@ namespace DisCatSharp.Entities;
17
17
/// <summary>
18
18
/// Represents a discord role, to which users can be assigned.
19
19
/// </summary>
20
- public class DiscordRole : SnowflakeObject , IEquatable < DiscordRole >
20
+ public sealed class DiscordRole : SnowflakeObject , IEquatable < DiscordRole >
21
21
{
22
22
[ JsonProperty ( "color" , NullValueHandling = NullValueHandling . Ignore ) ]
23
23
internal int ColorInternal ;
@@ -29,7 +29,7 @@ public class DiscordRole : SnowflakeObject, IEquatable<DiscordRole>
29
29
/// Gets the role unicode_emoji.
30
30
/// </summary>
31
31
[ JsonProperty ( "unicode_emoji" , NullValueHandling = NullValueHandling . Ignore ) ]
32
- internal string UnicodeEmojiString ;
32
+ internal string ? UnicodeEmojiString ;
33
33
34
34
/// <summary>
35
35
/// Initializes a new instance of the <see cref="DiscordRole" /> class.
@@ -53,7 +53,7 @@ internal DiscordRole()
53
53
/// Gets the description of this role.
54
54
/// </summary>
55
55
[ JsonProperty ( "description" , NullValueHandling = NullValueHandling . Ignore ) ]
56
- public string Description { get ; internal set ; }
56
+ public string ? Description { get ; internal set ; }
57
57
58
58
/// <summary>
59
59
/// Gets the color of this role.
@@ -96,26 +96,31 @@ public DiscordColor Color
96
96
/// Gets the tags this role has.
97
97
/// </summary>
98
98
[ JsonProperty ( "tags" , NullValueHandling = NullValueHandling . Ignore ) ]
99
- public DiscordRoleTags Tags { get ; internal set ; }
99
+ public DiscordRoleTags ? Tags { get ; internal set ; }
100
+
101
+ /// <summary>
102
+ /// Determines the type of role based on its tags.
103
+ /// </summary>
104
+ public RoleType Type => this . Tags ? . DetermineRoleType ( ) ?? RoleType . Normal ;
100
105
101
106
/// <summary>
102
107
/// Gets the role icon's hash.
103
108
/// </summary>
104
109
[ JsonProperty ( "icon" , NullValueHandling = NullValueHandling . Ignore ) ]
105
- public string IconHash { get ; internal set ; }
110
+ public string ? IconHash { get ; internal set ; }
106
111
107
112
/// <summary>
108
113
/// Gets the role icon's url.
109
114
/// </summary>
110
115
[ JsonIgnore ]
111
- public string IconUrl
116
+ public string ? IconUrl
112
117
=> ! string . IsNullOrWhiteSpace ( this . IconHash ) ? $ "{ DiscordDomain . GetDomain ( CoreDomain . DiscordCdn ) . Url } { Endpoints . ROLE_ICONS } /{ this . Id . ToString ( CultureInfo . InvariantCulture ) } /{ this . IconHash } .png?size=64" : null ;
113
118
114
119
/// <summary>
115
120
/// Gets the unicode emoji.
116
121
/// </summary>
117
122
[ JsonIgnore ]
118
- public DiscordEmoji UnicodeEmoji
123
+ public DiscordEmoji ? UnicodeEmoji
119
124
=> this . UnicodeEmojiString != null ? DiscordEmoji . FromName ( this . Discord , $ ":{ this . UnicodeEmojiString } :", false ) : null ;
120
125
121
126
/// <summary>
@@ -132,7 +137,7 @@ public DiscordGuild Guild
132
137
}
133
138
134
139
[ JsonIgnore ]
135
- internal DiscordGuild GuildInternal { get ; set ; }
140
+ internal DiscordGuild ? GuildInternal { get ; set ; }
136
141
137
142
/// <summary>
138
143
/// Gets the role flags.
@@ -231,7 +236,7 @@ public override int GetHashCode()
231
236
/// <exception cref="NotFoundException">Thrown when the role does not exist.</exception>
232
237
/// <exception cref="BadRequestException">Thrown when an invalid parameter was provided.</exception>
233
238
/// <exception cref="ServerErrorException">Thrown when Discord is unable to process the request.</exception>
234
- public Task ModifyPositionAsync ( int position , string reason = null )
239
+ public Task ModifyPositionAsync ( int position , string ? reason = null )
235
240
{
236
241
var roles = this . Guild . Roles . Values . OrderByDescending ( xr => xr . Position )
237
242
. Select ( x => new RestGuildRoleReorderPayload
@@ -263,7 +268,7 @@ public Task ModifyPositionAsync(int position, string reason = null)
263
268
/// <exception cref="NotFoundException">Thrown when the role does not exist.</exception>
264
269
/// <exception cref="BadRequestException">Thrown when an invalid parameter was provided.</exception>
265
270
/// <exception cref="ServerErrorException">Thrown when Discord is unable to process the request.</exception>
266
- public Task ModifyAsync ( string name = null , Permissions ? permissions = null , DiscordColor ? color = null , bool ? hoist = null , bool ? mentionable = null , string reason = null )
271
+ public Task ModifyAsync ( string name = null , Permissions ? permissions = null , DiscordColor ? color = null , bool ? hoist = null , bool ? mentionable = null , string ? reason = null )
267
272
=> this . Discord . ApiClient . ModifyGuildRoleAsync ( this . GuildId , this . Id , name , permissions , color ? . Value , hoist , mentionable , Optional . None , Optional . None , reason ) ;
268
273
269
274
/// <summary>
@@ -326,7 +331,7 @@ public Task ModifyAsync(Action<RoleEditModel> action)
326
331
/// <exception cref="NotFoundException">Thrown when the role does not exist.</exception>
327
332
/// <exception cref="BadRequestException">Thrown when an invalid parameter was provided.</exception>
328
333
/// <exception cref="ServerErrorException">Thrown when Discord is unable to process the request.</exception>
329
- public Task DeleteAsync ( string reason = null )
334
+ public Task DeleteAsync ( string ? reason = null )
330
335
=> this . Discord . ApiClient . DeleteRoleAsync ( this . GuildId , this . Id , reason ) ;
331
336
332
337
#endregion
0 commit comments