-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathsettings.js
More file actions
24 lines (20 loc) · 816 Bytes
/
settings.js
File metadata and controls
24 lines (20 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const fs = require('fs');
const path = require('path');
// Path to settings file
const settingsFilePath = path.join(__dirname, 'settings.json');
// Load settings from the file
function loadSettings() {
if (fs.existsSync(settingsFilePath)) {
return JSON.parse(fs.readFileSync(settingsFilePath, 'utf-8'));
} else {
// Create a default settings file if it doesn't exist
const defaultSettings = { antilink: false, antiinvite: false, antispam: false, antinuke: false };
fs.writeFileSync(settingsFilePath, JSON.stringify(defaultSettings, null, 2));
return defaultSettings;
}
}
// Save settings to the file
function saveSettings(settings) {
fs.writeFileSync(settingsFilePath, JSON.stringify(settings, null, 2));
}
module.exports = { loadSettings, saveSettings };