MinnDevelopment / discord-webhooks

Provides easy to use bindings for the Discord Webhook API
Apache License 2.0
180 stars 34 forks source link

UnsupportedOperationException when sending DataMessages #53

Closed Zavarov closed 2 years ago

Zavarov commented 2 years ago

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:?]
MinnDevelopment commented 2 years ago

Fixed in 0.7.5