mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-21 20:54:58 +05:00
change backup folder to bot folder
This commit is contained in:
parent
80bbc69d82
commit
2d5cb0ed13
2 changed files with 17 additions and 21 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -9,6 +9,9 @@ yarn.lock
|
|||
# DB
|
||||
giveaways.json
|
||||
|
||||
# Backups
|
||||
backups
|
||||
|
||||
# Mac OS files
|
||||
.DS_Store
|
||||
|
||||
|
|
|
@ -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
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue