Fixed EditServer error 500s

This commit is contained in:
RogueException
2015-12-13 23:16:19 -04:00
parent 2dca7d9ebe
commit 3e72954c4c
3 changed files with 26 additions and 12 deletions

View File

@@ -69,16 +69,16 @@ namespace Discord.API
//Edit //Edit
internal sealed class EditServerRequest internal sealed class EditServerRequest
{ {
[JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)] [JsonProperty("name")]
public string Name; public string Name;
[JsonProperty("region", NullValueHandling = NullValueHandling.Ignore)] [JsonProperty("region")]
public string Region; public string Region;
[JsonProperty("icon", NullValueHandling = NullValueHandling.Ignore)] [JsonProperty("icon")]
public string Icon; public string Icon;
[JsonProperty("afk_channel_id", NullValueHandling = NullValueHandling.Ignore)] [JsonProperty("afk_channel_id")]
[JsonConverter(typeof(NullableLongStringConverter))] [JsonConverter(typeof(NullableLongStringConverter))]
public ulong? AFKChannelId; public ulong? AFKChannelId;
[JsonProperty("afk_timeout", NullValueHandling = NullValueHandling.Ignore)] [JsonProperty("afk_timeout")]
public int AFKTimeout; public int AFKTimeout;
} }
public sealed class EditServerResponse : GuildInfo { } public sealed class EditServerResponse : GuildInfo { }

View File

@@ -244,17 +244,24 @@ namespace Discord
{ {
return _rest.Delete<DeleteServerResponse>(Endpoints.Server(serverId)); return _rest.Delete<DeleteServerResponse>(Endpoints.Server(serverId));
} }
public Task<EditServerResponse> EditServer(ulong serverId, string name = null, string region = null, public Task<EditServerResponse> EditServer(ulong serverId, string name, string region,
Stream icon = null, ImageType iconType = ImageType.Png, string existingIcon = null) Stream icon, ImageType iconType, string existingIcon,
ulong? afkChannelId, int afkTimeout)
{ {
var request = new EditServerRequest { Name = name, Region = region, Icon = Base64Picture(icon, iconType, existingIcon) }; var request = new EditServerRequest {
Name = name,
Region = region,
Icon = Base64Picture(icon, iconType, existingIcon),
AFKChannelId = afkChannelId,
AFKTimeout = afkTimeout
};
return _rest.Patch<EditServerResponse>(Endpoints.Server(serverId), request); return _rest.Patch<EditServerResponse>(Endpoints.Server(serverId), request);
} }
//User //User
public Task<EditUserResponse> EditProfile(string currentPassword = "", public Task<EditUserResponse> EditProfile(string currentPassword,
string username = null, string email = null, string password = null, string username, string email, string password,
Stream avatar = null, ImageType avatarType = ImageType.Png, string existingAvatar = null) Stream avatar, ImageType avatarType, string existingAvatar)
{ {
if (currentPassword == null) throw new ArgumentNullException(nameof(currentPassword)); if (currentPassword == null) throw new ArgumentNullException(nameof(currentPassword));

View File

@@ -99,7 +99,14 @@ namespace Discord
if (server == null) throw new ArgumentNullException(nameof(server)); if (server == null) throw new ArgumentNullException(nameof(server));
CheckReady(); CheckReady();
var response = await _api.EditServer(server.Id, name: name ?? server.Name, region: region, icon: icon, iconType: iconType).ConfigureAwait(false); var response = await _api.EditServer(
server.Id, name: name ?? server.Name,
region: region ?? server.Region,
icon: icon,
iconType: iconType,
existingIcon: server.IconId,
afkChannelId: server.AFKChannel?.Id,
afkTimeout: server.AFKTimeout).ConfigureAwait(false);
server.Update(response); server.Update(response);
} }