From 2d5cb0ed1306851ff4ba9be9d2fac4058166baeb Mon Sep 17 00:00:00 2001 From: JonnyBro Date: Tue, 4 Jan 2022 23:54:12 +0500 Subject: [PATCH] change backup folder to bot folder --- .gitignore | 3 +++ commands/Administration/backup.js | 35 +++++++++++++------------------ 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 4ce366a1..d3019cc4 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,9 @@ yarn.lock # DB giveaways.json +# Backups +backups + # Mac OS files .DS_Store diff --git a/commands/Administration/backup.js b/commands/Administration/backup.js index 62a62bf5..15457c9f 100644 --- a/commands/Administration/backup.js +++ b/commands/Administration/backup.js @@ -2,6 +2,8 @@ const Command = require("../../base/Command.js"), Discord = require("discord.js"), backup = require("discord-backup"); +backup.setStorageFolder(__dirname + "../../../backups"); + class Backup extends Command { constructor(client) { super(client, { @@ -49,24 +51,21 @@ class Backup extends Command { max: 1, time: 20000, errors: ["time"] - }).catch(() => { - // if the author of the commands does not confirm the backup loading + }).catch((err) => { + console.error(err); return message.error("administration/backup:TIMES_UP"); }); - // When the author of the command has confirmed that he wants to load the backup on his server message.author.send(message.translate("administration/backup:START_LOADING")); - // Load the backup + backup.load(backupID, message.guild).then(() => { - // When the backup is loaded, delete them from the server backup.remove(backupID); message.author.send(message.translate("administration/backup:LOAD_SUCCESS")); }).catch((err) => { console.error(err); - // If an error occurenced return message.error("misc:ERR_OCCURRED"); }); - }).catch(() => { - // if the backup wasn't found + }).catch((err) => { + console.error(err); return message.error("administration/backup:NO_BACKUP_FOUND", { backupID }); @@ -75,19 +74,15 @@ class Backup extends Command { const backupID = args[1]; if (!backupID) return message.error("administration/backup:MISSING_BACKUP_ID"); - backup.fetch(backupID).then(async (backupInfos) => { + backup.fetch(backupID).then(async (backupInfo) => { const embed = new Discord.MessageEmbed() .setAuthor({ name: message.translate("administration/backup:TITLE_INFO") }) - // Display the backup ID - .addField(message.translate("administration/backup:TITLE_ID"), backupInfos.id, true) - // Displays the server from which this backup comes - .addField(message.translate("administration/backup:TITLE_SERVER_ID"), backupInfos.data.guildId, true) - // Display the size (in mb) of the backup - .addField(message.translate("administration/backup:TITLE_SIZE"), `${backupInfos.size}mb`, true) - // Display when the backup was created - .addField(message.translate("administration/backup:TITLE_CREATED_AT"), message.printDate(new Date(backupInfos.data.createdTimestamp)), true) + .addField(message.translate("administration/backup:TITLE_ID"), backupInfo.id, true) + .addField(message.translate("administration/backup:TITLE_SERVER_ID"), backupInfo.data.guildID.toString(), true) + .addField(message.translate("administration/backup:TITLE_SIZE"), `${backupInfo.size} kb`, true) + .addField(message.translate("administration/backup:TITLE_CREATED_AT"), message.printDate(new Date(backupInfo.data.createdTimestamp)), true) .setColor(data.config.embed.color) .setFooter({ text: data.config.embed.footer @@ -97,7 +92,6 @@ class Backup extends Command { }); }).catch((err) => { console.error(err); - // if the backup wasn't found return message.error("administration/backup:NO_BACKUP_FOUND", { backupID }); @@ -113,15 +107,14 @@ class Backup extends Command { time: 20000, errors: ["time"] }).catch(() => { - // if the author of the commands does not confirm the backup loading return message.error("administration/backup:TIMES_UP"); }); backup.remove(backupID).then(async () => { message.success("administration/backup:SUCCESS_REMOVED"); }); - }).catch(() => { - // if the backup wasn't found + }).catch((err) => { + console.error(err); return message.error("administration/backup:NO_BACKUP_FOUND", { backupID });