所以,我是一个初学者的东西,使机器人和我半自在的我在现在只在Discord.js闲逛的空间,但我已经遇到了,我似乎无法前进的问题上。
我有一个是应该来检测,如果一个人的发送的图像或链接,输出的答复,然后删除图像(或链接)一个笑话机器人的东西。 (说真的,我宁愿删除任何没有文字,但我需要的回应说,它到底是什么样的媒体,所以我不在乎,如果它是特别的限制......)
下面是我有:
//remove instances of images
if (message.attachments.length > 0) {
message.channel.send(`${message.author} sent an image!`);
message.channel.send('This constitutes revelry and merriment and is strictly outlawed!')
message.delete();
}
//remove instances of links
if (message.embeds.length > 0) {
message.channel.send(`${message.author} sent an link!`);
message.channel.send('This constitutes revelry and merriment and is strictly outlawed!')
message.delete();
}
然而,如果我发送图像,它只是什么都不做。
提前致谢!
编辑:我还想说,机器人具有完美的作品其他功能(反应,删除,回复的某些词提及),所以希望唯一相关的代码应该是以上。
message#attachments
是一个集合,所以你必须使用:message.attachments.size