Message toSend = new MessageBuilder().append("aa").build();
channel.sendMessage(toSend).queue();
message.delete().complete();
toSend.delete().queueAfter(5, TimeUnit.SECONDS);
The last line returns a NPE.
at net.dv8tion.jda.core.entities.impl.MessageImpl.delete(MessageImpl.java:471)
Message is being sent. If I try to delete it with TextChannel#deleteMessageById it returns a 400 saying "snowflake should be less than or equal to "
You can't delete messages from message builder, these messages have no ID assigned and thus cannot be modified or deleted.
You need to use the response message from sendMessage:
channel.sendMessage(toSend).queue( message -> message.delete().queueAfter(5, TimeUnit.SECONDS) );
Oh, yes, I was wondering what the "-1" in MessageBuilder was for.
It does now not works
Go to discord.gg/0hMr4ce0tIl3SLv5 to receive support
@RasFlor what do you mean?
maybe you're bot doesn't have permissions for deleting message
Most helpful comment
You can't delete messages from message builder, these messages have no ID assigned and thus cannot be modified or deleted.
You need to use the response message from sendMessage: