const { Client, Collection } = require('discord.js');
const { loadCommands, loadEvents } = require('./utils/loader');
const { TOKEN } = require('./config');
const client = new Client();
['commands', 'cooldowns'].forEach(x => client[x] = new Collection());
loadCommands(client);
loadEvents(client);
client.login(TOKEN);
const { Collection } = require('discord.js'); // Retrieving DiscordJS functionalities
const { PREFIX } = require('../../config'); // Retrieving the information contained in the file 'config.js'
module.exports = (client, message) => {
if (!message.content.startsWith(PREFIX) || message.author.bot) return; // Ignore the message if it's not a command
const args = message.content.slice(PREFIX.length).split(/ +/); // Arguments can be found within the command
const commandName = args.shift().toLowerCase(); // We establish the command that is requested
const user = message.mentions.users.first();
// Check if the requested command exists
// THE ERROR IS ON THE LINE BELOW
const command = client.commands.get(commandName) || client.commmands.find(cmd => cmd.help.aliases && cmd.help.aliases.includes(commandName));
if (!command) return;
[...]
// Execution of the command
command.run(client, message, args);
}
D:\Developpement\Chamiro\events\client\message.js:11
const command = client.commands.get(commandName) || client.commmands.find(cmd => cmd.help.aliases && cmd.help.aliases.includes(commandName));
^
TypeError: Cannot read property 'find' of undefined
at module.exports (D:\Developpement\Chamiro\events\client\message.js:11:74)
at Client.emit (events.js:315:20)
at MessageCreateAction.handle (D:\Developpement\Chamiro\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (D:\Developpement\Chamiro\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (D:\Developpement\Chamiro\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31)
at WebSocketShard.onPacket (D:\Developpement\Chamiro\node_modules\discord.js\src\client\websocket\WebSocketShard.js:436:22)
at WebSocketShard.onMessage (D:\Developpement\Chamiro\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10)
at WebSocket.onMessage (D:\Developpement\Chamiro\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (D:\Developpement\Chamiro\node_modules\ws\lib\websocket.js:797:20)
一点帮助就好了:) 谢谢
答案 0 :(得分:0)
看起来像第 11 行的拼写错误。命令是用 3x "m" 写的