Skip to content

"data.map is not a function" when using REST/Channels.getPollAnswerUsers method #149

Description

Hello 👋
While I was testing the version 1.10.0 to see which users voted the answers from a poll, I used this code

const data = await client.rest.channels.getPollAnswerUsers(
  "CHANNEL_ID",
  "MESSAGE_ID",
  1
);

But when I was executing that code, I saw this error

TypeError: data.map is not a function

I did a custom request to see what was the response, so I used this code

const data = await client.rest.authRequest({
  method: "GET",
  path: "/channels/CHANNEL_ID/polls/MESSAGE_ID/answers/1",
});
{
  users: [
    // Discord API User Objects
  ]
}

So, from this line

const users = data.map(user => this.#manager.client.users.update(user));

I think it should be changed to this due to response body being an object with an array of users inside

const users = data.users.map(user => this.#manager.client.users.update(user));

Thanks for reading

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions