How do you add commands to user-installed apps?

I'm not sure how to add commands to the apps. I'm using the default deploy script shown from https://discordjs.guide/creating-your-bot/command-deployment.html#guild-commands. Here's the code for the command:
const {SlashCommandBuilder,ApplicationIntegrationType,InteractionContextType} = require("discord.js")
module.exports = {
data: new SlashCommandBuilder()
.setName("test")
.setDescription("user-installed app test")
.setIntegrationTypes(ApplicationIntegrationType.UserInstall)
.setContexts(InteractionContextType.Guild,InteractionContextType.BotDM,InteractionContextType.PrivateChannel),
async execute(interaction){
await interaction.reply("Hello, world!")
}
}
const {SlashCommandBuilder,ApplicationIntegrationType,InteractionContextType} = require("discord.js")
module.exports = {
data: new SlashCommandBuilder()
.setName("test")
.setDescription("user-installed app test")
.setIntegrationTypes(ApplicationIntegrationType.UserInstall)
.setContexts(InteractionContextType.Guild,InteractionContextType.BotDM,InteractionContextType.PrivateChannel),
async execute(interaction){
await interaction.reply("Hello, world!")
}
}
I've deployed it and added it to my user. npm list: 14.16 Node version: 20.16.0
3 Replies
d.js toolkit
d.js toolkit2mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by staff
BestSpark687090
BestSpark687090OP2mo ago
I managed to solve it on my own.
.setIntegrationTypes([ApplicationIntegrationType.UserInstall])
.setContexts(1,2,0)
.setIntegrationTypes([ApplicationIntegrationType.UserInstall])
.setContexts(1,2,0)
I think i needed to set it to the numbers, and the setIntegrationTypes to an array. Not sure though, but it works now.
monbrey
monbrey2mo ago
Neither of those changes should be necessary

Did you find this page helpful?