MessageCreate handle command does not work

In the process of moving from v13 to v14, the slash command was successful, but the normal command did not work, so I'm asking you a question

client.commands = new Collection()
client.aliases = new Collection()

const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'))

for (const file of commandFiles) {
    const command = require(`./commands/${file}`)
    client.commands.set(command.name, command)
    console.log("--------------------\nload | " + command.name + ` | ${client.commands.size}개`)
}


client.on('messageCreate', (message) => {
    if (!message.content.startsWith(prefix) || message.author.bot) return
    blacklist.findOne({ id : message.author.id }
        .then((data) => {
        if(err) throw err;
        if(!data) {
        const args = message.content.slice(prefix.length).trim().split(/ +/)
      const commandName = args.shift().toLowerCase()
      client.run(commandName)
      const command = client.commands.get(commandName) || client.commands.find(a => a.aliases && a.aliases.includes(commandName))
    if (!command) return
    try{
        command.execute(message, args, client)
        const utc = new Date().getTime() + (new Date().getTimezoneOffset() * 60 * 1000)
        var currentdate = new Date(utc + (9 * 60 * 60 * 1000))
        var datetime = currentdate.getFullYear() + "-"
        + (currentdate.getMonth()+1)  + "-" 
        + currentdate.getDate() + " "  
        + currentdate.getHours() + ":"  
        + currentdate.getMinutes() + ":" 
        + currentdate.getSeconds()
        const wc = new WebhookClient({
            id: 'id',
            token: 'token'
        })
        const embed = new EmbedBuilder()
    .setTitle(`시간: ${datetime}`)
    .addFields('핸들링: 커맨드', `command: 『${command.name}』`)
    .setTimestamp()
    .setColor('#2C2F33')
    wc.send({
        avatarURL : "png",
        embeds : [embed]
    })
        } catch (error) {
        console.error(error)
        message.reply('error')
    }
        }
    }))
})

discord.js: 14.14.1
Node.js: 20.11.0
Was this page helpful?