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

204
Views
¿Cómo puedo crear campos opcionales para incrustar campos en mi bot de discordia?

Este es mi código simple. y necesito campos opcionales (fd, fdd) en mi constructor de inserción de comando slesh. ¿Como lo puedo hacer? los campos vacíos no se eliminan , por lo tanto, si el valor de mi campo está vacío, entonces no aparece, y si el campo tiene un valor, entonces agregue incrustado. valores opcionales.

 const desc = options.getString("leírás"); const fd1 = options.getString("field1"); const fd2 = options.getString("field2"); const fd3 = options.getString("field3"); const fdd1 = options.getString("fielddesc1"); const fdd2 = options.getString("fielddesc2"); const fdd3 = options.getString("fielddesc3"); //cache.find(role => role.id === "967822275355246732");A const Response = new MessageEmbed() .setColor("RANDOM") .setDescription(`${interaction.member} létrehozott egy <@&963762743150796810>-t, **${type}** kategóriával.`) .setThumbnail('https://media.discordapp.net/attachments/967828295121006592/969690574674354337/958794200999145513.png') .addField("⟬Cím⟭", `${title}`) .addField("⟬Leírás⟭", `${desc}`) .addField(`${fd1}`, `${fdd1}`) .addField(`${fd1}`, `${fdd1}`) .addField(`${fd2}`, `${fdd2}`) .addField(`${fd3}`, `${fdd3}`) .setFooter({text: "*`Telihold, Tele mosoly :)`*"}) .setTimestamp() const message = await interaction.reply({embeds: [Response], fetchReply: true}); message.react('🔥') .then(() => message.react('❤️')) .catch(error => console.error('Nem tudom betölteni az egyik hangulatjelet', error)); }

}

///Lo intenté de esta manera pero no bien///

 .addField("⟬Cím⟭", `${title}`) .addField("⟬Leírás⟭", `${desc}`) .setFooter({text: "*`Telihold, Tele mosoly :)`*"}) .setTimestamp() const message = await interaction.reply({embeds: [Response], fetchReply: true}); message.react('🔥') .then(() => message.react('❤️')) .catch(error => console.error('Nem tudom betölteni az egyik hangulatjelet', error)); if (`${fd1}`) Response.addField(`${fd1}`, `${fdd1}`) if (`${fd2}`) Response.addField(`${fd1}`, `${fdd1}`) if (`${fd3}`) Response.addField(`${fd1}`, `${fdd1}`) return interaction.reply({embeds: [Response], fetchReply: true});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Use una declaración if para verificar si la variable existe primero.

 let Response = new MessageEmbed() .setColor("RANDOM") .setDescription(` egy <@&963762743150796810>-t, kategóriával.`) .setThumbnail('https://media.discordapp.net/attachments/967828295121006592/969690574674354337/958794200999145513.png') .addField("⟬Cím⟭", `abc`) .addField("⟬Leírás⟭", `def`) .setFooter({ text: "*`Telihold, Tele mosoly :)`*" }) .setTimestamp() if (fd1) { Response.addField(`${fd1}`, `${fdd1}`) }

Entonces podrá evitar que diga "nulo" cuando la variable no esté configurada.

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!