discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.25k stars 3.95k forks source link

getNumber() function is unusable due to API changes #8295

Closed link-discord closed 2 years ago

link-discord commented 2 years ago

Which package is this bug report for?

discord.js

Issue description

The interaction.options.getNumber() function (for slash commands) can't resolve the option value because it expects the option to be of type 4 but due to api changes the option type for numbers is now 10

https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type

Error:

[Error] TypeError [CommandInteractionOptionType]: Option "threshold" is of type: 4; expected 10. TypeError [CommandInteractionOptionType]: Option "threshold" is of type: 4; expected 10.
    at CommandInteractionOptionResolver._getTypedOption (/app/node_modules/discord.js/src/structures/CommandInteractionOptionResolver.js:99:13)
    at CommandInteractionOptionResolver.getNumber (/app/node_modules/discord.js/src/structures/CommandInteractionOptionResolver.js:182:25)
    at SetThresholdCommand.execute (/app/dist/commands/set-threshold.js:34:47)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async InteractionEvent.execute (/app/dist/events/interactionCreate.js:17:13)

Code sample

const number = interaction.options.getNumber('option')

Package version

14.0.0-dev.1657757514-fe34f48

Node.js version

Node.js version 16.14.0, Typescript version 4.7.4

Operating system

Linux Ubuntu

Priority this issue should have

Medium (should be fixed soon)

Which partials do you have configured?

Channel, Message

Which gateway intents are you subscribing to?

Guilds, GuildMessages, MessageContent

I have tested this issue on a development release

fe34f48

vladfrangu commented 2 years ago

This sounds more like an issue in your command's option (its defined as type 4) whereas number is type 10. Are you sure your option is a NUMBER one and not an INTEGER one?

link-discord commented 2 years ago

Ooooooooooooooooooooooooooohhh Ok I feel insanely stupid now sorry