| @@ -331,7 +331,7 @@ namespace Discord.API | |||||
| var ids = new BucketIds(channelId: channelId); | var ids = new BucketIds(channelId: channelId); | ||||
| return await SendAsync<Channel>("DELETE", () => $"channels/{channelId}", ids, options: options).ConfigureAwait(false); | return await SendAsync<Channel>("DELETE", () => $"channels/{channelId}", ids, options: options).ConfigureAwait(false); | ||||
| } | } | ||||
| public async Task<Channel> ModifyGuildChannelAsync(ulong channelId, ModifyGuildChannelParams args, RequestOptions options = null) | |||||
| public async Task<Channel> ModifyGuildChannelAsync(ulong channelId, Rest.ModifyGuildChannelParams args, RequestOptions options = null) | |||||
| { | { | ||||
| Preconditions.NotEqual(channelId, 0, nameof(channelId)); | Preconditions.NotEqual(channelId, 0, nameof(channelId)); | ||||
| Preconditions.NotNull(args, nameof(args)); | Preconditions.NotNull(args, nameof(args)); | ||||
| @@ -342,7 +342,7 @@ namespace Discord.API | |||||
| var ids = new BucketIds(channelId: channelId); | var ids = new BucketIds(channelId: channelId); | ||||
| return await SendJsonAsync<Channel>("PATCH", () => $"channels/{channelId}", args, ids, options: options).ConfigureAwait(false); | return await SendJsonAsync<Channel>("PATCH", () => $"channels/{channelId}", args, ids, options: options).ConfigureAwait(false); | ||||
| } | } | ||||
| public async Task<Channel> ModifyGuildChannelAsync(ulong channelId, ModifyTextChannelParams args, RequestOptions options = null) | |||||
| public async Task<Channel> ModifyGuildChannelAsync(ulong channelId, Rest.ModifyTextChannelParams args, RequestOptions options = null) | |||||
| { | { | ||||
| Preconditions.NotEqual(channelId, 0, nameof(channelId)); | Preconditions.NotEqual(channelId, 0, nameof(channelId)); | ||||
| Preconditions.NotNull(args, nameof(args)); | Preconditions.NotNull(args, nameof(args)); | ||||
| @@ -353,7 +353,7 @@ namespace Discord.API | |||||
| var ids = new BucketIds(channelId: channelId); | var ids = new BucketIds(channelId: channelId); | ||||
| return await SendJsonAsync<Channel>("PATCH", () => $"channels/{channelId}", args, ids, options: options).ConfigureAwait(false); | return await SendJsonAsync<Channel>("PATCH", () => $"channels/{channelId}", args, ids, options: options).ConfigureAwait(false); | ||||
| } | } | ||||
| public async Task<Channel> ModifyGuildChannelAsync(ulong channelId, ModifyVoiceChannelParams args, RequestOptions options = null) | |||||
| public async Task<Channel> ModifyGuildChannelAsync(ulong channelId, Rest.ModifyVoiceChannelParams args, RequestOptions options = null) | |||||
| { | { | ||||
| Preconditions.NotEqual(channelId, 0, nameof(channelId)); | Preconditions.NotEqual(channelId, 0, nameof(channelId)); | ||||
| Preconditions.NotNull(args, nameof(args)); | Preconditions.NotNull(args, nameof(args)); | ||||
| @@ -366,7 +366,7 @@ namespace Discord.API | |||||
| var ids = new BucketIds(channelId: channelId); | var ids = new BucketIds(channelId: channelId); | ||||
| return await SendJsonAsync<Channel>("PATCH", () => $"channels/{channelId}", args, ids, options: options).ConfigureAwait(false); | return await SendJsonAsync<Channel>("PATCH", () => $"channels/{channelId}", args, ids, options: options).ConfigureAwait(false); | ||||
| } | } | ||||
| public async Task ModifyGuildChannelsAsync(ulong guildId, IEnumerable<ModifyGuildChannelsParams> args, RequestOptions options = null) | |||||
| public async Task ModifyGuildChannelsAsync(ulong guildId, IEnumerable<Rest.ModifyGuildChannelsParams> args, RequestOptions options = null) | |||||
| { | { | ||||
| Preconditions.NotEqual(guildId, 0, nameof(guildId)); | Preconditions.NotEqual(guildId, 0, nameof(guildId)); | ||||
| Preconditions.NotNull(args, nameof(args)); | Preconditions.NotNull(args, nameof(args)); | ||||
| @@ -378,7 +378,7 @@ namespace Discord.API | |||||
| case 0: | case 0: | ||||
| return; | return; | ||||
| case 1: | 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; | break; | ||||
| default: | default: | ||||
| var ids = new BucketIds(guildId: guildId); | var ids = new BucketIds(guildId: guildId); | ||||
| @@ -695,7 +695,7 @@ namespace Discord.API | |||||
| var ids = new BucketIds(guildId: guildId); | var ids = new BucketIds(guildId: guildId); | ||||
| return await SendAsync<Guild>("DELETE", () => $"users/@me/guilds/{guildId}", ids, options: options).ConfigureAwait(false); | return await SendAsync<Guild>("DELETE", () => $"users/@me/guilds/{guildId}", ids, options: options).ConfigureAwait(false); | ||||
| } | } | ||||
| public async Task<Guild> ModifyGuildAsync(ulong guildId, ModifyGuildParams args, RequestOptions options = null) | |||||
| public async Task<Guild> ModifyGuildAsync(ulong guildId, Rest.ModifyGuildParams args, RequestOptions options = null) | |||||
| { | { | ||||
| Preconditions.NotEqual(guildId, 0, nameof(guildId)); | Preconditions.NotEqual(guildId, 0, nameof(guildId)); | ||||
| Preconditions.NotNull(args, nameof(args)); | Preconditions.NotNull(args, nameof(args)); | ||||
| @@ -773,7 +773,7 @@ namespace Discord.API | |||||
| } | } | ||||
| catch (HttpException ex) when (ex.StatusCode == HttpStatusCode.NotFound) { return null; } | catch (HttpException ex) when (ex.StatusCode == HttpStatusCode.NotFound) { return null; } | ||||
| } | } | ||||
| public async Task<GuildEmbed> ModifyGuildEmbedAsync(ulong guildId, ModifyGuildEmbedParams args, RequestOptions options = null) | |||||
| public async Task<GuildEmbed> ModifyGuildEmbedAsync(ulong guildId, Rest.ModifyGuildEmbedParams args, RequestOptions options = null) | |||||
| { | { | ||||
| Preconditions.NotNull(args, nameof(args)); | Preconditions.NotNull(args, nameof(args)); | ||||
| Preconditions.NotEqual(guildId, 0, nameof(guildId)); | Preconditions.NotEqual(guildId, 0, nameof(guildId)); | ||||
| @@ -811,7 +811,7 @@ namespace Discord.API | |||||
| var ids = new BucketIds(guildId: guildId); | var ids = new BucketIds(guildId: guildId); | ||||
| return await SendAsync<Integration>("DELETE", () => $"guilds/{guildId}/integrations/{integrationId}", ids, options: options).ConfigureAwait(false); | return await SendAsync<Integration>("DELETE", () => $"guilds/{guildId}/integrations/{integrationId}", ids, options: options).ConfigureAwait(false); | ||||
| } | } | ||||
| public async Task<Integration> ModifyGuildIntegrationAsync(ulong guildId, ulong integrationId, ModifyGuildIntegrationParams args, RequestOptions options = null) | |||||
| public async Task<Integration> ModifyGuildIntegrationAsync(ulong guildId, ulong integrationId, Rest.ModifyGuildIntegrationParams args, RequestOptions options = null) | |||||
| { | { | ||||
| Preconditions.NotEqual(guildId, 0, nameof(guildId)); | Preconditions.NotEqual(guildId, 0, nameof(guildId)); | ||||
| Preconditions.NotEqual(integrationId, 0, nameof(integrationId)); | Preconditions.NotEqual(integrationId, 0, nameof(integrationId)); | ||||
| @@ -934,7 +934,7 @@ namespace Discord.API | |||||
| var ids = new BucketIds(guildId: guildId); | var ids = new BucketIds(guildId: guildId); | ||||
| await SendAsync("DELETE", () => $"guilds/{guildId}/members/{userId}", ids, options: options).ConfigureAwait(false); | 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(guildId, 0, nameof(guildId)); | ||||
| Preconditions.NotEqual(userId, 0, nameof(userId)); | Preconditions.NotEqual(userId, 0, nameof(userId)); | ||||
| @@ -945,7 +945,7 @@ namespace Discord.API | |||||
| if (isCurrentUser && args.Nickname.IsSpecified) | 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); | await ModifyMyNickAsync(guildId, nickArgs).ConfigureAwait(false); | ||||
| args.Nickname = Optional.Create<string>(); //Remove | args.Nickname = Optional.Create<string>(); //Remove | ||||
| } | } | ||||
| @@ -982,7 +982,7 @@ namespace Discord.API | |||||
| var ids = new BucketIds(guildId: guildId); | var ids = new BucketIds(guildId: guildId); | ||||
| await SendAsync("DELETE", () => $"guilds/{guildId}/roles/{roleId}", ids, options: options).ConfigureAwait(false); | await SendAsync("DELETE", () => $"guilds/{guildId}/roles/{roleId}", ids, options: options).ConfigureAwait(false); | ||||
| } | } | ||||
| public async Task<Role> ModifyGuildRoleAsync(ulong guildId, ulong roleId, ModifyGuildRoleParams args, RequestOptions options = null) | |||||
| public async Task<Role> ModifyGuildRoleAsync(ulong guildId, ulong roleId, Rest.ModifyGuildRoleParams args, RequestOptions options = null) | |||||
| { | { | ||||
| Preconditions.NotEqual(guildId, 0, nameof(guildId)); | Preconditions.NotEqual(guildId, 0, nameof(guildId)); | ||||
| Preconditions.NotEqual(roleId, 0, nameof(roleId)); | Preconditions.NotEqual(roleId, 0, nameof(roleId)); | ||||
| @@ -995,7 +995,7 @@ namespace Discord.API | |||||
| var ids = new BucketIds(guildId: guildId); | var ids = new BucketIds(guildId: guildId); | ||||
| return await SendJsonAsync<Role>("PATCH", () => $"guilds/{guildId}/roles/{roleId}", args, ids, options: options).ConfigureAwait(false); | return await SendJsonAsync<Role>("PATCH", () => $"guilds/{guildId}/roles/{roleId}", args, ids, options: options).ConfigureAwait(false); | ||||
| } | } | ||||
| public async Task<IReadOnlyCollection<Role>> ModifyGuildRolesAsync(ulong guildId, IEnumerable<ModifyGuildRolesParams> args, RequestOptions options = null) | |||||
| public async Task<IReadOnlyCollection<Role>> ModifyGuildRolesAsync(ulong guildId, IEnumerable<Rest.ModifyGuildRolesParams> args, RequestOptions options = null) | |||||
| { | { | ||||
| Preconditions.NotEqual(guildId, 0, nameof(guildId)); | Preconditions.NotEqual(guildId, 0, nameof(guildId)); | ||||
| Preconditions.NotNull(args, nameof(args)); | Preconditions.NotNull(args, nameof(args)); | ||||
| @@ -1053,7 +1053,7 @@ namespace Discord.API | |||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| return await SendAsync<Application>("GET", () => "oauth2/applications/@me", new BucketIds(), options: options).ConfigureAwait(false); | return await SendAsync<Application>("GET", () => "oauth2/applications/@me", new BucketIds(), options: options).ConfigureAwait(false); | ||||
| } | } | ||||
| public async Task<User> ModifySelfAsync(ModifyCurrentUserParams args, RequestOptions options = null) | |||||
| public async Task<User> ModifySelfAsync(Rest.ModifyCurrentUserParams args, RequestOptions options = null) | |||||
| { | { | ||||
| Preconditions.NotNull(args, nameof(args)); | Preconditions.NotNull(args, nameof(args)); | ||||
| Preconditions.NotNullOrEmpty(args.Username, nameof(args.Username)); | Preconditions.NotNullOrEmpty(args.Username, nameof(args.Username)); | ||||
| @@ -1061,7 +1061,7 @@ namespace Discord.API | |||||
| return await SendJsonAsync<User>("PATCH", () => "users/@me", args, new BucketIds(), options: options).ConfigureAwait(false); | return await SendJsonAsync<User>("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, nameof(args)); | ||||
| Preconditions.NotNull(args.Nickname, nameof(args.Nickname)); | Preconditions.NotNull(args.Nickname, nameof(args.Nickname)); | ||||
| @@ -17,5 +17,10 @@ namespace Discord.API | |||||
| Stream = null; | Stream = null; | ||||
| Hash = hash; | Hash = hash; | ||||
| } | } | ||||
| public static Image Create(Discord.Image image) | |||||
| { | |||||
| return new Image(image.Stream); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,8 @@ | |||||
| namespace Discord | |||||
| { | |||||
| public class ModifyGuildChannelParams | |||||
| { | |||||
| public Optional<string> Name { get; set; } | |||||
| public Optional<int> Position { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,7 @@ | |||||
| namespace Discord | |||||
| { | |||||
| public class ModifyTextChannelParams : ModifyGuildChannelParams | |||||
| { | |||||
| public Optional<string> Topic { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,8 @@ | |||||
| namespace Discord | |||||
| { | |||||
| public class ModifyVoiceChannelParams : ModifyGuildChannelParams | |||||
| { | |||||
| public Optional<int> Bitrate { get; set; } | |||||
| public Optional<int> UserLimit { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,8 @@ | |||||
| namespace Discord | |||||
| { | |||||
| public class ModifyGuildEmbedParams | |||||
| { | |||||
| public Optional<bool> Enabled { get; set; } | |||||
| public Optional<ulong?> ChannelId { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,9 @@ | |||||
| namespace Discord | |||||
| { | |||||
| public class ModifyGuildIntegrationParams | |||||
| { | |||||
| public Optional<int> ExpireBehavior { get; set; } | |||||
| public Optional<int> ExpireGracePeriod { get; set; } | |||||
| public Optional<bool> EnableEmoticons { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,16 @@ | |||||
| namespace Discord | |||||
| { | |||||
| public class ModifyGuildParams | |||||
| { | |||||
| public Optional<string> Username { get; set; } | |||||
| public Optional<string> Name { get; set; } | |||||
| public Optional<string> RegionId { get; set; } | |||||
| public Optional<VerificationLevel> VerificationLevel { get; set; } | |||||
| public Optional<DefaultMessageNotifications> DefaultMessageNotifications { get; set; } | |||||
| public Optional<int> AfkTimeout { get; set; } | |||||
| public Optional<Image?> Icon { get; set; } | |||||
| public Optional<Image?> Splash { get; set; } | |||||
| public Optional<ulong?> AfkChannelId { get; set; } | |||||
| public Optional<ulong> OwnerId { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -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); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -5,7 +5,7 @@ using Field = Discord.API.EmbedField; | |||||
| using Author = Discord.API.EmbedAuthor; | using Author = Discord.API.EmbedAuthor; | ||||
| using Footer = Discord.API.EmbedFooter; | using Footer = Discord.API.EmbedFooter; | ||||
| using Thumbnail = Discord.API.EmbedThumbnail; | using Thumbnail = Discord.API.EmbedThumbnail; | ||||
| using Image = Discord.API.EmbedImage; | |||||
| using ImageEmbed = Discord.API.EmbedImage; | |||||
| namespace Discord | namespace Discord | ||||
| { | { | ||||
| @@ -0,0 +1,11 @@ | |||||
| namespace Discord | |||||
| { | |||||
| public class ModifyGuildRoleParams | |||||
| { | |||||
| public Optional<string> Name { get; set; } | |||||
| public Optional<ulong> Permissions { get; set; } | |||||
| public Optional<int> Position { get; set; } | |||||
| public Optional<uint> Color { get; set; } | |||||
| public Optional<bool> Hoist { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,12 @@ | |||||
| namespace Discord | |||||
| { | |||||
| public class ModifyGuildRolesParams : ModifyGuildRoleParams | |||||
| { | |||||
| public ulong Id { get; } | |||||
| public ModifyGuildRolesParams(ulong id) | |||||
| { | |||||
| Id = id; | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,12 @@ | |||||
| namespace Discord | |||||
| { | |||||
| public class ModifyCurrentUserNickParams | |||||
| { | |||||
| public string Nickname { get; } | |||||
| public ModifyCurrentUserNickParams(string nickname) | |||||
| { | |||||
| Nickname = nickname; | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,8 @@ | |||||
| namespace Discord | |||||
| { | |||||
| public class ModifyCurrentUserParams | |||||
| { | |||||
| public Optional<string> Username { get; set; } | |||||
| public Optional<Image> Avatar { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,11 @@ | |||||
| namespace Discord | |||||
| { | |||||
| public class ModifyGuildMemberParams | |||||
| { | |||||
| public Optional<bool> Mute { get; set; } | |||||
| public Optional<bool> Deaf { get; set; } | |||||
| public Optional<string> Nickname { get; set; } | |||||
| public Optional<ulong[]> RoleIds { get; set; } | |||||
| public Optional<ulong> ChannelId { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -1,6 +1,7 @@ | |||||
| using Discord.API; | using Discord.API; | ||||
| using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
| using System; | using System; | ||||
| using Model = Discord.API.Image; | |||||
| namespace Discord.Net.Converters | namespace Discord.Net.Converters | ||||
| { | { | ||||
| @@ -19,7 +20,7 @@ namespace Discord.Net.Converters | |||||
| public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||||
| { | { | ||||
| var image = (Image)value; | |||||
| var image = (Model)value; | |||||
| if (image.Stream != null) | if (image.Stream != null) | ||||
| { | { | ||||
| @@ -24,7 +24,12 @@ namespace Discord.Rest | |||||
| { | { | ||||
| var args = new ModifyGuildChannelParams(); | var args = new ModifyGuildChannelParams(); | ||||
| func(args); | 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<Model> ModifyAsync(ITextChannel channel, BaseDiscordClient client, | public static async Task<Model> ModifyAsync(ITextChannel channel, BaseDiscordClient client, | ||||
| Action<ModifyTextChannelParams> func, | Action<ModifyTextChannelParams> func, | ||||
| @@ -32,7 +37,13 @@ namespace Discord.Rest | |||||
| { | { | ||||
| var args = new ModifyTextChannelParams(); | var args = new ModifyTextChannelParams(); | ||||
| func(args); | 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<Model> ModifyAsync(IVoiceChannel channel, BaseDiscordClient client, | public static async Task<Model> ModifyAsync(IVoiceChannel channel, BaseDiscordClient client, | ||||
| Action<ModifyVoiceChannelParams> func, | Action<ModifyVoiceChannelParams> func, | ||||
| @@ -40,7 +51,14 @@ namespace Discord.Rest | |||||
| { | { | ||||
| var args = new ModifyVoiceChannelParams(); | var args = new ModifyVoiceChannelParams(); | ||||
| func(args); | 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 | //Invites | ||||
| @@ -7,6 +7,7 @@ using System.Threading.Tasks; | |||||
| using EmbedModel = Discord.API.GuildEmbed; | using EmbedModel = Discord.API.GuildEmbed; | ||||
| using Model = Discord.API.Guild; | using Model = Discord.API.Guild; | ||||
| using RoleModel = Discord.API.Role; | using RoleModel = Discord.API.Role; | ||||
| using ImageModel = Discord.API.Image; | |||||
| namespace Discord.Rest | namespace Discord.Rest | ||||
| { | { | ||||
| @@ -21,12 +22,24 @@ namespace Discord.Rest | |||||
| var args = new ModifyGuildParams(); | var args = new ModifyGuildParams(); | ||||
| func(args); | 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<EmbedModel> ModifyEmbedAsync(IGuild guild, BaseDiscordClient client, | public static async Task<EmbedModel> ModifyEmbedAsync(IGuild guild, BaseDiscordClient client, | ||||
| Action<ModifyGuildEmbedParams> func, RequestOptions options) | Action<ModifyGuildEmbedParams> func, RequestOptions options) | ||||
| @@ -35,17 +48,24 @@ namespace Discord.Rest | |||||
| var args = new ModifyGuildEmbedParams(); | var args = new ModifyGuildEmbedParams(); | ||||
| func(args); | 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, | public static async Task ModifyChannelsAsync(IGuild guild, BaseDiscordClient client, | ||||
| IEnumerable<ModifyGuildChannelsParams> args, RequestOptions options) | IEnumerable<ModifyGuildChannelsParams> 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<IReadOnlyCollection<RoleModel>> ModifyRolesAsync(IGuild guild, BaseDiscordClient client, | public static async Task<IReadOnlyCollection<RoleModel>> ModifyRolesAsync(IGuild guild, BaseDiscordClient client, | ||||
| IEnumerable<ModifyGuildRolesParams> args, RequestOptions options) | IEnumerable<ModifyGuildRolesParams> 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, | public static async Task LeaveAsync(IGuild guild, BaseDiscordClient client, | ||||
| RequestOptions options) | RequestOptions options) | ||||
| @@ -61,7 +61,13 @@ namespace Discord.Rest | |||||
| var args = new ModifyGuildIntegrationParams(); | var args = new ModifyGuildIntegrationParams(); | ||||
| func(args); | 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); | Update(model); | ||||
| } | } | ||||
| @@ -18,7 +18,15 @@ namespace Discord.Rest | |||||
| { | { | ||||
| var args = new ModifyGuildRoleParams(); | var args = new ModifyGuildRoleParams(); | ||||
| func(args); | 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); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -2,6 +2,7 @@ | |||||
| using System; | using System; | ||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
| using Model = Discord.API.User; | using Model = Discord.API.User; | ||||
| using ImageModel = Discord.API.Image; | |||||
| namespace Discord.Rest | namespace Discord.Rest | ||||
| { | { | ||||
| @@ -12,14 +13,27 @@ namespace Discord.Rest | |||||
| { | { | ||||
| var args = new ModifyCurrentUserParams(); | var args = new ModifyCurrentUserParams(); | ||||
| func(args); | 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<ImageModel>(), | |||||
| Username = args.Username | |||||
| }; | |||||
| return await client.ApiClient.ModifySelfAsync(apiArgs, options).ConfigureAwait(false); | |||||
| } | } | ||||
| public static async Task<ModifyGuildMemberParams> ModifyAsync(IGuildUser user, BaseDiscordClient client, Action<ModifyGuildMemberParams> func, | public static async Task<ModifyGuildMemberParams> ModifyAsync(IGuildUser user, BaseDiscordClient client, Action<ModifyGuildMemberParams> func, | ||||
| RequestOptions options) | RequestOptions options) | ||||
| { | { | ||||
| var args = new ModifyGuildMemberParams(); | var args = new ModifyGuildMemberParams(); | ||||
| func(args); | 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; | return args; | ||||
| } | } | ||||