Move Datastore class to src/client/classes folder

This commit is contained in:
Christer Warén 2021-09-10 23:25:48 +03:00
parent b9e1945719
commit 57f63c3838
2 changed files with 5 additions and 5 deletions

View File

@ -1,6 +1,6 @@
import Discord, { Client, Collection } from "discord.js";
import fs from "fs";
import Datastore from "./client/datastore.js";
import Datastore from "./client/classes/Datastore.js";
import { command, radio } from "./client/utils/typings.js";
import config from "./config.js";
import messages from "./client/messages.js";

View File

@ -8,15 +8,15 @@ module.exports = class {
}
loadData() {
const dir = path.join(path.dirname(__dirname), '../datastore');
const dir = path.join(path.dirname(__dirname), '../../datastore');
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
//console.log("");
const dataFiles = fs.readdirSync(path.join(path.dirname(__dirname), '../datastore')).filter(f => f.endsWith('.json'));
const dataFiles = fs.readdirSync(path.join(path.dirname(__dirname), '../../datastore')).filter(f => f.endsWith('.json'));
for (const file of dataFiles) {
try {
const json = require(`../../datastore/${file}`);
const json = require(`../../../datastore/${file}`);
this.map.set(json.guild.id, json);
//console.log('[LOADED] ' + file + " (" + json.guild.id + ")");
//console.log(JSON.stringify(json, null, 4));
@ -127,7 +127,7 @@ module.exports = class {
saveEntry(file, data) {
data = JSON.stringify(data, null, 4);
fs.writeFile(path.join(path.dirname(__dirname), '../datastore') + "/" + file + ".json", data, 'utf8', function(err) {
fs.writeFile(path.join(path.dirname(__dirname), '../../datastore') + "/" + file + ".json", data, 'utf8', function(err) {
if (err) {
//console.log(err);
}