From d534ea163d71312ae8ac63055a9b02e39e5acf03 Mon Sep 17 00:00:00 2001 From: Bsian Date: Tue, 9 Jun 2020 12:40:02 +0100 Subject: [PATCH] Clean up --- src/commands/lock.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/commands/lock.ts b/src/commands/lock.ts index d3df486..7769fab 100644 --- a/src/commands/lock.ts +++ b/src/commands/lock.ts @@ -25,10 +25,8 @@ export default class Lock extends Command { await account.updateOne({ locked: true }); const expiry = new Date(); - const lockLength = args[1].match(/[a-z]+|[^a-z]+/gi); - const length = Number(lockLength[0]); - const unit = lockLength[1] as unitOfTime.Base; - const momentMilliseconds = moment.duration(length, unit).asMilliseconds(); + const [length, unit] = args[1].match(/[a-z]+|[^a-z]+/gi); + const momentMilliseconds = moment.duration(Number(length), unit as unitOfTime.Base).asMilliseconds(); const reason = momentMilliseconds ? args.slice(2).join(' ') : args.slice(1).join(' '); await this.client.util.createModerationLog(account.userID, message.member, 2, reason, momentMilliseconds);