Package net.dv8tion.jda.api.audit
Class ThreadLocalReason.Closable
java.lang.Object
net.dv8tion.jda.api.audit.ThreadLocalReason.Closable
- All Implemented Interfaces:
AutoCloseable
- Enclosing class:
ThreadLocalReason
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 Summary
-
Method Summary
-
Constructor Details
-
Closable
-
-
Method Details
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-