Coder Social home page Coder Social logo

androz2091 / discord-backup Goto Github PK

View Code? Open in Web Editor NEW
433.0 12.0 81.0 273 KB

📦 Complete framework to facilitate server backup using discord.js v13

Home Page: https://npmjs.com/package/discord-backup

License: MIT License

TypeScript 100.00%
discord backup framework clone server

discord-backup's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

discord-backup's Issues

Error with infos

Hello,

The backup system works successfully, but the problem arises when I want to load, it always puts me: "Sorry, an error occur ... Please check that I have administrator permissions!" Every time. For he has permission. I searched deeply and found no errors. I simply did a setStorageFolder to store the data in a folder. It saves successfully, but neither load or info works ...

no load backup

I have the code , i create the backups
And for load this i enter the cmd but this don't work , this not replie a msg

the script :

if(message.content === config.prefix + "backup load") {
let args = message.content.slice("&backup load").trim().split(/ +/g);
if(!message.member.hasPermission("ADMINISTRATOR")){
return message.channel.send(":x: | You must be an administrator of this server to load a backup!");
}
let backupID = args[3];
if(!backupID){
return message.channel.send(":x: | You must specify a valid backup ID!");
}
// Fetching the backup to know if it exists
backup.fetch(backupID).then(async () => {
// If the backup exists, request for confirmation
backup.load("id", message.guild, {
clearGuildBeforeRestore: true
});
}).catch((err) => {
// if the backup wasn't found
return message.channel.send(":x: | No backup found for "+backupID+"!");
});

}

Errod discord.js version 12

Hello i have a problem...

I type: b!create and i have this error:

Uncaught Promise Error You must install and use discord.js version 12 or higher to use this package! [FATAL] Possibly Unhandled Rejection at: Promise Promise { 'You must install and use discord.js version 12 or higher to use this package!' } reason: undefined

How to resolve this??

Custom IDs

Hello, I would like to know if there is a way to set an ID for the backup when creating it.

Way to read data.

Hello, I was wondering if there is a way of reading data that has been saved.
For ex.

const SavedData = new Discord.MessageEmbed()
.setAuthor("Guild has been Backuped")
.setDescription("Number of Saved Channels, Roles, Emojis..")
.addField("Channels: ", number_of_saved_channels)
.addField("Roles: ", number_of_saved_roles)
.addField("Emojis", number_of_saved_emojis)
.setTimestamp()

Backup fails to create

Hi, whenever I try to use the b!create command, I get this error in console:

