How to use getAnswerVoters for new polls

Not sure if its just not fully implemented yet or what but I cant seem to figure out how to get the function to be called. Dont see any examples anywhere for it either. I never get to that logger.info(pollAPI). I just get back Cannot read properties of undefined (reading 'poll') (user-service). Any ideas? Or am I just trying to use new stuff too quickly lol?
const pollAPI = client.api.poll;
const answerIds = ['yes', 'no', 'maybe'];
logger.info(pollAPI);
for (const answerId of answerIds) {
try {
const voters = await pollAPI.getAnswerVoters(
activePoll.channelId,
activePoll.messageId,
`${answerId}_${activePoll.pokerId}`,
{ limit: 100 }
);
logger.info(`Poll: ${JSON.stringify(voters, null, 2)}`);
const pollAPI = client.api.poll;
const answerIds = ['yes', 'no', 'maybe'];
logger.info(pollAPI);
for (const answerId of answerIds) {
try {
const voters = await pollAPI.getAnswerVoters(
activePoll.channelId,
activePoll.messageId,
`${answerId}_${activePoll.pokerId}`,
{ limit: 100 }
);
logger.info(`Poll: ${JSON.stringify(voters, null, 2)}`);
10 Replies
d.js toolkit
d.js toolkit5mo 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!
duck
duck5mo ago
just to clarify, are you using discord.js or @discordjs/core?
synik4l
synik4lOP5mo ago
discord.js i was kind of just stumbling around. i dont know if im using the right stuff at all for this lol. Just basically trying to get the responses period. Whatever the "correct" way is now for the new style polls.
duck
duck5mo ago
this code appears to be for @discordjs/core <Client>.api and PollAPI don't exist in discord.js you can fetch an answer's voters by id with <TextChannel>.messages.fetchPollAnswerVoters()
d.js docs
d.js docs5mo ago
:method: MessageManager#fetchPollAnswerVoters @14.15.3 Fetches the users that voted for a poll answer.
synik4l
synik4lOP5mo ago
ah yes i was just noticing that theres a difference lol between the two. Okay. Cool. So that still works for the newer style polls?
No description
synik4l
synik4lOP5mo ago
Thse ones?
NyR
NyR5mo ago
Yes, I mean those are the only type of polls by discord
synik4l
synik4lOP5mo ago
Hmm. but didnt those style polls just come out? They are sent differently than the old ones Got it. I was being dumb how i was sending the parameters for it. Was sending the message id and answer id as strings. Thanks
duck
duck5mo ago
the old ones being reaction/component based polls? it's not as if the api recognized those as polls, just reactions/components while these new polls are recent, there wasn't an actual predecessor, so it's not as if these methods could have been for reaction/component based polls
Want results from more Discord servers?
Add your server