Reputation: 47
Getting an error all the time,
this is what i have,
client.on('ready', () => {
console.log('Malosa SentryBot started successfully');
client.users.cache.get('43437XXXXXX25418').send('Blabla')});
and this is the error:
Malosa SentryBot started successfully
(node:8584) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 's
end' of undefined
at Client.<anonymous> (D:\discordbot2\new\Malosa-Sentry.js:1040:46)
at Client.emit (events.js:327:22)
My id is 100% correct, i really don't know whats wrong. the thing worked on v11, now on v12 it stopped working.
So what this does is when the bot starts it sends me an DM..
Upvotes: 2
Views: 5009
Reputation: 6720
Try fetching the user. Always best to fetch than to rely on the cache.
client.on('ready', async() => {
console.log('Malosa SentryBot started successfully');
const user = await client.users.fetch('43437XXXXXX25418');
user.send('Blabla');
});
Upvotes: 4
Reputation: 104
Try getting first the user and then, send the message
const user = client.users.cache.get('<id>');
user.send('<message>');
Upvotes: 0