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

377
Views
How to send a message to a specific channel with Discord.JS

I try all the possibilities of stack overflow on this subject and that doesn't work for me, I think that outdated. I'm on Discord.JS V13.6

So, for the moment, I have this :

const channel = client.channels.cache.get('my_id-channel');
channel.send('content');

I take my_id-channel with a right click on the channel → copy id

My error : Uncaught TypeError: Cannot read property 'send' of undefined

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

0

It's likely the channel doesn't currently exist in the ChannelManager's cache, try using the ChannelManager.fetch() method.

Your code should look something like this:

client.channels.fetch('my_id-channel').then(channel => channel.send('content'));

If you're unfamiliar, a cache is a local temporary storage used to save data temporarily so you don't have to do operations which may take a long time (i.e. requesting information from a server). Essentially this means that a cache is volatile and you can't always guarantee what you're looking for is there.

I suspect in this case the channel has not previously been retrieved so it does not exist in the cache yet.

about 4 years ago · Juan Pablo Isaza Report

0

After a switch ON my brain, I understand my stupid script -_-

I didn't know I'm supposed to write my script here :

client.on("ready", () => {
    // HERE MY CODE
});

So now that's work ^^'

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!