| @@ -241,6 +241,9 @@ | |||||
| <Compile Include="..\Discord.Net\API\Client\Rest\AddGuildBan.cs"> | <Compile Include="..\Discord.Net\API\Client\Rest\AddGuildBan.cs"> | ||||
| <Link>API\Client\Rest\AddGuildBan.cs</Link> | <Link>API\Client\Rest\AddGuildBan.cs</Link> | ||||
| </Compile> | </Compile> | ||||
| <Compile Include="..\Discord.Net\API\Client\Rest\BulkMessageDelete.cs"> | |||||
| <Link>API\Client\Rest\BulkMessageDelete.cs</Link> | |||||
| </Compile> | |||||
| <Compile Include="..\Discord.Net\API\Client\Rest\CreateChannel.cs"> | <Compile Include="..\Discord.Net\API\Client\Rest\CreateChannel.cs"> | ||||
| <Link>API\Client\Rest\CreateChannel.cs</Link> | <Link>API\Client\Rest\CreateChannel.cs</Link> | ||||
| </Compile> | </Compile> | ||||
| @@ -0,0 +1,23 @@ | |||||
| using Newtonsoft.Json; | |||||
| namespace Discord.API.Client.Rest | |||||
| { | |||||
| [JsonObject(MemberSerialization.OptIn)] | |||||
| public class BulkMessageDelete : IRestRequest | |||||
| { | |||||
| string IRestRequest.Endpoint => $"/channels/{ChannelId}/messages/bulk_delete"; | |||||
| string IRestRequest.Method => "POST"; | |||||
| object IRestRequest.Payload => this; | |||||
| public ulong ChannelId { get; set; } | |||||
| public BulkMessageDelete(ulong channelId, ulong[] messageIds) | |||||
| { | |||||
| ChannelId = channelId; | |||||
| MessageIds = messageIds; | |||||
| } | |||||
| [JsonProperty("messages")] | |||||
| public ulong[] MessageIds { get; set; } | |||||
| } | |||||
| } | |||||
| @@ -200,6 +200,13 @@ namespace Discord | |||||
| } | } | ||||
| } | } | ||||
| public async Task DeleteMessages(Message[] messages) => await DeleteMessages(messages.Select(m => m.Id).ToArray()); | |||||
| public async Task DeleteMessages(ulong[] messageIds) | |||||
| { | |||||
| await Client.ClientAPI.Send(new BulkMessageDelete(Id, messageIds)); | |||||
| } | |||||
| public async Task Delete() | public async Task Delete() | ||||
| { | { | ||||
| try { await Client.ClientAPI.Send(new DeleteChannelRequest(Id)).ConfigureAwait(false); } | try { await Client.ClientAPI.Send(new DeleteChannelRequest(Id)).ConfigureAwait(false); } | ||||