Interaction class

I created a handler that loads the commands and executes the run function when they are called, nothing unusual. The problem is that I pass the interaction as an argument to the function, but for some reason, inside the run function it is an incomplete object that does not have some properties like "options", and in the event receiver that executes the run function of commands, it is a class that contains the "options" property, how can I solve this? typescript: 5(beta)
3 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Sexus Prime
Sexus PrimeOP2y ago
node: v16.19.0
bot.on('interactionCreate', (interaction) => {
if(!interaction.isChatInputCommand()) return;

const selectedCommand = bot.commands.get(interaction.commandName);

if(selectedCommand) {
const responseMethods = ResponseMethods.get();
Object.assign(interaction, responseMethods);

selectedCommand.run({ bot, interaction });
}
})
bot.on('interactionCreate', (interaction) => {
if(!interaction.isChatInputCommand()) return;

const selectedCommand = bot.commands.get(interaction.commandName);

if(selectedCommand) {
const responseMethods = ResponseMethods.get();
Object.assign(interaction, responseMethods);

selectedCommand.run({ bot, interaction });
}
})
static async run(interaction: ChatInputCommandInteraction) {
console.log()
let groupSubCommand = interaction.options.data.find(d => d.type === 2)?.name;
let subCommand = interaction.options.data.find(d => d.type === 1)?.name;

if(groupSubCommand) {
executionPaths[groupSubCommand][<string>subCommand](interaction);
}
else if(subCommand) {
executionPaths[subCommand](interaction);
}
else {
executionPaths.main(interaction);
}
}
static async run(interaction: ChatInputCommandInteraction) {
console.log()
let groupSubCommand = interaction.options.data.find(d => d.type === 2)?.name;
let subCommand = interaction.options.data.find(d => d.type === 1)?.name;

if(groupSubCommand) {
executionPaths[groupSubCommand][<string>subCommand](interaction);
}
else if(subCommand) {
executionPaths[subCommand](interaction);
}
else {
executionPaths.main(interaction);
}
}
d.js docs
d.js docs2y ago
The order of function parameters must match between definition and function call.
function execute(client, message, args) { ... };
execute(message, client, args);
function execute(client, message, args) { ... };
execute(message, client, args);
• mismatch! you pass a Message where the client is expected • mismatch! you pass the Client where a Message is expected
Want results from more Discord servers?
Add your server