Weird bug (?) with typescript and SlashCommandBuilders
I've ran into a weird issue with ts and SlashCommandBuilders
4 Replies
⢠What's your exact discord.js
npm list discord.js and node node -v version?
⢠Post the full error stack trace, not just the top part!
⢠Show your code!
⢠Explain what exactly your issue is.
⢠Not a discord.js issue? Check out #useful-servers.To declare the data type use
Pick<SlashCommandBuilder, 'name' | 'toJSON'> and other properties you actually need.i maybe should've used pastebin
ah
that fixes it indeed, still weird though that changing the position of .setDMPermissions solved it in my previous code
Changing the position of
#setDMPermissions() "solved" it before because the type check you had in place was for a SlashCommandBuilder and it seems that setting the DM permissions after a slash command option removes the omitted generic from the instance. As Syjalo already pointed out, adding a generic to account for this in your check removes the issue all together as it allows for this omitted generic to pass the type check as well as a regular SlashCommandBuilder instance :P