[英]TypeError: Cannot read property 'setPresence' of null discord.js v13
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
使用 discord.js V13
Presence can be set via the options
parameter in the Discord.Client(options)
constructor like so: Presence 可以通过
Discord.Client(options)
构造函数中的options
参数设置,如下所示:
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"
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.