| @@ -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 { } | ||||
| @@ -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, | |||||
| 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<EditServerResponse> 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<EditServerResponse>(Endpoints.Server(serverId), request); | return _rest.Patch<EditServerResponse>(Endpoints.Server(serverId), request); | ||||
| } | } | ||||
| //User | //User | ||||
| public Task<EditUserResponse> EditProfile(string currentPassword = "", | |||||
| string username = null, string email = null, string password = null, | |||||
| Stream avatar = null, ImageType avatarType = ImageType.Png, string existingAvatar = null) | |||||
| public Task<EditUserResponse> EditProfile(string currentPassword, | |||||
| string username, string email, string password, | |||||
| Stream avatar, ImageType avatarType, string existingAvatar) | |||||
| { | { | ||||
| if (currentPassword == null) throw new ArgumentNullException(nameof(currentPassword)); | if (currentPassword == null) throw new ArgumentNullException(nameof(currentPassword)); | ||||
| @@ -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); | ||||
| } | } | ||||