Dateien nach "commands/backup" hochladen
This commit is contained in:
parent
15a0d94f6a
commit
72aae26bc6
|
@ -0,0 +1,75 @@
|
|||
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!');
|
||||
});
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
const Discord = require('discord.js');
|
||||
const backup = require('discord-backup');
|
||||
|
||||
|
||||
module.exports = {
|
||||
name: 'info-backup',
|
||||
aliases: [],
|
||||
category: 'backup',
|
||||
|
||||
|
||||
run: async (client, message, args) => {
|
||||
// If the member doesn't have enough permissions
|
||||
if(!message.member.hasPermission('ADMINISTRATOR')){
|
||||
return message.reply(':x: Sie benötigen Administratorrechte, um auf diesem Server ein Backup zu erstellen.');
|
||||
}
|
||||
|
||||
const backupID = args.join(' ');
|
||||
|
||||
if (!backupID)
|
||||
return message.channel.send(':x: Bitte geben Sie eine gültige Backup-ID an!');
|
||||
|
||||
backup.fetch(backupID).then((backup) => {
|
||||
|
||||
const date = new Date(backup.data.createdTimestamp);
|
||||
const yyyy = date.getFullYear().toString(), mm = (date.getMonth()+1).toString(), dd = date.getDate().toString();
|
||||
const formattedDate = `${yyyy}/${(mm[1]?mm:"0"+mm[0])}/${(dd[1]?dd:"0"+dd[0])}`;
|
||||
|
||||
const embed = new Discord.MessageEmbed()
|
||||
.setAuthor(':information_source: Backup', backup.data.iconURL)
|
||||
.addField('Server name', backup.data.name)
|
||||
.addField('Size', backup.size + ' kb')
|
||||
.addField('Created at', formattedDate)
|
||||
.setFooter('Backup ID: '+backup.id);
|
||||
|
||||
return message.channel.send(embed);
|
||||
|
||||
}).catch((err) => {
|
||||
|
||||
if (err === 'Kein Backup gefunden')
|
||||
return message.channel.send(':x: Kein Backup mit der ID gefunden '+backupID+'!');
|
||||
else
|
||||
return message.channel.send(':x: An error occurred: '+(typeof err === 'string') ? err : JSON.stringify(err));
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
const backup = require('discord-backup');
|
||||
module.exports = {
|
||||
name: "backup-create",
|
||||
aliases: ["bc"],
|
||||
category: "backup",
|
||||
usage: "backup-create",
|
||||
description: "Get the bot's ping!",
|
||||
run: async (client, message, args) => {
|
||||
if(!message.member.hasPermission('MANAGE_MESSAGES')){
|
||||
return message.channel.send(':x: Sie benötigen die Berechtigung zum Verwalten von Nachrichten, um auf diesem Server ein Backup zu erstellen.');
|
||||
}
|
||||
|
||||
backup.create(message.guild).then((backupData) => {
|
||||
|
||||
return message.channel.send('Backup erstellt! Hier ist Ihre ID: `'+backupData.id+'` Verwenden Sie `load-backup '+backupData.id+'` um das Backup auf einen anderen Server zu laden!');
|
||||
|
||||
}).catch(() => {
|
||||
|
||||
return message.channel.send(':x: Ein Fehler ist aufgetreten, bitte melden Sie sich beim Support-Server ');
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue