This package has been deprecated

Author message:

Package moved to https://www.npmjs.com/package/@discord-util/backup

@smaug-6739/discord-backup

1.0.1 • Public • Published

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 :

npm install @smaug-6739/discord-backup

With yarn :

yarn add @smaug-6739/discord-backup

Usage

Import the module from node_modules :

With CommonJS syntax :

const { DiscordBackup } = require("@smaug-6739/discord-backup");

With module syntax :

import { DiscordBackup } = from "@smaug-6739/discord-backup";

Create a new instance of DiscordBackup with the client as a parameter and the database in options :

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

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

Readme

Keywords

none

Package Sidebar

Install

npm i @smaug-6739/discord-backup

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

30.8 kB

Total Files

31

Last publish

Collaborators

  • smaug-6739