我想发出一个命令,其中!send image将在我的电脑上发送随机指定的图像。这是我的图像阵列
const images = [
'/mybot/images/any image i have there',
'other images'
]
这就是应该选择的方式
if(message.content === prefix + 'send image')
{
message.channel.send(`${message.author} here you have image`, {
file: RetardedImage[Math.floor(Math.random() * RetardedImage.length)]
});
}```
but it doesnt work and problem is that it doesnt even say error or something so i dont know what the problem is, can someone please help me?
答案 0 :(得分:0)
消息没有file
选项,它称为files
,它是一个数组:
if(message.content === prefix + 'send image')
{
message.channel.send(`${message.author} here you have image`, {
files: [
{
name: "myimage.png",
attachment: RetardedImage[Math.floor(Math.random() * RetardedImage.length)]
}
]
});
}
这将正确发送您的文件。
答案 1 :(得分:0)
您可以像这样进行附件
const attachment = new <Discord>.Attachment("PATH","NAME.EXTENSION")
message.channel.send(`blah blah`+attachment)