【发布时间】:2020-07-02 05:07:50
【问题描述】:
基本上,我已经使用 discord.js 库开发了一个机器人好几个星期了,最近遇到了一个小而关键的问题。本质上,当我声明我的论点时,我也这样做了,以便使用 .toUpperCase() 将消息内容 (message.content) 大写。基本上这样做,无论您输入的前缀类型如何(符号方面),程序都会将其全部读取为有效。
仅举例:!help - 应该可以,但是如果我输入 .help,它也会被读取为有效。
无论如何,这里是代码。感谢所有帮助!
bot.on('message', message =>{
let args = message.content.toUpperCase().substring(PREFIX.length).split(" ");
const sender = message.member;
switch(args[0])
{
case 'HELP':
message.reply("I've sent you some documentation on all the commands that you can use...").then(d_msg => {d_msg.delete(3000); });
message.delete(3000);
const attachment = new Attachment('./UtilityBot_Documentation.txt')
message.author.send('[Education] Bot - Documentation');
message.author.send(attachment);
break;
}
})
【问题讨论】:
-
有什么问题?
标签: api bots discord discord.js