Stopped hardcoding regions
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
namespace Discord
|
||||
{
|
||||
public class Region : StringEnum
|
||||
{
|
||||
public static readonly Region USWest = new Region("us-west");
|
||||
public static readonly Region USEast = new Region("us-east");
|
||||
public static readonly Region Singapore = new Region("singapore");
|
||||
public static readonly Region London = new Region("london");
|
||||
public static readonly Region Sydney = new Region("sydney");
|
||||
public static readonly Region Amsterdam = new Region("amsterdam");
|
||||
public static readonly Region Frankfurt = new Region("frankfurt");
|
||||
|
||||
private Region(string value)
|
||||
: base(value) { }
|
||||
|
||||
public static Region FromString(string value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case null:
|
||||
return null;
|
||||
case "us-west":
|
||||
return Region.USWest;
|
||||
case "us-east":
|
||||
return Region.USEast;
|
||||
case "singapore":
|
||||
return Region.Singapore;
|
||||
case "london":
|
||||
return Region.London;
|
||||
case "sydney":
|
||||
return Region.Sydney;
|
||||
case "amsterdam":
|
||||
return Region.Amsterdam;
|
||||
default:
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ namespace Discord.Tests
|
||||
_observerBot.AllServers.Select(x => _observerBot.LeaveServer(x)));
|
||||
|
||||
//Create new server and invite the other bots to it
|
||||
_testServer = _hostClient.CreateServer("Discord.Net Testing", Region.USEast).Result;
|
||||
_testServer = _hostClient.CreateServer("Discord.Net Testing", _hostClient.GetVoiceRegions().Result.First()).Result;
|
||||
_testServerChannel = _testServer.DefaultChannel;
|
||||
Invite invite = _hostClient.CreateInvite(_testServer, 60, 1, false, false).Result;
|
||||
WaitAll(
|
||||
|
||||
Reference in New Issue
Block a user