Add per server prefix (#7)

* Add ability to load server prefix

* Add ability to set prefix for a server

* Create serverPrefixes.json file if not found
This commit is contained in:
Ozzy 2021-03-13 03:57:53 +01:00 committed by GitHub
parent ae1ce65602
commit 4717de1712
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 79 additions and 8 deletions

View file

@ -0,0 +1,18 @@
const fs = require('fs')
module.exports = function (client) {
try {
if(!fs.existsSync('serverPrefixes.json')){
console.log("Creating loadServerPrefixes.json...")
fs.writeFileSync("serverPrefixes.json","[]")
}
const json = fs.readFileSync('serverPrefixes.json', 'utf8');
const serverPrefixes = JSON.parse(json);
serverPrefixes.forEach(server => {
client.serverPrefixes.set(server.id, server.prefix)
});
} catch (err) {
console.log(`Error reading file from disk: ${err}`);
}
}