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