首页 > 解决方案 > 将文件复制到新位置

问题描述

我正在尝试使用文件夹中的新文件中的数据复制文件。
我试过这样做,但没有奏效:

copyFile(`./data/guilddata/guilds/default/GUILDID.json`, `./data/guilddata/guilds/${guild.id}/GUILDID.json`, (err) => {
    if (err) throw err;
});

https://www.npmjs.com/package/fs-copy-file

有谁知道该怎么做?(${guild.id}仅表示公会ID,该文件夹已经存在)。我也没有错误。谢谢

标签: javascriptbotsdiscordfsdiscord.js

解决方案


const fs = require('fs');

fs.copyFile('./data/guilddata/guilds/default/GUILDID.json', './data/guilddata/guilds/' + guild.id + '/GUILDID.json', (err) => {
  if (err) throw err;
  console.log('All done! The file is copied!');
});

推荐阅读