Home > OS >  My discord.js code is just not working at all
My discord.js code is just not working at all

Time:08-16

I don't know why but mybot was working pretty well and I didn't touched it and went offline and when I was back every time I try to launch my bot it just doesn't work ,The bot doesn't get online

const express = require("express")
const app = express()

app.listen(3000, () => {
  console.log("bot is ready ");

})

app.get("/", (req, res) => {
  res.send("Hello world!");
})

const Discord = require("discord.js");
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES", "GUILD_MESSAGE_REACTIONS"] });
const Canvas = require('canvas')

   client.on("message",async function(msg) {
    //cant enter my Code cuz it's too long
})

  client.login(/*my token*/);

and also there s no errors to fix and I doubled checked that the Token is right

CodePudding user response:

If you're using the latest discord.js version, the string intents are now camelcase, for example:

const client = new Discord.Client({
    intents: ["Guilds", "GuildMessages", "GuildMessageReactions"]
});

But it would be even better to use the GatewayIntentBits object from discord.js:

const { Client, GatewayIntentBits } = require("discord.js");
const client = new Client({
    intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildMessageReactions]
});
  • Related