TypeScript .getSubcommand() issue

Hello there. I'll make this as short as possible. I am starting to port over my code to TypeScript for the sake of making my development process much faster and save myself from unecessary bugs. While porting over my base classes, I came across an issue. For some reason, the .getSubcommand() function is highlighted red. Not sure what I can do. A picture of what I'm talking about is attached. I'll send the code in another message since I don't have enough space here. Thank you for your time and help, they are truly appreciated.
2 Replies
d.js toolkit
d.js toolkit16mo 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!
Batimius
BatimiusOP16mo ago
static startup() {
try {
SlashCommandBase.client.on('interactionCreate', async inter => {
if (!inter.isCommand()) return

try {
if (inter.user.id === SlashCommandBase.client.user.id) return
let subCommand = inter.options.getSubcommand(false)
if (subCommand) {
if (subCommand in SlashCommandBase.commandSubGroups) {
let command = SlashCommandBase.commandSubGroups[subCommand]
if (command.commandEnabled) {
await command.invoke(inter)
} else {
await inter.reply({content: `${inter.user}, Command is disabled.`, ephemeral: true})
}
}
return
}

if (inter.commandName in SlashCommandBase.commands) {
let command = SlashCommandBase.commands[inter.commandName]
if (command.commandEnabled) {
await command.invoke(inter as ChatInputCommandInteraction)
} else {
await inter.reply({content: `${inter.user}, Command is disabled.`, ephemeral: true})
}
}
} catch (error) {
console.error(error)
}
});
} catch {
return
}

SlashCommandBase.clientReady = true
}
static startup() {
try {
SlashCommandBase.client.on('interactionCreate', async inter => {
if (!inter.isCommand()) return

try {
if (inter.user.id === SlashCommandBase.client.user.id) return
let subCommand = inter.options.getSubcommand(false)
if (subCommand) {
if (subCommand in SlashCommandBase.commandSubGroups) {
let command = SlashCommandBase.commandSubGroups[subCommand]
if (command.commandEnabled) {
await command.invoke(inter)
} else {
await inter.reply({content: `${inter.user}, Command is disabled.`, ephemeral: true})
}
}
return
}

if (inter.commandName in SlashCommandBase.commands) {
let command = SlashCommandBase.commands[inter.commandName]
if (command.commandEnabled) {
await command.invoke(inter as ChatInputCommandInteraction)
} else {
await inter.reply({content: `${inter.user}, Command is disabled.`, ephemeral: true})
}
}
} catch (error) {
console.error(error)
}
});
} catch {
return
}

SlashCommandBase.clientReady = true
}
Ah, I see. I'll try that and send an update here. Yep. It works perfectly. Thank you for the help!
Want results from more Discord servers?
Add your server