【发布时间】:2020-10-03 00:58:45
【问题描述】:
我正在尝试创建一个执行此操作的不和谐机器人
如果消息中*有趣,它会将其从消息中分离出来,并发送与字符串“我不是爸爸。我是坏不和谐机器人”相结合的所有其他内容
const Discord = require('discord.js');
const bot2 = new Discord.Client();
const token2 = 'Not showing my token';
const mark = '*';
bot2.on('message', msg =>{
let args = msg.content.substring(mark.length).split(" ")
if(args[0] === "interesting"){
let argus = args.content.substring("interesting".length).split(" ")
var thee = concat(argus, " I'm not dad. I'm bad discord bot")
msg.channel.send(thee)
}
})
bot2.login(token2)
我更改了令牌,所以这里不显示。这是我运行此程序时遇到的错误。 c:\Users\Artashes\Desktop\bots\letus\index.js:9 让 argus = args.content.substring("interesting".length).split("") ^
TypeError: 无法读取未定义的属性“子字符串”
我终于明白没有定义的东西是 args.content。
我尝试将其更改为 args 无济于事。
我也尝试过 args.prototype 但出现了同样的错误。
我该如何解决这个错误
【问题讨论】:
标签: node.js discord.js