Class ThreadLocalReason.Closable

java.lang.Object
net.dv8tion.jda.api.audit.ThreadLocalReason.Closable
All Implemented Interfaces:
AutoCloseable
Enclosing class:
ThreadLocalReason

public static class ThreadLocalReason.Closable extends Object implements AutoCloseable
Allows to use try-with-resources blocks for setting reasons

Example:


 try (ThreadLocalReason.Closable closable = new ThreadLocalReason.Closable("Massban")) { // calls setCurrent("Massban")
     List<Member> mentions = event.getMessage().getMentionedMembers();
     Guild guild = event.getGuild();
     mentions.stream()
             .map(m -> guild.ban(m, 7))
             .forEach(RestAction::queue);
 } // calls resetCurrent()
 
  • Constructor Details

  • Method Details