【发布时间】:2020-12-31 14:39:27
【问题描述】:
我一直在尝试编写这个不和谐机器人来通过 DM 向某个人发送消息。它应该工作的方式是:
tb!send @usernamehere Hi
然后这应该向@usernamehere发送一条DM消息,说“嗨”。但相反,我收到一条错误消息TypeError: mention.send is not a function。这是我的代码:
client.on('message', (message) => {
var msg = message.content.toLowerCase();
if (message.author.bot) return;
let mention = message.mentions.users.first().id;
if (msg.startsWith(prefix + 'send')) {
console.log('ok');
if (mention == null) return;
message.delete();
var mentionMessage = message.content.slice(8);
mention.send(mentionMessage);
message.channel.send('done!');
}
});
【问题讨论】:
标签: javascript discord discord.js typeerror