Home > Software design >  TypeError [COMMAND_INTERACTION_OPTION_EMPTY]: Required option "message" is of type: _MESSA
TypeError [COMMAND_INTERACTION_OPTION_EMPTY]: Required option "message" is of type: _MESSA

Time:12-18

Why does this code throw error?

client.on("interaction", interaction => {
  if (!interaction.isContextMenu()) return;
  const msg = interaction.getMessage("message", true);
});
TypeError [COMMAND_INTERACTION_OPTION_EMPTY]: Required option "message" is of type: _MESSAGE; expected a non-empty value.

I'm using discord.js v 13 and the djs server couldn't help me.

Please help? thank you

Btw I have no intents because this is going to be application.commands only bot, so I have intents of intents: []

CodePudding user response:

Even though other sources may outline that you don't need any intents for an interaction-only bot that has only the application.commands scope, discord.js requires the GUILDS or 1 scope.

Your new client constructor should be:

const client = new Client({
  intents: 1,
  // ... rest of the client constructor
});

Also, the interaction event is deprecated. Use interactionCreate instead, it's the exact same thing, just a different name.

  • Related