75 lines
2.6 KiB
JavaScript
75 lines
2.6 KiB
JavaScript
|
const Discord = require("discord.js");
|
||
|
const backup = require('discord-backup');
|
||
|
module.exports = {
|
||
|
name: "backup-load",
|
||
|
aliases: ["bload"],
|
||
|
category: "backup",
|
||
|
usage: "qbackup-load",
|
||
|
description: "Laden Sie ein Server-Backup",
|
||
|
run: async (client, message, args) => {
|
||
|
if(!message.member.hasPermission('ADMINISTRATOR')){
|
||
|
return message.channel.send(':x: Sie benötigen die Berechtigung zum Verwalten von Nachrichten, um auf diesem Server ein Backup zu erstellen.');
|
||
|
}
|
||
|
|
||
|
const backupID = args.join(' ');
|
||
|
|
||
|
backup.fetch(backupID).then(() => {
|
||
|
|
||
|
let embed = new Discord.MessageEmbed()
|
||
|
.setTitle("Lesen Sie unten")
|
||
|
.setDescription(
|
||
|
':Warnung: Alle Serverkanäle, Rollen und Einstellungen werden gelöscht. Möchtest du fortfahren? Senden Sie `-confirm` oder `cancel`!'
|
||
|
)
|
||
|
.setThumbnail(client.user.displayAvatarURL())
|
||
|
.setTimestamp()
|
||
|
.setFooter(
|
||
|
`Difficult-Knights BOT`,
|
||
|
client.user.displayAvatarURL()
|
||
|
)
|
||
|
|
||
|
message.channel.send(embed);
|
||
|
|
||
|
const collector = message.channel.createMessageCollector((m) => m.author.id === message.author.id && ['-confirm', 'cancel'].includes(m.content), {
|
||
|
time: 60000,
|
||
|
max: 1
|
||
|
});
|
||
|
collector.on('collect', (m) => {
|
||
|
const confirm = m.content === '-confirm';
|
||
|
collector.stop();
|
||
|
if (confirm) {
|
||
|
|
||
|
backup.load(backupID, message.guild).then(() => {
|
||
|
|
||
|
const embed1 = new Discord.MessageEmbed()
|
||
|
.setTitle("Read below")
|
||
|
.setDescription(
|
||
|
"<a:tickYes:904236251190788116> Backup erfolgreich geladen! "
|
||
|
)
|
||
|
|
||
|
return message.author.send(embed1);
|
||
|
|
||
|
}).catch((err) => {
|
||
|
|
||
|
if (err === 'kein Backup gefunden')
|
||
|
return message.channel.send(':x: kein Backup mit der ID '+backupID+'gefunden!');
|
||
|
else
|
||
|
return message.author.send(':x: An error occurred: '+(typeof err === 'string') ? err : JSON.stringify(err));
|
||
|
|
||
|
});
|
||
|
|
||
|
} else {
|
||
|
return message.channel.send(':x: Cancelled.');
|
||
|
}
|
||
|
})
|
||
|
|
||
|
collector.on('end', (collected, reason) => {
|
||
|
if (reason === 'time')
|
||
|
return message.channel.send(':x: Zeitüberschreitung des Befehls! Bitte erneut versuchen.');
|
||
|
})
|
||
|
|
||
|
}).catch(() => {
|
||
|
return message.channel.send(':x: Kein Backup mit der ID '+backupID+'gefunden!');
|
||
|
});
|
||
|
|
||
|
}
|
||
|
}
|