Code Update

Hi all, just a quick one. I'm updating from v12 to v13, and need to amend about 90% of the bot's code. Once I've got the first part, I should be able to work out the rest, but can someone please help me with the updated code line for the following, please?
const Guild = Structures.get('Guild')
const Guild = Structures.get('Guild')
Many thanks in advance
13 Replies
d.js docs
d.js docs3y 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.
Squid
Squid3y ago
Structures were removed entirely in v13
≪ °✾° ≫ 𝓓𝓮𝓵𝓽𝓪_𝓑𝓻𝓪𝓿𝓸92 ≪ °✾° ≫
What do I need to be using instead, please? This is the error I have on my console: /home/container/structures/Guild.js:3 const Guild = Structures.get('Guild') ^ TypeError: Cannot read properties of undefined (reading 'get') at Object.<anonymous> (/home/container/structures/Guild.js:3:26) at Module._compile (node:internal/modules/cjs/loader:1099:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:975:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:999:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (/home/container/index.js:1:1) at Module._compile (node:internal/modules/cjs/loader:1099:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) Node.js v17.9.1
space
space3y ago
You can use the Guild exported from discord.js. Not sure what you'd need either though.
≪ °✾° ≫ 𝓓𝓮𝓵𝓽𝓪_𝓑𝓻𝓪𝓿𝓸92 ≪ °✾° ≫
So can I just remove that entire line, then?
space
space3y ago
If you are not using the variable you declare there anywhere, sure.
≪ °✾° ≫ 𝓓𝓮𝓵𝓽𝓪_𝓑𝓻𝓪𝓿𝓸92 ≪ °✾° ≫
My concern is that there are quite a few modules that do use that constant, so I do need to define it
space
space3y ago
Then you can use the class directly exported from discord.js.
≪ °✾° ≫ 𝓓𝓮𝓵𝓽𝓪_𝓑𝓻𝓪𝓿𝓸92 ≪ °✾° ≫
And where do I need to go to find that, please?
space
space3y ago
I don't quite understand, what do you mean?
≪ °✾° ≫ 𝓓𝓮𝓵𝓽𝓪_𝓑𝓻𝓪𝓿𝓸92 ≪ °✾° ≫
Where would I find the "class directly exported from discord.js" so that I can make sure it is defined?
space
space3y ago
You mean how to import it? The same as you did with Structures.
≪ °✾° ≫ 𝓓𝓮𝓵𝓽𝓪_𝓑𝓻𝓪𝓿𝓸92 ≪ °✾° ≫
It's so long since I created the bot, I can't remember how I imported Literally only have:
const { Structures } = require('discord.js')
const { Structures } = require('discord.js')
Want results from more Discord servers?
Add your server