我有一个小问题。我正在使用事件处理程序准备好事件,但我遇到了这个错误:
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
答案 0 :(得分:1)
Presence 可以通过 Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python39\Lib\site-
packages\flask\app.py", line 2088, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Users\User\AppData\Local\Programs\Python\Python39\Lib\site-
packages\flask\app.py", line 2073, in wsgi_app
response = self.handle_exception(e)
File "C:\Users\User\AppData\Local\Programs\Python\Python39\Lib\site-
packages\flask\app.py", line 2070, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\User\AppData\Local\Programs\Python\Python39\Lib\site-
packages\flask\app.py", line 1515, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\User\AppData\Local\Programs\Python\Python39\Lib\site-
packages\flask\app.py", line 1513, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\User\AppData\Local\Programs\Python\Python39\Lib\site-
packages\flask\app.py", line 1499, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])
(**req.view_args)
File "C:\Users\User\Desktop\abc\test.py", line 51, in upload_file
input_file = open(pdf_file,'rb')
TypeError: expected str, bytes or os.PathLike object, not FileStorage
构造函数中的 options
参数设置,如下所示:
Discord.Client(options)
答案 1 :(得分:1)
这应该会有所帮助!!
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"
})