MinnDevelopment/discord-webhooks

UnsupportedOperationException when sending DataMessages

Zavarov opened this issue · 1 comments

When trying to send JDA messages that have been constructed using the MessageBuilder, the Webhook client fails with an UnsupportedOperationException.

The main issue seems to be caused by the isEphemeral() method, which is called regardless of the message type. I suggest allowing this attribute only for received messages.

Here's the corresponding stack trace:

java.lang.UnsupportedOperationException: This operation is not supported for Messages that were created by a MessageBuilder!
	at net.dv8tion.jda.internal.entities.DataMessage.unsupported(DataMessage.java:131) ~[JDA-4.4.0_350.jar:4.4.0_350]
	at net.dv8tion.jda.internal.entities.AbstractMessage.isEphemeral(AbstractMessage.java:610) ~[JDA-4.4.0_350.jar:4.4.0_350]
	at club.minnced.discord.webhook.send.WebhookMessageBuilder.fromJDA(WebhookMessageBuilder.java:436) ~[discord-webhooks-0.7.4.jar:?]
	at club.minnced.discord.webhook.external.JDAWebhookClient.send(JDAWebhookClient.java:119) ~[discord-webhooks-0.7.4.jar:?]

Fixed in 0.7.5