Transitioned all Misc, audio, Selmer Specific, admin, anime/manga, and inventory commands to Slash Command format. The RSS and reactionrole commands are still broken and all game commands are still in message format due to compications

This commit is contained in:
ION606
2022-09-27 16:45:50 -04:00
parent a190a250a6
commit e1002d748d
45 changed files with 1951 additions and 1058 deletions
+63
View File
@@ -0,0 +1,63 @@
const fs = require('fs');
const {Buffer} = require('buffer');
function mapToObj(map){
const obj = {}
for (let [k,v] of map) {
obj[k] = v
}
return obj
}
function objToMap(obj) {
const m = new Map();
for (i in obj) {
m.set(i, obj[i]);
}
return m;
}
async function backupLists(bot, IDM) {
try {
var backups = {}
backups.locked = mapToObj(bot.lockedChannels);
const bts = JSON.stringify({ "backups": backups });
if (IDM) {
fs.writeFile('commands/admin/backup.json', bts, 'utf8', (err) => {
// error checking
if(err) throw err;
console.log("New data added: " + bts);
process.exit(0);
});
} else {
process.env.backupLists = bts;
process.exit(0);
}
} catch (err) {
console.error(err);
exit(-1);
}
}
async function loadBotBackups(bot, IDM) {
try {
if (IDM) {
const botBackups = require('./backup.json').backups;
bot.lockedChannels = objToMap(botBackups.locked);
} else {
bot.lockedChannels = objToMap(JSON.parse(botBackups.locked));
}
} catch (err) {
console.error(err);
bot.lockedChannels = new Map();
const a = new Map();
}
}
module.exports = { backupLists, loadBotBackups }