Browse Source

Dont send nickname in User.Edit unless one is specified

pull/101/head
RogueException 9 years ago
parent
commit
d1ae0db741
2 changed files with 6 additions and 3 deletions
  1. +1
    -1
      src/Discord.Net/API/Client/Rest/UpdateMember.cs
  2. +5
    -2
      src/Discord.Net/Models/User.cs

+ 1
- 1
src/Discord.Net/API/Client/Rest/UpdateMember.cs View File

@@ -22,7 +22,7 @@ namespace Discord.API.Client.Rest
public ulong? VoiceChannelId { get; set; }
[JsonProperty("roles"), JsonConverter(typeof(LongStringArrayConverter))]
public ulong[] RoleIds { get; set; }
[JsonProperty("nick", DefaultValueHandling = DefaultValueHandling.Ignore), DefaultValue("")]
[JsonProperty("nick", NullValueHandling = NullValueHandling.Ignore)]
public string Nickname { get; set; }

public UpdateMemberRequest(ulong guildId, ulong userId)


+ 5
- 2
src/Discord.Net/Models/User.cs View File

@@ -272,14 +272,17 @@ namespace Discord
}
if (!isCurrentUser || isMuted != null || isDeafened != null | voiceChannel != null || roles != null)
{
if (nickname == "") nickname = Nickname;
//Swap "" and null. Our libs meanings and the API's are flipped.
if (nickname == null) nickname = "";
else if (nickname == "") nickname = null;

var request = new UpdateMemberRequest(Server.Id, Id)
{
IsMuted = isMuted ?? IsServerMuted,
IsDeafened = isDeafened ?? IsServerDeafened,
VoiceChannelId = voiceChannel?.Id,
RoleIds = roleIds,
Nickname = nickname ?? ""
Nickname = nickname
};
await Client.ClientAPI.Send(request).ConfigureAwait(false);
}


Loading…
Cancel
Save