After recently diving into TypeScript and seeing that Discord.js has made the move to v13, I have encountered an issue with sending messages to a specific channel using a Channel ID. Below is the code snippet I am currently using:
// 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');
Interestingly, the above code successfully sends the message 'Hello World' to the designated channel. However, when I hover over the send method, I receive an intellisense error in Visual Studio Code stating
Property 'send' does not exist on type 'Channel'
. If anyone can explain why this occurs or offer a solution, I would greatly appreciate it. The Discord.js documentation does not list the send method under the Channel type, yet it still functions without errors.
Thank you for any assistance provided.