diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-09-18 22:27:57 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-09-18 22:27:57 -0400 |
commit | dca5041fab25eb7c81cabd6ddbd418b311c65fcc (patch) | |
tree | a3adf9b13d5ca13dcd44112ef18abd0e7315d4d1 /src/lib/extensions/discord-akairo | |
parent | 04dc104726fa1519480ba1889c1307ec3ad9be19 (diff) | |
download | tanzanite-dca5041fab25eb7c81cabd6ddbd418b311c65fcc.tar.gz tanzanite-dca5041fab25eb7c81cabd6ddbd418b311c65fcc.tar.bz2 tanzanite-dca5041fab25eb7c81cabd6ddbd418b311c65fcc.zip |
fix slowmode
Diffstat (limited to 'src/lib/extensions/discord-akairo')
-rw-r--r-- | src/lib/extensions/discord-akairo/BushClient.ts | 4 | ||||
-rw-r--r-- | src/lib/extensions/discord-akairo/BushClientUtil.ts | 9 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts index 48ba90d..1ac0ee9 100644 --- a/src/lib/extensions/discord-akairo/BushClient.ts +++ b/src/lib/extensions/discord-akairo/BushClient.ts @@ -26,6 +26,7 @@ import { abbreviatedNumberTypeCaster } from '../../../arguments/abbreviatedNumbe import { contentWithDurationTypeCaster } from '../../../arguments/contentWithDuration'; import { discordEmojiTypeCaster } from '../../../arguments/discordEmoji'; import { durationTypeCaster } from '../../../arguments/duration'; +import { durationSecondsTypeCaster } from '../../../arguments/durationSeconds'; import { permissionTypeCaster } from '../../../arguments/permission'; import { roleWithDurationTypeCaster } from '../../../arguments/roleWithDuation'; import { snowflakeTypeCaster } from '../../../arguments/snowflake'; @@ -326,7 +327,8 @@ export class BushClient<Ready extends boolean = boolean> extends AkairoClient<Re snowflake: snowflakeTypeCaster, discordEmoji: discordEmojiTypeCaster, roleWithDuration: roleWithDurationTypeCaster, - abbreviatedNumber: abbreviatedNumberTypeCaster + abbreviatedNumber: abbreviatedNumberTypeCaster, + durationSeconds: durationSecondsTypeCaster }); // loads all the handlers const loaders = { diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts index 5a71167..2345ac7 100644 --- a/src/lib/extensions/discord-akairo/BushClientUtil.ts +++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts @@ -1056,10 +1056,11 @@ export class BushClientUtil extends ClientUtil { return array.map((a) => `${surroundChar1}${a}${surroundChar2 ?? surroundChar1}`); } - public parseDuration(content: string, remove = true): { duration: number; contentWithoutTime: string | null } { + public parseDuration(content: string, remove = true): { duration: number | null; contentWithoutTime: string | null } { if (!content) return { duration: 0, contentWithoutTime: null }; - let duration = 0; + // eslint-disable-next-line prefer-const + let duration = null; // Try to reduce false positives by requiring a space before the duration, this makes sure it still matches if it is // in the beginning of the argument let contentWithoutTime = ` ${content}`; @@ -1067,8 +1068,8 @@ export class BushClientUtil extends ClientUtil { for (const unit in BushConstants.TimeUnits) { const regex = BushConstants.TimeUnits[unit].match; const match = regex.exec(contentWithoutTime); - const value = Number(match?.groups?.[unit] ?? 0); - duration += value * BushConstants.TimeUnits[unit].value; + const value = Number(match?.groups?.[unit]); + if (!isNaN(value)) (duration as unknown as number) += value * BushConstants.TimeUnits[unit].value; if (remove) contentWithoutTime = contentWithoutTime.replace(regex, ''); } |