#v13 to v14
1 messages · Page 1 of 1 (latest)
const BaseEvent = require('../../utils/structures/BaseEvent');
const { REST, Routes, Collection } = require('discord.js')
const StateManager = require('../../utils/StateManager');
const path = require("path");
const fs = require("node:fs");
require('dotenv').config({ path: '../.env' });
const rest = new REST({
version: '10'
}).setToken(process.env.BOT_TOKEN);
module.exports = class ReadyEvent extends BaseEvent {
constructor() {
super('ready');
this.connection = StateManager.connection;
}
async run(client) {
console.log(client.user.tag + ' has logged in.');
client.slashCommands = new Collection();
client.guildCommandPrefixes = new Collection();
// start of ( / ) cmds refreshing
// End of section
// Start of checking if all Guild-Ids are in the database
// End of section
// Start of getting all data out of the database
// End of section
// some code
}
}

thats my ready.js, it handels all the commands and interactions...
or do you want the bot.js
And that's not the way to do it I'm afraid.
Things are different in v14.
You should use a separate deploy-commands.js file like the new guide suggests
okay, ig i keep it in v13...
Your choice if you want to, but I advise against it
is it hard to switch?
No actually. If you were on v12 yes.
And depending on the size of the codebase
or is it more or less a copy and paste and re-arranging the code
its about 1200 lines...
excl. commands
but the commands stay the same (?)
The pain will be worth it trust me.
v13 will be deprecated sooner or later in favor for v14.
Major changes are mentioned in the guide as well I linked you.
If you follow that exactly and iron out the errors your're get you're good to go
I can feel the pain because I myself translated a whole JS project to TS alone with over a few hundred files 
But now I'm stress free and just maintaining the code.
why do they change it all the time :(((
v13 was a long time ago
alright, i wont do that but v14 sounds promissing..
With new discord changes it's necessary
You won't be able to do much in the v13 I'm afraid
And new updates to Discord is only available in v14
Like the new name change in the future dJS update
So on and so forth
const { MessageEmbed, SlashCommandBuilder } = require("discord.js");
module.exports = {
data: new SlashCommandBuilder()
.setName('info')
.setDescription('Info about the bot'),
when i do that, i get the error that SlashCommandBuilder is not a constructor... idk what to do, its the same style as on the discordjs site..
v13 to v14
npm ls discord.js
jonas@MacBook-Air-von-Jonas fr24db % npm ls discord.js
orange.db@1.2.7 /Users/jonas/Coding/fr24db
└── discord.js@14.11.0
jonas@MacBook-Air-von-Jonas fr24db %
strange.... wtf 
Also it's EmbedBuilder now. Use that instead of MessageEmbed.
Can you show the full error if possible
okay... i uninstalled and installed it, its working now, but other problems are there still...
problems like ?
And yeah removing and uninstalling is the better way.... I think the guide says it
redefining flags, but thats no problem 😄
Good luck then ! 
Keep it up.
thanks for your help

RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined.
what does that mean and how to fix it? it happend as soon as i changed from intent to gatewayintentbits
Code ples thx
const path = require('path');
require('dotenv').config({ path: path.join(__dirname, '..', '.env') });
const {Client, GatewayIntentBits, Collection, REST, Routes} = require('discord.js');
const {registerCommands, registerEvents} = require('./utils/register');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMemebers,
],
});
sure thing
The bits are right hmmm.
I just double checked with the enum
The problem is from where it's getting the undefined flag when you don't have something like that
okay i removed all npm packages and installing them rn... i made a backup maybe its working
still the same error...
Copy paste the entire error here
sure
[Running] node "/Users/jonas/Coding/fr24db/src/bot.js"
/Users/jonas/Coding/fr24db/node_modules/discord.js/src/util/BitField.js:172
throw new DiscordjsRangeError(ErrorCodes.BitFieldInvalid, bit);
^
RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined.
at IntentsBitField.resolve (/Users/jonas/Coding/fr24db/node_modules/discord.js/src/util/BitField.js:172:11)
at /Users/jonas/Coding/fr24db/node_modules/discord.js/src/util/BitField.js:167:54
at Array.map (<anonymous>)
at IntentsBitField.resolve (/Users/jonas/Coding/fr24db/node_modules/discord.js/src/util/BitField.js:167:40)
at new BitField (/Users/jonas/Coding/fr24db/node_modules/discord.js/src/util/BitField.js:33:38)
at new IntentsBitField (/Users/jonas/Coding/fr24db/node_modules/discord.js/src/util/IntentsBitField.js:9:1)
at Client._validateOptions (/Users/jonas/Coding/fr24db/node_modules/discord.js/src/client/Client.js:494:25)
at new Client (/Users/jonas/Coding/fr24db/node_modules/discord.js/src/client/Client.js:78:10)
at Object.<anonymous> (/Users/jonas/Coding/fr24db/src/bot.js:5:16)
at Module._compile (node:internal/modules/cjs/loader:1254:14) {
code: 'BitFieldInvalid'
}
Node.js v18.14.1
[Done] exited with code=1 in 0.213 seconds
This ?
Members
Not Memebers

lmao
The importance of paying attention to what VS Code points out

i feel so stupid rn
Happens. Iz fine.
||That's why I use TypeScript||
lmao its working now, still some things to fix but the hard work is over hahaha
thanks haha
Happy to help. Ping me if I don't respond immediately
Sure
Thanks
@snow edge
https://pastebin.com/3RKw3RzX
its starting normal but / commands wont work...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
console.log(Successfully reloaded ${data.length} application (/) commands.);
What does this line say ?
0 ?
Means the commands are in the API without errors hmmm
Restarting DC also fixes that sometimes.... also takes some time in rare cases
If even still same then code issue somewhere
Okay, I’ll try that later I have a train to catch but I hope that’ll work
okay so i always get the error "The application did not respond"
const { MessageEmbed, SlashCommandBuilder } = require("discord.js");
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('latency'),
async execute(client, interaction) {
await interaction.reply({
content: "pinging..."
});
const Botlatency = Math.abs(Date.now() - interaction.createdTimestamp);
const Apilatency = client.ws.ping;
await interaction.editReply({
content: `Bot latency: \`${Botlatency}ms\`, Api latency: \`${Apilatency}ms\` `
});
}
}
this is my code
i debugged it with a break point and it never reached it...