Jda: Can't delete own message

Created on 6 Oct 2017  路  7Comments  路  Source: DV8FromTheWorld/JDA

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)

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:

channel.sendMessage(toSend).queue( message -> message.delete().queueAfter(5, TimeUnit.SECONDS) );

All 7 comments

Was this page helpful?
0 / 5 - 0 ratings

Related issues

istamendil picture istamendil  路  3Comments

StijnSimons picture StijnSimons  路  3Comments

Bastian picture Bastian  路  5Comments

stefaandevylder picture stefaandevylder  路  5Comments

xeu100 picture xeu100  路  5Comments