diff --git a/src/Discord.Net.Core/API/DiscordRestApiClient.cs b/src/Discord.Net.Core/API/DiscordRestApiClient.cs index bc7436cd4..167be4397 100644 --- a/src/Discord.Net.Core/API/DiscordRestApiClient.cs +++ b/src/Discord.Net.Core/API/DiscordRestApiClient.cs @@ -331,7 +331,7 @@ namespace Discord.API var ids = new BucketIds(channelId: channelId); return await SendAsync("DELETE", () => $"channels/{channelId}", ids, options: options).ConfigureAwait(false); } - public async Task ModifyGuildChannelAsync(ulong channelId, ModifyGuildChannelParams args, RequestOptions options = null) + public async Task ModifyGuildChannelAsync(ulong channelId, Rest.ModifyGuildChannelParams args, RequestOptions options = null) { Preconditions.NotEqual(channelId, 0, nameof(channelId)); Preconditions.NotNull(args, nameof(args)); @@ -342,7 +342,7 @@ namespace Discord.API var ids = new BucketIds(channelId: channelId); return await SendJsonAsync("PATCH", () => $"channels/{channelId}", args, ids, options: options).ConfigureAwait(false); } - public async Task ModifyGuildChannelAsync(ulong channelId, ModifyTextChannelParams args, RequestOptions options = null) + public async Task ModifyGuildChannelAsync(ulong channelId, Rest.ModifyTextChannelParams args, RequestOptions options = null) { Preconditions.NotEqual(channelId, 0, nameof(channelId)); Preconditions.NotNull(args, nameof(args)); @@ -353,7 +353,7 @@ namespace Discord.API var ids = new BucketIds(channelId: channelId); return await SendJsonAsync("PATCH", () => $"channels/{channelId}", args, ids, options: options).ConfigureAwait(false); } - public async Task ModifyGuildChannelAsync(ulong channelId, ModifyVoiceChannelParams args, RequestOptions options = null) + public async Task ModifyGuildChannelAsync(ulong channelId, Rest.ModifyVoiceChannelParams args, RequestOptions options = null) { Preconditions.NotEqual(channelId, 0, nameof(channelId)); Preconditions.NotNull(args, nameof(args)); @@ -366,7 +366,7 @@ namespace Discord.API var ids = new BucketIds(channelId: channelId); return await SendJsonAsync("PATCH", () => $"channels/{channelId}", args, ids, options: options).ConfigureAwait(false); } - public async Task ModifyGuildChannelsAsync(ulong guildId, IEnumerable args, RequestOptions options = null) + public async Task ModifyGuildChannelsAsync(ulong guildId, IEnumerable args, RequestOptions options = null) { Preconditions.NotEqual(guildId, 0, nameof(guildId)); Preconditions.NotNull(args, nameof(args)); @@ -378,7 +378,7 @@ namespace Discord.API case 0: return; case 1: - await ModifyGuildChannelAsync(channels[0].Id, new ModifyGuildChannelParams { Position = channels[0].Position }).ConfigureAwait(false); + await ModifyGuildChannelAsync(channels[0].Id, new Rest.ModifyGuildChannelParams { Position = channels[0].Position }).ConfigureAwait(false); break; default: var ids = new BucketIds(guildId: guildId); @@ -695,7 +695,7 @@ namespace Discord.API var ids = new BucketIds(guildId: guildId); return await SendAsync("DELETE", () => $"users/@me/guilds/{guildId}", ids, options: options).ConfigureAwait(false); } - public async Task ModifyGuildAsync(ulong guildId, ModifyGuildParams args, RequestOptions options = null) + public async Task ModifyGuildAsync(ulong guildId, Rest.ModifyGuildParams args, RequestOptions options = null) { Preconditions.NotEqual(guildId, 0, nameof(guildId)); Preconditions.NotNull(args, nameof(args)); @@ -773,7 +773,7 @@ namespace Discord.API } catch (HttpException ex) when (ex.StatusCode == HttpStatusCode.NotFound) { return null; } } - public async Task ModifyGuildEmbedAsync(ulong guildId, ModifyGuildEmbedParams args, RequestOptions options = null) + public async Task ModifyGuildEmbedAsync(ulong guildId, Rest.ModifyGuildEmbedParams args, RequestOptions options = null) { Preconditions.NotNull(args, nameof(args)); Preconditions.NotEqual(guildId, 0, nameof(guildId)); @@ -811,7 +811,7 @@ namespace Discord.API var ids = new BucketIds(guildId: guildId); return await SendAsync("DELETE", () => $"guilds/{guildId}/integrations/{integrationId}", ids, options: options).ConfigureAwait(false); } - public async Task ModifyGuildIntegrationAsync(ulong guildId, ulong integrationId, ModifyGuildIntegrationParams args, RequestOptions options = null) + public async Task ModifyGuildIntegrationAsync(ulong guildId, ulong integrationId, Rest.ModifyGuildIntegrationParams args, RequestOptions options = null) { Preconditions.NotEqual(guildId, 0, nameof(guildId)); Preconditions.NotEqual(integrationId, 0, nameof(integrationId)); @@ -934,7 +934,7 @@ namespace Discord.API var ids = new BucketIds(guildId: guildId); await SendAsync("DELETE", () => $"guilds/{guildId}/members/{userId}", ids, options: options).ConfigureAwait(false); } - public async Task ModifyGuildMemberAsync(ulong guildId, ulong userId, ModifyGuildMemberParams args, RequestOptions options = null) + public async Task ModifyGuildMemberAsync(ulong guildId, ulong userId, Rest.ModifyGuildMemberParams args, RequestOptions options = null) { Preconditions.NotEqual(guildId, 0, nameof(guildId)); Preconditions.NotEqual(userId, 0, nameof(userId)); @@ -945,7 +945,7 @@ namespace Discord.API if (isCurrentUser && args.Nickname.IsSpecified) { - var nickArgs = new ModifyCurrentUserNickParams(args.Nickname.Value ?? ""); + var nickArgs = new Rest.ModifyCurrentUserNickParams(args.Nickname.Value ?? ""); await ModifyMyNickAsync(guildId, nickArgs).ConfigureAwait(false); args.Nickname = Optional.Create(); //Remove } @@ -982,7 +982,7 @@ namespace Discord.API var ids = new BucketIds(guildId: guildId); await SendAsync("DELETE", () => $"guilds/{guildId}/roles/{roleId}", ids, options: options).ConfigureAwait(false); } - public async Task ModifyGuildRoleAsync(ulong guildId, ulong roleId, ModifyGuildRoleParams args, RequestOptions options = null) + public async Task ModifyGuildRoleAsync(ulong guildId, ulong roleId, Rest.ModifyGuildRoleParams args, RequestOptions options = null) { Preconditions.NotEqual(guildId, 0, nameof(guildId)); Preconditions.NotEqual(roleId, 0, nameof(roleId)); @@ -995,7 +995,7 @@ namespace Discord.API var ids = new BucketIds(guildId: guildId); return await SendJsonAsync("PATCH", () => $"guilds/{guildId}/roles/{roleId}", args, ids, options: options).ConfigureAwait(false); } - public async Task> ModifyGuildRolesAsync(ulong guildId, IEnumerable args, RequestOptions options = null) + public async Task> ModifyGuildRolesAsync(ulong guildId, IEnumerable args, RequestOptions options = null) { Preconditions.NotEqual(guildId, 0, nameof(guildId)); Preconditions.NotNull(args, nameof(args)); @@ -1053,7 +1053,7 @@ namespace Discord.API options = RequestOptions.CreateOrClone(options); return await SendAsync("GET", () => "oauth2/applications/@me", new BucketIds(), options: options).ConfigureAwait(false); } - public async Task ModifySelfAsync(ModifyCurrentUserParams args, RequestOptions options = null) + public async Task ModifySelfAsync(Rest.ModifyCurrentUserParams args, RequestOptions options = null) { Preconditions.NotNull(args, nameof(args)); Preconditions.NotNullOrEmpty(args.Username, nameof(args.Username)); @@ -1061,7 +1061,7 @@ namespace Discord.API return await SendJsonAsync("PATCH", () => "users/@me", args, new BucketIds(), options: options).ConfigureAwait(false); } - public async Task ModifyMyNickAsync(ulong guildId, ModifyCurrentUserNickParams args, RequestOptions options = null) + public async Task ModifyMyNickAsync(ulong guildId, Rest.ModifyCurrentUserNickParams args, RequestOptions options = null) { Preconditions.NotNull(args, nameof(args)); Preconditions.NotNull(args.Nickname, nameof(args.Nickname)); diff --git a/src/Discord.Net.Core/API/Image.cs b/src/Discord.Net.Core/API/Image.cs index 5442bd30f..44c58f344 100644 --- a/src/Discord.Net.Core/API/Image.cs +++ b/src/Discord.Net.Core/API/Image.cs @@ -17,5 +17,10 @@ namespace Discord.API Stream = null; Hash = hash; } + + public static Image Create(Discord.Image image) + { + return new Image(image.Stream); + } } } diff --git a/src/Discord.Net.Core/Entities/Channels/ModifyGuildChannelParams.cs b/src/Discord.Net.Core/Entities/Channels/ModifyGuildChannelParams.cs new file mode 100644 index 000000000..2f1cce4b1 --- /dev/null +++ b/src/Discord.Net.Core/Entities/Channels/ModifyGuildChannelParams.cs @@ -0,0 +1,8 @@ +namespace Discord +{ + public class ModifyGuildChannelParams + { + public Optional Name { get; set; } + public Optional Position { get; set; } + } +} diff --git a/src/Discord.Net.Core/Entities/Channels/ModifyGuildChannelsParams.cs b/src/Discord.Net.Core/Entities/Channels/ModifyGuildChannelsParams.cs new file mode 100644 index 000000000..e46e172b9 --- /dev/null +++ b/src/Discord.Net.Core/Entities/Channels/ModifyGuildChannelsParams.cs @@ -0,0 +1,14 @@ +namespace Discord +{ + public class ModifyGuildChannelsParams + { + public ulong Id { get; set; } + public int Position { get; set; } + + public ModifyGuildChannelsParams(ulong id, int position) + { + Id = id; + Position = position; + } + } +} diff --git a/src/Discord.Net.Core/Entities/Channels/ModifyTextChannelParams.cs b/src/Discord.Net.Core/Entities/Channels/ModifyTextChannelParams.cs new file mode 100644 index 000000000..fc5c2aad4 --- /dev/null +++ b/src/Discord.Net.Core/Entities/Channels/ModifyTextChannelParams.cs @@ -0,0 +1,7 @@ +namespace Discord +{ + public class ModifyTextChannelParams : ModifyGuildChannelParams + { + public Optional Topic { get; set; } + } +} diff --git a/src/Discord.Net.Core/Entities/Channels/ModifyVoiceChannelParams.cs b/src/Discord.Net.Core/Entities/Channels/ModifyVoiceChannelParams.cs new file mode 100644 index 000000000..36941e03b --- /dev/null +++ b/src/Discord.Net.Core/Entities/Channels/ModifyVoiceChannelParams.cs @@ -0,0 +1,8 @@ +namespace Discord +{ + public class ModifyVoiceChannelParams : ModifyGuildChannelParams + { + public Optional Bitrate { get; set; } + public Optional UserLimit { get; set; } + } +} diff --git a/src/Discord.Net.Core/Entities/Guilds/ModifyGuildEmbedParams.cs b/src/Discord.Net.Core/Entities/Guilds/ModifyGuildEmbedParams.cs new file mode 100644 index 000000000..83a32a79c --- /dev/null +++ b/src/Discord.Net.Core/Entities/Guilds/ModifyGuildEmbedParams.cs @@ -0,0 +1,8 @@ +namespace Discord +{ + public class ModifyGuildEmbedParams + { + public Optional Enabled { get; set; } + public Optional ChannelId { get; set; } + } +} diff --git a/src/Discord.Net.Core/Entities/Guilds/ModifyGuildIntegrationParams.cs b/src/Discord.Net.Core/Entities/Guilds/ModifyGuildIntegrationParams.cs new file mode 100644 index 000000000..b9375d907 --- /dev/null +++ b/src/Discord.Net.Core/Entities/Guilds/ModifyGuildIntegrationParams.cs @@ -0,0 +1,9 @@ +namespace Discord +{ + public class ModifyGuildIntegrationParams + { + public Optional ExpireBehavior { get; set; } + public Optional ExpireGracePeriod { get; set; } + public Optional EnableEmoticons { get; set; } + } +} diff --git a/src/Discord.Net.Core/Entities/Guilds/ModifyGuildParams.cs b/src/Discord.Net.Core/Entities/Guilds/ModifyGuildParams.cs new file mode 100644 index 000000000..19f2476f2 --- /dev/null +++ b/src/Discord.Net.Core/Entities/Guilds/ModifyGuildParams.cs @@ -0,0 +1,16 @@ +namespace Discord +{ + public class ModifyGuildParams + { + public Optional Username { get; set; } + public Optional Name { get; set; } + public Optional RegionId { get; set; } + public Optional VerificationLevel { get; set; } + public Optional DefaultMessageNotifications { get; set; } + public Optional AfkTimeout { get; set; } + public Optional Icon { get; set; } + public Optional Splash { get; set; } + public Optional AfkChannelId { get; set; } + public Optional OwnerId { get; set; } + } +} diff --git a/src/Discord.Net.Core/Entities/Image.cs b/src/Discord.Net.Core/Entities/Image.cs new file mode 100644 index 000000000..bb305f113 --- /dev/null +++ b/src/Discord.Net.Core/Entities/Image.cs @@ -0,0 +1,17 @@ +using System.IO; + +namespace Discord +{ + public struct Image + { + public Stream Stream { get; } + public Image(Stream stream) + { + Stream = stream; + } + public Image(string path) + { + Stream = File.OpenRead(path); + } + } +} diff --git a/src/Discord.Net.Core/Entities/Messages/EmbedBuilder.cs b/src/Discord.Net.Core/Entities/Messages/EmbedBuilder.cs index 40ef93e10..a6c9cfb8c 100644 --- a/src/Discord.Net.Core/Entities/Messages/EmbedBuilder.cs +++ b/src/Discord.Net.Core/Entities/Messages/EmbedBuilder.cs @@ -5,7 +5,7 @@ using Field = Discord.API.EmbedField; using Author = Discord.API.EmbedAuthor; using Footer = Discord.API.EmbedFooter; using Thumbnail = Discord.API.EmbedThumbnail; -using Image = Discord.API.EmbedImage; +using ImageEmbed = Discord.API.EmbedImage; namespace Discord { diff --git a/src/Discord.Net.Core/Entities/Roles/ModifyGuildRoleParams.cs b/src/Discord.Net.Core/Entities/Roles/ModifyGuildRoleParams.cs new file mode 100644 index 000000000..486d56513 --- /dev/null +++ b/src/Discord.Net.Core/Entities/Roles/ModifyGuildRoleParams.cs @@ -0,0 +1,11 @@ +namespace Discord +{ + public class ModifyGuildRoleParams + { + public Optional Name { get; set; } + public Optional Permissions { get; set; } + public Optional Position { get; set; } + public Optional Color { get; set; } + public Optional Hoist { get; set; } + } +} diff --git a/src/Discord.Net.Core/Entities/Roles/ModifyGuildRolesParams.cs b/src/Discord.Net.Core/Entities/Roles/ModifyGuildRolesParams.cs new file mode 100644 index 000000000..4d6a0f63b --- /dev/null +++ b/src/Discord.Net.Core/Entities/Roles/ModifyGuildRolesParams.cs @@ -0,0 +1,12 @@ +namespace Discord +{ + public class ModifyGuildRolesParams : ModifyGuildRoleParams + { + public ulong Id { get; } + + public ModifyGuildRolesParams(ulong id) + { + Id = id; + } + } +} diff --git a/src/Discord.Net.Core/Entities/Users/ModifyCurrentUserNickParams.cs b/src/Discord.Net.Core/Entities/Users/ModifyCurrentUserNickParams.cs new file mode 100644 index 000000000..c8d2b5199 --- /dev/null +++ b/src/Discord.Net.Core/Entities/Users/ModifyCurrentUserNickParams.cs @@ -0,0 +1,12 @@ +namespace Discord +{ + public class ModifyCurrentUserNickParams + { + public string Nickname { get; } + + public ModifyCurrentUserNickParams(string nickname) + { + Nickname = nickname; + } + } +} diff --git a/src/Discord.Net.Core/Entities/Users/ModifyCurrentUserParams.cs b/src/Discord.Net.Core/Entities/Users/ModifyCurrentUserParams.cs new file mode 100644 index 000000000..cdd031c34 --- /dev/null +++ b/src/Discord.Net.Core/Entities/Users/ModifyCurrentUserParams.cs @@ -0,0 +1,8 @@ +namespace Discord +{ + public class ModifyCurrentUserParams + { + public Optional Username { get; set; } + public Optional Avatar { get; set; } + } +} diff --git a/src/Discord.Net.Core/Entities/Users/ModifyGuildMemberParams.cs b/src/Discord.Net.Core/Entities/Users/ModifyGuildMemberParams.cs new file mode 100644 index 000000000..8e74d80e0 --- /dev/null +++ b/src/Discord.Net.Core/Entities/Users/ModifyGuildMemberParams.cs @@ -0,0 +1,11 @@ +namespace Discord +{ + public class ModifyGuildMemberParams + { + public Optional Mute { get; set; } + public Optional Deaf { get; set; } + public Optional Nickname { get; set; } + public Optional RoleIds { get; set; } + public Optional ChannelId { get; set; } + } +} diff --git a/src/Discord.Net.Core/Net/Converters/ImageConverter.cs b/src/Discord.Net.Core/Net/Converters/ImageConverter.cs index 79e8c984d..e82b7952b 100644 --- a/src/Discord.Net.Core/Net/Converters/ImageConverter.cs +++ b/src/Discord.Net.Core/Net/Converters/ImageConverter.cs @@ -1,6 +1,7 @@ using Discord.API; using Newtonsoft.Json; using System; +using Model = Discord.API.Image; namespace Discord.Net.Converters { @@ -19,7 +20,7 @@ namespace Discord.Net.Converters public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { - var image = (Image)value; + var image = (Model)value; if (image.Stream != null) { diff --git a/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs b/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs index 99edc6f48..9db89bb34 100644 --- a/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs +++ b/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs @@ -24,7 +24,12 @@ namespace Discord.Rest { var args = new ModifyGuildChannelParams(); func(args); - return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, args, options).ConfigureAwait(false); + var apiArgs = new API.Rest.ModifyGuildChannelParams + { + Name = args.Name, + Position = args.Position + }; + return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false); } public static async Task ModifyAsync(ITextChannel channel, BaseDiscordClient client, Action func, @@ -32,7 +37,13 @@ namespace Discord.Rest { var args = new ModifyTextChannelParams(); func(args); - return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, args, options).ConfigureAwait(false); + var apiArgs = new API.Rest.ModifyTextChannelParams + { + Name = args.Name, + Position = args.Position, + Topic = args.Topic + }; + return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false); } public static async Task ModifyAsync(IVoiceChannel channel, BaseDiscordClient client, Action func, @@ -40,7 +51,14 @@ namespace Discord.Rest { var args = new ModifyVoiceChannelParams(); func(args); - return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, args, options).ConfigureAwait(false); + var apiArgs = new API.Rest.ModifyVoiceChannelParams + { + Bitrate = args.Bitrate, + Name = args.Name, + Position = args.Position, + UserLimit = args.UserLimit + }; + return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false); } //Invites diff --git a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs index 7aaa19304..fb3e8e2cf 100644 --- a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs +++ b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using EmbedModel = Discord.API.GuildEmbed; using Model = Discord.API.Guild; using RoleModel = Discord.API.Role; +using ImageModel = Discord.API.Image; namespace Discord.Rest { @@ -21,12 +22,24 @@ namespace Discord.Rest var args = new ModifyGuildParams(); func(args); - if (args.Splash.IsSpecified && guild.SplashId != null) - args.Splash = new API.Image(guild.SplashId); - if (args.Icon.IsSpecified && guild.IconId != null) - args.Icon = new API.Image(guild.IconId); - - return await client.ApiClient.ModifyGuildAsync(guild.Id, args, options).ConfigureAwait(false); + var apiArgs = new API.Rest.ModifyGuildParams + { + AfkChannelId = args.AfkChannelId, + AfkTimeout = args.AfkTimeout, + DefaultMessageNotifications = args.DefaultMessageNotifications, + Name = args.Name, + OwnerId = args.OwnerId, + RegionId = args.RegionId, + Username = args.Username, + VerificationLevel = args.VerificationLevel + }; + + if (apiArgs.Splash.IsSpecified && guild.SplashId != null) + apiArgs.Splash = new ImageModel(guild.SplashId); + if (apiArgs.Icon.IsSpecified && guild.IconId != null) + apiArgs.Icon = new ImageModel(guild.IconId); + + return await client.ApiClient.ModifyGuildAsync(guild.Id, apiArgs, options).ConfigureAwait(false); } public static async Task ModifyEmbedAsync(IGuild guild, BaseDiscordClient client, Action func, RequestOptions options) @@ -35,17 +48,24 @@ namespace Discord.Rest var args = new ModifyGuildEmbedParams(); func(args); - return await client.ApiClient.ModifyGuildEmbedAsync(guild.Id, args, options).ConfigureAwait(false); + var apiArgs = new API.Rest.ModifyGuildEmbedParams + { + ChannelId = args.ChannelId, + Enabled = args.Enabled + }; + return await client.ApiClient.ModifyGuildEmbedAsync(guild.Id, apiArgs, options).ConfigureAwait(false); } public static async Task ModifyChannelsAsync(IGuild guild, BaseDiscordClient client, IEnumerable args, RequestOptions options) { - await client.ApiClient.ModifyGuildChannelsAsync(guild.Id, args, options).ConfigureAwait(false); + var apiArgs = args.Select(x => new API.Rest.ModifyGuildChannelsParams(x.Id, x.Position)); + await client.ApiClient.ModifyGuildChannelsAsync(guild.Id, apiArgs, options).ConfigureAwait(false); } public static async Task> ModifyRolesAsync(IGuild guild, BaseDiscordClient client, IEnumerable args, RequestOptions options) { - return await client.ApiClient.ModifyGuildRolesAsync(guild.Id, args, options).ConfigureAwait(false); + var apiArgs = args.Select(x => new API.Rest.ModifyGuildRolesParams(x.Id) { Color = x.Color, Hoist = x.Hoist, Name = x.Name, Permissions = x.Permissions, Position = x.Position }); + return await client.ApiClient.ModifyGuildRolesAsync(guild.Id, apiArgs, options).ConfigureAwait(false); } public static async Task LeaveAsync(IGuild guild, BaseDiscordClient client, RequestOptions options) diff --git a/src/Discord.Net.Rest/Entities/Guilds/RestGuildIntegration.cs b/src/Discord.Net.Rest/Entities/Guilds/RestGuildIntegration.cs index fc2bfd8b2..5405becc4 100644 --- a/src/Discord.Net.Rest/Entities/Guilds/RestGuildIntegration.cs +++ b/src/Discord.Net.Rest/Entities/Guilds/RestGuildIntegration.cs @@ -61,7 +61,13 @@ namespace Discord.Rest var args = new ModifyGuildIntegrationParams(); func(args); - var model = await Discord.ApiClient.ModifyGuildIntegrationAsync(GuildId, Id, args).ConfigureAwait(false); + var apiArgs = new API.Rest.ModifyGuildIntegrationParams + { + EnableEmoticons = args.EnableEmoticons, + ExpireBehavior = args.ExpireBehavior, + ExpireGracePeriod = args.ExpireGracePeriod + }; + var model = await Discord.ApiClient.ModifyGuildIntegrationAsync(GuildId, Id, apiArgs).ConfigureAwait(false); Update(model); } diff --git a/src/Discord.Net.Rest/Entities/Roles/RoleHelper.cs b/src/Discord.Net.Rest/Entities/Roles/RoleHelper.cs index 0b102098c..bea2547e9 100644 --- a/src/Discord.Net.Rest/Entities/Roles/RoleHelper.cs +++ b/src/Discord.Net.Rest/Entities/Roles/RoleHelper.cs @@ -18,7 +18,15 @@ namespace Discord.Rest { var args = new ModifyGuildRoleParams(); func(args); - return await client.ApiClient.ModifyGuildRoleAsync(role.Guild.Id, role.Id, args, options).ConfigureAwait(false); + var apiArgs = new API.Rest.ModifyGuildRoleParams + { + Color = args.Color, + Hoist = args.Hoist, + Name = args.Name, + Permissions = args.Permissions, + Position = args.Position + }; + return await client.ApiClient.ModifyGuildRoleAsync(role.Guild.Id, role.Id, apiArgs, options).ConfigureAwait(false); } } } diff --git a/src/Discord.Net.Rest/Entities/Users/UserHelper.cs b/src/Discord.Net.Rest/Entities/Users/UserHelper.cs index 545703f0d..4499e1ec1 100644 --- a/src/Discord.Net.Rest/Entities/Users/UserHelper.cs +++ b/src/Discord.Net.Rest/Entities/Users/UserHelper.cs @@ -2,6 +2,7 @@ using System; using System.Threading.Tasks; using Model = Discord.API.User; +using ImageModel = Discord.API.Image; namespace Discord.Rest { @@ -12,14 +13,27 @@ namespace Discord.Rest { var args = new ModifyCurrentUserParams(); func(args); - return await client.ApiClient.ModifySelfAsync(args, options).ConfigureAwait(false); + var apiArgs = new API.Rest.ModifyCurrentUserParams + { + Avatar = args.Avatar.IsSpecified ? ImageModel.Create(args.Avatar.Value) : Optional.Create(), + Username = args.Username + }; + return await client.ApiClient.ModifySelfAsync(apiArgs, options).ConfigureAwait(false); } public static async Task ModifyAsync(IGuildUser user, BaseDiscordClient client, Action func, RequestOptions options) { var args = new ModifyGuildMemberParams(); func(args); - await client.ApiClient.ModifyGuildMemberAsync(user.GuildId, user.Id, args, options).ConfigureAwait(false); + var apiArgs = new API.Rest.ModifyGuildMemberParams + { + ChannelId = args.ChannelId, + Deaf = args.Deaf, + Mute = args.Mute, + Nickname = args.Nickname, + RoleIds = args.RoleIds + }; + await client.ApiClient.ModifyGuildMemberAsync(user.GuildId, user.Id, apiArgs, options).ConfigureAwait(false); return args; }