我是 discord bot 开发的新手,我收到如下错误:
WOKCommands > Loaded 12 commands.
WOKCommands > Loaded 3 listeners.
(node:14932) **UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'startsWith' of undefined**
at module.exports (C:\Users\melih\Desktop\lechsbott\features\message.js:4:25)
at FeatureHandler.registerFeature (C:\Users\melih\Desktop\lechsbott\node_modules\wokcommands\dist\FeatureHandler.js:107:13)
at FeatureHandler.<anonymous> (C:\Users\melih\Desktop\lechsbott\node_modules\wokcommands\dist\FeatureHandler.js:161:28)
at step (C:\Users\melih\Desktop\lechsbott\node_modules\wokcommands\dist\FeatureHandler.js:52:23)
at Object.next (C:\Users\melih\Desktop\lechsbott\node_modules\wokcommands\dist\FeatureHandler.js:33:53)
at fulfilled (C:\Users\melih\Desktop\lechsbott\node_modules\wokcommands\dist\FeatureHandler.js:24:58)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
出现错误的代码:
module.exports = (Discord, client, message) =>{
const fs = 'l!';
const prefix = process.env.PREFIX;
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const cmd = args.shift().toLowerCase();
const command = client.commands.get(cmd);
if(command) command.execute(client, message, args, Discord);
}