How do I convert this code to v14 ?

const discord = require('discord.js')
const client = new discord.Client({
intents: [discord.Intents.FLAGS.GUILDS, discord.Intents.FLAGS.GUILD_MESSAGES]
})
const fs = require('fs')

client.slashcommands = new discord.Collection()
const slashCommandFiles = fs.readdirSync('./slashcmd').filter(file => file.endsWith('.js'))

for (let file of slashCommandFiles) {
const slash = require(`./slashcmd/${file}`)
console.log(`Slash command - ${file} loaded!`)
client.slashcommands.set(slash.data.name, slash)
}

client.on('ready', () => {

})

client.on('interactionCreate', async (interaction) => {
if (!interaction.isCommand()) return

const slashcmds = client.slashcommands.get(interaction.commandName)
if (!slashcmds) return

try {
await slashcmds.run(client, interaction)
} catch (e) {
console.error(e)
}
})

client.login('a') 
const discord = require('discord.js')
const client = new discord.Client({
intents: [discord.Intents.FLAGS.GUILDS, discord.Intents.FLAGS.GUILD_MESSAGES]
})
const fs = require('fs')

client.slashcommands = new discord.Collection()
const slashCommandFiles = fs.readdirSync('./slashcmd').filter(file => file.endsWith('.js'))

for (let file of slashCommandFiles) {
const slash = require(`./slashcmd/${file}`)
console.log(`Slash command - ${file} loaded!`)
client.slashcommands.set(slash.data.name, slash)
}

client.on('ready', () => {

})

client.on('interactionCreate', async (interaction) => {
if (!interaction.isCommand()) return

const slashcmds = client.slashcommands.get(interaction.commandName)
if (!slashcmds) return

try {
await slashcmds.run(client, interaction)
} catch (e) {
console.error(e)
}
})

client.login('a') 
3 Replies
d.js toolkit
d.js toolkit2mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
no sleep
no sleep2mo ago
Also how do I convert this code in v14 ?? Ping for replies
d.js docs
d.js docs2mo ago
Tag suggestion for @zack2345.: 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) Tag suggestion for @zack2345.: RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined - All SCREAMING_SNAKE_CASE enums have been changed to PascalCase - Intents: Intents.FLAGS.GUILD_MESSAGES -> GatewayIntentBits.GuildMessages - Permissions: Permissions.FLAGS.SEND_MESSAGES -> PermissionFlagsBits.SendMessages Suggestion for @zack2345.: :guide: Additional Information: Updating from v13 to v14 read more