Closed rakosi2 closed 4 months ago
Personally speaking, I feel like this would not be a reliable way at all to check for polls.
While I haven't encountered any other cases, I'm sure there can be situations where a message may not contain any content while of message type default (I would assume Webhook messages can be?). This just wouldn't be reliable in the slightest.
What should be done instead is to request proper addition of API from Discord, so that bots have a reliable way of figuring out if a message is a poll... As an example:
poll
attribute in the Message object or alternatively a POLL
message typeI agree that Polls in their current form are a mess to put it very simple, so changes are necessary here.
In the meantime, set up auto-mod rules, since Polls also are send through it, so if you have a decent auto-mod setup, polls may not get send at all.
If you look at the raw data, it is similar to an embed but unlike an embed, only one poll can be in a message.
I've looked at the API docs repository of Discord and it seems there is actually API available, just not yet documented. And from what I can see is it pretty much what I was talking about above, meaning:
poll?
attribute in the retrieved message/interaction object that also contains info such as the question, answers, expiry date, etc.So, we better should wait for the docs to be finalized and published before making any changes to JDA here.
If your goal is to know if a poll is in a message, you can check it the data Discord sends with [MessageReceivedEvent.getRawData()
](https://docs.jda.wiki/net/dv8tion/jda/api/events/GenericEvent.html#getRawData()), after enabling JDABuilder#setEventPassthrough
There is a usable PR (#2649), which implements polls. However, the underlying API is still somewhat unstable and not fully released by Discord.
This is now supported in 5.0.0-beta.23
General Troubleshooting
Feature Request
Allow getMessage() to see if the message contains a poll and get its contents. Currently, there is no way to disable polls and anyone with send message perms are able to send polls. Discord has now enabled polls on all servers and this is causing users to bypass filters and create spam. Messages with polls are currently MessageType.DEFAULT and have content of "".
https://support.discord.com/hc/en-us/articles/22163184112407-Polls-FAQ#h_01HSED5BPEDH4YYFVVCXQ2NKZ1
Example Use-Case