targetchannel.send is not a function

await client.guilds.cache.map(guild => {
guild.channels.cache.forEach(async channel => {
try {
const targetchannel = client.channels.cache.get(channel.id);
if (targetchannel.permissionsFor(client.user).has("SEND_MESSAGES")) {
await targetchannel.send(messageContent)
nmsgsend = nmsgsend + 1
}
} catch (e) {
console.log(e);
}
});
});
await client.guilds.cache.map(guild => {
guild.channels.cache.forEach(async channel => {
try {
const targetchannel = client.channels.cache.get(channel.id);
if (targetchannel.permissionsFor(client.user).has("SEND_MESSAGES")) {
await targetchannel.send(messageContent)
nmsgsend = nmsgsend + 1
}
} catch (e) {
console.log(e);
}
});
});
that give error targetchannel.send is not a function, why ?
10 Replies
d.js toolkit
d.js toolkit13mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
treble/luna
treble/luna13mo ago
why are you spamming all your guilds
Marion Maréchal
Marion MaréchalOP13mo ago
It's my bot that starts an event
treble/luna
treble/luna13mo ago
by sending a message in every single channel of every single guild it is in? doubt
Marion Maréchal
Marion MaréchalOP13mo ago
Because I have several discord servers, and I want to be able to launch an event on all of them
treble/luna
treble/luna13mo ago
yeah i'm not gonna help you spam servers. No one is
Marion Maréchal
Marion MaréchalOP13mo ago
wtf it's not contrary to discord's ToS and that is my serveur with my bot in
treble/luna
treble/luna13mo ago
make an announcment channels and have your servers follow it
Marion Maréchal
Marion MaréchalOP13mo ago
Except that's not what I want to do
Mark
Mark13mo ago
that is what discord designed announcement channels for. use them or don't, but you will not get support for sending a message to all channels like you're currently trying to do

Did you find this page helpful?