New discord Poll detection

is it possible to detect if a message is actually a poll (new discord poll) via API?
12 Replies
d.js toolkit
d.js toolkit9mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Toast
Toast9mo ago
Raw API, yes. Djs currently don't support it. I think it's in APIMessage or something.
sludge
sludge9mo ago
not through DJS directly, but on the API yes, messages with a poll in them have a new poll property that contains everything relating to the poll
"poll": {
"question": {
"text": "testing"
},
"answers": [
{
"answer_id": 1,
"poll_media": {
"text": "1"
}
},
{
"answer_id": 2,
"poll_media": {
"text": "2"
}
}
],
"expiry": "2024-04-11T14:30:13.975179+00:00",
"allow_multiselect": false,
"layout_type": 1,
"results": {
"answer_counts": [],
"is_finalized": false
}
}
"poll": {
"question": {
"text": "testing"
},
"answers": [
{
"answer_id": 1,
"poll_media": {
"text": "1"
}
},
{
"answer_id": 2,
"poll_media": {
"text": "2"
}
}
],
"expiry": "2024-04-11T14:30:13.975179+00:00",
"allow_multiselect": false,
"layout_type": 1,
"results": {
"answer_counts": [],
"is_finalized": false
}
}
Lopunny Owner
Lopunny Owner9mo ago
how can i access this data? its not included in the messageCreate message data
sludge
sludge9mo ago
well of course, because DJS doesn't support it yet but the data is there on the API directly
Lopunny Owner
Lopunny Owner9mo ago
alright i just used events.raw to detect a poll
Mark
Mark9mo ago
GitHub
feat: polls by almeidx · Pull Request #10185 · discordjs/discord.js
Please describe the changes this PR makes and why it should be merged: Added support for polls. Upstream: discord/discord-api-docs#6746 Depends on: discordjs/discord-api-types#925 Status and ve...
darp
darp9mo ago
dont spoonfeed also that can quickly get bot ratelimited no i mean fetching message part
souji
souji9mo ago
don't need to do that, listen for raw/the dispatch event on client#ws, match the event and make the delete rest call that fetch not being associated with the rest instance, so not respecting rate limits is a huge issue
Exa
Exa9mo ago
Definitely seems like a clunky workaround yeah. I worked my way through the raw event and figured out a way to detect a poll, timeout the poster, and delete the poll, in my own script.
souji
souji9mo ago
lol, timeout anyone who makes a poll it's immensely funny to see how people overreact over polls
Exa
Exa9mo ago
I mean it's a one minute timeout to dissuade spamming them I have a server with ~11k people in it and we use automod, which seems not to work in polls. I'd just as soon disallow polls, but Discord as usual decided not to provide a functional permission for this feature. Sometimes if you want something to work right you just have to do it yourself.
Want results from more Discord servers?
Add your server