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

192
Views
How to send message to specified Channel - Discord.js v13 TypeScript

I have recently started using TypeScript, and as you are all surely aware Discord.js has recently moved to v13. Following this I have been struggling to find a way to send messages to a specified channel using a given Channel ID. Here is the current code I use:

// Define Channel ID
const messageChannelId = 'CHANNEL_ID';

// Define Channel
const messageChannel = client.channels.cache.get(messageChannelId);

// Send Message to Channel
if (messageChannel && messageChannel.type === 'GUILD_TEXT') messageChannel.send('Hello World');

Oddly enough, the following code works fine and it sends the message 'Hello World' to the channel, but I always end up with an intellisense error when I hover over the send method that says Property 'send' does not exist on type 'Channel' in Visual Studio Code. If anyone knows why this happens, or has a solution to this error, please let me know. The documentation for Discord.js does not show the send method on the Channel type, but still allows it to work and I do not know a way around this.

Thanks for any assistance.

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

0

The send method is not on type Channel. It is on type TextChannel. client.channels.cache.get returns a Channel as it could be a voice channel too! You will have to add as TextChannel to remove that error

const { TextChannel } = require('discord.js')
// Define Channel
const messageChannel = client.channels.cache.get(messageChannelId) as TextChannel;
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!