gex
gex
DIAdiscord.js - Imagine a boo! 👻
Created by gex on 2/18/2024 in #djs-questions
I'm new to discord.js and I'd like to learn about the .env file
Nice. It's working.
20 replies
DIAdiscord.js - Imagine a boo! 👻
Created by gex on 2/18/2024 in #djs-questions
I'm new to discord.js and I'd like to learn about the .env file
I'm going to use config.json.
20 replies
DIAdiscord.js - Imagine a boo! 👻
Created by gex on 2/18/2024 in #djs-questions
I'm new to discord.js and I'd like to learn about the .env file
const { Client, Events, GatewayIntentBits } = require('discord.js');
const { DISCORD_TOKEN } = require('./.env');

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

client.once(Events.ClientReady, readyClient => {
console.log(`Ready! Logged in as ${readyClient.user.tag}`);
});

client.login(DISCORD_TOKEN)
const { Client, Events, GatewayIntentBits } = require('discord.js');
const { DISCORD_TOKEN } = require('./.env');

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

client.once(Events.ClientReady, readyClient => {
console.log(`Ready! Logged in as ${readyClient.user.tag}`);
});

client.login(DISCORD_TOKEN)
Note: Using the "preview" debug extension
"...\nodejs\node.exe" ".\...\index.js"
- Process exited with code 1
- Uncaught Error Error: Cannot find module './.env'
- Require stack:
- ...\index.js
- at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
- at Module._load (node:internal/modules/cjs/loader:985:27)
- at Module.require (node:internal/modules/cjs/loader:1235:19)
- at require (node:internal/modules/helpers:176:18)
- at <anonymous> (file:///.../index.js:2:27)
- at Module._compile (node:internal/modules/cjs/loader:1376:14)
- at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
- at Module.load (node:internal/modules/cjs/loader:1207:32)
- at Module._load (node:internal/modules/cjs/loader:1023:12)
- at executeUserEntryPoint (node:internal/modules/run_main:135:12)
- at <anonymous> (node:internal/main/run_main_module:28:49)
Note: Using the "preview" debug extension
"...\nodejs\node.exe" ".\...\index.js"
- Process exited with code 1
- Uncaught Error Error: Cannot find module './.env'
- Require stack:
- ...\index.js
- at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
- at Module._load (node:internal/modules/cjs/loader:985:27)
- at Module.require (node:internal/modules/cjs/loader:1235:19)
- at require (node:internal/modules/helpers:176:18)
- at <anonymous> (file:///.../index.js:2:27)
- at Module._compile (node:internal/modules/cjs/loader:1376:14)
- at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
- at Module.load (node:internal/modules/cjs/loader:1207:32)
- at Module._load (node:internal/modules/cjs/loader:1023:12)
- at executeUserEntryPoint (node:internal/modules/run_main:135:12)
- at <anonymous> (node:internal/main/run_main_module:28:49)
20 replies
DIAdiscord.js - Imagine a boo! 👻
Created by gex on 2/18/2024 in #djs-questions
I'm new to discord.js and I'd like to learn about the .env file
In the .env file, does the Token need to be enclosed in quotation marks?
20 replies
DIAdiscord.js - Imagine a boo! 👻
Created by gex on 2/18/2024 in #djs-questions
I'm new to discord.js and I'd like to learn about the .env file
Yes.
20 replies
DIAdiscord.js - Imagine a boo! 👻
Created by gex on 2/18/2024 in #djs-questions
I'm new to discord.js and I'd like to learn about the .env file
I'm going to delete everything and start from the beginning. The first thing I'm going to do is package.json.
20 replies
DIAdiscord.js - Imagine a boo! 👻
Created by gex on 2/18/2024 in #djs-questions
I'm new to discord.js and I'd like to learn about the .env file
Is it necessary to use config.json?
20 replies
DIAdiscord.js - Imagine a boo! 👻
Created by gex on 2/18/2024 in #djs-questions
I'm new to discord.js and I'd like to learn about the .env file
Oh, so my script.js is where the Client will be?
20 replies
DIAdiscord.js - Imagine a boo! 👻
Created by gex on 2/18/2024 in #djs-questions
I'm new to discord.js and I'd like to learn about the .env file
No description
20 replies
DIAdiscord.js - Imagine a boo! 👻
Created by gex on 2/18/2024 in #djs-questions
I'm new to discord.js and I'd like to learn about the .env file
I read. But I didn't find where that part was.
20 replies
DIAdiscord.js - Imagine a boo! 👻
Created by gex on 2/18/2024 in #djs-questions
I'm new to discord.js and I'd like to learn about the .env file
So, files like kick.js, ban.js, clear.js, help.js... Would I have to get them all to run?
20 replies
DIAdiscord.js - Imagine a boo! 👻
Created by gex on 2/18/2024 in #djs-questions
I'm new to discord.js and I'd like to learn about the .env file
Understood.
20 replies
DIAdiscord.js - Imagine a boo! 👻
Created by gex on 2/18/2024 in #djs-questions
I'm new to discord.js and I'd like to learn about the .env file
Ohhh
20 replies
DIAdiscord.js - Imagine a boo! 👻
Created by gex on 2/18/2024 in #djs-questions
I'm new to discord.js and I'd like to learn about the .env file
But is it used to run codes? I'm not saying that the codes will be inside .env, but the command files like:
ban.js
kick.js
etc...
ban.js
kick.js
etc...
In each of the commands will I have to put something like client.login(/.env) (example)?
20 replies
DIAdiscord.js - Imagine a boo! 👻
Created by gex on 2/18/2024 in #djs-questions
I'm new to discord.js and I'd like to learn about the .env file
Yes, I think I did that.
20 replies
DIAdiscord.js - Imagine a boo! 👻
Created by gex on 2/18/2024 in #djs-questions
I'm new to discord.js and I'd like to learn about the .env file
I didn't understand. If I do this can I create several files and run them all in a .env file? Like this: https://i.imgur.com/gDYxANM.png
20 replies
DIAdiscord.js - Imagine a boo! 👻
Created by gex on 2/18/2024 in #djs-questions
I'm new to discord.js and I'd like to learn about the .env file
discord.js - npm install discord.js package.json - npm init:
{
"name": "programming-things",
"version": "1.0.0",
"description": "A JavaScript BOT for Discord.",
"main": "index.js",
"scripts": {
"test": "node ."
},
"keywords": [
"Bot"
],
"author": "gamingexpert",
"license": "ISC",
"dependencies": {
"discord-gamecord": "^4.4.1",
"discord.js": "^14.14.1"
}
}
{
"name": "programming-things",
"version": "1.0.0",
"description": "A JavaScript BOT for Discord.",
"main": "index.js",
"scripts": {
"test": "node ."
},
"keywords": [
"Bot"
],
"author": "gamingexpert",
"license": "ISC",
"dependencies": {
"discord-gamecord": "^4.4.1",
"discord.js": "^14.14.1"
}
}
20 replies