@@ -25,9 +25,9 @@ namespace Discord.API | |||||
return Http.Post(Endpoints.AuthLogout, options); | return Http.Post(Endpoints.AuthLogout, options); | ||||
} | } | ||||
public static Task CreateServer(string name, Region region, HttpOptions options) | |||||
public static Task CreateServer(string name, string region, HttpOptions options) | |||||
{ | { | ||||
var request = new CreateServerRequest { Name = name, Region = RegionConverter.Convert(region) }; | |||||
var request = new CreateServerRequest { Name = name, Region = region }; | |||||
return Http.Post(Endpoints.Servers, request, options); | return Http.Post(Endpoints.Servers, request, options); | ||||
} | } | ||||
public static Task DeleteServer(string id, HttpOptions options) | public static Task DeleteServer(string id, HttpOptions options) | ||||
@@ -212,7 +212,7 @@ namespace Discord | |||||
_isClosing = false; | _isClosing = false; | ||||
} | } | ||||
public Task CreateServer(string name, Region region) | |||||
public Task CreateServer(string name, string region) | |||||
{ | { | ||||
CheckReady(); | CheckReady(); | ||||
return DiscordAPI.CreateServer(name, region, _httpOptions); | return DiscordAPI.CreateServer(name, region, _httpOptions); | ||||
@@ -1,32 +1,12 @@ | |||||
using System; | |||||
namespace Discord | |||||
namespace Discord | |||||
{ | { | ||||
public enum Region | |||||
public static class Region | |||||
{ | { | ||||
US_West, | |||||
US_East, | |||||
Singapore, | |||||
London, | |||||
Sydney, | |||||
Amsterdam | |||||
} | |||||
internal static class RegionConverter | |||||
{ | |||||
public static string Convert(Region region) | |||||
{ | |||||
switch (region) | |||||
{ | |||||
case Region.US_West: return "us-west"; | |||||
case Region.US_East: return "us-east"; | |||||
case Region.Singapore: return "singapore"; | |||||
case Region.London: return "london"; | |||||
case Region.Sydney: return "sydney"; | |||||
case Region.Amsterdam: return "amsterdam"; | |||||
default: | |||||
throw new ArgumentOutOfRangeException("Unknown server region"); | |||||
} | |||||
} | |||||
} | |||||
public const string US_West = "us-west"; | |||||
public const string US_East = "us-east"; | |||||
public const string Singapore = "singapore"; | |||||
public const string London = "london"; | |||||
public const string Sydney = "sydney"; | |||||
public const string Amsterdam = "amsterdam"; | |||||
} | |||||
} | } |