【发布时间】:2020-12-25 06:35:48
【问题描述】:
我正在制作一个不和谐的机器人,我想知道你是否可以用它创建一个 JSON 文件。我还没有找到办法。我的命令对 &createfile {name} 做出反应,它总是会创建一个 JSON 文件。到目前为止我的代码:
const Discord = require('discord.js');
module.exports = {
name: 'createfile',
description: "The bot will create a .json file named after the argument",
execute(message, args){
var fileName = args[0]
if(!args) {
return message.reply('invalid name')
};
// Create file {fileName}.json
}
}
有没有办法创建这样的文件?谢谢:)
【问题讨论】:
-
你可能想看看 node.js 的
fs模块,尤其是writeFileSync函数。谷歌一下,你很快就明白了
标签: javascript json discord.js