├── config.json ├── .replit ├── events ├── ready.js └── messageCreate.js ├── README.md ├── index.js ├── commands ├── backup-create.js ├── help.js ├── backup-info.js └── backup-load.js ├── package.json └── handler └── index.js /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "prefix": "-" 3 | } -------------------------------------------------------------------------------- /.replit: -------------------------------------------------------------------------------- 1 | language = "nodejs" 2 | run = "npx node index.js" 3 | -------------------------------------------------------------------------------- /events/ready.js: -------------------------------------------------------------------------------- 1 | const client = require("../index"); 2 | 3 | client.on("ready", () => 4 | console.log(`${client.user.tag} has been successfully deployed!! 🚀`) 5 | ); 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # discord.js_BackupBot-v13 2 | A discord backup bot made using discord.js v13 and [discord-backup](https://www.npmjs.com/package/discord-backup) package!! 3 | 4 | # Setup?? 5 | You can refer to this **[Video](https://youtube.com/discordtricks)** for guide!! If you have any errors make sure to join our **[Discord Server](https://discord.gg/DGbR83bcF6)** 6 | 7 | # Some common Faq's 8 | -> How can I change bot prefix?? 9 | You can change your prefix from the config.json file.. 10 | 11 | -> Will my bot token be compromised?? 12 | No your bot token won't be compromised bcz you will be storing it in the client secrets 13 | 14 | 15 | Thanks for choosing djs_BackupBot-v13 :) 16 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const app = express(); 3 | const port = 3000; 4 | 5 | app.get('/', (req, res) => res.send('Yo boi!!')); 6 | 7 | app.listen(port, () => 8 | console.log(`Your app is listening to http://localhost:${port}`) 9 | ); 10 | 11 | const discord = require('discord.js') 12 | const { Client, Collection } = require("discord.js"); 13 | 14 | const client = new Client({ 15 | intents: 32767, 16 | }); 17 | module.exports = client; 18 | 19 | // Global Variables 20 | client.commands = new Collection 21 | client.slashCommands = new Collection(); 22 | client.config = require("./config.json"); 23 | 24 | require("./handler")(client); 25 | 26 | client.login(process.env.token); -------------------------------------------------------------------------------- /commands/backup-create.js: -------------------------------------------------------------------------------- 1 | const backup = require('discord-backup') 2 | const config = require('../config.json') 3 | 4 | module.exports = { 5 | name: "backup-create", 6 | description: "create backup", 7 | permissions: ["ADMINISTRATOR"], 8 | 9 | run: async (client, message, args) => { 10 | 11 | backup.create(message.guild).then((backupData) => { 12 | 13 | return message.channel.send('Backup created! Here is your ID: `'+backupData.id+'`! Use `'+config.prefix+'backup-load '+backupData.id+'` to load the backup on another server!'); 14 | 15 | }).catch(() => { 16 | 17 | return message.channel.send(':x: An error occurred, please check if the bot is administrator!'); 18 | 19 | }); 20 | 21 | }} 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "//1": "describes your app and its dependencies", 3 | "//2": "https://docs.npmjs.com/files/package.json", 4 | "//3": "updating this file will download and update your packages", 5 | "name": "hello-express", 6 | "version": "0.0.1", 7 | "description": "A simple Node app built on Express, instantly up and running.", 8 | "main": "index.js", 9 | "scripts": { 10 | "start": "node index.js" 11 | }, 12 | "dependencies": { 13 | "discord.js": "^13.1.0", 14 | "express": "^4.17.1", 15 | "glob": "^7.2.0" 16 | }, 17 | "engines": { 18 | "node": "12.x" 19 | }, 20 | "repository": { 21 | "url": "https://glitch.com/edit/#!/hello-express" 22 | }, 23 | "license": "MIT", 24 | "keywords": [ 25 | "node", 26 | "glitch", 27 | "express" 28 | ], 29 | "devDependencies": { 30 | "node": "^16.9.1" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /commands/help.js: -------------------------------------------------------------------------------- 1 | const { MessageEmbed, MessageActionRow, MessageButton } = require('discord.js') 2 | const prefix = require('./../config.json').prefix 3 | 4 | module.exports = { 5 | name: "help", 6 | description: "help cmmd", 7 | permissions: ["ADMINISTRATOR"], 8 | 9 | run: async (client, message, args) => { 10 | 11 | const embed = new MessageEmbed() 12 | .setTitle('**__Backup Bot Help Command__**') 13 | .setDescription(`***Here are all the commands available in this bot!!*** 14 | -> ${prefix}backup-create => Creates backup of the server.. 15 | -> ${prefix}backup-info => Displays the info on the provided id.. 16 | -> ${prefix}backup-load => Loads backup of the given server.. 17 | -> ${prefix}help => Loads the help command`) 18 | .setThumbnail(message.author.displayAvatarURL({ dynamic: true })) 19 | .setFooter('Help Command') 20 | .setColor('RANDOM') 21 | 22 | const row = new MessageActionRow() 23 | .addComponents( 24 | new MessageButton() 25 | .setLabel('Invite Me') 26 | .setStyle('LINK') 27 | .setURL('https://discord.com/'), //Inv link here 28 | 29 | new MessageButton() 30 | .setLabel('Support Server') 31 | .setStyle('LINK') 32 | .setURL('https://discord.com/') //Support Server Link 33 | ) 34 | 35 | message.channel.send({ embeds: [embed], components: [row] }) 36 | 37 | 38 | }} 39 | -------------------------------------------------------------------------------- /commands/backup-info.js: -------------------------------------------------------------------------------- 1 | const backup = require('discord-backup') 2 | const config = require('../config.json') 3 | const { MessageEmbed } = require('discord.js') 4 | 5 | module.exports = { 6 | name: "backup-info", 7 | description: "backup info", 8 | permissions: ["ADMINISTRATOR"], 9 | 10 | run: async (client, message, args) => { 11 | 12 | const backupID = args.join(' '); 13 | 14 | if (!backupID) 15 | return message.channel.send({ content: ':x: Please specify a valid backup ID!' }); 16 | 17 | backup.fetch(backupID).then((backup) => { 18 | 19 | const date = new Date(backup.data.createdTimestamp); 20 | const yyyy = date.getFullYear().toString(), mm = (date.getMonth()+1).toString(), dd = date.getDate().toString(); 21 | const formattedDate = `${yyyy}/${(mm[1]?mm:"0"+mm[0])}/${(dd[1]?dd:"0"+dd[0])}`; 22 | 23 | const embed = new MessageEmbed() 24 | .setAuthor('ℹ️ Backup', backup.data.iconURL) 25 | .addField('Server name', backup.data.name) 26 | .addField('Size', backup.size + ' kb') 27 | .addField('Created at', formattedDate) 28 | .setColor('RANDOM') 29 | .setFooter('Backup ID: '+backup.id); 30 | 31 | return message.channel.send({embeds:[embed]}); 32 | 33 | }).catch((err) => { 34 | 35 | if (err === 'No backup found') 36 | return message.channel.send(':x: No backup found for ID '+backupID+'!'); 37 | else 38 | return message.channel.send(':x: An error occurred: '+(typeof err === 'string') ? err : JSON.stringify(err)); 39 | 40 | }); 41 | 42 | }} 43 | -------------------------------------------------------------------------------- /handler/index.js: -------------------------------------------------------------------------------- 1 | const { glob } = require("glob"); 2 | const { promisify } = require("util"); 3 | const { Client } = require("discord.js"); 4 | 5 | const globPromise = promisify(glob); 6 | 7 | /** 8 | * @param {Client} client 9 | */ 10 | module.exports = async (client) => { 11 | // Commands 12 | const commandFiles = await globPromise(`${process.cwd()}/commands/**/*.js`); 13 | commandFiles.map((value) => { 14 | const file = require(value); 15 | const splitted = value.split("/"); 16 | const directory = splitted[splitted.length - 2]; 17 | 18 | if (file.name) { 19 | const properties = { directory, ...file }; 20 | client.commands.set(file.name, properties); 21 | } 22 | }); 23 | 24 | // Events 25 | const eventFiles = await globPromise(`${process.cwd()}/events/*.js`); 26 | eventFiles.map((value) => require(value)); 27 | 28 | // Slash Commands 29 | const slashCommands = await globPromise( 30 | `${process.cwd()}/SlashCommands/*/*.js` 31 | ); 32 | 33 | const arrayOfSlashCommands = []; 34 | slashCommands.map((value) => { 35 | const file = require(value); 36 | if (!file?.name) return; 37 | client.slashCommands.set(file.name, file); 38 | 39 | if (["MESSAGE", "USER"].includes(file.type)) delete file.description; 40 | 41 | 42 | arrayOfSlashCommands.push(file); 43 | }); 44 | client.on("ready", async () => { 45 | // Register for a single guild 46 | //await client.guilds.cache 47 | //.get("826101795868246016") 48 | //.commands.set(arrayOfSlashCommands); 49 | 50 | // Register for all the guilds the bot is in 51 | await client.application.commands.set(arrayOfSlashCommands); 52 | }); 53 | }; 54 | -------------------------------------------------------------------------------- /commands/backup-load.js: -------------------------------------------------------------------------------- 1 | const config = require('../config.json') 2 | const backup = require("discord-backup"); 3 | 4 | module.exports = { 5 | name: "backup-load", 6 | description: "load backup", 7 | permissions: ["ADMINISTRATOR"], 8 | 9 | run: async (client, message, args) => { 10 | 11 | const backupID = args.join(' '); 12 | 13 | backup.fetch(backupID).then(async () => { 14 | 15 | message.channel.send({ content: ':warning: All the server channels, roles, emojis and settings will be cleared. type `-cancel` to cancel and `-confirm` to confirm.' }); 16 | 17 | // const collector = message.channel.createMessageCollector((m) => m.author.id === message.author.id && ['-confirm', 'cancel'].includes(m.content), { 18 | // time: 60000, 19 | // max: 1 20 | // }); 21 | // collector.on('collect', (m) => { 22 | // const confirm = m.content === '-confirm'; 23 | // collector.stop(); 24 | // if (confirm) { 25 | const msg_filter = (m) => m.author.id === message.author.id; 26 | const collected = await message.channel.awaitMessages({ filter: msg_filter, max: 1 }); 27 | 28 | if (!collected.first() || collected.first().content === '-cancel') return message.channel.send(':x: Cancelled!'); 29 | if (collected.first().content !== '-confirm') return message.channel.send('Invalid option!'); 30 | backup.load(backupID, message.guild).then(() => { 31 | 32 | return message.author.send({ content: 'Backup loaded successfully!' }); 33 | 34 | }).catch((err) => { 35 | 36 | if (err === 'No backup found') 37 | return message.channel.send({ content: ':x: No backup found for ID ' + backupID + '!' }); 38 | else 39 | return message.author.send({ content: ':x: An error occurred: ' } + (typeof err === 'string') ? err : JSON.stringify(err)); 40 | 41 | }); 42 | 43 | // } else { 44 | // return message.channel.send({ content: ':x: Cancelled.'}); 45 | // } 46 | // }) 47 | 48 | // collector.on('end', (collected, reason) => { 49 | // if (reason === 'time') 50 | // return message.channel.send({ content: ':x: Command timed out! Please retry.' }); 51 | // }) 52 | 53 | }).catch(() => { 54 | return message.channel.send({ content: ':x: No backup found for ID ' + backupID + '!' }); 55 | }); 56 | 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /events/messageCreate.js: -------------------------------------------------------------------------------- 1 | const client = require("../index"); 2 | const Discord = require("discord.js") 3 | const MessageActionRow = require('discord.js') 4 | client.on("messageCreate", async (message) => { 5 | if ( 6 | message.author.bot || 7 | !message.guild //|| 8 | // !message.content.toLowerCase().startsWith(client.config.prefix) 9 | ) 10 | return; 11 | 12 | const [cmd, ...args] = message.content 13 | .slice(client.config.prefix.length) 14 | .trim() 15 | .split(" "); 16 | 17 | const command = client.commands.get(cmd.toLowerCase()) || client.commands.find(c => c.aliases?.includes(cmd.toLowerCase())); 18 | 19 | if (command) { 20 | if (!message.content.toLowerCase().startsWith(client.config.prefix)) return; 21 | const PermissionsFlags = [ 22 | 'ADMINISTRATOR', 23 | 'CREATE_INSTANT_INVITE', 24 | 'KICK_MEMBERS', 25 | 'BAN_MEMBERS', 26 | 'MANAGE_CHANNELS', 27 | 'MANAGE_GUILD', 28 | 'ADD_REACTIONS', 29 | 'VIEW_AUDIT_LOG', 30 | 'PRIORITY_SPEAKER', 31 | 'STREAM', 32 | 'VIEW_CHANNEL', 33 | 'SEND_MESSAGES', 34 | 'SEND_TTS_MESSAGES', 35 | 'MANAGE_MESSAGES', 36 | 'EMBED_LINKS', 37 | 'ATTACH_FILES', 38 | 'READ_MESSAGE_HISTORY', 39 | 'MENTION_EVERYONE', 40 | 'USE_EXTERNAL_EMOJIS', 41 | 'VIEW_GUILD_INSIGHTS', 42 | 'CONNECT', 43 | 'SPEAK', 44 | 'MUTE_MEMBERS', 45 | 'DEAFEN_MEMBERS', 46 | 'MOVE_MEMBERS', 47 | 'USE_VAD', 48 | 'CHANGE_NICKNAME', 49 | 'MANAGE_SERVER', 50 | 'MANAGE_NICKNAMES', 51 | 'MANAGE_ROLES', 52 | 'MANAGE_WEBHOOKS', 53 | 'MANAGE_EMOJIS' 54 | ]; 55 | 56 | if (command.permissions && command.permissions.length) { 57 | let invalidPermissionsFlags = []; 58 | for (const permission of command.permissions) { 59 | if (!PermissionsFlags.includes(permission)) { 60 | return console.log(`Invalid Permissions : ${permission}`); 61 | } 62 | 63 | if (!message.member.permissions.has(permission)) { 64 | invalidPermissionsFlags.push(permission); 65 | } 66 | } 67 | 68 | if (invalidPermissionsFlags.length) { 69 | const noPermissionEmbed = new Discord.MessageEmbed() 70 | .setColor('RED') 71 | .setTitle('INVALID PERMISSION!!') 72 | .setDescription("You don't have that permission to use the command!!") 73 | .addField('Permission Required', `\`${invalidPermissionsFlags}\``) 74 | .setFooter(client.user.username, client.user.displayAvatarURL()) 75 | .setTimestamp(); 76 | 77 | return message.channel.send({ embeds: [noPermissionEmbed] }); 78 | } 79 | } 80 | command.run(client, message,args) 81 | } 82 | }) 83 | --------------------------------------------------------------------------------