Cleaned up and fixed several reorder issues.
This commit is contained in:
@@ -75,23 +75,16 @@ namespace Discord.Rest
|
||||
|
||||
return await client.ApiClient.ModifyGuildEmbedAsync(guild.Id, apiArgs, options).ConfigureAwait(false);
|
||||
}
|
||||
public static async Task ModifyChannelsAsync(IGuild guild, BaseDiscordClient client,
|
||||
IEnumerable<BulkGuildChannelProperties> args, RequestOptions options)
|
||||
public static async Task ReorderChannelsAsync(IGuild guild, BaseDiscordClient client,
|
||||
IEnumerable<ReorderChannelProperties> args, RequestOptions options)
|
||||
{
|
||||
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<BulkRoleProperties> args, RequestOptions options)
|
||||
public static async Task<IReadOnlyCollection<RoleModel>> ReorderRolesAsync(IGuild guild, BaseDiscordClient client,
|
||||
IEnumerable<ReorderRoleProperties> args, RequestOptions options)
|
||||
{
|
||||
var apiArgs = args.Select(x => new API.Rest.ModifyGuildRolesParams(x.Id)
|
||||
{
|
||||
Color = x.Color.IsSpecified ? x.Color.Value.RawValue : Optional.Create<uint>(),
|
||||
Hoist = x.Hoist,
|
||||
Name = x.Name,
|
||||
Permissions = x.Permissions.IsSpecified ? x.Permissions.Value.RawValue : Optional.Create<ulong>(),
|
||||
Position = x.Position
|
||||
});
|
||||
var apiArgs = args.Select(x => new API.Rest.ModifyGuildRolesParams(x.Id, x.Position));
|
||||
return await client.ApiClient.ModifyGuildRolesAsync(guild.Id, apiArgs, options).ConfigureAwait(false);
|
||||
}
|
||||
public static async Task LeaveAsync(IGuild guild, BaseDiscordClient client,
|
||||
|
||||
@@ -114,14 +114,14 @@ namespace Discord.Rest
|
||||
var model = await GuildHelper.ModifyEmbedAsync(this, Discord, func, options).ConfigureAwait(false);
|
||||
Update(model);
|
||||
}
|
||||
public async Task ModifyChannelsAsync(IEnumerable<BulkGuildChannelProperties> args, RequestOptions options = null)
|
||||
public async Task ReorderChannelsAsync(IEnumerable<ReorderChannelProperties> args, RequestOptions options = null)
|
||||
{
|
||||
var arr = args.ToArray();
|
||||
await GuildHelper.ModifyChannelsAsync(this, Discord, arr, options);
|
||||
await GuildHelper.ReorderChannelsAsync(this, Discord, arr, options);
|
||||
}
|
||||
public async Task ModifyRolesAsync(IEnumerable<BulkRoleProperties> args, RequestOptions options = null)
|
||||
public async Task ReorderRolesAsync(IEnumerable<ReorderRoleProperties> args, RequestOptions options = null)
|
||||
{
|
||||
var models = await GuildHelper.ModifyRolesAsync(this, Discord, args, options).ConfigureAwait(false);
|
||||
var models = await GuildHelper.ReorderRolesAsync(this, Discord, args, options).ConfigureAwait(false);
|
||||
foreach (var model in models)
|
||||
{
|
||||
var role = GetRole(model.Id);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Model = Discord.API.Role;
|
||||
using BulkParams = Discord.API.Rest.ModifyGuildRolesParams;
|
||||
|
||||
namespace Discord.Rest
|
||||
{
|
||||
@@ -23,10 +24,17 @@ namespace Discord.Rest
|
||||
Hoist = args.Hoist,
|
||||
Mentionable = args.Mentionable,
|
||||
Name = args.Name,
|
||||
Permissions = args.Permissions.IsSpecified ? args.Permissions.Value.RawValue : Optional.Create<ulong>(),
|
||||
Position = args.Position
|
||||
Permissions = args.Permissions.IsSpecified ? args.Permissions.Value.RawValue : Optional.Create<ulong>()
|
||||
};
|
||||
return await client.ApiClient.ModifyGuildRoleAsync(role.Guild.Id, role.Id, apiArgs, options).ConfigureAwait(false);
|
||||
var model = await client.ApiClient.ModifyGuildRoleAsync(role.Guild.Id, role.Id, apiArgs, options).ConfigureAwait(false);
|
||||
|
||||
if (args.Position.IsSpecified)
|
||||
{
|
||||
var bulkArgs = new[] { new BulkParams(role.Id, args.Position.Value) };
|
||||
await client.ApiClient.ModifyGuildRolesAsync(role.Guild.Id, bulkArgs, options).ConfigureAwait(false);
|
||||
model.Position = args.Position.Value;
|
||||
}
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user