mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-25 06:34: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
|
# DB
|
||||||
giveaways.json
|
giveaways.json
|
||||||
|
|
||||||
|
# Backups
|
||||||
|
backups
|
||||||
|
|
||||||
# Mac OS files
|
# Mac OS files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@ const Command = require("../../base/Command.js"),
|
||||||
Discord = require("discord.js"),
|
Discord = require("discord.js"),
|
||||||
backup = require("discord-backup");
|
backup = require("discord-backup");
|
||||||
|
|
||||||
|
backup.setStorageFolder(__dirname + "../../../backups");
|
||||||
|
|
||||||
class Backup extends Command {
|
class Backup extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
super(client, {
|
super(client, {
|
||||||
|
@ -49,24 +51,21 @@ class Backup extends Command {
|
||||||
max: 1,
|
max: 1,
|
||||||
time: 20000,
|
time: 20000,
|
||||||
errors: ["time"]
|
errors: ["time"]
|
||||||
}).catch(() => {
|
}).catch((err) => {
|
||||||
// if the author of the commands does not confirm the backup loading
|
console.error(err);
|
||||||
return message.error("administration/backup:TIMES_UP");
|
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"));
|
message.author.send(message.translate("administration/backup:START_LOADING"));
|
||||||
// Load the backup
|
|
||||||
backup.load(backupID, message.guild).then(() => {
|
backup.load(backupID, message.guild).then(() => {
|
||||||
// When the backup is loaded, delete them from the server
|
|
||||||
backup.remove(backupID);
|
backup.remove(backupID);
|
||||||
message.author.send(message.translate("administration/backup:LOAD_SUCCESS"));
|
message.author.send(message.translate("administration/backup:LOAD_SUCCESS"));
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
// If an error occurenced
|
|
||||||
return message.error("misc:ERR_OCCURRED");
|
return message.error("misc:ERR_OCCURRED");
|
||||||
});
|
});
|
||||||
}).catch(() => {
|
}).catch((err) => {
|
||||||
// if the backup wasn't found
|
console.error(err);
|
||||||
return message.error("administration/backup:NO_BACKUP_FOUND", {
|
return message.error("administration/backup:NO_BACKUP_FOUND", {
|
||||||
backupID
|
backupID
|
||||||
});
|
});
|
||||||
|
@ -75,19 +74,15 @@ class Backup extends Command {
|
||||||
const backupID = args[1];
|
const backupID = args[1];
|
||||||
if (!backupID) return message.error("administration/backup:MISSING_BACKUP_ID");
|
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()
|
const embed = new Discord.MessageEmbed()
|
||||||
.setAuthor({
|
.setAuthor({
|
||||||
name: message.translate("administration/backup:TITLE_INFO")
|
name: message.translate("administration/backup:TITLE_INFO")
|
||||||
})
|
})
|
||||||
// Display the backup ID
|
.addField(message.translate("administration/backup:TITLE_ID"), backupInfo.id, true)
|
||||||
.addField(message.translate("administration/backup:TITLE_ID"), backupInfos.id, true)
|
.addField(message.translate("administration/backup:TITLE_SERVER_ID"), backupInfo.data.guildID.toString(), true)
|
||||||
// Displays the server from which this backup comes
|
.addField(message.translate("administration/backup:TITLE_SIZE"), `${backupInfo.size} kb`, true)
|
||||||
.addField(message.translate("administration/backup:TITLE_SERVER_ID"), backupInfos.data.guildId, true)
|
.addField(message.translate("administration/backup:TITLE_CREATED_AT"), message.printDate(new Date(backupInfo.data.createdTimestamp)), 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)
|
|
||||||
.setColor(data.config.embed.color)
|
.setColor(data.config.embed.color)
|
||||||
.setFooter({
|
.setFooter({
|
||||||
text: data.config.embed.footer
|
text: data.config.embed.footer
|
||||||
|
@ -97,7 +92,6 @@ class Backup extends Command {
|
||||||
});
|
});
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
// if the backup wasn't found
|
|
||||||
return message.error("administration/backup:NO_BACKUP_FOUND", {
|
return message.error("administration/backup:NO_BACKUP_FOUND", {
|
||||||
backupID
|
backupID
|
||||||
});
|
});
|
||||||
|
@ -113,15 +107,14 @@ class Backup extends Command {
|
||||||
time: 20000,
|
time: 20000,
|
||||||
errors: ["time"]
|
errors: ["time"]
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
// if the author of the commands does not confirm the backup loading
|
|
||||||
return message.error("administration/backup:TIMES_UP");
|
return message.error("administration/backup:TIMES_UP");
|
||||||
});
|
});
|
||||||
|
|
||||||
backup.remove(backupID).then(async () => {
|
backup.remove(backupID).then(async () => {
|
||||||
message.success("administration/backup:SUCCESS_REMOVED");
|
message.success("administration/backup:SUCCESS_REMOVED");
|
||||||
});
|
});
|
||||||
}).catch(() => {
|
}).catch((err) => {
|
||||||
// if the backup wasn't found
|
console.error(err);
|
||||||
return message.error("administration/backup:NO_BACKUP_FOUND", {
|
return message.error("administration/backup:NO_BACKUP_FOUND", {
|
||||||
backupID
|
backupID
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue