Browse Source

Stopped hardcoding regions

tags/docs-0.9
RogueException 9 years ago
parent
commit
085138c182
2 changed files with 1 additions and 46 deletions
  1. +0
    -45
      src/Discord.Net/API/Enums/Region.cs
  2. +1
    -1
      test/Discord.Net.Tests/Tests.cs

+ 0
- 45
src/Discord.Net/API/Enums/Region.cs View File

@@ -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();
}
}

+ 1
- 1
test/Discord.Net.Tests/Tests.cs View File

@@ -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(


Loading…
Cancel
Save