GetRoleAsync W (#2989)
This commit is contained in:
@@ -953,6 +953,17 @@ namespace Discord
|
|||||||
/// A role that is associated with the specified <paramref name="id"/>; <see langword="null" /> if none is found.
|
/// A role that is associated with the specified <paramref name="id"/>; <see langword="null" /> if none is found.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
IRole GetRole(ulong id);
|
IRole GetRole(ulong id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a role in this guild.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">The snowflake identifier for the role.</param>
|
||||||
|
/// <returns>
|
||||||
|
/// A task that represents the asynchronous creation operation. The task result contains the role
|
||||||
|
/// that is associated with the specified <paramref name="id"/>; <see langword="null" /> if none is found.
|
||||||
|
/// </returns>
|
||||||
|
Task<IRole> GetRoleAsync(ulong id, RequestOptions options = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new role with the provided name.
|
/// Creates a new role with the provided name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -790,6 +790,17 @@ namespace Discord.API
|
|||||||
var ids = new BucketIds(guildId: guildId);
|
var ids = new BucketIds(guildId: guildId);
|
||||||
return SendAsync("DELETE", () => $"guilds/{guildId}/members/{userId}/roles/{roleId}", ids, options: options);
|
return SendAsync("DELETE", () => $"guilds/{guildId}/members/{userId}/roles/{roleId}", ids, options: options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task<API.Role> GetRoleAsync(ulong guildId, ulong roleId, RequestOptions options = null)
|
||||||
|
{
|
||||||
|
Preconditions.NotEqual(guildId, 0, nameof(guildId));
|
||||||
|
Preconditions.NotEqual(roleId, 0, nameof(roleId));
|
||||||
|
options = RequestOptions.CreateOrClone(options);
|
||||||
|
|
||||||
|
var ids = new BucketIds(guildId: guildId);
|
||||||
|
return SendAsync<API.Role>("GET", () => $"guilds/{guildId}/roles/{roleId}", ids, options: options);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Channel Messages
|
#region Channel Messages
|
||||||
|
|||||||
@@ -644,6 +644,13 @@ namespace Discord.Rest
|
|||||||
|
|
||||||
return RestRole.Create(client, guild, model);
|
return RestRole.Create(client, guild, model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async Task<RestRole> GetRoleAsync(IGuild guild, BaseDiscordClient client, ulong roleId, RequestOptions options)
|
||||||
|
{
|
||||||
|
var model = await client.ApiClient.GetRoleAsync(guild.Id, roleId, options).ConfigureAwait(false);
|
||||||
|
return model is null ? null : RestRole.Create(client, guild, model);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Users
|
#region Users
|
||||||
|
|||||||
@@ -1596,6 +1596,15 @@ namespace Discord.Rest
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
IRole IGuild.GetRole(ulong id)
|
IRole IGuild.GetRole(ulong id)
|
||||||
=> GetRole(id);
|
=> GetRole(id);
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IGuild.GetRole" />
|
||||||
|
public Task<RestRole> GetRoleAsync(ulong id, RequestOptions options = null)
|
||||||
|
=> GuildHelper.GetRoleAsync(this, Discord, id, options);
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
async Task<IRole> IGuild.GetRoleAsync(ulong id, RequestOptions options)
|
||||||
|
=> await GetRoleAsync(id);
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
async Task<IRole> IGuild.CreateRoleAsync(string name, GuildPermissions? permissions, Color? color, bool isHoisted, RequestOptions options)
|
async Task<IRole> IGuild.CreateRoleAsync(string name, GuildPermissions? permissions, Color? color, bool isHoisted, RequestOptions options)
|
||||||
=> await CreateRoleAsync(name, permissions, color, isHoisted, false, options).ConfigureAwait(false);
|
=> await CreateRoleAsync(name, permissions, color, isHoisted, false, options).ConfigureAwait(false);
|
||||||
|
|||||||
@@ -2200,6 +2200,15 @@ namespace Discord.WebSocket
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
IRole IGuild.GetRole(ulong id)
|
IRole IGuild.GetRole(ulong id)
|
||||||
=> GetRole(id);
|
=> GetRole(id);
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IGuild.GetRole" />
|
||||||
|
public Task<RestRole> GetRoleAsync(ulong id, RequestOptions options = null)
|
||||||
|
=> GuildHelper.GetRoleAsync(this, Discord, id, options);
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
async Task<IRole> IGuild.GetRoleAsync(ulong id, RequestOptions options)
|
||||||
|
=> await GetRoleAsync(id);
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
async Task<IRole> IGuild.CreateRoleAsync(string name, GuildPermissions? permissions, Color? color, bool isHoisted, RequestOptions options)
|
async Task<IRole> IGuild.CreateRoleAsync(string name, GuildPermissions? permissions, Color? color, bool isHoisted, RequestOptions options)
|
||||||
=> await CreateRoleAsync(name, permissions, color, isHoisted, false, options).ConfigureAwait(false);
|
=> await CreateRoleAsync(name, permissions, color, isHoisted, false, options).ConfigureAwait(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user