【发布时间】:2018-12-06 10:10:22
【问题描述】:
已经找到same issue,但是那里没有答案:C
所以我的问题是一样的,使用 Discord.js 库,这是我的代码:
client.on('message', msg => {
var splittedMessage = msg.content.split("#");
if (msg.channel.type == "dm") {
if (msg.content === "booya") {
msg.channel.send('Hello there, ' + msg.author.username)
.then(msg => console.log('Sent #' + msg.id + ': ' + msg.content))
.catch(console.error);
return
} else {
msg.channel.send('No query found')
.then(msg => console.log('Sent #' + msg.id + ': ' + msg.content))
.catch(console.error);
return
}
}
});
这是结果:Screenshot
【问题讨论】:
-
是否有可能
client.on('message')也被调用以获取机器人本身发送的消息?你试过console.log(message)看看发生了什么吗? -
@AKX 例如,这段代码只能正常工作一次:https://pastebin.com/3e9K6S16
标签: javascript node.js discord.js