| @@ -88,8 +88,8 @@ | |||||
| <Compile Include="..\Discord.Net\API\Enums\PermissionTarget.cs"> | <Compile Include="..\Discord.Net\API\Enums\PermissionTarget.cs"> | ||||
| <Link>API\Enums\PermissionTarget.cs</Link> | <Link>API\Enums\PermissionTarget.cs</Link> | ||||
| </Compile> | </Compile> | ||||
| <Compile Include="..\Discord.Net\API\Enums\Regions.cs"> | |||||
| <Link>API\Enums\Regions.cs</Link> | |||||
| <Compile Include="..\Discord.Net\API\Enums\Region.cs"> | |||||
| <Link>API\Enums\Region.cs</Link> | |||||
| </Compile> | </Compile> | ||||
| <Compile Include="..\Discord.Net\API\Enums\StringEnum.cs"> | <Compile Include="..\Discord.Net\API\Enums\StringEnum.cs"> | ||||
| <Link>API\Enums\StringEnum.cs</Link> | <Link>API\Enums\StringEnum.cs</Link> | ||||
| @@ -24,5 +24,11 @@ | |||||
| return new ChannelType(value); | return new ChannelType(value); | ||||
| } | } | ||||
| } | } | ||||
| public static implicit operator ChannelType(string value) => FromString(value); | |||||
| public static bool operator ==(ChannelType a, ChannelType b) => a?._value == b?._value; | |||||
| public static bool operator !=(ChannelType a, ChannelType b) => a?._value != b?._value; | |||||
| public override bool Equals(object obj) => (obj as ChannelType)?._value == _value; | |||||
| public override int GetHashCode() => _value.GetHashCode(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -24,5 +24,11 @@ | |||||
| return new PermissionTarget(value); | return new PermissionTarget(value); | ||||
| } | } | ||||
| } | } | ||||
| public static implicit operator PermissionTarget(string value) => FromString(value); | |||||
| public static bool operator ==(PermissionTarget a, PermissionTarget b) => a?._value == b?._value; | |||||
| public static bool operator !=(PermissionTarget a, PermissionTarget b) => a?._value != b?._value; | |||||
| public override bool Equals(object obj) => (obj as PermissionTarget)?._value == _value; | |||||
| public override int GetHashCode() => _value.GetHashCode(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -34,5 +34,11 @@ | |||||
| return new Region(value); | return new Region(value); | ||||
| } | } | ||||
| } | } | ||||
| public static implicit operator Region(string value) => FromString(value); | |||||
| public static bool operator ==(Region a, Region b) => a?._value == b?._value; | |||||
| public static bool operator !=(Region a, Region b) => a?._value != b?._value; | |||||
| public override bool Equals(object obj) => (obj as Region)?._value == _value; | |||||
| public override int GetHashCode() => _value.GetHashCode(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -2,7 +2,7 @@ | |||||
| { | { | ||||
| public abstract class StringEnum | public abstract class StringEnum | ||||
| { | { | ||||
| private string _value; | |||||
| protected string _value; | |||||
| protected StringEnum(string value) | protected StringEnum(string value) | ||||
| { | { | ||||
| _value = value; | _value = value; | ||||
| @@ -10,43 +10,5 @@ | |||||
| public string Value => _value; | public string Value => _value; | ||||
| public override string ToString() => _value; | public override string ToString() => _value; | ||||
| public override bool Equals(object obj) | |||||
| { | |||||
| var enum2 = obj as StringEnum; | |||||
| if (enum2 == (StringEnum)null) | |||||
| return false; | |||||
| else | |||||
| return _value == enum2._value; | |||||
| } | |||||
| public override int GetHashCode() | |||||
| { | |||||
| return _value.GetHashCode(); | |||||
| } | |||||
| public static bool operator ==(StringEnum a, StringEnum b) | |||||
| { | |||||
| return a?._value == b?._value; | |||||
| } | |||||
| public static bool operator !=(StringEnum a, StringEnum b) | |||||
| { | |||||
| return a?._value != b?._value; | |||||
| } | |||||
| public static bool operator ==(StringEnum a, string b) | |||||
| { | |||||
| return a?._value == b; | |||||
| } | |||||
| public static bool operator !=(StringEnum a, string b) | |||||
| { | |||||
| return a?._value != b; | |||||
| } | |||||
| public static bool operator ==(string a, StringEnum b) | |||||
| { | |||||
| return a == b?._value; | |||||
| } | |||||
| public static bool operator !=(string a, StringEnum b) | |||||
| { | |||||
| return a != b?._value; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -28,5 +28,11 @@ | |||||
| return new UserStatus(value); | return new UserStatus(value); | ||||
| } | } | ||||
| } | } | ||||
| public static implicit operator UserStatus(string value) => FromString(value); | |||||
| public static bool operator ==(UserStatus a, UserStatus b) => a?._value == b?._value; | |||||
| public static bool operator !=(UserStatus a, UserStatus b) => a?._value != b?._value; | |||||
| public override bool Equals(object obj) => (obj as UserStatus)?._value == _value; | |||||
| public override int GetHashCode() => _value.GetHashCode(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -98,14 +98,14 @@ namespace Discord | |||||
| if (channel != null) | if (channel != null) | ||||
| query = query.Concat(new Channel[] { channel }); | query = query.Concat(new Channel[] { channel }); | ||||
| } | } | ||||
| else if (name[0] == '#' && (type == (ChannelType)null || type == ChannelType.Text)) //If we somehow get text starting with # but isn't a mention | |||||
| else if (name[0] == '#' && (type == null || type == ChannelType.Text)) //If we somehow get text starting with # but isn't a mention | |||||
| { | { | ||||
| string name2 = name.Substring(1); | string name2 = name.Substring(1); | ||||
| query = query.Concat(server.TextChannels.Where(x => string.Equals(x.Name, name2, StringComparison.OrdinalIgnoreCase))); | query = query.Concat(server.TextChannels.Where(x => string.Equals(x.Name, name2, StringComparison.OrdinalIgnoreCase))); | ||||
| } | } | ||||
| } | } | ||||
| if (type != (string)null) | |||||
| if (type != null) | |||||
| query = query.Where(x => x.Type == type); | query = query.Where(x => x.Type == type); | ||||
| return query; | return query; | ||||
| } | } | ||||
| @@ -115,7 +115,7 @@ namespace Discord | |||||
| { | { | ||||
| if (server == null) throw new ArgumentNullException(nameof(server)); | if (server == null) throw new ArgumentNullException(nameof(server)); | ||||
| if (name == null) throw new ArgumentNullException(nameof(name)); | if (name == null) throw new ArgumentNullException(nameof(name)); | ||||
| if (type == (string)null) throw new ArgumentNullException(nameof(type)); | |||||
| if (type == null) throw new ArgumentNullException(nameof(type)); | |||||
| CheckReady(); | CheckReady(); | ||||
| var response = await _api.CreateChannel(server.Id, name, type.Value).ConfigureAwait(false); | var response = await _api.CreateChannel(server.Id, name, type.Value).ConfigureAwait(false); | ||||
| @@ -84,7 +84,7 @@ namespace Discord | |||||
| public async Task<Server> CreateServer(string name, Region region) | public async Task<Server> CreateServer(string name, Region region) | ||||
| { | { | ||||
| if (name == null) throw new ArgumentNullException(nameof(name)); | if (name == null) throw new ArgumentNullException(nameof(name)); | ||||
| if (region == (string)null) throw new ArgumentNullException(nameof(region)); | |||||
| if (region == null) throw new ArgumentNullException(nameof(region)); | |||||
| CheckReady(); | CheckReady(); | ||||
| var response = await _api.CreateServer(name, region.Value).ConfigureAwait(false); | var response = await _api.CreateServer(name, region.Value).ConfigureAwait(false); | ||||
| @@ -250,7 +250,7 @@ namespace Discord | |||||
| public Task SetStatus(UserStatus status) | public Task SetStatus(UserStatus status) | ||||
| { | { | ||||
| if (status == (string)null) throw new ArgumentNullException(nameof(status)); | |||||
| if (status == null) throw new ArgumentNullException(nameof(status)); | |||||
| if (status != UserStatus.Online && status != UserStatus.Idle) | if (status != UserStatus.Online && status != UserStatus.Idle) | ||||
| throw new ArgumentException($"Invalid status, must be {UserStatus.Online} or {UserStatus.Idle}", nameof(status)); | throw new ArgumentException($"Invalid status, must be {UserStatus.Online} or {UserStatus.Idle}", nameof(status)); | ||||
| CheckReady(); | CheckReady(); | ||||