@@ -424,6 +424,9 @@ | |||||
<Compile Include="..\Discord.Net\Format.cs"> | <Compile Include="..\Discord.Net\Format.cs"> | ||||
<Link>Format.cs</Link> | <Link>Format.cs</Link> | ||||
</Compile> | </Compile> | ||||
<Compile Include="..\Discord.Net\IMentionable.cs"> | |||||
<Link>IMentionable.cs</Link> | |||||
</Compile> | |||||
<Compile Include="..\Discord.Net\IService.cs"> | <Compile Include="..\Discord.Net\IService.cs"> | ||||
<Link>IService.cs</Link> | <Link>IService.cs</Link> | ||||
</Compile> | </Compile> | ||||
@@ -0,0 +1,7 @@ | |||||
namespace Discord | |||||
{ | |||||
public interface IMentionable | |||||
{ | |||||
string Mention { get; } | |||||
} | |||||
} |
@@ -12,7 +12,7 @@ using APIChannel = Discord.API.Client.Channel; | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
public sealed class Channel | |||||
public sealed class Channel : IMentionable | |||||
{ | { | ||||
private struct Member | private struct Member | ||||
{ | { | ||||
@@ -9,7 +9,7 @@ using APIRole = Discord.API.Client.Role; | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
public sealed class Role | |||||
public sealed class Role : IMentionable | |||||
{ | { | ||||
internal DiscordClient Client => Server.Client; | internal DiscordClient Client => Server.Client; | ||||
@@ -37,16 +37,7 @@ namespace Discord | |||||
public IEnumerable<User> Members => IsEveryone ? Server.Users : Server.Users.Where(x => x.HasRole(this)); | public IEnumerable<User> Members => IsEveryone ? Server.Users : Server.Users.Where(x => x.HasRole(this)); | ||||
/// <summary> Gets the string used to mention this role. </summary> | /// <summary> Gets the string used to mention this role. </summary> | ||||
public string Mention | |||||
{ | |||||
get | |||||
{ | |||||
if (IsEveryone) | |||||
return "@everyone"; | |||||
else | |||||
throw new InvalidOperationException("Roles may only be mentioned if IsEveryone is true"); | |||||
} | |||||
} | |||||
public string Mention => IsEveryone ? "@everyone" : ""; | |||||
internal Role(ulong id, Server server) | internal Role(ulong id, Server server) | ||||
{ | { | ||||
@@ -9,7 +9,7 @@ using APIMember = Discord.API.Client.Member; | |||||
namespace Discord | namespace Discord | ||||
{ | { | ||||
public sealed class User | |||||
public sealed class User : IMentionable | |||||
{ | { | ||||
internal static string GetAvatarUrl(ulong userId, string avatarId) | internal static string GetAvatarUrl(ulong userId, string avatarId) | ||||
=> avatarId != null ? $"{DiscordConfig.ClientAPIUrl}users/{userId}/avatars/{avatarId}.jpg" : null; | => avatarId != null ? $"{DiscordConfig.ClientAPIUrl}users/{userId}/avatars/{avatarId}.jpg" : null; | ||||