How to update a v12 bot to current

i made a bot "rick-bot" 2 years ago and it has been working fine until the 3rd May 2023 and i have the replit but i didn't log in to it for 2 years and i did today and press ran and it said "hello, hell" meaning its running and no response from the bot when i try to do .help or anything (it is in 100 servers and isn't verified) and i am not sure on why it isnt working, i am not sure on what to do. Help appreciated.
213 Replies
d.js toolkit
d.js toolkitโ€ข3y 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.
Louis
LouisOPโ€ข3y ago
I didn't know what flair to use :/
treble/luna
treble/lunaโ€ข3y ago
and the reason its not working is probably because you dont have the message content intent
Louis
LouisOPโ€ข3y ago
what do you mean by that?
treble/luna
treble/lunaโ€ข3y ago
you need an intent to receive message content, which would explain why your bot is unresponsive
Louis
LouisOPโ€ข3y ago
how do i get a intent?
treble/luna
treble/lunaโ€ข3y ago
by providing in it your client constructor but first npm ls discord.js and show me the output
Louis
LouisOPโ€ข3y ago
treble/luna
treble/lunaโ€ข3y ago
yeah so v12 isnt supported anymore
Louis
LouisOPโ€ข3y ago
ah ok how do i update?
d.js docs
d.js docsโ€ข3y ago
guide Additional Information: Updating from v13 to v14 read moreguide Additional Information: Updating from v12 to v13 read more
treble/luna
treble/lunaโ€ข3y ago
its recommeded to update to v14
Zero Two
Zero Twoโ€ข3y ago
see @louisnecker
Louis
LouisOPโ€ข3y ago
bro why r u here lol
Zero Two
Zero Twoโ€ข3y ago
to see if you got help lol
Louis
LouisOPโ€ข3y ago
lol just fixing it now i think ๐Ÿคž
Louis
LouisOPโ€ข3y ago
Louis
LouisOPโ€ข3y ago
he he he uh which command do i run its still at the same version
treble/luna
treble/lunaโ€ข3y ago
npm update discord.js
d.js docs
d.js docsโ€ข3y ago
Version 14 has released! Please update at your earliest convenience. - Update: npm rm discord.js npm i discord.js - Update guide (use CTRL + F to search for the old method or property)
Louis
LouisOPโ€ข3y ago
Louis
LouisOPโ€ข3y ago
@wolvinny it wont update
treble/luna
treble/lunaโ€ข3y ago
do this
Louis
LouisOPโ€ข3y ago
ok one after the other?
treble/luna
treble/lunaโ€ข3y ago
yes
Louis
LouisOPโ€ข3y ago
treble/luna
treble/lunaโ€ข3y ago
and now you'll have to update your code
Louis
LouisOPโ€ข3y ago
ok i think i need to update the token but i don't no where i update it
treble/luna
treble/lunaโ€ข3y ago
and update node
Louis
LouisOPโ€ข3y ago
Louis
LouisOPโ€ข3y ago
how do i do this?
treble/luna
treble/lunaโ€ข3y ago
Node.js
Node.js
Node.jsยฎ is a JavaScript runtime built on Chrome's V8 JavaScript engine.
Louis
LouisOPโ€ข3y ago
i use replit?
treble/luna
treble/lunaโ€ข3y ago
i have no experience with replit, and i dont really recommend it either, better to get a real host, #resources
Louis
LouisOPโ€ข3y ago
i use uptime robot worked fine for the 2 years i was absent do you know where i update the token
treble/luna
treble/lunaโ€ข3y ago
there's no need to update the token, you need to update node
Louis
LouisOPโ€ข3y ago
all i have in the code with the word token is "process.env.TOKEN" i changed the token in the discord app
treble/luna
treble/lunaโ€ข3y ago
this has nothing to do with djs, this is your node being outdated
Louis
LouisOPโ€ข3y ago
why do i download this to update node everything was on replit for me
treble/luna
treble/lunaโ€ข3y ago
again, i have no experience with replit, and i dont intend to change that
Louis
LouisOPโ€ข3y ago
do you know anyone else that can help
treble/luna
treble/lunaโ€ข3y ago
google it or get a real host, #resources
Louis
LouisOPโ€ข3y ago
google what?
treble/luna
treble/lunaโ€ข3y ago
how to update node....
Louis
LouisOPโ€ข3y ago
why does it need updating though ive never updated it
Unknown User
Unknown Userโ€ข3y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOPโ€ข3y ago
export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" && [ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bashcompletion" && nvm install --lts && nvm use --lts someone said paste this into it? it doesnt work .. how do i check what version node.js is on @qjuh
Unknown User
Unknown Userโ€ข3y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOPโ€ข3y ago
its at v12 npm i node@16.6.0 would be 16.??
Unknown User
Unknown Userโ€ข3y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOPโ€ข3y ago
isnt there a replit server??? i cant find it
egliod ๐ŸŽƒ
egliod ๐ŸŽƒโ€ข3y ago
@louisnecker
Louis
LouisOPโ€ข3y ago
yes ?
egliod ๐ŸŽƒ
egliod ๐ŸŽƒโ€ข3y ago
I have experience with replit. on your left there should button "packages" pressing on that will bring a screen where you can update all packages that are currently installed pretty easy
egliod ๐ŸŽƒ
egliod ๐ŸŽƒโ€ข3y ago
this button
Louis
LouisOPโ€ข3y ago
got it
egliod ๐ŸŽƒ
egliod ๐ŸŽƒโ€ข3y ago
here you can update it
Unknown User
Unknown Userโ€ข3y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOPโ€ข3y ago
?
egliod ๐ŸŽƒ
egliod ๐ŸŽƒโ€ข3y ago
lets move it to DMs
Louis
LouisOPโ€ข3y ago
ok it is djs related now
Louis
LouisOPโ€ข3y ago
d.js docs
d.js docsโ€ข3y ago
- Websocket intents limit events and decrease memory usage: learn more - See what intents you need here
Louis
LouisOPโ€ข3y ago
not sure about these intents @Jรด ๐ŸŒˆ ๐Ÿฆ„ i dont know what i am supposed to be looking at
Unknown User
Unknown Userโ€ข3y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOPโ€ข3y ago
i did all this 2 years ago and i have forgotton a lot but i just need jumps to get me back on track
treble/luna
treble/lunaโ€ข3y ago
.
Unknown User
Unknown Userโ€ข3y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOPโ€ข3y ago
this one here? yes i have updated everything to the latest version
Unknown User
Unknown Userโ€ข3y ago
Message Not Public
Sign In & Join Server To View
treble/luna
treble/lunaโ€ข3y ago
yeah but i doubt the rest is updated, and if it is, that would be the fastest time ive seen someone update their code tbh
Louis
LouisOPโ€ข3y ago
but im not sure what i am supposed to be doing
Unknown User
Unknown Userโ€ข3y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOPโ€ข3y ago
Unknown User
Unknown Userโ€ข3y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOPโ€ข3y ago
how do i know what i need to fix
Louis
LouisOPโ€ข3y ago
the website is just double dutch to me
Unknown User
Unknown Userโ€ข3y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOPโ€ข3y ago
they just list them right? if thats the case it has no bearing on what i need to fix all i need is to get the bot running again and i am facing some troubles with intents, you know a lot more about them than me which is why i requested your help which is appreciated. I just want to know what intents need to be fixed i dont even know where the intents are in my code
d.js docs
d.js docsโ€ข3y ago
guide Popular Topics: Gateway Intents read more
Louis
LouisOPโ€ข3y ago
i dont have const { Client, GatewayIntentBits } = require('discord.js'); const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMembers, ], }); in my code how do you update the code accordingly?
Louis
LouisOPโ€ข3y ago
i have read it all and none of it applies to my bot, all of it isn't relevant to my bots code
Unknown User
Unknown Userโ€ข3y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOPโ€ข3y ago
?
Unknown User
Unknown Userโ€ข3y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOPโ€ข3y ago
what ?
Unknown User
Unknown Userโ€ข3y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOPโ€ข3y ago
it isnt in my bots code
MENIX
MENIXโ€ข3y ago
Updating your intents and following the guides posted earlier regards to updating from V12 > V13 & then V13 > V14 is very relevant to your bots code. Embeds are changed, How you use the bot is changed (Intents), how you send messages embeds are changed. There is a lot of things, you will need to update code wise. As you say yourself, not everything will apply to your bot - thats fine, however take one step at a time, go through the red [-] & green [+] fields in the update guide. if somethings not relevant for you, move on - but there has to be a lot.
Louis
LouisOPโ€ข3y ago
what do you mean???
treble/luna
treble/lunaโ€ข3y ago
just because it isnt in your bots code doesnt mean its not relevant. client.login is relevant too, if you forgot it wouldnt be relevant?
Louis
LouisOPโ€ข3y ago
7neckerl
replit
muffin bot-2
Run Node.js code live in your browser. Write and run code in 50+ languages online with Replit, a powerful IDE, compiler, & interpreter.
Louis
LouisOPโ€ข3y ago
can you guys look at it?
treble/luna
treble/lunaโ€ข3y ago
what is there to look at? You've been told what to add
Louis
LouisOPโ€ข3y ago
i dont know what to add and where
Louis
LouisOPโ€ข3y ago
not to me it doesn't
treble/luna
treble/lunaโ€ข3y ago
then you should read
Louis
LouisOPโ€ข3y ago
im not refusing to do anything i just don't know what to add and where and how i know if things are relevant if i think everything isnt relevant then i need some help
Louis
LouisOPโ€ข3y ago
where am i putting this?
treble/luna
treble/lunaโ€ข3y ago
i dont know how else i can make it easier did you even write your bots code?
Louis
LouisOPโ€ข3y ago
treble/luna
treble/lunaโ€ข3y ago
now where do you think it should be added? please just read
Louis
LouisOPโ€ข3y ago
replace the const client line?
treble/luna
treble/lunaโ€ข3y ago
yes
Louis
LouisOPโ€ข3y ago
IDE?
treble/luna
treble/lunaโ€ข3y ago
code editor
d.js docs
d.js docsโ€ข3y ago
Snipe commands are widely considered a violation of user privacy. If a message is deleted it should stay that way. - Logs for moderation purposes are fine - Bringing back a deleted message by just anyone to expose or humiliate a user is not
Louis
LouisOPโ€ข3y ago
Louis
LouisOPโ€ข3y ago
like this?
treble/luna
treble/lunaโ€ข3y ago
try it and see, i'm not gonna hold your hand
Louis
LouisOPโ€ข3y ago
treble/luna
treble/lunaโ€ข3y ago
import it, basic js
Louis
LouisOPโ€ข3y ago
import what?
treble/luna
treble/lunaโ€ข3y ago
.... what do you think you should import?
Louis
LouisOPโ€ข3y ago
๐Ÿ˜•
Unknown User
Unknown Userโ€ข3y ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docsโ€ข3y ago
- ReferenceError: "x" is not defined: learn more - TypeError: Cannot read properties of undefined/null (reading "x"): learn more
Louis
LouisOPโ€ข3y ago
so i need to add this to define it then?
treble/luna
treble/lunaโ€ข3y ago
no?
Unknown User
Unknown Userโ€ข3y ago
Message Not Public
Sign In & Join Server To View
treble/luna
treble/lunaโ€ข3y ago
i'm giving up, please read the guide or actually do what we tell you
Louis
LouisOPโ€ข3y ago
or make it const client = new discord.client({
treble/luna
treble/lunaโ€ข3y ago
if discord is how you import it yes, you can also destructure it directly
Louis
LouisOPโ€ข3y ago
im trying my best, sorry.
Unknown User
Unknown Userโ€ข3y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOPโ€ข3y ago
Louis
LouisOPโ€ข3y ago
its doing something when i run it anyway which i think is good
Louis
LouisOPโ€ข3y ago
Louis
LouisOPโ€ข3y ago
so im not on the latest version of Node then? ah
Louis
LouisOPโ€ข3y ago
Louis
LouisOPโ€ข3y ago
anyone know what this means? It looks bad and ive never seen it looks like some corruption ๐Ÿ˜Ÿ
treble/luna
treble/lunaโ€ข3y ago
thats your ide not being able to display a .sqlite file this isnt djs related though
Louis
LouisOPโ€ข3y ago
Louis
LouisOPโ€ข3y ago
this is a previous version and still a bit weird
treble/luna
treble/lunaโ€ข3y ago
again, not djs related
Louis
LouisOPโ€ข3y ago
what does that mean
treble/luna
treble/lunaโ€ข3y ago
that your editor cannot display that file extension
Panda
Pandaโ€ข3y ago
Name: SQLite Viewer Id: qwtel.sqlite-viewer Description: SQLite Viewer for VSCode Version: 0.2.5 Publisher: Florian Klampfer VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=qwtel.sqlite-viewer if you're using vscode get this, should let u view the file properly
SQLite Viewer - Visual Studio Marketplace
Extension for Visual Studio Code - SQLite Viewer for VSCode
Unknown User
Unknown Userโ€ข3y ago
Message Not Public
Sign In & Join Server To View
Panda
Pandaโ€ข3y ago
Ah my bad, should've paid attention
Unknown User
Unknown Userโ€ข3y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOPโ€ข3y ago
Replit Ask
SQLite Database File Corruption When Opened In Repl.it Online Text ...
Hello @ShaneAtReplit ! Sorry for the late response. But I tried out your solution and restored the file to itโ€™s first iteration through the history tab. Sadly, it still gave the same error. The history showed that I accidentally modified the file once by appending the โ€˜fโ€™ character to line 1. But I already removed that mistake before and Iโ€™ve ...
Louis
LouisOPโ€ข3y ago
found this in may but doesn't really show a solution
Unknown User
Unknown Userโ€ข3y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOPโ€ข3y ago
why is it like this?
Louis
LouisOPโ€ข3y ago
it had 1000s of members?
Unknown User
Unknown Userโ€ข3y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOPโ€ข3y ago
do you know anywhere?
Unknown User
Unknown Userโ€ข3y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOPโ€ข3y ago
i don't think they really have my issue do you know what i mean?
Unknown User
Unknown Userโ€ข3y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOPโ€ข3y ago
Louis
LouisOPโ€ข3y ago
had this earlier, now this
Louis
LouisOPโ€ข3y ago
Louis
LouisOPโ€ข3y ago
it clearly says the module express and defines it so i dont know what the problem is
Unknown User
Unknown Userโ€ข3y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOPโ€ข3y ago
what should i label it on other js-ts
Unknown User
Unknown Userโ€ข3y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOPโ€ข3y ago
Louis
LouisOPโ€ข3y ago
Louis
LouisOPโ€ข3y ago
what is it instead of this, i know its changed
d.js docs
d.js docsโ€ข3y ago
Tag suggestion for @louisnecker: Sending and editing now takes only a single object parameter!
- channel.send(embed);
+ channel.send({ embeds: [embed, embed2] });
- channel.send('Hello!', { embed });
+ channel.send({ content: 'Hello!', embeds: [embed, embed2] });
- channel.send(embed);
+ channel.send({ embeds: [embed, embed2] });
- channel.send('Hello!', { embed });
+ channel.send({ content: 'Hello!', embeds: [embed, embed2] });
- V12-v13 migration guide: learn more - V13-v14 migration guide: learn more
Louis
LouisOPโ€ข3y ago
@sir.lupus sorry, regarding this it shoul d it be channel.send({ embed: [embed}}; but i need get(muffinpoo) right?
const muffinpoo = '810943143314587688'
const muffinpoo = '810943143314587688'
`
lupus
lupusโ€ข3y ago
That depends on what the variable โ€œmuffinpooโ€ is
Louis
LouisOPโ€ข3y ago
its the logs channel in my server to see what servers are added and removed
Louis
LouisOPโ€ข3y ago
Louis
LouisOPโ€ข3y ago
basically to do this (last time it worked was may) what does it need to be instead then?
lupus
lupusโ€ข3y ago
If muffinpoo is an embed, you can use <Channel>.send({ embeds: [muffinpoo]}); to send an embed to <Channel>.
Louis
LouisOPโ€ข3y ago
Sorry I don't know what you mean <channel>
Louis
LouisOPโ€ข3y ago
what do you want before .send
Louis
LouisOPโ€ข3y ago
muffinpoo is just the channel i want to send it in but how to i sent the embed
KAVI
KAVIโ€ข3y ago
Basically the channel object If muffinpoo is the stored channel Then use send on that Oh wait I just backread No You have to get the channel from the cache using that ID And then use send on it
Louis
LouisOPโ€ข3y ago
So what exactly do I need to send? message.channel.send({ embeds: [muffinpoo] }) ?
Louis
LouisOPโ€ข3y ago
Louis
LouisOPโ€ข3y ago
client.channels.cache.get('channel id to send in').send({ embeds: [muffinpoo] }) using that
lupus
lupusโ€ข3y ago
Is muffinpoo the channel id you want the message to be sent in?
Louis
LouisOPโ€ข3y ago
Yes
KAVI
KAVIโ€ข3y ago
Then yes Wait no Omg muffinpoo IS the ID you need to use there To get the channel from the cache It is NOT and embed
Louis
LouisOPโ€ข3y ago
Yes, so how do I get it to do the embed
KAVI
KAVIโ€ข3y ago
you can ONLY send embed objects in the embed array I just explained..... Use muffinpoo variable in the cache.get() fn and then send whatever embed you want to send. There are additional stuff like making sure the channel you're getting is what you want but yeah.
Louis
LouisOPโ€ข3y ago
So it's client.channels.cache.get('muffinpoo').send({ embeds: [????] })
KAVI
KAVIโ€ข3y ago
yes Client's channel cache is way bigger than the guild's channel cache, if the bot is in multiple servers So if you have the guild object use it on that instead
Louis
LouisOPโ€ข3y ago
What's the ????? Gonna be? ? Sorry what?
KAVI
KAVIโ€ข3y ago
<:T_high:800810451302088718> The embed object you created using EmbedBuilder or an APIEmbed object
Louis
LouisOPโ€ข3y ago
What is the embed object
KAVI
KAVIโ€ข3y ago
<Guild>.channels.cache also exists. Which searches the guild's own cache. Searching for <Client>.channels.cache is not necessary if you have the said guild object.
lupus
lupusโ€ข3y ago
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
Louis
LouisOPโ€ข3y ago
Ok why are you adding <> either side
KAVI
KAVIโ€ข3y ago
Because those objects can be stored in variables as well. We don't know what others use in their code for variables. It's to show what the variable should contain in that scenario. You have the freedom to store anything in variables and call functions on them Rather than using them directly Depends on the code style
Louis
LouisOPโ€ข3y ago
What so does it need to be guild.channel.cache or 'guildid'.channel.cache
KAVI
KAVIโ€ข3y ago
Strings don't have a channel cache The first case and channels Not channel
Louis
LouisOPโ€ข3y ago
No I don't need ' but I ment if the guild id is 3848398783747 then would I do 38474833773747.channel.cache
KAVI
KAVIโ€ข3y ago
Doesn't change anything mate That makes it a very big integer Without the ' ' Integers don't have caches as well Use the guild object Directly
Louis
LouisOPโ€ข3y ago
So what exactly do I need to replace this
lupus
lupusโ€ข3y ago
Quick Side question: Wouldnโ€™t it be better to use .fetch as that would first attempt the cache and after that query discord if for some reason cache isnโ€™t up to date or is .cache preferred?
KAVI
KAVIโ€ข3y ago
What you said is correct yes. Normally the cache is populated with all the channels inside the guild when a guild.fetch() is used anywhere once within the code afaik Except for archived threads or the sort. In those cases using fetch is preferred to prevent errors. But if you don't have anything that caches everything at start from the gateway and prefers to populate it on the go... then your method is the best way to go <:teri_point2:947453665164283935>
lupus
lupusโ€ข3y ago
Alright, this confused me for a while now as I kind of always use fetch and the method itself only uses this.cache.get internally but Iโ€™ve always seen others recommending cache, Ty for the clarification.
KAVI
KAVIโ€ข3y ago
caches are like in memory data stores so hitting the memory is always faster to get stuff. And idk if it's just me but sometimes using fetch is slower than the cache... idk if it's when the channel is actually not inside the cache and the process goes. Fetch from API -> Cache -> Then process But yeah.... fetch is overall better to prevent any overhead errors so dun change your code to cache all of a sudden <:nb_cat_pat:851511871664029707>
Louis
LouisOPโ€ข3y ago
But if this is wrong what should iy be with guild.channel or whatever?
KAVI
KAVIโ€ข3y ago
Bro.... Like I said...... It's wrong because for two reasons. One is you're trying to send a string in the embeds array which won't work. Two is there's no need to probe the Client's cache while a local guild cache exists. You can do guild.channels.cache.get(channelID)?.send({ embeds: [] }) or like our discussion above. await guild.channels.fetch(channelID).then(c => c.send()) or use variables to hold the result and do it like that
lupus
lupusโ€ข3y ago
Hmm, I can't really see anything suggesting that in the source code of .fetch() but it might be for some reason, yeah
KAVI
KAVIโ€ข3y ago
Maybe it's my imagination then. Thanks for the clarification as well
Louis
LouisOPโ€ข3y ago
guild.channels.cache.get(channelID).send({ embeds: [muffinpoo] })
lupus
lupusโ€ข3y ago
Are you aware of how plain JS objects and similar work?
Louis
LouisOPโ€ข3y ago
No
KAVI
KAVIโ€ข3y ago
Are you aware of how JS works ? And nodeJS If you're gonna say no then it's better if you can brush up your knowledge on the language first using our #resources And #rules 3 If yes then that's now how the embeds array handles embeds lupus even linked you a guide on how to handle embeds
Louis
LouisOPโ€ข3y ago
Yes the tag didn't make sense @qjuh As you can see the tag looks completely different to my code
Louis
LouisOPโ€ข3y ago
Can you see mine is client.channels.cache.... and the tag is channel.send which isn't my code
Louis
LouisOPโ€ข3y ago
What?
KAVI
KAVIโ€ข3y ago
dogeHaHa lemme ask it more simply for you. There's a bucket, which has a lot of channels in it. you reach in and grab something out, what do you have in your hand If you think a bit on that question along with the tag that qjuh provied for you You have the answer And if you think hard enough. What we all said after that will be clear

Did you find this page helpful?