Package net.dv8tion.jda.core.audit
Class ThreadLocalReason.Closable
- java.lang.Object
-
- net.dv8tion.jda.core.audit.ThreadLocalReason.Closable
-
- All Implemented Interfaces:
java.lang.AutoCloseable
- Enclosing class:
- ThreadLocalReason
public static class ThreadLocalReason.Closable extends java.lang.Object implements java.lang.AutoCloseable
Allows to use try-with-resources blocks for setting reasonsExample:
try (ThreadLocalReason.Closable closable = new ThreadLocalReason.Closable("Massban")) { // calls setCurrent("Massban") List<Member> mentions = event.getMessage().getMentionedMembers(); GuildController controller = event.getGuild().getController(); mentions.stream() .map(m -> controller.ban(m, 7)) .forEach(RestAction::queue); } // calls resetCurrent()
-
-
Constructor Summary
Constructors Constructor Description Closable(java.lang.String reason)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
-