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

216
Vistas
DiscordJS v13 Cannot read properties of undefined (reading 'channels')

Code:

const config = require('../../config.json');
const Discord = require('discord.js');

module.exports = async(guild, bannerURL, client) => {
    const logChannel = await client.channels.cache.get(config.log_channel_id);
    if (!logChannel) return;
    const embed = new Discord.MessageEmbed()
    .setAuthor({ name: guild.name, iconURL: guild.iconURL() })
    .setDescription(`**${guild.name} has banner now!**`)
    .setImage(bannerURL)
    .setColor(config.colour)
    .setTimestamp()
    return logChannel.send({ embeds: [embed] })
}

When adding a banner to the server it gives the error Unhandled Rejection: TypeError: Cannot read properties of undefined (reading 'channels')

The other logging files have the exact same line of code const logChannel = await client.channels.cache.get(config.log_channel_id); and it works fine

Adding console.log(client) before const logChannel returns undefined

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This code below works after we troubleshot the issue.

banner.js

module.exports = {
    name: 'banner',
    description: 'emit update',
    devs: true,
    run: async (guild, message) => {
        guild.emit('guildBannerAdd', message.member);
        message.channel.send('Done ...');
    },
};

guildBannerAdd.js

const config = require('../../config.json')
const Discord = require('discord.js')

module.exports = async (client, member) => {
    const guild = client.guilds.cache.get(config.serverID)
    const logChannel = client.channels.cache.get(config.log_channel_id);
    if (!logChannel) return;
    const embed = new Discord.MessageEmbed()
        .setAuthor({
            name: guild.name,
            iconURL: guild.iconURL()
        })
        .setDescription(`**${guild.name} has banner now!**`)
        .setImage(guild.bannerURL())
        .setColor(config.colour)
        .setTimestamp();
    return logChannel.send({
        embeds: [embed]
    });
}
about 4 years ago · Juan Pablo Isaza 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