• Stars
    star
    411
  • Rank 105,247 (Top 3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

Discord Backup

downloadsBadge versionBadge

Note: this module uses recent discordjs features and requires discord.js v13.

Discord Backup is a powerful Node.js module that allows you to easily manage discord server backups.

  • Unlimited backups!
  • Backup creation takes less than 10 seconds!
  • Even restores messages with webhooks!
  • And restores everything that is possible to restore (channels, roles, permissions, bans, emojis, name, icon, and more!)

Changelog

  • Supports base64 for emojis/icon/banner backup
  • New option to save backups in your own database
  • backup#delete() removed in favor of backup#remove()

Installation

npm install --save discord-backup

Examples

You can read this example bot on Github: backups-bot

Create

Create a backup for the server specified in the parameters!

/**
 * @param {Guild} [Guild] - The discord server you want to backup
 * @param {object} [options] - The backup options
 */

const backup = require("discord-backup");
backup.create(Guild, options).then((backupData) => {
    console.log(backupData.id); // NSJH2
});

Click here to learn more about backup options.

Load

Allows you to load a backup on a Discord server!

/**
 * @param {string} [backupID] - The ID of the backup that you want to load
 * @param {Guild} [Guild] - The discord server on which you want to load the backup
 */

const backup = require("discord-backup");
backup.load(backupID, Guild).then(() => {
    backup.remove(backupID); // When the backup is loaded, it's recommended to delete it
});

Fetch

Fetches information from a backup

/**
 * @param {string} [backupID] - The ID of the backup to fetch
 */

const backup = require("discord-backup");
backup.fetch(backupID).then((backupInfos) => {
    console.log(backupInfos);
    /*
    {
        id: "BC5qo",
        size: 0.05
        data: {BackupData}
    }
    */
});

Remove

Warn: once the backup is removed, it is impossible to recover it!

/**
 * @param {string} [backupID] - The ID of the backup to remove
 */

const backup = require("discord-backup");
backup.remove(backupID);

List

Note: backup#list() simply returns an array of IDs, you must fetch the ID to get complete information.

const backup = require("discord-backup");
backup.list().then((backups) => {
    console.log(backups); // Expected Output [ "BC5qo", "Jdo91", ...]
});

SetStorageFolder

Updates the storage folder to another

const backup = require("discord-backup");
backup.setStorageFolder(__dirname+"/backups/");
await backup.create(guild); // Backup created in ./backups/
backup.setStorageFolder(__dirname+"/my-backups/");
await backup.create(guild); // Backup created in ./my-backups/

Advanced usage

Create [advanced]

You can use more options for backup creation:

const backup = require("discord-backup");
backup.create(guild, {
    maxMessagesPerChannel: 10,
    jsonSave: false,
    jsonBeautify: true,
    doNotBackup: [ "roles",  "channels", "emojis", "bans" ],
    saveImages: "base64"
});

maxMessagesPerChannel: Maximum of messages to save in each channel. "0" won't save any messages.
jsonSave: Whether to save the backup into a json file. You will have to save the backup data in your own db to load it later.
jsonBeautify: Whether you want your json backup pretty formatted.
doNotBackup: Things you don't want to backup. Available items are: roles, channels, emojis, bans.
saveImages: How to save images like guild icon and emojis. Set to "url" by default, restoration may not work if the old server is deleted. So, url is recommended if you want to clone a server (or if you need very light backups), and base64 if you want to backup a server. Save images as base64 creates heavier backups.

Load [advanced]

As you can see, you're able to load a backup from your own data instead of from an ID:

const backup = require("discord-backup");
backup.load(backupData, guild, {
    clearGuildBeforeRestore: true
});

clearGuildBeforeRestore: Whether to clear the guild (roles, channels, etc... will be deleted) before the backup restoration (recommended).
maxMessagesPerChannel: Maximum of messages to restore in each channel. "0" won't restore any messages.

Example Bot

// Load modules
const Discord = require("discord.js"),
backup = require("discord-backup"),
client = new Discord.Client(),
settings = {
    prefix: "b!",
    token: "YOURTOKEN"
};

client.on("ready", () => {
    console.log("I'm ready !");
});

client.on("message", async message => {

    // This reads the first part of your message behind your prefix to see which command you want to use.
    let command = message.content.toLowerCase().slice(settings.prefix.length).split(" ")[0];

    // These are the arguments behind the commands.
    let args = message.content.split(" ").slice(1);

    // If the message does not start with your prefix return.
    // If the user that types a message is a bot account return.
    // If the command comes from DM return.
    if (!message.content.startsWith(settings.prefix) || message.author.bot || !message.guild) return;

    if(command === "create"){
        // Check member permissions
        if(!message.member.hasPermission("ADMINISTRATOR")){
            return message.channel.send(":x: | You must be an administrator of this server to request a backup!");
        }
        // Create the backup
        backup.create(message.guild, {
            jsonBeautify: true
        }).then((backupData) => {
            // And send informations to the backup owner
            message.author.send("The backup has been created! To load it, type this command on the server of your choice: `"+settings.prefix+"load "+backupData.id+"`!");
            message.channel.send(":white_check_mark: Backup successfully created. The backup ID was sent in dm!");
        });
    }

    if(command === "load"){
        // Check member permissions
        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[0];
        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
            message.channel.send(":warning: | When the backup is loaded, all the channels, roles, etc. will be replaced! Type `-confirm` to confirm!");
                await message.channel.awaitMessages(m => (m.author.id === message.author.id) && (m.content === "-confirm"), {
                    max: 1,
                    time: 20000,
                    errors: ["time"]
                }).catch((err) => {
                    // if the author of the commands does not confirm the backup loading
                    return message.channel.send(":x: | Time's up! Cancelled backup loading!");
                });
                // When the author of the command has confirmed that he wants to load the backup on his server
                message.author.send(":white_check_mark: | Start loading the backup!");
                // Load the backup
                backup.load(backupID, message.guild).then(() => {
                    // When the backup is loaded, delete them from the server
                    backup.remove(backupID);
                }).catch((err) => {
                    // If an error occurred
                    return message.author.send(":x: | Sorry, an error occurred... Please check that I have administrator permissions!");
                });
        }).catch((err) => {
            console.log(err);
            // if the backup wasn't found
            return message.channel.send(":x: | No backup found for `"+backupID+"`!");
        });
    }

    if(command === "infos"){
        let backupID = args[0];
        if(!backupID){
            return message.channel.send(":x: | You must specify a valid backup ID!");
        }
        // Fetch the backup
        backup.fetch(backupID).then((backupInfos) => {
            const date = new Date(backupInfos.data.createdTimestamp);
            const yyyy = date.getFullYear().toString(), mm = (date.getMonth()+1).toString(), dd = date.getDate().toString();
            const formatedDate = `${yyyy}/${(mm[1]?mm:"0"+mm[0])}/${(dd[1]?dd:"0"+dd[0])}`;
            let embed = new Discord.MessageEmbed()
                .setAuthor("Backup Informations")
                // Display the backup ID
                .addField("Backup ID", backupInfos.id, false)
                // Displays the server from which this backup comes
                .addField("Server ID", backupInfos.data.guildID, false)
                // Display the size (in mb) of the backup
                .addField("Size", `${backupInfos.size} kb`, false)
                // Display when the backup was created
                .addField("Created at", formatedDate, false)
                .setColor("#FF0000");
            message.channel.send(embed);
        }).catch((err) => {
            // if the backup wasn't found
            return message.channel.send(":x: | No backup found for `"+backupID+"`!");
        });
    }

});

