#Enzyy bot.token undefined
1 messages ยท Page 1 of 1 (latest)
I don't see the execute function being called in that file?
(Pulled this into a thread to cut down on spam in the main channel ๐ )
yup ๐
uh well
so we need to see where the code is that calls that execute function
since thats the function getting passed the bot, and the code that thinks bot is undefined
I'm not so sure why it's bringing this error now that I'm using / commands, on my normal timeout.js command it worked just fine
try console.logging bot in your execute function, is it undefined?
tried console.log(bot) on my deploy-commands.js file, it doesn't say undefined
hmm, so personally I've never tried accessing the token off the DJS Client object, so unsure about how it gets set or whatever...
But if your bot variable is the client object, then thats good, it means the bot variable is being passed properly.
Not sure how to fix the 'original' DJS Client object token throwing undefined unfortunately...
Fortunately, easy fix is just pull in your token from your config file into that file
const { token } = require(/* path to config.json */)
does that solve the error in the meantime?
hey sorry was out for a sec
I'm already doing that
except your code you were doing bot.token??
which is what was erroring
- in my timeout command file
yep, so import the token into that file and swap out bot.token with the imported token
to get your code working
Works now.. tysm 
np
looking at the source code for DJS
looks like when you define your bot const bot = ... you can possibly do bot.token = <tokenhere> and that should mean that bot.token would work?
(in the code it's listed as a writable parameter)
the only time client.token is auto set is if you are using a .env file and the dotenv npm package and the token is called DISCORD_TOKEN in your .env file
but yea otherwise you can just import the token when and where you need it ๐คทโโ๏ธ
I just removed bot. from bot.token & it worked just fine ๐
yep
Once again thank you very much for the help, appreciate it!
looking at the code, you need to actually assign the token to the bot object if you want it to be stored in the bot (or use dotenv and a .env file with a DISCORD_TOKEN value`
and np happy to help ๐
๐
still learning myself so having to pick out errors in other peoples code helps me get my head around how things work more xD