From ec9cbeb68ffb646c7443a6f2a77c394e8dcfd2f9 Mon Sep 17 00:00:00 2001 From: GhomKrosmonaute Date: Thu, 24 Oct 2024 00:37:24 +0200 Subject: [PATCH] fixed backup commands --- src/commands/backup.ts | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/commands/backup.ts b/src/commands/backup.ts index 9773b14..a04e70d 100644 --- a/src/commands/backup.ts +++ b/src/commands/backup.ts @@ -27,15 +27,17 @@ export default new app.Command({ }, ], async run(message) { - const backups = await fs.promises.readdir( - app.database.config.backups!.location!, - ) - - if (backups.includes(message.args.name)) { - return message.reply( - `${app.emote(message, "Cross")} Backup with that name already exists.`, + try { + const backups = await fs.promises.readdir( + app.database.config.backups!.location!, ) - } + + if (backups.includes(message.args.name)) { + return message.reply( + `${app.emote(message, "Cross")} Backup with that name already exists.`, + ) + } + } catch {} await app.database.createBackup(message.args.name) @@ -84,15 +86,21 @@ export default new app.Command({ channelType: "all", botOwnerOnly: true, async run(message) { - const backups = await fs.promises.readdir( - app.database.config.backups!.location!, - ) + try { + const backups = await fs.promises.readdir( + app.database.config.backups!.location!, + ) - return message.reply( - backups.length - ? backups.join("\n") - : `${app.emote(message, "Cross")} No backups found.`, - ) + return message.reply( + backups.length + ? backups.join("\n") + : `${app.emote(message, "Cross")} No backups found.`, + ) + } catch { + return message.reply( + `${app.emote(message, "Cross")} No backups found.`, + ) + } }, }), ],