I have djs @ v12 just because everything is just getting more hard to learn every new update.

[nodemon] 2.0.22 [nodemon] to restart at any time, enter rs [nodemon] watching path(s): . [nodemon] watching extensions: js,mjs,json [nodemon] starting node src/index.js C:\Users\Joshua\Desktop\discordbot2\src\index.js:11 command(client, 'ping', message => { ^ TypeError: command is not a function
const Discord = require('discord.js');
const config = require('./config.json')
const client = new Discord.Client();
const command = require('./command')


client.on('ready', () => {
console.log`${client.user.tag} is online and ready to go!✅`
})

command(client, 'ping', message => {
message.channel.send('Pong')
})

client.on('message', () => {
})

client.login(config.token);
const Discord = require('discord.js');
const config = require('./config.json')
const client = new Discord.Client();
const command = require('./command')


client.on('ready', () => {
console.log`${client.user.tag} is online and ready to go!✅`
})

command(client, 'ping', message => {
message.channel.send('Pong')
})

client.on('message', () => {
})

client.login(config.token);
120 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs2y ago
guide Additional Information: Updating from v12 to v13 read moreguide Additional Information: Updating from v13 to v14 read more
shadow1111
shadow1111OP2y ago
too difficult the basics changed to me you need to add some weird intentbit stuff or sm
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
what are the basics of v14
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
whats the easiest library? i know that is the + like what to do? from the changes cus theres + and -
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
shadow1111
shadow1111OP2y ago
and the + is what i use now?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
and sorry 1 more thing do i still use module.exports for my command handler the reason i downgraded djs is because my slash commands dont work!
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
sooo yea?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
"REST" like they just werent registering therefore, I downgraded
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs2y ago
guide Home: Before you begin... read more
shadow1111
shadow1111OP2y ago
is v13 supported tho?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
and how do i upgrade to v14?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
i am it just says i have to uninstall it still v13
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
yea so i uninstalled it and its still v13
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
k thanks and the documentation is for v14 right?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
kk ty omg im so sorry can i still use config.json file for my prefix and token or should i use .env
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
so both still work?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
k ty and this is what I mean PS C:\Users\Joshua\Desktop\discordbot2> nodemon [nodemon] 2.0.22 [nodemon] to restart at any time, enter `rs` [nodemon] watching path(s): *.* [nodemon] watching extensions: js,mjs,json [nodemon] starting `node src/index.js` C:\Users\Joshua\Desktop\discordbot2\node_modules\discord.js\src\client\Client.js:492 throw new DiscordjsTypeError(ErrorCodes.ClientMissingIntents); ^ TypeError [ClientMissingIntents]: Valid intents must be provided for the Client. at Client._validateOptions (C:\Users\Joshua\Desktop\discordbot2\node_modules\discord.js\src\client\Client.js:492:13) at new Client (C:\Users\Joshua\Desktop\discordbot2\node_modules\discord.js\src\client\Client.js:78:10) at Object.<anonymous> (C:\Users\Joshua\Desktop\discordbot2\src\index.js:3:16) at Module._compile (node:internal/modules/cjs/loader:1256:14) at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) at Module.load (node:internal/modules/cjs/loader:1119:32) at Module._load (node:internal/modules/cjs/loader:960:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:23:47 { code: 'ClientMissingIntents' } Node.js v18.16.1 [nodemon] app crashed - waiting for file changes before starting...
const { Client, GatewayIntentBits, Partials } = require('discord.js');


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

client.on('ready', () => {
console.log(`${client.user.tag} is online and ready to go!`);
})



client.login(config.token);
const { Client, GatewayIntentBits, Partials } = require('discord.js');


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

client.on('ready', () => {
console.log(`${client.user.tag} is online and ready to go!`);
})



client.login(config.token);
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
they are now it says token invalid but i literally just reset it
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
oops i didnt copy that part its there tho
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
const { config } = require('dotenv');
const { config } = require('dotenv');
yea
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
yea
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
it says token invalid
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
it does
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
ok it wasnt the full token tho
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
you dont see that?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
bro its not even half of the token
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
it kind of does you need the whole token to do anything
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
shadow1111
shadow1111OP2y ago
I already did reset it twice now and i put the new token in both times
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
yes
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
where
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
index?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
im confused
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
yes i did that
const { Client, GatewayIntentBits, Partials } = require('discord.js');
const { config } = require('dotenv');
config();
const { Client, GatewayIntentBits, Partials } = require('discord.js');
const { config } = require('dotenv');
config();
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
shadow1111
shadow1111OP2y ago
yes i do it worked when i just used client.login( token here ) so its the right token
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
shadow1111
shadow1111OP2y ago
shadow1111
shadow1111OP2y ago
its the correct token
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
ITS THE SAME TOKEN LMFAO is it formatted correctly?
shadow1111
shadow1111OP2y ago
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
so no ""?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
fawg.. dawg* its still not working sooooo?
</> Idris
</> Idris2y ago
do you know that your current isn’t related to discord.js at all? like doesn’t even matter v12 or v50
shadow1111
shadow1111OP2y ago
bro what
</> Idris
</> Idris2y ago
your issue is related to dotenv (or just your JS knowledge ?)
shadow1111
shadow1111OP2y ago
i mean both I want to learn but the dotenv isnt working at all it worked when i had v12
</> Idris
</> Idris2y ago
no no ^
shadow1111
shadow1111OP2y ago
i know its not related to the version im saying it worked perfectly fine last night
</> Idris
</> Idris2y ago
does it return an error?
shadow1111
shadow1111OP2y ago
yes i already sent it
</> Idris
</> Idris2y ago
where
shadow1111
shadow1111OP2y ago
Error [TokenInvalid]: An invalid token was provided.
at Client.login (C:\Users\Joshua\Desktop\discordbot2\node_modules\discord.js\src\client\Client.js:214:52)
at Object.<anonymous> (C:\Users\Joshua\Desktop\discordbot2\src\index.js:17:8)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47 {
code: 'TokenInvalid'
}

Node.js v18.16.1
Error [TokenInvalid]: An invalid token was provided.
at Client.login (C:\Users\Joshua\Desktop\discordbot2\node_modules\discord.js\src\client\Client.js:214:52)
at Object.<anonymous> (C:\Users\Joshua\Desktop\discordbot2\src\index.js:17:8)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47 {
code: 'TokenInvalid'
}

Node.js v18.16.1
</> Idris
</> Idris2y ago
remove client.login(…) and replace it by console.log(process.env)
shadow1111
shadow1111OP2y ago
.TOKEN?
</> Idris
</> Idris2y ago
no just process.env
shadow1111
shadow1111OP2y ago
um its showing my pc stuff
</> Idris
</> Idris2y ago
you don’t see your token in the terminal?
shadow1111
shadow1111OP2y ago
no
</> Idris
</> Idris2y ago
just two sec I'm gonna move on my PC
shadow1111
shadow1111OP2y ago
ok
</> Idris
</> Idris2y ago
the following code sample is working for me
</> Idris
</> Idris2y ago
that's my .env
shadow1111
shadow1111OP2y ago
can i use (c) instead of (client)? and thats exaclty what I have
</> Idris
</> Idris2y ago
then something wrong in your side not the library's side name your params however you want
shadow1111
shadow1111OP2y ago
ill try resetting my token one more time
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
shadow1111
shadow1111OP2y ago
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
</> Idris
</> Idris2y ago
mines
shadow1111
shadow1111OP2y ago
me too
</> Idris
</> Idris2y ago
^ ^
shadow1111
shadow1111OP2y ago
sooooooooooooo what do i do i dont get the error any more but it says
undefined
undefined
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
</> Idris
</> Idris2y ago
you don't get the error because I told you to remove your client.login(...)
shadow1111
shadow1111OP2y ago
when i try to node . oh yea
𝒄𝒐𝒄𝒐𝒌𝒊𝒕𝒕𝒆𝒏
u can infact have it as string no whitespace, all caps is the general formatting also use unique names, nothing that other programs or the OS could set
shadow1111
shadow1111OP2y ago
do i need to use a config file or env file if I dont put it on github?
</> Idris
</> Idris2y ago
please start moving to #other-js-ts nothing related to djs now
𝒄𝒐𝒄𝒐𝒌𝒊𝒕𝒕𝒆𝒏
mby try moving .env in ur root directory instead of ./src but idk if that makes a difference
Want results from more Discord servers?
Add your server