升级到 discord.js v13 后,如果想从一条消息中发送附件,则需要使用
错误发生的部分在这里:
Array.from(message.attachments.values())
代替 message.attachments.array()
。message.client.channels.cache.get("123456789").send({
files: [Array.from(message.attachments.values())],
content: `test`
});
我从node模块的控制台中得到一个错误:
Desktop\Bot\node_modules\discord.js\src\structures\MessagePayload.js:223
if (thing.path) {
^
TypeError: Cannot read property 'path' of undefined
错误发生的部分在这里:
const findName = thing => {
if (typeof thing === 'string') {
return Util.basename(thing);
}
if (thing.path) {
return Util.basename(thing.path);
}
return 'file.jpg';
};
我真的很困惑,不知道出了什么问题或者如何解决,有人能帮帮我吗?