use os.tmp() to get tmp dir instead of /tmp/

This commit is contained in:
loicbersier 2019-09-13 19:06:19 +02:00
parent 2337047752
commit 5dd5a73dfc

View file

@ -1,6 +1,7 @@
const { Command } = require('discord-akairo'); const { Command } = require('discord-akairo');
const Tag = require('../../models').Tag; const Tag = require('../../models').Tag;
const fs = require('fs'); const fs = require('fs');
const os = require('os');
const { MessageEmbed } = require('discord.js'); const { MessageEmbed } = require('discord.js');
@ -60,9 +61,9 @@ class seetagCommand extends Command {
tagList.forEach(tag => { tagList.forEach(tag => {
tagArray.push(tag.dataValues); tagArray.push(tag.dataValues);
}); });
fs.writeFile('/tmp/tagslist.txt',JSON.stringify(tagArray, null, 2), function(err) { fs.writeFile(`${os.tmpdir()}/tagslist.txt`,JSON.stringify(tagArray, null, 2), function(err) {
if (err) return console.error(err); if (err) return console.error(err);
return message.channel.send('Here are your tags', {files: ['/tmp/tagslist.txt']}); return message.channel.send('Here are your tags', {files: [`${os.tmpdir()}/tagslist.txt`]});
}); });
} else { } else {
let tagList = await Tag.findAll({attributes: ['trigger'], where: {serverID: message.guild.id}}); let tagList = await Tag.findAll({attributes: ['trigger'], where: {serverID: message.guild.id}});