Search code examples
discorddiscord.js

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


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)

Solution

  • Try this:

    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)