Cleaned up Hierarchy PR

This commit is contained in:
RogueException
2016-11-12 01:37:35 -04:00
5 changed files with 48 additions and 7 deletions

View File

@@ -4,7 +4,7 @@ using System.Threading.Tasks;
namespace Discord
{
public interface IRole : ISnowflakeEntity, IDeletable, IMentionable
public interface IRole : ISnowflakeEntity, IDeletable, IMentionable, IComparable<IRole>
{
/// <summary> Gets the guild owning this role.</summary>
IGuild Guild { get; }
@@ -27,4 +27,4 @@ namespace Discord
///// <summary> Modifies this role. </summary>
Task ModifyAsync(Action<ModifyGuildRoleParams> func, RequestOptions options = null);
}
}
}

View File

@@ -0,0 +1,18 @@
namespace Discord
{
internal static class RoleExtensions
{
internal static int Compare(this IRole left, IRole right)
{
if (left == null)
return -1;
if (right == null)
return 1;
var result = left.Position.CompareTo(right.Position);
// As per Discord's documentation, a tie is broken by ID
if (result != 0)
return result;
return left.Id.CompareTo(right.Id);
}
}
}