my problem is that when user go live and have live status on discord, in console i get error "
TypeError: Cannot read property 'activities' of undefined" and bot is crashing. I expect to bot send a message with link to stream.
Discord.js - v12
Code:
client.on('presenceUpdate', (oldMember, newMember) => {
const channel = newMember.guild.channels.cache.find(x => x.name === "test");
if (!channel) return;
let oldStreamingStatus = oldMember.presence.activities.type ? oldMember.presence.activities.streaming : false;
let newStreamingStatus = newMember.presence.activities.type ? newMember.presence.activities.streaming : false;
if(oldStreamingStatus == newStreamingStatus){
return;
}
if(newStreamingStatus){
if(message.member.roles.cache.find(r => r.name === "test")) {
channel.send(`${newMember.user}, is live URL: ${newMember.presence.activities.url} ${newMember.presence.activities.name}`);
return;
}else
return;
}});