1 year ago
#386354
Théo
Discord.JS property 'send' does not exist on type 'AnyChannel'
I'm trying to send a message when a Discord bot is ready and more generally without waiting for a message or an interaction.
I tried 2 ways to do so:
client.guilds.cache
.find((guild) => guild.id === "xxxxxxxxxxxxxxxxxx")
.channels.cache.find((channel) => channel.id === "xxxxxxxxxxxxxxxxxx")
.send("Some content");
client.channels.cache
.find((channel) => channel.id === "xxxxxxxxxxxxxxxxxx")
.send("Some content");
Both work well and the message is sent to the specified channel, but because I'm using typesrcript I get an error that says:
Property 'send' does not exist on type 'AnyChannel'.
Property 'send' does not exist on type 'CategoryChannel'.
After taking a look at the documentation, it seems that there is no method called "send" in AnyChannel or CategoryChannel types.
So my question is the following:
- Why is there a "send" method if it is not described in typescript? Is it an oversight?
- Is there an other way to send a message in a channel when the bot is ready without the need to add
// @ts-ignore
--
Edit: Figured out that this question is a duplicate of this thread that answers the question
node.js
typescript
discord.js
0 Answers
Your Answer