I have a little problem. I'm doing the event ready, with an event handler, but I come across this error:
client.user.setPresence({
^
TypeError: Cannot read property 'setPresence' of null
I don't really know what I'm doing wrong, here is the code:
const mongo = require('../../mongo');
const mongoose = require('mongoose');
const messageCount = require('../../message-counter')
const Discord = require('discord.js')
module.exports = async (Discord, client) => {
let serverIn = client.guilds.cache.size;
console.log('[INFO] Doose is online');
client.user.setPresence({
status: "dnd",
activity: {
name: `${serverIn} servers! | BETA | d.help`,
type: "WATCHING"
}
});
console.log('[INFO] Connected to MongoDB')
messageCount(client)
};
MUST READ: Extra Info
Using discord.js V13
Presence can be set via the options
parameter in the Discord.Client(options)
constructor like so:
const client = new Client({
presence: {
status: 'online',
afk: false,
activities: [{
name: ...,
type: ...,
}],
},
intents: [...],
partials: [...],
});
This should help !!
client.on('ready', () => {
client.user.setActivity(`!help || ${client.guilds.cache.size} Servers `, { type: "LISTENING" })
console.log(`Logged in as ${client.user.tag}`);
})
and for the other , you can use something like this ⬇️
client.user.setPresence({
status: "idle"
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.