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);