#client.channels.cache.get or client.channels.fetch doesn't have send function
31 messages · Page 1 of 1 (latest)
• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.
you need to check if channel is text-based .isTextBased()
because you can send messages only in text-based channels
no you are wrong
this will return boolean
i tried
just sending a message in specific channel
Referring to this
"nope" is not an answer to "What exactly did you try?"
When you said you tried this solution, what modifications did you make?
i didn't modified on channel class
literary copied from this https://discordjs.guide/popular-topics/faq.html#how-do-i-send-a-message-to-a-specific-channel
using typescript anyway
That’s bc it’s a type guard
channel // Channel
if (!channel.isTextBased()) return …
channel // TextBasedChannel```
thank you, its working. i didn't know the concept of type guard
More on type guard methods https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates
I don't know if it will autocomplete like that but .send() should work
yo
this doesn't work in collector string select menu
i.channel // Channel
if (!i.channel?.isTextBased()) return …
i.channel // Channel
it is bug?
wait nvm
i think its code bug
const collector = options.createMessageComponentCollector({
time: 30_000,
componentType: ComponentType.StringSelect,
})
collector.on("collect", (i) => {
interaction.editReply({
content: `**Creating Ticket**... (1-3s)`,
components: [],
});
const channel = client.channels.cache.get(client.config.ticket.channel);
if(!channel?.isTextBased()) return;
channel?.isTextBased()
});