Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

94
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda