[英]Discord bot not responding to command javascript
I have been trying to make a Discord bot that responds to the user when they ask for help.我一直在尝试制作一个 Discord 机器人,当用户寻求帮助时,它会响应用户。 Sadly I can't seem to get the bot to work.
可悲的是,我似乎无法让机器人工作。 I am using Discord.JS on Node.JS.
我在 Node.JS 上使用 Discord.JS。 Any help would be welcome.
欢迎任何帮助。
const Discord = require('discord.js');
const bot = new Discord.Client();
const token = '[token removed]';
const PREFIX = '!';
bot.on('ready', () => {
console.log('K08 Help Bot is online!');
})
bot.on('message', message=>{
let args = message.content.substring(PREFIX.lenght).split(" ");
switch(args[0]){
case 'help':
message.reply('HELLO');
break;
}
})
bot.login(token);
This might be the issue: let args = message.content.substring(PREFIX.lenght).split(" ");
这可能是问题所在:
let args = message.content.substring(PREFIX.lenght).split(" ");
- length
is mistyped as lenght
-
length
被错误输入为lenght
On a side note: I've submitted an edit to hide your token in this question.附带说明:我已提交编辑以在此问题中隐藏您的令牌。 For security, you should never share your token;
为了安全起见,你永远不应该分享你的代币; it would allow someone to take over your bot!
它将允许某人接管您的机器人!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.