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

205
Views
DiscordJS v13 No se pueden leer las propiedades de undefined (leyendo 'canales')

Código:

 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] }) }

Al agregar un banner al servidor, da el error Unhandled Rejection: TypeError: Cannot read properties of undefined (reading 'channels')

Los otros archivos de registro tienen exactamente la misma línea de código const logChannel = await client.channels.cache.get(config.log_channel_id); y funciona bien

Agregar console.log(client) antes const logChannel devuelve undefined

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Este código a continuación funciona después de que solucionamos el problema.

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 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!