0

error

I got this error message on heroku and I'm not sure how to fix it, since my code is very basic. I've been following a tutorial on how to set my discord bot up 24/7. If anyone can help me fix this, much appreciated! :)

const Discord = require('discord.js');
const bot = new Discord.Client({
    intents: [
        Discord.Intents.FLAGS.GUILDS,
        Discord.Intents.FLAGS.GUILD_MESSAGES,
        Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
        Discord.Intents.FLAGS.DIRECT_MESSAGES
    ]
});


bot.on("ready", function () {
    console.log("Hello!");
});

bot.login(process.env.token);

Above is my code in index.js and below is package.json

{
  "name": "discordbot",
  "version": "1.0.0",
  "engines": {
    "node": ">=16.11.0"
  },
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "discord.js": "^13.2.0",
    "dotenv": "^10.0.0"
  }
}
3
  • 1
    Are you sure you provided valid token in heroku value and value name is exactly "token" and not "ToKen" for example? Commented Oct 9, 2021 at 17:47
  • Try to do console.log(process.env.token) to see if you really are able to get the token.
    – Luuk
    Commented Oct 10, 2021 at 11:21
  • Make sure you do require('dotenv').config() to load your env variables into process.env before trying to use them, since you're using dotenv.
    – Cannicide
    Commented Oct 12, 2021 at 19:33

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.