ids method

Future<void> ids(
  1. List<Snowflake> ids, {
  2. String? reason,
})

Delete Message with their ids

Example :

final TextChannel channel = await guild.channels.resolve('240561194958716924');
await channel.bulkDelete.ids(["1077565703416193125", "1077383535477927977"]);

Implementation

Future<void> ids(List<Snowflake> ids, {String? reason}) async {
  Response response = await ioc.use<DiscordApiHttpService>()
    .post(url: '/channels/${_manager._channelId}/messages/bulk-delete')
    .payload({ 'messages': ids })
    .auditLog(reason)
    .build();

  if (response.statusCode != 204) {
    throw ApiException("Unable to delete messages : ${response.statusCode} - ${response.body}");
  }

  for (final id in ids) {
    _manager.cache.remove(id);
  }
}