no sleep
no sleep
DIAdiscord.js - Imagine an app
Created by no sleep on 5/13/2024 in #djs-questions
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') 
7 replies