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')
}
}
}))
})
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
6 Replies
d.js toolkit
d.js toolkit11mo 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! - Marked as resolved by OP
treble/luna
treble/luna11mo ago
Show your client constructor
!                             알파
! 알파OP11mo ago
No description
d.js docs
d.js docs11mo ago
We highly recommend only specifying the intents you actually need. - Note, that 98303, 32767 or whatever other magic number you read that represents "all intents", gets outdated as soon as new intents are introduced. - The number will always represent the same set of intents, and will not include new ones. There is no magic "all intents" bit.
treble/luna
treble/luna11mo ago
Consider not using a magic number you dont know the meaning of Because there's your issue
!                             알파
! 알파OP11mo ago
oh Thank you
Want results from more Discord servers?
Add your server