Error with commands

Hey, here is my code: const { ApplicationCommandOptionType, PermissionFlagsBits, } = require('discord.js');
module.exports = { deleted: false, name: 'embed', description: 'Embed a certain message!', // devOnly: Boolean, // testOnly: Boolean, options: [ { name: 'embed', description: 'The embed to send.', required: true, type: ApplicationCommandOptionType.String, choices: [ { name: 'rules', value: '1', }, ], }, ], permissionsRequired: [PermissionFlagsBits.Administrator], botPermissions: [PermissionFlagsBits.Administrator],
callback: (interaction) => { console.log('Interaction options:', interaction.options);
const category = interaction.options.getString('embed'); console.log('Embed option:', embed);
if (embed && embed.value === "rules") { // Perform actions specific to the embed command with the whyimbetter option value of 1 interaction.reply('Embed with whyimbetter option value of 1'); } else { // Perform actions specific to the embed command without the whyimbetter option interaction.reply('Embed without whyimbetter option'); } }, }; It generates: ⏩ Skipping registering command "ban" as it's set to delete. Interaction options: { closeTimeout: 5000, waitGuildTimeout: 15000, shardCount: 1, makeCache: [Function (anonymous)], partials: [], failIfNotExists: true, presence: { status: 'online', user: { id: null } }, sweepers: { threads: { interval: 3600, lifetime: 14400 } }, ws: { large_threshold: 50, version: 10, presence: { activities: [], afk: false, since: null, status: 'online' } }, rest: { agent: null, api: 'https://discord.com/api', authPrefix: 'Bot', cdn: 'https://cdn.discordapp.com', headers: {}, invalidRequestWarningInterval: 0, globalRequestsPerSecond: 50, offset: 50, rejectOnRateLimit: null, retries: 3, timeout: 15000, userAgentAppendix: undefined, version: '10', hashSweepInterval: 14400000, hashLifetime: 86400000, handlerSweepInterval: 3600000, makeRequest: [AsyncFunction: makeRequest] }, jsonTransformer: [Function: toSnakeCase], intents: IntentsBitField { bitfield: 33283 }, shards: [ 0 ] } There was an error running this command: TypeError: interaction.options.getString is not a function
4 Replies
d.js toolkit
d.js toolkit9mo 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!
monbrey
monbrey9mo ago
You've mixed up your params
d.js docs
d.js docs9mo ago
The order of function parameters must match between definition and function call.
function execute(client, interaction) { ... };
execute(interaction, client);
function execute(client, interaction) { ... };
execute(interaction, client);
- mismatch! you pass an interaction where the client is expected - mismatch! you pass the client where an interaction is expected
monbrey
monbrey9mo ago
Those are the client options, not the interaction options
Want results from more Discord servers?
Add your server