discord.js状态“无法读取null的属性” setActivity”

时间:2020-06-07 12:14:16

标签: javascript discord status

尝试运行我的漫游器时出现此错误:

client.user.setActivity(status,{type:'WATCHING'}) TypeError:无法读取null的属性“ setActivity”

console.log('fentabot')

let statuses=[
    'ɪɴɢʏᴇɴ',
    'ʟᴜᴀ ᴇxᴇᴄᴜᴛᴏʀ',
    'ᴍᴏᴅ ᴍᴇɴᴜ'
]
setInterval(function(){
    let status = statuses[Math.floor(Math.random() * statuses.lenght)]
    client.user.setActivity(status, { type: 'WATCHING' })
}, 2000)

2 个答案:

答案 0 :(得分:0)

console.log('fentabot')

let statuses = [
    'ɪɴɢʏᴇɴ',
    'ʟᴜᴀ ᴇxᴇᴄᴜᴛᴏʀ',
    'ᴍᴏᴅ ᴍᴇɴᴜ'
]
let status = statuses[Math.floor(Math.random() * statuses.lenght)]

setInterval(() {
    client.user.setActivity(status, { type: 'WATCHING' })
}, 5000)

注意:2000毫秒可能会导致DISCORD API滥用,请使用5000毫秒

答案 1 :(得分:0)

请确保您的漫游器准备就绪后运行此代码,否则它将无法正常工作:

client.on("ready", () => {
    // Place your code here
});