Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

88
Vistas
Discord JS v12 Add Field Issues
let xp = db.get(`xpchannel_${message.guild.id}`)
let wel = db.get(`welchannel_${message.guild.id}`)
let px = db.get(`prefix_${message.guild.id}`)
let defaultprefix = '.'

let disabled = ':white_circle: Disabled'

let embed = new Discord.MessageEmbed()
    .setColor(ee.color)
    .setAuthor('Database Settings', client.user.avatarURL())
    .setThumbnail(ee.thumbnail)
    .addFields(
        { name: '__**XP Channel**__', value: `${xp || `${disabled}`}`, inline: true },
        { name: '__**Welcomer Channel**__', value: `${wel || `${disabled}`}`, inline: true },
        { name: '__**Set Prefix**__', value: `\`${px || `${defaultprefix}`}\``, inline: true },
    )

if (!message.member.permissions.has('ADMINISTRATOR')) {
    return message.channel.send("<:warning:943421375526355024> | **You Need `ADMINISTRATOR` Permissions To Use This Command!**");
}

message.channel.send(embed)

Whenever I use this command and theres a xp channel or welcomer channel in the database it returns the channel id instead of the channel itself, I have tried to fix this by adding <# > at the front and end of the variable but then when theres no channel in the database it returns <#null> instead of the disabled variable. How would i fix that?

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

You should check if the values of those variables (xp and wel) are truthy. If they are, the channel ID is returned from the database, you can squeeze them beetween <# and >. If the returned value is null, you can simply pass the disabled variable:

.addFields(
  {
    name: '__**XP Channel**__',
    value: xp ? `<#${xp}>` : disabled,
    inline: true,
  },
  {
    name: '__**Welcomer Channel**__',
    value: wel ? `<#${wel}>` : disabled,
    inline: true,
  },
  {
    name: '__**Set Prefix**__',
    value: `\`${px || defaultprefix}\``,
    inline: true,
  },
);

about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda