mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2024-12-23 06:33:18 +00:00
Move Datastore class to src/client/classes folder
This commit is contained in:
parent
b9e1945719
commit
57f63c3838
@ -1,6 +1,6 @@
|
|||||||
import Discord, { Client, Collection } from "discord.js";
|
import Discord, { Client, Collection } from "discord.js";
|
||||||
import fs from "fs";
|
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 { command, radio } from "./client/utils/typings.js";
|
||||||
import config from "./config.js";
|
import config from "./config.js";
|
||||||
import messages from "./client/messages.js";
|
import messages from "./client/messages.js";
|
||||||
|
@ -8,15 +8,15 @@ module.exports = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadData() {
|
loadData() {
|
||||||
const dir = path.join(path.dirname(__dirname), '../datastore');
|
const dir = path.join(path.dirname(__dirname), '../../datastore');
|
||||||
if (!fs.existsSync(dir)) {
|
if (!fs.existsSync(dir)) {
|
||||||
fs.mkdirSync(dir);
|
fs.mkdirSync(dir);
|
||||||
}
|
}
|
||||||
//console.log("");
|
//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) {
|
for (const file of dataFiles) {
|
||||||
try {
|
try {
|
||||||
const json = require(`../../datastore/${file}`);
|
const json = require(`../../../datastore/${file}`);
|
||||||
this.map.set(json.guild.id, json);
|
this.map.set(json.guild.id, json);
|
||||||
//console.log('[LOADED] ' + file + " (" + json.guild.id + ")");
|
//console.log('[LOADED] ' + file + " (" + json.guild.id + ")");
|
||||||
//console.log(JSON.stringify(json, null, 4));
|
//console.log(JSON.stringify(json, null, 4));
|
||||||
@ -127,7 +127,7 @@ module.exports = class {
|
|||||||
saveEntry(file, data) {
|
saveEntry(file, data) {
|
||||||
data = JSON.stringify(data, null, 4);
|
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) {
|
if (err) {
|
||||||
//console.log(err);
|
//console.log(err);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user