(node:19982) UnhandledPromiseRejectionWarning: TypeError: backup.create is not a function
    at Client.<anonymous> (/root/discord-backup/index.js:33:16)
    at Client.emit (events.js:311:20)
    at MessageCreateAction.handle (/root/discord-backup/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (/root/discord-backup/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (/root/discord-backup/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
    at WebSocketShard.onPacket (/root/discord-backup/node_modules/discord.js/src/client/websocket/WebSocketShard.js:435:22)
    at WebSocketShard.onMessage (/root/discord-backup/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)
    at WebSocket.onMessage (/root/discord-backup/node_modules/ws/lib/event-target.js:120:16)
    at WebSocket.emit (events.js:311:20)
    at Receiver.receiverOnMessage (/root/discord-backup/node_modules/ws/lib/websocket.js:801:20)
(node:19982) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:19982) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Anyone knows what's wrong?

Loading a backup - cannot read property 'maxMessagePerChannel' of undefined

Hello,
When i'm loading a backup, all the channels appears, but after that i had a lot a these errors :

(node:3372) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'maxMessagesPerChannel' of undefined
at Object. (c:\Users\xBlad\OneDrive\Documents\TEST-BOT\blade_bot\node_modules\discord-backup\lib\master\util.js:256:105)
at step (c:\Users\xBlad\OneDrive\Documents\TEST-BOT\blade_bot\node_modules\discord-backup\lib\master\util.js:33:23)
at Object.next (c:\Users\xBlad\OneDrive\Documents\TEST-BOT\blade_bot\node_modules\discord-backup\lib\master\util.js:14:53)
at c:\Users\xBlad\OneDrive\Documents\TEST-BOT\blade_bot\node_modules\discord-backup\lib\master\util.js:8:71
at new Promise ()
at __awaiter (c:\Users\xBlad\OneDrive\Documents\TEST-BOT\blade_bot\node_modules\discord-backup\lib\master\util.js:4:12)
at c:\Users\xBlad\OneDrive\Documents\TEST-BOT\blade_bot\node_modules\discord-backup\lib\master\util.js:250:83
at processTicksAndRejections (internal/process/task_queues.js:97:5)

Can you help me ?

guild.roles.forEach is not a function

Trying to create backup i get following error:

 (node:21278) UnhandledPromiseRejectionWarning: TypeError: guild.roles.forEach is not a function
    at Object.<anonymous> (/root/Desktop/discordjs/node_modules/discord-backup/lib/master/create.js:78:25)

Im using discordjs v12, bot has admin permissions and even admin role in server

seems like they changed some stuff in discordjs's API

Custom files names.

Possibility to set a custom name for backuped files, instead of a random id.

automatically errors out

when I load a backup it automatically errors out saying it doesn't have admin perms in the server yet it does have perms...also is it possible to make it take a few seconds so it doesn't just nuke the server and then not work?

I am a noob.

can I have a link to ur server? I need help. I know nothing about programming. Please help me use this cloner

I have a problem for create a backup

My code is :

if(args[0] === "create"){
   if(!message.member.hasPermission("ADMINISTRATOR")){
            return message.channel.send(":x: | Tu dois être un administrateur pour éxécuter cette commande !");
        }
 
        backup.create(message.guild).then((backupID) => {
          
            message.author.send("La backup a été crée, tu peux la load en faisant "+prefix+"load "+backupID+"`!");
        }).catch(() => {
          message.channel.send('Une erreur est survenue, merci de report ce bug à Azkun#9867')
        });
    }

This code return message.channel.send('Une erreur est survenue, merci de report ce bug à Azkun#9867'), this is for message.guild ? Or a another error ?

Announcement Channel

Please update this module to support Announcement channels. If the channel does not have community enabled, then use text channel instead

ERROR node modules\discord-backup\lib\index.js

Waiting for the deError: Cannot find module 'c:\Users\frees\OneDrive\Bureau\futuraself\node_modules\discord-backup\lib\index.js'. Please verify that the package.json has a valid "main" entry

there is the error

Installing discord-backup for discord v11 doesn't work

I'm tryna install discord-backup for djs v11 but when i run

npm install Androz2091/discord-backup#discordjs-v11

it returns me

npm ERR! code ENOLOCAL
npm ERR! Could not install from "Androz2091\discord-backup@discordjs-v11" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Win10SSD1\AppData\Roaming\npm-cache\_logs\2020-04-09T15_58_28_380Z-debug.log```

any help ?

Backup not found while a backup existing.

After some troubleshooting.. i figured out that problem was in functions/utils.js:76:84
Error was miss-thrown by the promise at line 150 in index.js.

Original error stack:

TypeError: Cannot read property 'id' of undefined
 at guild.roles.filter (/home/mraugu/ftp/bots/f-u/node_modules/discord-backup/functions/utils.js:76:84)
 at Map.filter (/home/mraugu/ftp/bots/f-u/node_modules/discord.js/src/util/Collection.js:227:11)
 at Object.clearGuild (/home/mraugu/ftp/bots/f-u/node_modules/discord-backup/functions/utils.js:76:17)
 at getBackupInformations.then (/home/mraugu/ftp/bots/f-u/node_modules/discord-backup/index.js:164:29)

It was fixed by fixing the filtering condition on the line 76.

// Old:
guild.roles.filter((role) => role.editable && role.id !== guild.roles.everyone.id).forEach((role) => {
  role.delete().catch((err) => {});
});
// New:
guild.roles.filter((role) => role.managed === false  && role.id !== guild.id && role.editable).forEach((role) => {
  role.delete().catch((err) => {});
});

Update backups

Add the possibility to update a backup. By giving the backup id and checking if the backup id is associated to the guild.

Different id setup

Is there a way to shorten the id? or atleast make it something like 8 characters long with a mixture of numbers and letters? I looked through the code and didn't see anything that caught my eye.

role permissions on text/voice channel

I guess it doesn't back them up. This is the biggest problem I have with "backup" ... it would be great if it was added and you can add the system that saves the role and gives them back the role to saved users.

Error discord.js version

Hello i have a problem...

I type: b!create and i have this error:

Uncaught Promise Error You must install and use discord.js version 12 or higher to use this package!
[FATAL] Possibly Unhandled Rejection at: Promise Promise {
'You must install and use discord.js version 12 or higher to use this package!' } reason: undefined

How to resolve this??

New saveImages option

Hi, I thing that it will be a good idea add imgur to the system for upload images, with that, the backup will be light and if the Discord is deleted, you can do this equally.

Setting up automatic backups

Hi, I was trying to set up the bot to do daily automatic backups using the cron tool by npm. I'm struggling into one issue, i'm getting this error:

 TypeError: guild.iconURL is not a function
5|index  |     at /root/bot/node_modules/discord-backup/lib/index.js:147:44
5|index  |     at step (/root/bot/node_modules/discord-backup/lib/index.js:33:23)
5|index  |     at Object.next (/root/bot/node_modules/discord-backup/lib/index.js:14:53)
5|index  |     at /root/bot/node_modules/discord-backup/lib/index.js:8:71
5|index  |     at new Promise (<anonymous>)
5|index  |     at __awaiter (/root/bot/node_modules/discord-backup/lib/index.js:4:12)
5|index  |     at /root/bot/node_modules/discord-backup/lib/index.js:119:83
5|index  |     at new Promise (<anonymous>)
5|index  |     at /root/bot/node_modules/discord-backup/lib/index.js:119:35
5|index  |     at step (/root/bot/node_modules/discord-backup/lib/index.js:33:23)

Consider that the bot is working fine if I use it with the original code and I have the latest updates for discord.js, npm and such, so I think I messed up while coding the automatic backup part, can anyone give me an help or advice?
This is the code:

client.on("ready", () => {
    console.log("I'm ready !");
    
        const channel = client.channels.cache.get('669955470823260190');
        const CronJob = require('cron').CronJob;
        
let autobackup = new CronJob ("00 15 17 * * *", function() {
console.log("Backupping now!");
channel.send('Daily Backup starting now.');
   backup.create({
            jsonBeautify: true
        })
        }, null, true, 'Europe/Rome');
    autobackup.start();
    
});

Loading backup from file

Hey, trying to load the attached test backup file
684874311907016704.json.txt
(added the txt extension for github to want to attach it)

(node:24652) UnhandledPromiseRejectionWarning: TypeError [INVALID_TYPE]: Supplied overwrites is not an Array or Collection of Permission Overwrites.
at CategoryChannel.overwritePermissions (/Users/robert/Desktop/DiscordBackupBot/node_modules/discord.js/src/structures/GuildChannel.js:208:9)
at Object.<anonymous> (/Users/robert/Desktop/DiscordBackupBot/node_modules/discord-backup/lib/master/util.js:181:71)

Tried an early out in case the array of permissions is empty to get rid of this exception, but the restore still fails - no text channels get restored.

(An unrelated issue, but might point out that there's something wrong with my setup: loading backup by id doesn't work either - the backup can't be found, even though listing the backups with list() shows the id)

load Error

It doesn't automatically turn off after 20,000 seconds...

Channels not backuping?

I tried the example bot and the channels are not backuping. Roles and bans are backuping properly. Can you please fix the issue or edit the example bot?

EODENT Error

Hello there. It could just be my own incompetence, but whenever I try to install the package I get an EOENT error. I'd like to mention in advance I'm a novice with these types of things, but I have Node.js installed and I've installed and used some modules before. Thank you.

Auto assign roles

Hey, I was wondering if it's possible to make the bot automatically assign the roles that users had when you created the backup when loading the backup into a new server. What do you think about it?

Issue with backup ID

https://sourceb.in/627aec8bac

^^^ Above is my code
When I do !backup create, it send me a dm. The backup ID shown is true687285487278358529. Is there any way to get rid of the true?
Also, just wondering, where does the backup save? I want to delete it manually, is that possible?
Lastly, is it possible to list all backup ids?

Thanks for making this amazing package!

just a question

What does the jsonSave option do? Is it just so it saves the backups to the bot folder?

max messages ?

I have a very active discord. I used your sample bot . The issue I having is it is only saving like 10 messages per channel.

I increased the maxMessagesPerChannel to 1000000 and 100000 and 10000 . The bot runs , it gets up to 1.5 GB of memory after about 30 minutes and just stop without saving the backup file.

Could you point me in the right direction on how to get a full message backup? Can I adit the code or does it need a rewrite to do it?

Error when install

npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno -4058
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t ssh://[email protected]/discordjs/discord.js.git
npm ERR! enoent
npm ERR! enoent
npm ERR! enoent spawn git ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Romaiin\AppData\Roaming\npm-cache_logs\2019-12-25T18_46_43_748Z-debug.log

DiscordJS ver 12

This isn't even a thing yet?..
How is one supposed to go about getting version 12 of it xD

Cannot read property 'filter' of undefined

Im using atlanta master branch.

TypeError: Cannot read property 'filter' of undefined
    at Object.<anonymous> (Z:\Coding\Zeka Discord Bot\node_modules\discord-backup\lib\master\create.js:79:18)
    at step (Z:\Coding\Zeka Discord Bot\node_modules\discord-backup\lib\master\create.js:33:23)
    at Object.next (Z:\Coding\Zeka Discord Bot\node_modules\discord-backup\lib\master\create.js:14:53)
    at Z:\Coding\Zeka Discord Bot\node_modules\discord-backup\lib\master\create.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (Z:\Coding\Zeka Discord Bot\node_modules\discord-backup\lib\master\create.js:4:12)
    at Object.getRoles (Z:\Coding\Zeka Discord Bot\node_modules\discord-backup\lib\master\create.js:74:12)
    at Z:\Coding\Zeka Discord Bot\node_modules\discord-backup\lib\index.js:192:67
    at step (Z:\Coding\Zeka Discord Bot\node_modules\discord-backup\lib\index.js:33:23)
    at Object.next (Z:\Coding\Zeka Discord Bot\node_modules\discord-backup\lib\index.js:14:53)
    at fulfilled (Z:\Coding\Zeka Discord Bot\node_modules\discord-backup\lib\index.js:5:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

No delete of categorie/channels/roles...etc after loading a backup

Hello,
i actually have an issue when i try to load a backup, all the channels in my discord are always here.
So they are not deleted. after that all my backup is importing channel role categories.

I don't have any errors on the console.
i had try with parameter : clearGuildBeforeRestore: true, and without but nothing change

thanks in advance

Storage Folder Problem

Hey

I made a backup code using your package
I set a storage folder for it but I always get this error

I made a folder called backup to store the data in, any solutions?
I use glitch host, should I use my PC or a Linux, which are better?

Invite people

Is it possible to make it so the bot is able to invite everyone from the old server to the new one?

Restoring timestamps

Timestamps don't get restored.

I see that's because the messages are being added to text channels by webhook.send(), so they get the timestamp of when the backup was loaded.

Would be great if the timestamp could be assigned afterwards, but after a quick look through the discord.js api, I don't see an option for that.

Hmm, any ideas? :)

guild.iconURL is not a function

Can you help me?

When I run this:

// Create the backup
backup.create(message.guild, { jsonBeautify: true }).catch(console.error)

It happens:

TypeError: guild.iconURL is not a function
    at /home/user/projet/node_modules/discord-backup/lib/index.js:147:44
    at step (/home/user/projet/node_modules/discord-backup/lib/index.js:33:23)
    at Object.next (/home/user/projet/node_modules/discord-backup/lib/index.js:14:53)
    at /home/user/projet/node_modules/discord-backup/lib/index.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/home/user/projet/node_modules/discord-backup/lib/index.js:4:12)
    at /home/user/projet/node_modules/discord-backup/lib/index.js:119:83
    at new Promise (<anonymous>)
    at /home/user/projet/node_modules/discord-backup/lib/index.js:119:35
    at step (/home/user/projet/node_modules/discord-backup/lib/index.js:33:23) 

But

console.log(message.guild.iconURL);

The funny thing is that there is an image in message.guild.iconURL, and I use it without being a function.

rm -rf node_modules && rm package-lock.json && npm install

Yes, I already tried that. Unsuccessfully.


Additional information:

  • Node.js version: v13.7.0
  • Npm version: 6.13.6
  • Operation System: W10 (SO 19041,113)
  • WSL:
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.4 LTS
Release:        18.04
Codename:       bionic

invite people

if I load a backup will it invite the people from the old server?

Error in creating backup

Error:

(node:25990) UnhandledPromiseRejectionWarning: TypeError: guild.iconURL is not a function
at /root/node_modules/discord-backup/lib/index.js:147:56
at step (/root/node_modules/discord-backup/lib/index.js:33:23)
at Object.next (/root/node_modules/discord-backup/lib/index.js:14:53)
at /root/node_modules/discord-backup/lib/index.js:8:71
at new Promise ()
at __awaiter (/root/node_modules/discord-backup/lib/index.js:4:12)
at /root/node_modules/discord-backup/lib/index.js:111:79
at new Promise ()
at /root/node_modules/discord-backup/lib/index.js:111:31
at step (/root/node_modules/discord-backup/lib/index.js:33:23)
(node:25990) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:25990) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.