#When I type node index.js in the terminal nothing happens

22 messages · Page 1 of 1 (latest)

subtle sphinxBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
steel lance
#

did you save your code

manic jungle
#

no how do I save it

steel lance
#

ctrl + s

#

though if you dont even know how you save code, i would check out #resources first

manic jungle
#

now it says something

#

I have a .env file with the discord token set next to the equal sign

steel lance
#

show your code then

#

but that makes me believe you just cloned a repo / code

manic jungle
#

const { Client, GatewayIntentBits } = require('discord.js');
require('dotenv').config(); // Load environment variables from .env

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.once('ready', () => {
console.log(Bot is online as ${client.user.tag}!);
});

const token = process.env.DISCORD_TOKEN;
if (!token) {
console.error('Bot token is missing. Make sure you have a .env file with DISCORD_TOKEN set.');
process.exit(1);
}
client.login(token);

steel lance
#

is your env file in your root directory

#

and does it actually have a key named DISCORD_TOKEN

manic jungle
#

yes

steel lance
#

which question is that an answer to

manic jungle
#

2nd

#

is this the root directory

steel lance
#

show whats in your env (but remove the token)

manic jungle
#

this is whats in there, DISCORD_TOKEN=

steel lance
#

is your env file saved

manic jungle
#

i fixed it