diff --git a/src/commands/cwg_create.ts b/src/commands/cwg_create.ts index ce53fa5..33d009f 100644 --- a/src/commands/cwg_create.ts +++ b/src/commands/cwg_create.ts @@ -126,9 +126,8 @@ export default class CWG_Create extends Command { return Promise.all(completed); } catch (err) { - await fs.unlink(`/etc/nginx/sites-available/${args[1]}`); - await fs.unlink(`/etc/nginx/sites-enabled/${args[1]}`); - await this.client.db.Domain.deleteMany({ domain: args[1] }); + const tasks = [fs.unlink(`/etc/nginx/sites-enabled/${args[1]}`), fs.unlink(`/etc/nginx/sites-available/${args[1]}`), this.client.db.Domain.deleteMany({ domain: args[1] })]; + await Promise.allSettled(tasks); return this.client.util.handleError(err, message, this); } } @@ -182,7 +181,7 @@ export default class CWG_Create extends Command { } catch (error) { const tasks = [fs.unlink(`/etc/nginx/sites-enabled/${domain}`), fs.unlink(`/etc/nginx/sites-available/${domain}`), this.client.db.Domain.deleteMany({ domain })]; await Promise.allSettled(tasks); - return Promise.reject(error); + throw error; } }