@@ -17,7 +17,7 @@ namespace Discord.Rest
return RestApplication.Create(client, model);
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)
ulong id, RequestOptions options)
{
{
var model = await client.ApiClient.GetChannelAsync(id, options).ConfigureAwait(false);
var model = await client.ApiClient.GetChannelAsync(id, options).ConfigureAwait(false);
@@ -45,13 +45,13 @@ namespace Discord.Rest
.Where(x => x.Type == ChannelType.Group)
.Where(x => x.Type == ChannelType.Group)
.Select(x => RestGroupChannel.Create(client, x)).ToImmutableArray();
.Select(x => RestGroupChannel.Create(client, x)).ToImmutableArray();
}
}
public static async Task<IReadOnlyCollection<RestConnection>> GetConnectionsAsync(BaseDiscordClient client, RequestOptions options)
public static async Task<IReadOnlyCollection<RestConnection>> GetConnectionsAsync(BaseDiscordClient client, RequestOptions options)
{
{
var models = await client.ApiClient.GetMyConnectionsAsync(options).ConfigureAwait(false);
var models = await client.ApiClient.GetMyConnectionsAsync(options).ConfigureAwait(false);
return models.Select(RestConnection.Create).ToImmutableArray();
return models.Select(RestConnection.Create).ToImmutableArray();
}
}
public static async Task<RestInviteMetadata> GetInviteAsync(BaseDiscordClient client,
public static async Task<RestInviteMetadata> GetInviteAsync(BaseDiscordClient client,
string inviteId, RequestOptions options)
string inviteId, RequestOptions options)
{
{
@@ -60,7 +60,7 @@ namespace Discord.Rest
return RestInviteMetadata.Create(client, null, null, model);
return RestInviteMetadata.Create(client, null, null, model);
return null;
return null;
}
}
public static async Task<RestGuild> GetGuildAsync(BaseDiscordClient client,
public static async Task<RestGuild> GetGuildAsync(BaseDiscordClient client,
ulong id, bool withCounts, RequestOptions options)
ulong id, bool withCounts, RequestOptions options)
{
{
@@ -85,7 +85,7 @@ namespace Discord.Rest
return RestGuildWidget.Create(model);
return RestGuildWidget.Create(model);
return null;
return null;
}
}
public static IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(BaseDiscordClient client,
public static IAsyncEnumerable<IReadOnlyCollection<RestUserGuild>> GetGuildSummariesAsync(BaseDiscordClient client,
ulong? fromGuildId, int? limit, RequestOptions options)
ulong? fromGuildId, int? limit, RequestOptions options)
{
{
return new PagedAsyncEnumerable<RestUserGuild>(
return new PagedAsyncEnumerable<RestUserGuild>(
@@ -136,7 +136,7 @@ namespace Discord.Rest
var model = await client.ApiClient.CreateGuildAsync(args, options).ConfigureAwait(false);
var model = await client.ApiClient.CreateGuildAsync(args, options).ConfigureAwait(false);
return RestGuild.Create(client, model);
return RestGuild.Create(client, model);
}
}
public static async Task<RestUser> GetUserAsync(BaseDiscordClient client,
public static async Task<RestUser> GetUserAsync(BaseDiscordClient client,
ulong id, RequestOptions options)
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);
}
}
}
}