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

592
Vistas
Sending message to specific channel in discord.js

I want to send a message to a specific channel but it doesn't work, I've tried client.guilds.cache.get("<id>").send("<msg>") but I get the error ".send is not a function". What am I missing here?

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

0

You are trying to get from the cache a Guild not a Channel, or more specifically a TextChannel, that's why what you try is not working, you should try to change the code to something like this and it should work.

const channel = client.channels.cache.get('Channel Id');
channel.send({ content: 'This is a message' });

Also, as something extra, I would recommend using the fetch method for these things, since it checks the bot's cache and in the case of not finding the requested object it sends a request to the api, but it depends on the final use if you need it or not.

const channel = await client.channels.fetch('Channel Id');
channel.send({ content: 'This is a message' });
about 4 years ago · Juan Pablo Isaza Denunciar

0

There are three ways of sending message to a specific channel.

1. Using a fetch method

const channel = await <client>.channels.fetch('channelID')
channel.send({content: "Example Message"})

2. Using a get method

const channel = await <client>.channels.cache.get('channelID')
channel.send({content: "Example Message"})

3. Using a find method

a.

const channel = await <client>.channels.cache.find(channel => channel.id === "channelID")
channel.send({content: "Example Message"})

b.

const channel = await <client>.channels.cache.find(channel => channel.name === "channelName")
channel.send({content: "Example Message})

Your current code line is getting the GUILD_ID not the CHANNEL_ID.

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