#commandName is not definedd
1 messages · Page 1 of 1 (latest)
Correct, it is indeed not a function
Well, not even variable it seems so it doesn't exist under Interaction object
It does though, assuming its a command interaction
Hadn't you posted code?
Can you please share your code and the error from the console?
public listen(): Promise<string> {
this.client.on(Events.InteractionCreate, (interaction) => {
switch (interaction.type) {
case InteractionType.ModalSubmit:
this.interactionResponder.handle(interaction);
break;
case InteractionType.ApplicationCommand:
this.commandResponder.handle(interaction.commandName);
break;
}
});
return this.client.login(this.token);
}
Not on the computer rn, I'll quickly get on in a moment to send you the error but basically it doesn't see commandName as part of Interaction object
public listen(): Promise<string> {
this.client.on(Events.InteractionCreate, (interaction) => {
console.log(interaction.commandName)
});
return this.client.login(this.token);
}
Property 'commandName' does not exist on type 'StringSelectMenuInteraction<CacheType>'.ts(2339)
Well that error is correct, you havent got any typeguarding on the second example
If you want to typeguard use the interaction.isModalSubmit() methods
BaseInteraction#isChatInputCommand()
Indicates whether this interaction is a [ChatInputCommandInteraction](<https://old.discordjs.dev/#/docs/discord.js/14.9.0/class/ChatInputCommandInteraction>).