diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-02 19:33:29 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-02 19:33:29 -0400 |
commit | 34f0d1d3ff3e2a90193c9a4d4de29d8335160d6a (patch) | |
tree | f5a069b332b649f510aac741ae2484e853efc6a2 /src/arguments | |
parent | 6c3ab0e2e4239a2122d1d8ce8ed7bc9673fdde6a (diff) | |
download | tanzanite-34f0d1d3ff3e2a90193c9a4d4de29d8335160d6a.tar.gz tanzanite-34f0d1d3ff3e2a90193c9a4d4de29d8335160d6a.tar.bz2 tanzanite-34f0d1d3ff3e2a90193c9a4d4de29d8335160d6a.zip |
started restructuring moderation commands,
note: nothing currently works :flushed:
Diffstat (limited to 'src/arguments')
-rw-r--r-- | src/arguments/contentWithDuration.ts | 9 | ||||
-rw-r--r-- | src/arguments/duration.ts | 30 |
2 files changed, 23 insertions, 16 deletions
diff --git a/src/arguments/contentWithDuration.ts b/src/arguments/contentWithDuration.ts index e69de29..8dd7621 100644 --- a/src/arguments/contentWithDuration.ts +++ b/src/arguments/contentWithDuration.ts @@ -0,0 +1,9 @@ +import { BushArgumentTypeCaster } from '../lib/extensions/discord-akairo/BushArgumentTypeCaster'; +import { BushMessage } from '../lib/extensions/discord.js/BushMessage'; + +export const contentWithDurationTypeCaster: BushArgumentTypeCaster = async ( + _message: BushMessage, + phrase +): Promise<{ duration: number; contentWithoutTime: string }> => { + return client.util.parseDuration(phrase); +}; diff --git a/src/arguments/duration.ts b/src/arguments/duration.ts index 6007b4e..f8b6ab1 100644 --- a/src/arguments/duration.ts +++ b/src/arguments/duration.ts @@ -1,21 +1,19 @@ import { BushArgumentTypeCaster } from '../lib/extensions/discord-akairo/BushArgumentTypeCaster'; import { BushMessage } from '../lib/extensions/discord.js/BushMessage'; -import { BushConstants } from '../lib/utils/BushConstants'; -export const durationTypeCaster: BushArgumentTypeCaster = async (_message: BushMessage, phrase): Promise<number> => { - if (!phrase) return null; +export const durationTypeCaster: BushArgumentTypeCaster = (_message: BushMessage, phrase): number => { + // if (!phrase) return null; + // const regexString = Object.entries(BushConstants.TimeUnits) + // .map(([name, { label }]) => String.raw`(?:(?<${name}>-?(?:\d+)?\.?\d+) *${label})?`) + // .join('\\s*'); + // const match = new RegExp(`^${regexString}$`, 'im').exec(phrase); + // if (!match) return null; + // let milliseconds = 0; + // for (const key in match.groups) { + // const value = Number(match.groups[key] || 0); + // milliseconds += value * BushConstants.TimeUnits[key].value; + // } + // return milliseconds; - const regexString = Object.entries(BushConstants.TimeUnits) - .map(([name, { label }]) => String.raw`(?:(?<${name}>-?(?:\d+)?\.?\d+) *${label})?`) - .join('\\s*'); - const match = new RegExp(`^${regexString}$`, 'i').exec(phrase); - if (!match) return null; - - let milliseconds = 0; - for (const key in match.groups) { - const value = Number(match.groups[key] || 0); - milliseconds += value * BushConstants.TimeUnits[key].value; - } - - return milliseconds; + return client.util.parseDuration(phrase).duration; }; |