Skip to content

Commit

Permalink
fixed backup commands
Browse files Browse the repository at this point in the history
  • Loading branch information
GhomKrosmonaute committed Oct 23, 2024
1 parent 4c5dcef commit ec9cbeb
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions src/commands/backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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.`,
)
}
},
}),
],
Expand Down

0 comments on commit ec9cbeb

Please sign in to comment.