Create wrapper modify objects
this was a big one
This commit is contained in:
@@ -331,7 +331,7 @@ namespace Discord.API
|
||||
var ids = new BucketIds(channelId: channelId);
|
||||
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.NotNull(args, nameof(args));
|
||||
@@ -342,7 +342,7 @@ namespace Discord.API
|
||||
var ids = new BucketIds(channelId: channelId);
|
||||
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.NotNull(args, nameof(args));
|
||||
@@ -353,7 +353,7 @@ namespace Discord.API
|
||||
var ids = new BucketIds(channelId: channelId);
|
||||
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.NotNull(args, nameof(args));
|
||||
@@ -366,7 +366,7 @@ namespace Discord.API
|
||||
var ids = new BucketIds(channelId: channelId);
|
||||
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.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<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.NotNull(args, nameof(args));
|
||||
@@ -773,7 +773,7 @@ namespace Discord.API
|
||||
}
|
||||
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.NotEqual(guildId, 0, nameof(guildId));
|
||||
@@ -811,7 +811,7 @@ namespace Discord.API
|
||||
var ids = new BucketIds(guildId: guildId);
|
||||
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(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<string>(); //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<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(roleId, 0, nameof(roleId));
|
||||
@@ -995,7 +995,7 @@ namespace Discord.API
|
||||
var ids = new BucketIds(guildId: guildId);
|
||||
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.NotNull(args, nameof(args));
|
||||
@@ -1053,7 +1053,7 @@ namespace Discord.API
|
||||
options = RequestOptions.CreateOrClone(options);
|
||||
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.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);
|
||||
}
|
||||
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));
|
||||
|
||||
@@ -17,5 +17,10 @@ namespace Discord.API
|
||||
Stream = null;
|
||||
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; }
|
||||
}
|
||||
}
|
||||
16
src/Discord.Net.Core/Entities/Guilds/ModifyGuildParams.cs
Normal file
16
src/Discord.Net.Core/Entities/Guilds/ModifyGuildParams.cs
Normal file
@@ -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; }
|
||||
}
|
||||
}
|
||||
17
src/Discord.Net.Core/Entities/Image.cs
Normal file
17
src/Discord.Net.Core/Entities/Image.cs
Normal file
@@ -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 Footer = Discord.API.EmbedFooter;
|
||||
using Thumbnail = Discord.API.EmbedThumbnail;
|
||||
using Image = Discord.API.EmbedImage;
|
||||
using ImageEmbed = Discord.API.EmbedImage;
|
||||
|
||||
namespace Discord
|
||||
{
|
||||
|
||||
11
src/Discord.Net.Core/Entities/Roles/ModifyGuildRoleParams.cs
Normal file
11
src/Discord.Net.Core/Entities/Roles/ModifyGuildRoleParams.cs
Normal file
@@ -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 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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user