(all getter I mention below is not a real getter but a function to get something)
when using interaction, getting the following
getBoolean
getChannel
getString
getInteger
getNumber
getUser
getMember
getRole
getMentionable
getMessage
on interaction.options will throw a TypeError
This is due to getting them will involve _getTypedOption which check if the type is correct
when the interaction is created, the options will be transformed using transformOption, which it will add a type property that is typed using discord-api-types v9
The issue is the type passed by the getter and the discord-api-types v9 are different, the type name in the getter is all cap, while discord-api-types are cap only for the first letter. USER (discord-api-types) User (getter)
This issue will make all interactions using the above getter will not work and throw a type error
new SlashCommandBuilder()
.setName('avatar')
.setDescription('Get the avatar URL of the selected user, or your own avatar.')
.addUserOption((option) => option.setName('target').setDescription('The user\'s avatar to show'))
Run the following
client.on('interactionCreate', async (interaction) => {
if (!interaction.isCommand()) return;
interaction.options.getUser('target');
});
Which package is this bug report for?
discord.js
Issue description
(all getter I mention below is not a real getter but a function to get something) when using interaction, getting the following
on
interaction.options
will throw a TypeError This is due to getting them will involve _getTypedOption which check if the type is correctwhen the interaction is created, the options will be transformed using transformOption, which it will add a type property that is typed using discord-api-types v9
The issue is the type passed by the getter and the discord-api-types v9 are different, the type name in the getter is all cap, while discord-api-types are cap only for the first letter. USER (discord-api-types) User (getter)
This issue will make all interactions using the above getter will not work and throw a type error
Code sample
Deploy following command (example from discordjs guide https://github.com/discordjs/guide/blob/main/code-samples/creating-your-bot/command-handling/commands/avatar.js)
Run the following
Package version
14.0.0-dev
Node.js version
v16.13.1
Operating system
Windows 10 Pro 19042.1466
Priority this issue should have
High (immediate attention needed)
Which partials do you have configured?
No Partials
Which gateway intents are you subscribing to?
GUILDS, GUILD_MEMBERS, GUILD_INTEGRATIONS, GUILD_MESSAGES