presence update not working discord.js v12

864 Views Asked by At

I am trying to give a role if members has set a custom presence what I want set their custom status in discord!

but bot is giving a promblem


const Discord = require('discord.js')

const client = new Discord.Client()

client.on('ready', () => {
    console.log('bot sucessfully logged')
})

client.on("presenceUpdate", (oldPresence, newPresence) => {
    let guild = oldPresence.guild;
    //guild.roles => guild.roles.cache
    let playRole = guild.roles.cache.get("837208147302154252");
    if (!playRole) return;

    if (newPresence.find(e => e.name === "Testing")) {
        newPresence.member.roles.add(playRole);
    }
});

client.login("token")

Error is newPresence.find is not a function

0

There are 0 best solutions below