Package net.dv8tion.jda.api.audit
Class ThreadLocalReason.Closable
- java.lang.Object
-
- net.dv8tion.jda.api.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(); Guild guild = event.getGuild(); mentions.stream() .map(m -> guild.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()
-