Browse Source

Fixed EditServer error 500s

tags/docs-0.9
RogueException 9 years ago
parent
commit
3e72954c4c
3 changed files with 27 additions and 13 deletions
  1. +5
    -5
      src/Discord.Net/API/Messages/Servers.cs
  2. +14
    -7
      src/Discord.Net/DiscordAPIClient.cs
  3. +8
    -1
      src/Discord.Net/DiscordClient.Servers.cs

+ 5
- 5
src/Discord.Net/API/Messages/Servers.cs View File

@@ -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 { }


+ 14
- 7
src/Discord.Net/DiscordAPIClient.cs View File

@@ -244,17 +244,24 @@ namespace Discord
{
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);
}

//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));


+ 8
- 1
src/Discord.Net/DiscordClient.Servers.cs View File

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


Loading…
Cancel
Save