so i ve recently started using JDA and i have no problem when detecting that a message was sent . But for some reason it doesn't work when it related to attachments .(yes ,i activated the intent in the discord bot settings ) and here is my code .
public void onMessageReceived(MessageReceivedEvent event) {
if (event.getAuthor().isBot()) return; // Ignore messages from other bots
suppressContentIntentWarning();
List<Attachment> attachments = event.getMessage().getAttachments();
TextChannel textChannel = event.getChannel().asTextChannel();
for (Attachment attachment : attachments) {
String fileName = attachment.getFileName();
String fileExtension = attachment.getFileExtension();
int size = attachment.getSize();
if (attachment.isImage()) {
textChannel.sendMessage("Image detected: " + fileName + ", size: " + size + " bytes").queue();
} else if (attachment.isVideo()) {
textChannel.sendMessage("Video detected: " + fileName + ", size: " + size + " bytes").queue();
} else {
textChannel.sendMessage("Other attachment detected: " + fileName + ", size: " + size + " bytes").queue();
}
}
}
ps: i checked and attachments is always empty
Since you call suppressContentIntentWarning
, I would assume you did not do what the warning said. You have to enable the intent in the dev portal and in JDA.
See the troubleshooting guide for details.