Discord.js 未处理的PromisejectionWarning:TypeError:无法读取属性';从'开始;未定义的
我是discord bot开发的新手,遇到如下错误:Discord.js 未处理的PromisejectionWarning:TypeError:无法读取属性';从'开始;未定义的,discord.js,Discord.js,我是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\De
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)
消息。内容
未定义。可能以错误的顺序传递了(Discord、client、message)
。在将模块作为命令加载的主文件中,可能没有传递正确的变量
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);
}