Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

147
Views
Recibir los parámetros del comando de barra discord.js

Actualmente estoy tratando de hacer un cálculo utilizando la entrada de parámetros a través de un comando de barra inclinada. Ponerlos funciona bien, sin embargo, no sé cómo recuperarlos. el código actual produce un error TypeError: Cannot read properties of undefined (reading 'get') lo que me tiene bastante confundido, ya que la documentación de discord.js muestra que dicha función debería existir y ser exactamente lo que estoy buscando.

 const { SlashCommandBuilder } = require('discord.js'); module.exports = { data: new SlashCommandBuilder() .setName('manacost') .setDescription('Calculates the ´soul spawn cost using your inputs') .addStringOption(option => option.setName('health') .setDescription('The amount of health your soul has. Supports k=1000...') .setRequired(true)) .addStringOption(option => option.setName('damage') .setDescription('The amount of damage your soul has. Supports k=1000...') .setRequired(true)) .addIntegerOption(option => option.setName('breeze') .setDescription('The amount of breeze you have.(0-80)') .setRequired(false)), async execute(interaction) { if (!interaction.isChatInputCommand()) return; let hp = interaction.options.get('health'); let dmg = interaction.option.get('damage'); let b = interaction.option.get('breeze'); console.log({hp, dmg, b}); await interaction.reply({content: hp, dmg, b}); }, }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Las opciones de interacción se pueden encontrar mediante interaction.option.getString() o interaction.option.getInteger() . También en su Código ha mezclado interaction.options e interaction.option . Solo debe usar las opciones de interaction.options .

Eso significa que su código tiene que cambiar de

 let hp = interaction.options.get('health'); let dmg = interaction.option.get('damage'); let b = interaction.option.get('breeze');

a

 let hp = interaction.options.getString('health'); let dmg = interaction.options.getString('damage'); let b = interaction.options.getInteger('breeze');

Debería echar un vistazo a esta publicación de la guía discord.js para obtener más información y ver los otros tipos de opciones.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!