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