Skip to content

Client#api queries casts "null" and "undefined" to their actual value instead of counting them as a string #5072

@VoltrexKeyva

Description

@VoltrexKeyva

Please describe the problem you are having in as much detail as possible:

So i've been trying to play around with <client>.api and noticed the weird behavior of the query value changing in an unexpected way if given "null" and "undefined" as their value, as you see on the screenehot:
Screenshot_20201202-061204_Discord
first i tried null as a string and it causes a DiscordAPIError instead of returning the expected array of members, also tried with multiple other values as you see on the screenshot:
Screenshot_20201202-063240_Discord
as "null", "undefined" and "voltrex" and as you see, both of the "null" and "undefined" were casted to their original value and not considered a string while "voltrex" did work, however, doing a raw api request using node-fetch as you see on the screenshot:
Screenshot_20201202-072228_Discord
with the same values, all are successful without returning an error

Include a reproducible code sample here, if possible:

// Using <client>.api
<client>.api.guilds(<ID>).members.search.get({
query: {
query: "null",
limit: 1
}
}); // DiscordAPIError: Invalid Form Body query: This field is required

// Using node-fetch
<node-fetch>("https://discord.com/api/guilds/<ID>/members/search?query=null&limit=1", {
headers: {
Authorization: "Bot <Your bot token here>"
}
}).then(res => res.json()); // Returns an array of members as expected

Further details:

  • discord.js version: 12.5.1
  • Node.js version: v14.9.0
  • Operating system: Ubuntu
  • Priority this issue should have – please be realistic and elaborate if possible: low

Relevant client options:

  • partials: none

  • gateway intents: 1935

  • other: none

  • I have also tested the issue on latest master, commit hash:

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