discord-jda / JDA

Java wrapper for the popular chat & VOIP service: Discord https://discord.com
Apache License 2.0
4.28k stars 737 forks source link

Polls #2646

Closed rakosi2 closed 4 months ago

rakosi2 commented 5 months ago

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

getMessage().getPoll()
Andre601 commented 5 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:

I 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.

rakosi2 commented 5 months ago

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.

Andre601 commented 5 months ago

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:

So, we better should wait for the docs to be finalized and published before making any changes to JDA here.

freya022 commented 5 months ago

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

MinnDevelopment commented 5 months ago

There is a usable PR (#2649), which implements polls. However, the underlying API is still somewhat unstable and not fully released by Discord.

MinnDevelopment commented 4 months ago

This is now supported in 5.0.0-beta.23