Browse Source

Create wrapper modify objects

this was a big one
tags/1.0-rc
Christopher F 8 years ago
parent
commit
64681856b1
22 changed files with 245 additions and 32 deletions
  1. +14
    -14
      src/Discord.Net.Core/API/DiscordRestApiClient.cs
  2. +5
    -0
      src/Discord.Net.Core/API/Image.cs
  3. +8
    -0
      src/Discord.Net.Core/Entities/Channels/ModifyGuildChannelParams.cs
  4. +14
    -0
      src/Discord.Net.Core/Entities/Channels/ModifyGuildChannelsParams.cs
  5. +7
    -0
      src/Discord.Net.Core/Entities/Channels/ModifyTextChannelParams.cs
  6. +8
    -0
      src/Discord.Net.Core/Entities/Channels/ModifyVoiceChannelParams.cs
  7. +8
    -0
      src/Discord.Net.Core/Entities/Guilds/ModifyGuildEmbedParams.cs
  8. +9
    -0
      src/Discord.Net.Core/Entities/Guilds/ModifyGuildIntegrationParams.cs
  9. +16
    -0
      src/Discord.Net.Core/Entities/Guilds/ModifyGuildParams.cs
  10. +17
    -0
      src/Discord.Net.Core/Entities/Image.cs
  11. +1
    -1
      src/Discord.Net.Core/Entities/Messages/EmbedBuilder.cs
  12. +11
    -0
      src/Discord.Net.Core/Entities/Roles/ModifyGuildRoleParams.cs
  13. +12
    -0
      src/Discord.Net.Core/Entities/Roles/ModifyGuildRolesParams.cs
  14. +12
    -0
      src/Discord.Net.Core/Entities/Users/ModifyCurrentUserNickParams.cs
  15. +8
    -0
      src/Discord.Net.Core/Entities/Users/ModifyCurrentUserParams.cs
  16. +11
    -0
      src/Discord.Net.Core/Entities/Users/ModifyGuildMemberParams.cs
  17. +2
    -1
      src/Discord.Net.Core/Net/Converters/ImageConverter.cs
  18. +21
    -3
      src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs
  19. +29
    -9
      src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
  20. +7
    -1
      src/Discord.Net.Rest/Entities/Guilds/RestGuildIntegration.cs
  21. +9
    -1
      src/Discord.Net.Rest/Entities/Roles/RoleHelper.cs
  22. +16
    -2
      src/Discord.Net.Rest/Entities/Users/UserHelper.cs

+ 14
- 14
src/Discord.Net.Core/API/DiscordRestApiClient.cs View File

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


+ 5
- 0
src/Discord.Net.Core/API/Image.cs View File

@@ -17,5 +17,10 @@ namespace Discord.API
Stream = null;
Hash = hash;
}

public static Image Create(Discord.Image image)
{
return new Image(image.Stream);
}
}
}

+ 8
- 0
src/Discord.Net.Core/Entities/Channels/ModifyGuildChannelParams.cs View File

@@ -0,0 +1,8 @@
namespace Discord
{
public class ModifyGuildChannelParams
{
public Optional<string> Name { get; set; }
public Optional<int> Position { get; set; }
}
}

+ 14
- 0
src/Discord.Net.Core/Entities/Channels/ModifyGuildChannelsParams.cs View File

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

+ 7
- 0
src/Discord.Net.Core/Entities/Channels/ModifyTextChannelParams.cs View File

@@ -0,0 +1,7 @@
namespace Discord
{
public class ModifyTextChannelParams : ModifyGuildChannelParams
{
public Optional<string> Topic { get; set; }
}
}

+ 8
- 0
src/Discord.Net.Core/Entities/Channels/ModifyVoiceChannelParams.cs View File

@@ -0,0 +1,8 @@
namespace Discord
{
public class ModifyVoiceChannelParams : ModifyGuildChannelParams
{
public Optional<int> Bitrate { get; set; }
public Optional<int> UserLimit { get; set; }
}
}

+ 8
- 0
src/Discord.Net.Core/Entities/Guilds/ModifyGuildEmbedParams.cs View File

@@ -0,0 +1,8 @@
namespace Discord
{
public class ModifyGuildEmbedParams
{
public Optional<bool> Enabled { get; set; }
public Optional<ulong?> ChannelId { get; set; }
}
}

+ 9
- 0
src/Discord.Net.Core/Entities/Guilds/ModifyGuildIntegrationParams.cs View File

@@ -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
- 0
src/Discord.Net.Core/Entities/Guilds/ModifyGuildParams.cs View 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
- 0
src/Discord.Net.Core/Entities/Image.cs View 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);
}
}
}

+ 1
- 1
src/Discord.Net.Core/Entities/Messages/EmbedBuilder.cs View File

@@ -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
- 0
src/Discord.Net.Core/Entities/Roles/ModifyGuildRoleParams.cs View 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; }
}
}

+ 12
- 0
src/Discord.Net.Core/Entities/Roles/ModifyGuildRolesParams.cs View File

@@ -0,0 +1,12 @@
namespace Discord
{
public class ModifyGuildRolesParams : ModifyGuildRoleParams
{
public ulong Id { get; }

public ModifyGuildRolesParams(ulong id)
{
Id = id;
}
}
}

+ 12
- 0
src/Discord.Net.Core/Entities/Users/ModifyCurrentUserNickParams.cs View File

@@ -0,0 +1,12 @@
namespace Discord
{
public class ModifyCurrentUserNickParams
{
public string Nickname { get; }

public ModifyCurrentUserNickParams(string nickname)
{
Nickname = nickname;
}
}
}

+ 8
- 0
src/Discord.Net.Core/Entities/Users/ModifyCurrentUserParams.cs View File

@@ -0,0 +1,8 @@
namespace Discord
{
public class ModifyCurrentUserParams
{
public Optional<string> Username { get; set; }
public Optional<Image> Avatar { get; set; }
}
}

+ 11
- 0
src/Discord.Net.Core/Entities/Users/ModifyGuildMemberParams.cs View File

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

+ 2
- 1
src/Discord.Net.Core/Net/Converters/ImageConverter.cs View File

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


+ 21
- 3
src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs View File

@@ -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<Model> ModifyAsync(ITextChannel channel, BaseDiscordClient client,
Action<ModifyTextChannelParams> 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<Model> ModifyAsync(IVoiceChannel channel, BaseDiscordClient client,
Action<ModifyVoiceChannelParams> 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


+ 29
- 9
src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs View File

@@ -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<EmbedModel> ModifyEmbedAsync(IGuild guild, BaseDiscordClient client,
Action<ModifyGuildEmbedParams> 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<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,
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,
RequestOptions options)


+ 7
- 1
src/Discord.Net.Rest/Entities/Guilds/RestGuildIntegration.cs View File

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


+ 9
- 1
src/Discord.Net.Rest/Entities/Roles/RoleHelper.cs View File

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

+ 16
- 2
src/Discord.Net.Rest/Entities/Users/UserHelper.cs View File

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



Loading…
Cancel
Save