TypeError: interaction.isCommand is not a function
I made a instagram command however when i try to do the command i get the error
" TypeError: interaction.isCommand is not a function"
export async function InteractionCreate(interaction: BaseInteraction): Promise<void> {
try {
if (interaction.isCommand()) { // General check for command interactions
if (interaction instanceof ChatInputCommandInteraction) {
await handleCommandInteraction(interaction);
}
} else if (interaction.isButton()) {
await handleButtonInteraction(interaction);
}
} catch (error) {
console.error("Error handling interaction:", error);
if (interaction.isRepliable() && !interaction.replied && !interaction.deferred) {
try {
await interaction.reply({
content: "An error occurred while processing your request.",
ephemeral: true
});
} catch (replyError) {
console.error("Error sending error message:", replyError);
}
}
}
}
export async function InteractionCreate(interaction: BaseInteraction): Promise<void> {
try {
if (interaction.isCommand()) { // General check for command interactions
if (interaction instanceof ChatInputCommandInteraction) {
await handleCommandInteraction(interaction);
}
} else if (interaction.isButton()) {
await handleButtonInteraction(interaction);
}
} catch (error) {
console.error("Error handling interaction:", error);
if (interaction.isRepliable() && !interaction.replied && !interaction.deferred) {
try {
await interaction.reply({
content: "An error occurred while processing your request.",
ephemeral: true
});
} catch (replyError) {
console.error("Error sending error message:", replyError);
}
}
}
}
5 Replies
- 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!import { SlashCommandBuilder, EmbedBuilder } from 'discord.js';
import { startOAuthServer } from '../../services/instagram/oauthServer.js';
import { InstagramTokenService } from '../../services/instagram/tokenService.js';
import InstagramToken from '../../typeorm/entities/InstagramToken.js';
export default {
data: new SlashCommandBuilder()
.setName('instagram')
.setDescription('Manage Instagram integration')
.addSubcommand(subcommand =>
subcommand
.setName('setup')
.setDescription('Set up Instagram integration')
.addChannelOption(option =>
option
.setName('channel')
.setDescription('Channel to post Instagram updates')
.setRequired(true)
)
)
.addSubcommand(subcommand =>
subcommand
.setName('status')
.setDescription('Check Instagram integration status')
),
async execute(interaction: any) {
if (!interaction.memberPermissions.has('ADMINISTRATOR')) {
return interaction.reply({
content: '❌ You need administrator permissions to use this command.',
ephemeral: true
});
}
const subcommand = interaction.options.getSubcommand();
if (subcommand === 'setup') {
const channel = interaction.options.getChannel('channel');
await startOAuthServer(interaction, channel);
} else if (subcommand === 'status') {
await handleStatusCheck(interaction);
}
}
};
import { SlashCommandBuilder, EmbedBuilder } from 'discord.js';
import { startOAuthServer } from '../../services/instagram/oauthServer.js';
import { InstagramTokenService } from '../../services/instagram/tokenService.js';
import InstagramToken from '../../typeorm/entities/InstagramToken.js';
export default {
data: new SlashCommandBuilder()
.setName('instagram')
.setDescription('Manage Instagram integration')
.addSubcommand(subcommand =>
subcommand
.setName('setup')
.setDescription('Set up Instagram integration')
.addChannelOption(option =>
option
.setName('channel')
.setDescription('Channel to post Instagram updates')
.setRequired(true)
)
)
.addSubcommand(subcommand =>
subcommand
.setName('status')
.setDescription('Check Instagram integration status')
),
async execute(interaction: any) {
if (!interaction.memberPermissions.has('ADMINISTRATOR')) {
return interaction.reply({
content: '❌ You need administrator permissions to use this command.',
ephemeral: true
});
}
const subcommand = interaction.options.getSubcommand();
if (subcommand === 'setup') {
const channel = interaction.options.getChannel('channel');
await startOAuthServer(interaction, channel);
} else if (subcommand === 'status') {
await handleStatusCheck(interaction);
}
}
};
Error handling interaction: TypeError: interaction.isCommand is not a function
at Object.InteractionCreate (C:\Users\alixd\OneDrive\Bureaublad\forexfactorybot\bot\src\events\InteractionCreate\InteractionCreate.ts:11:25)
at Client.<anonymous> (C:\Users\alixd\OneDrive\Bureaublad\forexfactorybot\bot\src\events\eventhandler.ts:38:58)
at Client.emit (node:events:536:35)
at InteractionCreateAction.handle (C:\Users\alixd\OneDrive\Bureaublad\forexfactorybot\bot\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\alixd\OneDrive\Bureaublad\forexfactorybot\bot\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\Users\alixd\OneDrive\Bureaublad\forexfactorybot\bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:348:31)
at WebSocketManager.<anonymous> (C:\Users\alixd\OneDrive\Bureaublad\forexfactorybot\bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:232:12)
at WebSocketManager.emit (C:\Users\alixd\OneDrive\Bureaublad\forexfactorybot\bot\node_modules\@vladfrangu\async_event_emitter\src\index.ts:513:28)
at WebSocketShard.<anonymous> (C:\Users\alixd\OneDrive\Bureaublad\forexfactorybot\bot\node_modules\@discordjs\ws\src\strategies\sharding\SimpleShardingStrategy.ts:32:47)
at WebSocketShard.emit (C:\Users\alixd\OneDrive\Bureaublad\forexfactorybot\bot\node_modules\@vladfrangu\async_event_emitter\src\index.ts:513:28)
node:events:502
throw er; // Unhandled 'error' event
^
Error handling interaction: TypeError: interaction.isCommand is not a function
at Object.InteractionCreate (C:\Users\alixd\OneDrive\Bureaublad\forexfactorybot\bot\src\events\InteractionCreate\InteractionCreate.ts:11:25)
at Client.<anonymous> (C:\Users\alixd\OneDrive\Bureaublad\forexfactorybot\bot\src\events\eventhandler.ts:38:58)
at Client.emit (node:events:536:35)
at InteractionCreateAction.handle (C:\Users\alixd\OneDrive\Bureaublad\forexfactorybot\bot\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\alixd\OneDrive\Bureaublad\forexfactorybot\bot\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\Users\alixd\OneDrive\Bureaublad\forexfactorybot\bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:348:31)
at WebSocketManager.<anonymous> (C:\Users\alixd\OneDrive\Bureaublad\forexfactorybot\bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:232:12)
at WebSocketManager.emit (C:\Users\alixd\OneDrive\Bureaublad\forexfactorybot\bot\node_modules\@vladfrangu\async_event_emitter\src\index.ts:513:28)
at WebSocketShard.<anonymous> (C:\Users\alixd\OneDrive\Bureaublad\forexfactorybot\bot\node_modules\@discordjs\ws\src\strategies\sharding\SimpleShardingStrategy.ts:32:47)
at WebSocketShard.emit (C:\Users\alixd\OneDrive\Bureaublad\forexfactorybot\bot\node_modules\@vladfrangu\async_event_emitter\src\index.ts:513:28)
node:events:502
throw er; // Unhandled 'error' event
^
The order of function parameters must match between definition and function call.
- mismatch! you pass an interaction where the client is expected
- mismatch! you pass the client where an interaction is expected
function execute(client, interaction) { ... };
execute(interaction, client);
function execute(client, interaction) { ... };
execute(interaction, client);
also dont type as any
Those permissions are incorrect (which ts would tell you if you typed correctly )
are you talking about this code?