Skip to content

Commit

Permalink
🔥 Fixed JDA's buggy behavior with polls
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsTheSky committed Apr 21, 2024
1 parent 0e4c4a4 commit 879010c
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
import net.dv8tion.jda.api.utils.messages.MessageEditData;
import net.dv8tion.jda.api.utils.messages.MessagePollBuilder;
import net.dv8tion.jda.api.utils.messages.MessagePollData;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -104,6 +105,7 @@ else if (message instanceof EmbedBuilder)
builder = new MessageCreateBuilder().addEmbeds(((EmbedBuilder) message).build());
else
builder = new MessageCreateBuilder().setContent((String) message);
final @Nullable MessagePollData poll = builder.getPoll();

if (!builder.isValid()) {
SkriptUtils.error(node, "The provided message is not valid!");
Expand All @@ -128,11 +130,15 @@ else if (message instanceof EmbedBuilder)
return;
}

otherRestAction = callback.reply(builder.build()).setEphemeral(hidden);
otherRestAction = callback.reply(builder.build())
.setPoll(poll)
.setEphemeral(hidden);
}
} else {
final MessageEvent event = (MessageEvent) e;
messageRestAction = event.getMessageChannel().sendMessage(builder.build()).setMessageReference(reference);
messageRestAction = event.getMessageChannel().sendMessage(builder.build())
.setPoll(poll)
.setMessageReference(reference);
}
}

Expand Down

0 comments on commit 879010c

Please sign in to comment.