From 3e72954c4c75cc874518fb913683bd532d10f6b4 Mon Sep 17 00:00:00 2001 From: RogueException Date: Sun, 13 Dec 2015 23:16:19 -0400 Subject: [PATCH] Fixed EditServer error 500s --- src/Discord.Net/API/Messages/Servers.cs | 10 +++++----- src/Discord.Net/DiscordAPIClient.cs | 21 ++++++++++++++------- src/Discord.Net/DiscordClient.Servers.cs | 9 ++++++++- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/Discord.Net/API/Messages/Servers.cs b/src/Discord.Net/API/Messages/Servers.cs index 518e34886..a8ef377b6 100644 --- a/src/Discord.Net/API/Messages/Servers.cs +++ b/src/Discord.Net/API/Messages/Servers.cs @@ -69,16 +69,16 @@ namespace Discord.API //Edit internal sealed class EditServerRequest { - [JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)] + [JsonProperty("name")] public string Name; - [JsonProperty("region", NullValueHandling = NullValueHandling.Ignore)] + [JsonProperty("region")] public string Region; - [JsonProperty("icon", NullValueHandling = NullValueHandling.Ignore)] + [JsonProperty("icon")] public string Icon; - [JsonProperty("afk_channel_id", NullValueHandling = NullValueHandling.Ignore)] + [JsonProperty("afk_channel_id")] [JsonConverter(typeof(NullableLongStringConverter))] public ulong? AFKChannelId; - [JsonProperty("afk_timeout", NullValueHandling = NullValueHandling.Ignore)] + [JsonProperty("afk_timeout")] public int AFKTimeout; } public sealed class EditServerResponse : GuildInfo { } diff --git a/src/Discord.Net/DiscordAPIClient.cs b/src/Discord.Net/DiscordAPIClient.cs index 681c23f56..42c7e3a3d 100644 --- a/src/Discord.Net/DiscordAPIClient.cs +++ b/src/Discord.Net/DiscordAPIClient.cs @@ -244,17 +244,24 @@ namespace Discord { return _rest.Delete(Endpoints.Server(serverId)); } - public Task EditServer(ulong serverId, string name = null, string region = null, - Stream icon = null, ImageType iconType = ImageType.Png, string existingIcon = null) - { - var request = new EditServerRequest { Name = name, Region = region, Icon = Base64Picture(icon, iconType, existingIcon) }; + public Task EditServer(ulong serverId, string name, string region, + Stream icon, ImageType iconType, string existingIcon, + ulong? afkChannelId, int afkTimeout) + { + var request = new EditServerRequest { + Name = name, + Region = region, + Icon = Base64Picture(icon, iconType, existingIcon), + AFKChannelId = afkChannelId, + AFKTimeout = afkTimeout + }; return _rest.Patch(Endpoints.Server(serverId), request); } //User - public Task EditProfile(string currentPassword = "", - string username = null, string email = null, string password = null, - Stream avatar = null, ImageType avatarType = ImageType.Png, string existingAvatar = null) + public Task EditProfile(string currentPassword, + string username, string email, string password, + Stream avatar, ImageType avatarType, string existingAvatar) { if (currentPassword == null) throw new ArgumentNullException(nameof(currentPassword)); diff --git a/src/Discord.Net/DiscordClient.Servers.cs b/src/Discord.Net/DiscordClient.Servers.cs index 34e976e39..77b7f735e 100644 --- a/src/Discord.Net/DiscordClient.Servers.cs +++ b/src/Discord.Net/DiscordClient.Servers.cs @@ -99,7 +99,14 @@ namespace Discord if (server == null) throw new ArgumentNullException(nameof(server)); 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); }