//Your secret token to log the bot in. (never share this to anyone!)
client.login(settings.token);

Restored things

Here are all things that can be restored with discord-backup:

  • Server icon
  • Server banner
  • Server region
  • Server splash
  • Server verification level
  • Server explicit content filter
  • Server default message notifications
  • Server embed channel
  • Server bans (with reasons)
  • Server emojis
  • Server AFK (channel and timeout)
  • Server channels (with permissions, type, nsfw, messages, etc...)
  • Server roles (with permissions, color, etc...)

Example of things that can't be restored:

  • Server logs
  • Server invitations
  • Server vanity url

More Repositories

1

AtlantaBot

🤖 Another powerful Discord Bot with a web-dashboard used by more than 130k users!
JavaScript
845
star
2

discord-data-package-explorer

🌀 What's really in your Discord Data package?
Svelte
828
star
3

discord-player

🎧 Complete framework to simplify the implementation of music commands using discord.js v14
TypeScript
527
star
4

scratch-for-discord

🐱Create your own Discord Bot easily using Scratch-styled blocks! Made with Vue.js
JavaScript
341
star
5

discord-giveaways

🎉 Complete framework to facilitate the creation of giveaways using discord.js
JavaScript
335
star
6

discord-logs

📝Framework that simplify the usage of advanced Discord logs
TypeScript
243
star
7

discord-music-bot

