(ifcbrk) feature: Add ability to add/remove roles by id (#1757)
* Scaffold Add/Remove roles by id. (needs impl & docs) * Add docs * Add implementation * Expose Add/Remove role endpoints * Formatting * Fix wrong method call
This commit is contained in:
@@ -17,7 +17,7 @@ namespace Discord.Rest
|
||||
return RestApplication.Create(client, model);
|
||||
}
|
||||
|
||||
public static async Task<RestChannel> GetChannelAsync(BaseDiscordClient client,
|
||||
public static async Task<RestChannel> GetChannelAsync(BaseDiscordClient client,
|
||||
ulong id, RequestOptions options)
|
||||
{
|
||||
var model = await client.ApiClient.GetChannelAsync(id, options).ConfigureAwait(false);
|
||||
@@ -45,13 +45,13 @@ namespace Discord.Rest
|
||||
.Where(x => x.Type == ChannelType.Group)
|
||||
.Select(x => RestGroupChannel.Create(client, x)).ToImmutableArray();
|
||||
}
|
||||
|
||||
|
||||
public static async Task<IReadOnlyCollection<RestConnection>> GetConnectionsAsync(BaseDiscordClient client, RequestOptions options)
|
||||
{
|
||||
var models = await client.ApiClient.GetMyConnectionsAsync(options).ConfigureAwait(false);
|
||||
return models.Select(RestConnection.Create).ToImmutableArray();
|
||||
}
|
||||
|
||||
|
||||
public static async Task<RestInviteMetadata> GetInviteAsync(BaseDiscordClient client,
|
||||
string inviteId, RequestOptions options)
|
||||
{
|
||||
@@ -60,7 +60,7 @@ namespace Discord.Rest
|
||||
return RestInviteMetadata.Create(client, null, null, model);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static async Task<RestGuild> GetGuildAsync(BaseDiscordClient client,
|
||||
ulong id, bool withCounts, RequestOptions options)
|
||||
{
|
||||
@@ -85,7 +85,7 @@ namespace Discord.Rest
|
||||
return RestGuildWidget.Create(model);
|
||||
return null;
|
||||
}
|
||||
public static IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(BaseDiscordClient client,
|
||||
public static IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(BaseDiscordClient client,
|
||||
ulong? fromGuildId, int? limit, RequestOptions options)
|
||||
{
|
||||
return new PagedAsyncEnumerable<RestUserGuild>(
|
||||
@@ -136,7 +136,7 @@ namespace Discord.Rest
|
||||
var model = await client.ApiClient.CreateGuildAsync(args, options).ConfigureAwait(false);
|
||||
return RestGuild.Create(client, model);
|
||||
}
|
||||
|
||||
|
||||
public static async Task<RestUser> GetUserAsync(BaseDiscordClient client,
|
||||
ulong id, RequestOptions options)
|
||||
{
|
||||
@@ -201,5 +201,9 @@ namespace Discord.Rest
|
||||
}
|
||||
};
|
||||
}
|
||||
public static Task AddRoleAsync(BaseDiscordClient client, ulong guildId, ulong userId, ulong roleId, RequestOptions options = null)
|
||||
=> client.ApiClient.AddRoleAsync(guildId, userId, roleId, options);
|
||||
public static Task RemoveRoleAsync(BaseDiscordClient client, ulong guildId, ulong userId, ulong roleId, RequestOptions options = null)
|
||||
=> client.ApiClient.RemoveRoleAsync(guildId, userId, roleId, options);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user