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

219
Visualizações
I can't send a message to a specific channel discordjs

I was trying to send a message to a specific channel so I use the script below

let msg = "I am a message"
clients.channels.cache.get("902208249099612170").send(msg)

but all I got were this error

clients.channels.cache.get("902208249099612170").send(msg)
                                                 ^

TypeError: Cannot read properties of undefined (reading 'send')

I have no idea why can't it send a message, I am using discord js v13, anyone has any idea what is the problem? Thanks

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

The channel might not exist in the client's cache. Try fetching the channel instead:

clients.channels.fetch("902208249099612170").then((channel) => channel.send(msg));

// Or with async/await
const channel = await clients.channels.fetch("902208249099612170");
channel.send(msg)
about 4 years ago · Juan Pablo Isaza Relatório

0

It means that the channel either doesn't exist or the bot can't see the channel/server the channel is in. Try catching it :

let msg = "This is a message."
clients.channels.fetch("902208249099612170")
.then((channel) => channel.send(msg));
.catch(err => console.log("Could not find the channel."))
about 4 years ago · Juan Pablo Isaza Relatório

0

Well, I found the problem. Actually, there are multiple clients on the file and the one logged in to the bot isn't the one sending the message to the specific channel so that's why I am unable to send it. Sorry if I wasted you guys' time 😓.

Lesson learned: When you want to send a message to a specific channel make sure the client is logged into the bot's token!

about 4 years ago · Juan Pablo Isaza 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