# @smaug-6739/discord-backup

> Module for create backups of server discord and load this backups

Latest version **1.0.1** (published 2021-08-08) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @smaug-6739/discord-backup
pnpm add @smaug-6739/discord-backup
yarn add @smaug-6739/discord-backup
bun add @smaug-6739/discord-backup
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-08-08 |
| First published | 2021-08-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=16.6.0 |
| Dependencies | 2 |
| Unpacked size | 30.1 KB |
| Known vulnerabilities | 0 (+7 in 1 direct dependencies) |
| Install scripts | no |
| Author | Smaug6739 |
| Maintainers | smaug-6739 |

## Links

- npm: https://www.npmjs.com/package/@smaug-6739/discord-backup
- npm.io page: https://npm.io/package/@smaug-6739/discord-backup

## Dependencies (2)

- [mongoose](https://npm.io/package/mongoose.md) ^5.12.14
- [discord.js](https://npm.io/package/discord.js.md) ^13.0.1

## Recent versions

- 1.0.1 (latest) — 2021-08-08
- 1.0.0 — 2021-08-08

## README

# Discord-backup

A library for simplify the creation of backup system with mongodb database.
This module work with discord.js V13

## Getting Started

### Prerequisites

- Node.js 16.6.0 or newer is required.

- Discord.js 13.0.0 or newer is required.

### Instalation

With npm :

```sh-session
npm install @smaug-6739/discord-backup
```

With yarn :

```sh-session
yarn add @smaug-6739/discord-backup
```

## Usage

Import the module from node_modules :

With CommonJS syntax :

```js
const { DiscordBackup } = require("@smaug-6739/discord-backup");
```

With module syntax :

```js
import { DiscordBackup } = from "@smaug-6739/discord-backup";
```

Create a new instance of `DiscordBackup` with the client as a parameter and the database in options :

```js
const backup = new DiscordBackup(client, {
  database: "mongodb://localhost:27017/discord-backup",
});
```

## [async] DiscordBackup#create(guild)

Create a backup and save it to database.

Parameters :

- guild : The guild from create the backup (Guild).

Return : The id of the backup (Promise\<Snowflake>).

## [async] DiscordBackup#load(guild, options)

Load a backup from database to a specific guild.

Parameters :

- guild : The guild from load the backup (Guild).
- options : The options from load the backup (Object).
  - options.id : The id of the backup (Snowflake).
  - options.force : If the bot should delete the old server (Boolean).

Return : Promise\<boolean>.

## Example

```js
const { Client, Intents } = require("discord.js");
const { DiscordBackup } = require("@smaug-6739/discord-backup");
const client = new Client({ intents: ["GUILDS", "GUILD_MESSAGES"] });
const backup = new DiscordBackup(client, {
  database: "mongodb://localhost:27017/discord-backup",
});
client.on("messageCreate", async (msg) => {
  const args = msg.content.split(" ");
  if (args[0] === "!create-backup") {
    console.log(await backup.create(msg.guild));
  }
  if (args[0] === "!load-backup") {
    backup.load(msg.guild, {
      id: args[1],
      force: true,
    });
  }
});
client.login("<discord bot token>");
```

## Authors

- [Smaug6739](https://github.com/Smaug6739)

---
_Source: https://npm.io/package/@smaug-6739/discord-backup · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
