@@ -278,6 +278,9 @@ | |||||
<Compile Include="..\Discord.Net\API\Client\Rest\Gateway.cs"> | <Compile Include="..\Discord.Net\API\Client\Rest\Gateway.cs"> | ||||
<Link>API\Client\Rest\Gateway.cs</Link> | <Link>API\Client\Rest\Gateway.cs</Link> | ||||
</Compile> | </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"> | <Compile Include="..\Discord.Net\API\Client\Rest\GetInvite.cs"> | ||||
<Link>API\Client\Rest\GetInvite.cs</Link> | <Link>API\Client\Rest\GetInvite.cs</Link> | ||||
</Compile> | </Compile> | ||||
@@ -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 | #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) | public Task Ban(User user, int pruneDays = 0) | ||||
{ | { | ||||
var request = new AddGuildBanRequest(user.Server.Id, user.Id) | var request = new AddGuildBanRequest(user.Server.Id, user.Id) | ||||