The perfect music bot for your Discord server! 🤘
JavaScript
238
star
8

discord-giveaways-bot

🎁Giveways Bot using the discord-giveaways package
JavaScript
201
star
9

insta.js

💬 Object-oriented library for sending and receiving messages via Instagram
JavaScript
137
star
10

slash-commands-gui

GUI tool to explore Slash Commands of your bot, built on Vue 3 and TailwindCSS 🚀
Vue
131
star
11

vinted-discord-bot

🔔 BOT Discord qui envoie un message quand un nouvel article est publié sur Vinted (selon certains critères)
TypeScript
115
star
12

discord-temp-channels

Simple framework to facilitate the creation of a temporary voice channels system using Discord.js
TypeScript
113
star
13

DiscordYoutubeNotifier

Be notified when one of your favorite youtubers posts a video!
JavaScript
100
star
14

discord-invites-tracker

🐕 Track Discord invites to know who invited who and with which invite!
TypeScript
94
star
15

DiscordEconomyBot

A very simple bot with an economy system using the Discord.js API
JavaScript
87
star
16

vinted-api

JavaScript library to interact with the Vinted API
JavaScript
84
star
17

backups-bot

🌟 Backups Bot using the discord-backup package
JavaScript
78
star
18

minecraft-discord-bot

📊View the status and statistics of your MC server directly on Discord!
JavaScript
65
star
19

stripe-discord-bot

Discord bot to give a role to users paying a Stripe subscription
TypeScript
39
star
20

node-ecole-directe

Connexion à école directe sans passer par l'interface web!
JavaScript
38
star
21

instaddict

💊  How addicted are you to Instagram?
Svelte
37
star
22

paypal-bot

Générez des liens de factures et acceptez des paiements sur Discord!
CSS
32
star
23

pronote-bot

😎 Chatbot Instagram pour Pronote
JavaScript
30
star
24

paypal-api

💰Node.js package to interact with PayPal REST API
TypeScript
30
star
25

discord-bot-template

Custom Discord Bot template for my bots 🚀
TypeScript
29
star
26

discord-sync-commands

Easily keep your bot's slash commands synchronized with Discord
JavaScript
28
star
27

pronote-bot-discord

Un bot Discord pour envoyer les nouveaux devoirs dans un serveur Discord 📚
JavaScript
26
star
28

easy-json-database

📂 Easy to use json database. Used for Scratch For Discord.
JavaScript
26
star
29

tiktok-discord-bot

Simple Discord Bot that sends notifications on new TikTok posts
JavaScript
23
star
30

Sworder-Dashboard.io

🌐 Discord bot dashboard created by Sworder71
HTML
23
star
31

discbot.js

🚀 Powerful discord bot template, for a solid structure!
JavaScript
22
star
32

multilingual-discord-bot

A multilingual discord bot
JavaScript
22
star
33

nfts-discord-bot

✨ Get notified when an item is sold or listed on Solanart and MagicEden!
JavaScript
19
star
34

status

📈 Uptime monitor and status page for Upptime, powered by @upptime
Markdown
18
star
35

auto-github-bio

📚Automatized Github biography using openweathermap.org API
Python
18
star
36

simsimi-bot

Simsimi Discord Bot - The most clever chatbot
CoffeeScript
17
star
37

twitchdl

Download videos (and sub-only videos) from Twitch
JavaScript
16
star
38

arduino-is-mybot-online

🚨 Simple status LED with Arduino to alert you if your bot is down!
C++
13
star
39

pronote-qrcode-api

🧪 Stuff about Pronote QRCodes to connect using a mobile phone
JavaScript
13
star
40

AutoBanSelfbots

A bot that automatically detects selfbots and ban them
JavaScript
12
star
41

stop-fake-discord-friends

JavaScript
11
star
42

blog.androz2091.fr

✏️ My personal blog, built with Gatsby 2
MDX
11
star
43

wot-stats-bot

Discord bot that displays your World Of Tanks stats!
JavaScript
11
star
44

twittycord

Open source online service to verify Discord users social connections
TypeScript
10
star
45

AndrozDevBot

Official bot for the AndrozDev server
JavaScript
9
star
46

my-insta-stats

🚧 Instagram version of Discord Data Package Explorer. Under development.
Svelte
9
star
47

github-issues-discord-bot

Convert Discord messages to GitHub issues!
TypeScript
9
star
48

Atlantav2

The V2 of Atlanta. Don't judge please.
JavaScript
8
star
49

rockstar-games-status

