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 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.
Louis
LouisOP2y ago
I didn't know what flair to use :/
treble/luna
treble/luna2y ago
and the reason its not working is probably because you dont have the message content intent
Louis
LouisOP2y ago
what do you mean by that?
treble/luna
treble/luna2y ago
you need an intent to receive message content, which would explain why your bot is unresponsive
Louis
LouisOP2y ago
how do i get a intent?
treble/luna
treble/luna2y ago
by providing in it your client constructor but first npm ls discord.js and show me the output
Louis
LouisOP2y ago
treble/luna
treble/luna2y ago
yeah so v12 isnt supported anymore
Louis
LouisOP2y ago
ah ok how do i update?
d.js docs
d.js docs2y ago
guide Additional Information: Updating from v13 to v14 read moreguide Additional Information: Updating from v12 to v13 read more
treble/luna
treble/luna2y ago
its recommeded to update to v14
Zero Two
Zero Two2y ago
see @louisnecker
Louis
LouisOP2y ago
bro why r u here lol
Zero Two
Zero Two2y ago
to see if you got help lol
Louis
LouisOP2y ago
lol just fixing it now i think 🤞
Louis
LouisOP2y ago
Louis
LouisOP2y ago
he he he uh which command do i run its still at the same version
treble/luna
treble/luna2y ago
npm update discord.js
d.js docs
d.js docs2y 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
LouisOP2y ago
Louis
LouisOP2y ago
@wolvinny it wont update
treble/luna
treble/luna2y ago
do this
Louis
LouisOP2y ago
ok one after the other?
treble/luna
treble/luna2y ago
yes
Louis
LouisOP2y ago
treble/luna
treble/luna2y ago
and now you'll have to update your code
Louis
LouisOP2y ago
ok i think i need to update the token but i don't no where i update it
treble/luna
treble/luna2y ago
and update node
Louis
LouisOP2y ago
Louis
LouisOP2y ago
how do i do this?
treble/luna
treble/luna2y ago
Node.js
Node.js
Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.
Louis
LouisOP2y ago
i use replit?
treble/luna
treble/luna2y ago
i have no experience with replit, and i dont really recommend it either, better to get a real host, #resources
Louis
LouisOP2y 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/luna2y ago
there's no need to update the token, you need to update node
Louis
LouisOP2y 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/luna2y ago
this has nothing to do with djs, this is your node being outdated
Louis
LouisOP2y ago
why do i download this to update node everything was on replit for me
treble/luna
treble/luna2y ago
again, i have no experience with replit, and i dont intend to change that
Louis
LouisOP2y ago
do you know anyone else that can help
treble/luna
treble/luna2y ago
google it or get a real host, #resources
Louis
LouisOP2y ago
google what?
treble/luna
treble/luna2y ago
how to update node....
Louis
LouisOP2y ago
why does it need updating though ive never updated it
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOP2y 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 User2y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOP2y ago
its at v12 npm i [email protected] would be 16.??
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOP2y ago
isnt there a replit server??? i cant find it
egliod 🎃
egliod 🎃2y ago
@louisnecker
Louis
LouisOP2y ago
yes ?
egliod 🎃
egliod 🎃2y 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 🎃2y ago
this button
Louis
LouisOP2y ago
got it
egliod 🎃
egliod 🎃2y ago
here you can update it
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOP2y ago
?
egliod 🎃
egliod 🎃2y ago
lets move it to DMs
Louis
LouisOP2y ago
ok it is djs related now
Louis
LouisOP2y ago
d.js docs
d.js docs2y ago
- Websocket intents limit events and decrease memory usage: learn more - See what intents you need here
Louis
LouisOP2y ago
not sure about these intents @Jô 🌈 🦄 i dont know what i am supposed to be looking at
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOP2y 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/luna2y ago
.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOP2y ago
this one here? yes i have updated everything to the latest version
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
treble/luna
treble/luna2y 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
LouisOP2y ago
but im not sure what i am supposed to be doing
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOP2y ago
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOP2y ago
how do i know what i need to fix
Louis
LouisOP2y ago
the website is just double dutch to me
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOP2y 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 docs2y ago
guide Popular Topics: Gateway Intents read more
Louis
LouisOP2y 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
LouisOP2y 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 User2y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOP2y ago
?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOP2y ago
what ?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOP2y ago
it isnt in my bots code
MENIX
MENIX2y 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
LouisOP2y ago
what do you mean???
treble/luna
treble/luna2y 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
LouisOP2y 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
LouisOP2y ago
can you guys look at it?
treble/luna
treble/luna2y ago
what is there to look at? You've been told what to add
Louis
LouisOP2y ago
i dont know what to add and where
Louis
LouisOP2y ago
not to me it doesn't
treble/luna
treble/luna2y ago
then you should read
Louis
LouisOP2y 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
LouisOP2y ago
where am i putting this?
treble/luna
treble/luna2y ago
i dont know how else i can make it easier did you even write your bots code?
Louis
LouisOP2y ago
treble/luna
treble/luna2y ago
now where do you think it should be added? please just read
Louis
LouisOP2y ago
replace the const client line?
treble/luna
treble/luna2y ago
yes
Louis
LouisOP2y ago
IDE?
treble/luna
treble/luna2y ago
code editor
d.js docs
d.js docs2y 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
LouisOP2y ago
Louis
LouisOP2y ago
like this?
treble/luna
treble/luna2y ago
try it and see, i'm not gonna hold your hand
Louis
LouisOP2y ago
treble/luna
treble/luna2y ago
import it, basic js
Louis
LouisOP2y ago
import what?
treble/luna
treble/luna2y ago
.... what do you think you should import?
Louis
LouisOP2y ago
😕
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs2y ago
- ReferenceError: "x" is not defined: learn more - TypeError: Cannot read properties of undefined/null (reading "x"): learn more
Louis
LouisOP2y ago
so i need to add this to define it then?
treble/luna
treble/luna2y ago
no?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
treble/luna
treble/luna2y ago
i'm giving up, please read the guide or actually do what we tell you
Louis
LouisOP2y ago
or make it const client = new discord.client({
treble/luna
treble/luna2y ago
if discord is how you import it yes, you can also destructure it directly
Louis
LouisOP2y ago
im trying my best, sorry.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOP2y ago
Louis
LouisOP2y ago
its doing something when i run it anyway which i think is good
Louis
LouisOP2y ago
Louis
LouisOP2y ago
so im not on the latest version of Node then? ah
Louis
LouisOP2y ago
Louis
LouisOP2y ago
anyone know what this means? It looks bad and ive never seen it looks like some corruption 😟
treble/luna
treble/luna2y ago
thats your ide not being able to display a .sqlite file this isnt djs related though
Louis
LouisOP2y ago
Louis
LouisOP2y ago
this is a previous version and still a bit weird
treble/luna
treble/luna2y ago
again, not djs related
Louis
LouisOP2y ago
what does that mean
treble/luna
treble/luna2y ago
that your editor cannot display that file extension
Panda
Panda2y 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 User2y ago
Message Not Public
Sign In & Join Server To View
Panda
Panda2y ago
Ah my bad, should've paid attention
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOP2y 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
LouisOP2y ago
found this in may but doesn't really show a solution
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOP2y ago
why is it like this?
Louis
LouisOP2y ago
it had 1000s of members?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOP2y ago
do you know anywhere?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOP2y ago
i don't think they really have my issue do you know what i mean?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOP2y ago
Louis
LouisOP2y ago
had this earlier, now this
Louis
LouisOP2y ago
Louis
LouisOP2y ago
it clearly says the module express and defines it so i dont know what the problem is
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOP2y ago
what should i label it on other js-ts
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Louis
LouisOP2y ago
Louis
LouisOP2y ago
Louis
LouisOP2y ago
what is it instead of this, i know its changed
d.js docs
d.js docs2y 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
LouisOP2y 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
lupus2y ago
That depends on what the variable “muffinpoo” is
Louis
LouisOP2y ago
its the logs channel in my server to see what servers are added and removed
Louis
LouisOP2y ago
Louis
LouisOP2y ago
basically to do this (last time it worked was may) what does it need to be instead then?
lupus
lupus2y ago
If muffinpoo is an embed, you can use <Channel>.send({ embeds: [muffinpoo]}); to send an embed to <Channel>.
Louis
LouisOP2y ago
Sorry I don't know what you mean <channel>
Louis
LouisOP2y ago
what do you want before .send
Louis
LouisOP2y ago
muffinpoo is just the channel i want to send it in but how to i sent the embed
KAVI
KAVI2y 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
LouisOP2y ago
So what exactly do I need to send? message.channel.send({ embeds: [muffinpoo] }) ?
Louis
LouisOP2y ago
Louis
LouisOP2y ago
client.channels.cache.get('channel id to send in').send({ embeds: [muffinpoo] }) using that
lupus
lupus2y ago
Is muffinpoo the channel id you want the message to be sent in?
Louis
LouisOP2y ago
Yes
KAVI
KAVI2y 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
LouisOP2y ago
Yes, so how do I get it to do the embed
KAVI
KAVI2y 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
LouisOP2y ago
So it's client.channels.cache.get('muffinpoo').send({ embeds: [????] })
KAVI
KAVI2y 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
LouisOP2y ago
What's the ????? Gonna be? ? Sorry what?
KAVI
KAVI2y ago
<:T_high:800810451302088718> The embed object you created using EmbedBuilder or an APIEmbed object
Louis
LouisOP2y ago
What is the embed object
KAVI
KAVI2y 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
lupus2y ago
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
Louis
LouisOP2y ago
Ok why are you adding <> either side
KAVI
KAVI2y 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
LouisOP2y ago
What so does it need to be guild.channel.cache or 'guildid'.channel.cache
KAVI
KAVI2y ago
Strings don't have a channel cache The first case and channels Not channel
Louis
LouisOP2y ago
No I don't need ' but I ment if the guild id is 3848398783747 then would I do 38474833773747.channel.cache
KAVI
KAVI2y 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
LouisOP2y ago
So what exactly do I need to replace this
lupus
lupus2y 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
KAVI2y 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
lupus2y 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
KAVI2y 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
LouisOP2y ago
But if this is wrong what should iy be with guild.channel or whatever?
KAVI
KAVI2y 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
lupus2y 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
KAVI2y ago
Maybe it's my imagination then. Thanks for the clarification as well
Louis
LouisOP2y ago
guild.channels.cache.get(channelID).send({ embeds: [muffinpoo] })
lupus
lupus2y ago
Are you aware of how plain JS objects and similar work?
Louis
LouisOP2y ago
No
KAVI
KAVI2y 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
LouisOP2y ago
Yes the tag didn't make sense @qjuh As you can see the tag looks completely different to my code
Louis
LouisOP2y ago
Can you see mine is client.channels.cache.... and the tag is channel.send which isn't my code
Louis
LouisOP2y ago
What?
KAVI
KAVI2y 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
Want results from more Discord servers?
Add your server