Cannot read properties of undefined (reading 'send')

I'm awaiting the ready event from my bot to send a message. Sadly that doesn't work. Any ideas?
(async () => {
try {
await ready;
client.channels.cache.get(channelID).send({ content: " ", embeds: [embed_events] }).then(sent => {
databases.overview.message_id = sent.id;
});
} catch (err) {
console.error(err);
}
})();
(async () => {
try {
await ready;
client.channels.cache.get(channelID).send({ content: " ", embeds: [embed_events] }).then(sent => {
databases.overview.message_id = sent.id;
});
} catch (err) {
console.error(err);
}
})();
Error:
TypeError: Cannot read properties of undefined (reading 'send')
TypeError: Cannot read properties of undefined (reading 'send')
9 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Syjalo
Syjalo2y ago
1. Invalid channel id 2. Channel is not cached
Schlaumeyer
SchlaumeyerOP2y ago
Channel ID is correct. How can I see if the channel is cached? Or fix that?
Syjalo
Syjalo2y ago
Is that a guild channel?
Schlaumeyer
SchlaumeyerOP2y ago
It's a channel in a discord server, if you mean that, yes. The bot also has access to it (it has administrator permissions)
Syjalo
Syjalo2y ago
Do you have Guilds intent?
Schlaumeyer
SchlaumeyerOP2y ago
I guess so
const client = new Client({ intents: ['Guilds', 'GuildMessages'] });
const client = new Client({ intents: ['Guilds', 'GuildMessages'] });
Syjalo
Syjalo2y ago
What is in your ready variable?
Schlaumeyer
SchlaumeyerOP2y ago
Promise { undefined }
const ready = new Promise((resolve) => {
client.on('ready', () => resolve());
});

export { ready };

(async () => {
try {
await ready;
console.log(ready)
console.log(`Eingeloggt als ${client.user.tag}`);
} catch (err) {
console.error(err);
}
})();
const ready = new Promise((resolve) => {
client.on('ready', () => resolve());
});

export { ready };

(async () => {
try {
await ready;
console.log(ready)
console.log(`Eingeloggt als ${client.user.tag}`);
} catch (err) {
console.error(err);
}
})();
That's the index.js file. I'm importing ready in another file and wait that I can send a message
Want results from more Discord servers?
Add your server