Simple package to get the current status of Rockstar Games services
JavaScript
8
star
50

npm-files-explorer

Adds a button to browse files of a package on NPM
JavaScript
8
star
51

atlanta-emojis-mod

Moderator bot for the Atlanta Emojis servers
JavaScript
7
star
52

deno-diswho

Deno port of Diswho
JavaScript
7
star
53

androz2091.fr

👋 My personal website
HTML
6
star
54

Cicero

Great speaker, Cicero is a text-to-speech Discord Bot!
TypeScript
6
star
55

neko-love

🐱A Neko Love API wrapper !
TypeScript
6
star
56

floor-price-bot

Powerful bot that fetches floor prices from OpenSea and send them on Discord 🚀
TypeScript
6
star
57

disable-discord-notifications

Script that disable notifications for each of your servers
JavaScript
6
star
58

Androz2091

6
star
59

k8s-infrastructure

🕸️ 🚀 My personal server infrastructure - kubernetes cluster - ArgoCD, Longhorn, Kubeseal, Caddy
Shell
6
star
60

chess-ai-discord-bot

JavaScript
5
star
61

easy-discord-commands

Simple framework to create commands using Discord.js
TypeScript
5
star
62

pixpay-api

🏦 Reverse engineering of the PixPay Private API
JavaScript
5
star
63

fiverr-hmsip

Fiverr, How Much Should I Pay? chrome extension
JavaScript
5
star
64

dotapps

Exhaustive list of all the apps I use on my different devices
Ruby
5
star
65

androz2091-cors-anywhere

My own cors-anywhere proxy server
JavaScript
5
star
66

backups-manager

⚡ Gère vos fichiers de sauvegarde de manière intelligente.
Ruby
5
star
67

sleepingmoney-pushover

Realtime notifications from SleepingMoney using Pushover 🌩️
JavaScript
5
star
68

chatgpt-data-package-explorer

Get statistics about your ChatGPT usage
JavaScript
5
star
69

bereal-api

4
star
70

funcraft

🌐 Scrape data from funcraft.net easily!
JavaScript
4
star
71

plex.js

4
star
72

cloudflare-page-rules

Simple package to update cloudflare page rules dynamically
JavaScript
4
star
73

steam-usernames-scraper

Check a list of Steam usernames
JavaScript
4
star
74

diswho

Simple API to get information about a Discord user or a Discord invite
Go
4
star
75

arte-dl

Download ARTE.tv videos online, for free without any ads
HTML
4
star
76

blague.xyz

Wrapper pour Blague.xyz (blagues aléatoires, blague du jour, etc...)
TypeScript
4
star
77

marche-pala-bot

Le bot pour le serveur Marché Paladium | Paladium | V6
JavaScript
3
star
78

voice-user-bots

TypeScript
3
star
79

slowmode-discord-bot

🐌 Discord bot that allows you to set slowmodes in specific channels of your server
TypeScript
3
star
80

opm-partners-api

TypeScript
3
star
81

coders-bot

Coder's bot, a discord bot for developers written in V
V
3
star
82

export-my-fiverr-orders

JavaScript
3
star
83

milou

🐶🐶
EJS
3
star
84

bento-custom-domain

JavaScript
3
star
85

tradingview-bot

JavaScript
2
star
86

cyanide-happiness-bot

Bot pour le Discord Cyanide and Happiness VF
JavaScript
2
star
87

customgpt-discord-bot

JavaScript
2
star
88

expressio.fr

Obtenez des expressions aléatoires de expressio.fr
JavaScript
2
star
89

ljdc-bot

Un bot Discord qui affiche une image aléatoire du site lesjoiesducode.fr
JavaScript
2
star
90

ohorime

ohorime bot
JavaScript
2
star
91

imgur-app

Simple Flutter app to browse your imgur images
Dart
2
star
92

discord-code-generator

HTML
2
star
93

hello-world

JavaScript
2
star
94

kevintrades-discord-bot

TypeScript
2
star
95

discord-asker

A very simple package to easily use Discord collectors
2
star
96

liste-celebrites

Une liste de ~150 célébrités, dont certaines françaises, au format JSON.
2
star
97

kampios-discord-bot

TypeScript
2
star
98

slowmode-discordeno-bot

🐌 Slowmode Discord Bot rewritten for Deno
TypeScript
2
star
99

beefast

App iOS native pour comprendre comment fonctionne Storyboard, Xcode et les bases du Swift.
Swift
2
star
100

discord-whook.js

A simple discord webhook wrapper.
JavaScript
2
star