Discord.JS 我的机器人不上线但是有一个简单的代码

Discord.JS My bot don't turn online but there is a simple code

我的机器人没有上线但是有一个简单的代码:

const discord = require('discord.js')
const client = new discord.Client();
const token = ('my bot token')

client.on('ready', function(){
console.log('online')
})

client.login(token)

试试这个:

const discord = require('discord.js')
const client = new discord.Client(); 
// you will want to define some intents if you want the bot to be able to do anything
// see https://discordjs.guide/popular-topics/intents.html#enabling-intents and https://discord.js.org/#/docs/main/stable/class/Intents
const token = 'my bot token' // took away the ()

client.on('ready', () => { //removed 'function' and added => to pass everything through
console.log('online')
})

client.login(token)