Added Server.GetBans
This commit is contained in:
@@ -278,6 +278,9 @@
|
||||
<Compile Include="..\Discord.Net\API\Client\Rest\Gateway.cs">
|
||||
<Link>API\Client\Rest\Gateway.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Discord.Net\API\Client\Rest\GetBans.cs">
|
||||
<Link>API\Client\Rest\GetBans.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Discord.Net\API\Client\Rest\GetInvite.cs">
|
||||
<Link>API\Client\Rest\GetInvite.cs</Link>
|
||||
</Compile>
|
||||
|
||||
20
src/Discord.Net/API/Client/Rest/GetBans.cs
Normal file
20
src/Discord.Net/API/Client/Rest/GetBans.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API.Client.Rest
|
||||
{
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public sealed class GetBansRequest : IRestRequest<UserReference[]>
|
||||
{
|
||||
string IRestRequest.Method => "GET";
|
||||
string IRestRequest.Endpoint => $"guilds/{GuildId}/bans";
|
||||
object IRestRequest.Payload => null;
|
||||
bool IRestRequest.IsPrivate => false;
|
||||
|
||||
public ulong GuildId { get; }
|
||||
|
||||
public GetBansRequest(ulong guildId)
|
||||
{
|
||||
GuildId = guildId;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,6 +172,17 @@ namespace Discord
|
||||
}
|
||||
|
||||
#region Bans
|
||||
public async Task<IEnumerable<User>> GetBans()
|
||||
{
|
||||
var response = await Client.ClientAPI.Send(new GetBansRequest(Id)).ConfigureAwait(false);
|
||||
return response.Select(x =>
|
||||
{
|
||||
var user = new User(Client, x.Id, this);
|
||||
user.Update(x);
|
||||
return user;
|
||||
});
|
||||
}
|
||||
|
||||
public Task Ban(User user, int pruneDays = 0)
|
||||
{
|
||||
var request = new AddGuildBanRequest(user.Server.Id, user.Id)
|
||||
|
||||
Reference in New Issue
Block a user