![](/img/trans.png)
[英]DISCORD.JS V13 TypeError: Cannot read property 'has' of undefined
[英]TypeError: Cannot read property 'setPresence' of null discord.js v13
我有一個小問題。 我正在使用事件處理程序准備好事件,但我遇到了這個錯誤:
client.user.setPresence({
^
TypeError: Cannot read property 'setPresence' of null
我真的不知道我做錯了什么,這是代碼:
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)
};
必讀:額外信息
使用 discord.js V13
Presence 可以通過Discord.Client(options)
構造函數中的options
參數設置,如下所示:
const client = new Client({
presence: {
status: 'online',
afk: false,
activities: [{
name: ...,
type: ...,
}],
},
intents: [...],
partials: [...],
});
這應該有幫助!!
client.on('ready', () => {
client.user.setActivity(`!help || ${client.guilds.cache.size} Servers `, { type: "LISTENING" })
console.log(`Logged in as ${client.user.tag}`);
})
對於另一個,你可以使用這樣的東西⬇️
client.user.setPresence({
status: "idle"
})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.