Vincent Banks
Vincent Banks

Reputation: 55

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?

Upvotes: 2

Views: 956

Answers (1)

Minn
Minn

Reputation: 6134

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.

Upvotes: 2

Related Questions