Search code examples
javadiscorddiscord-jda

What method would I need to use in JDA to check if a message contains an image?


I am looking to create a command where you can type in the command with an image and have my bot return a random string answer, what I need to know is what method would I use to check if a message contains an image?


Solution

  • Images can be in the message attachments (Message#getAttachments) or in the message embeds (Message#getEmbeds).

    To check if an attachment is an image, use Attachment#isImage. For embeds, images can be provided by multiple components:

    All of these return wrapper objects which provide URLs to the image.