Download src/commands/backupLayout.js from APRKDEV/wsb-bot: direct link, hf CLI and curl.
- Browser
- Download file 2.48 kB
-
https://huggingface.co/spaces/APRKDEV/wsb-bot/resolve/c8f3880098432483b23491dd763585274d00f8c8/src/commands/backupLayout.js
- Command line
-
hf download hf://spaces/APRKDEV/wsb-bot@c8f3880098432483b23491dd763585274d00f8c8/src/commands/backupLayout.js
-
curl -L -o backupLayout.js https://huggingface.co/spaces/APRKDEV/wsb-bot/resolve/c8f3880098432483b23491dd763585274d00f8c8/src/commands/backupLayout.js
2.48 kB
| const { createEmbed } = require('../utils/embeds'); | |
| const { Colors } = require('../config'); | |
| module.exports = { | |
| name: 'backup layout', | |
| async execute(client, message) { | |
| const guildId = process.env.GUILD_ID; | |
| const guild = await client.guilds.fetch(guildId); | |
| // Fetch all channels and roles | |
| await guild.channels.fetch(); | |
| await guild.roles.fetch(); | |
| const backup = { | |
| guild: { | |
| name: guild.name, | |
| id: guild.id, | |
| backupDate: new Date().toISOString(), | |
| }, | |
| roles: guild.roles.cache | |
| .filter(r => r.name !== '@everyone') | |
| .sort((a, b) => b.position - a.position) | |
| .map(r => ({ | |
| name: r.name, | |
| color: r.hexColor, | |
| position: r.position, | |
| hoist: r.hoist, | |
| managed: r.managed, | |
| permissions: r.permissions.toArray(), | |
| })), | |
| categories: guild.channels.cache | |
| .filter(c => c.type === 4) // GuildCategory | |
| .sort((a, b) => a.position - b.position) | |
| .map(cat => ({ | |
| name: cat.name, | |
| position: cat.position, | |
| channels: guild.channels.cache | |
| .filter(c => c.parentId === cat.id) | |
| .sort((a, b) => a.position - b.position) | |
| .map(ch => ({ | |
| name: ch.name, | |
| type: ch.type === 2 ? 'voice' : 'text', | |
| position: ch.position, | |
| })), | |
| })), | |
| }; | |
| const json = JSON.stringify(backup, null, 2); | |
| const buffer = Buffer.from(json, 'utf-8'); | |
| const embed = createEmbed({ | |
| title: 'πΎ Server Backup', | |
| description: [ | |
| `**Guild:** ${guild.name}`, | |
| `**Roles:** ${backup.roles.length}`, | |
| `**Categories:** ${backup.categories.length}`, | |
| `**Total Channels:** ${backup.categories.reduce((sum, c) => sum + c.channels.length, 0)}`, | |
| ].join('\n'), | |
| color: Colors.SUCCESS, | |
| }); | |
| await message.reply({ | |
| embeds: [embed], | |
| files: [{ attachment: buffer, name: `backup-${guild.name.replace(/\s+/g, '-')}-${Date.now()}.json` }], | |
| }); | |
| }, | |
| }; | |