I am making a discord bot that sends an embed to display a users inventory(im making a game bot). To avoid clutter I want to delete the message after 10-20 seconds. Anyone know
You can use queueAfter
which will delay the execution of the RestAction
provided by delete()
.
public static void deleteAfter(Message message, int delay) {
message.delete().queueAfter(delay, TimeUnit.SECONDS);
}
This method can be used inside the success callback for your sendMessage
action.
someMethod().queue((result) -> { // the type for "result" is the T in RestAction
System.out.println(result);
}, (failure) -> { // failure is always a Throwable
failure.printStackTrace();
});
I recommend reading the documentation and wiki: