Skip to content

Commit

Permalink
Parse regex capture group as integer (and not string) [#141]
Browse files Browse the repository at this point in the history
  • Loading branch information
cannawen committed Jan 4, 2024
1 parent 3b804f7 commit 32cb5ca
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/assistants/setTimer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export default [
label: `sets buyback timer reminder for 8 minutes in the future`,
trigger: [topics.lastDiscordUtterance],
given: [topics.time, timerDataTopic],
when: ([utterance]) => utterance.match(/^set (buy|my) ?back timer$/i),
when: ([utterance]) =>
utterance.match(/^set (buy|my|by) ?back timer$/i),
then: (_, [time, currentTimers]) => [
new Fact(topics.configurableEffect, "resources/audio/success.mp3"),
new Fact(
Expand All @@ -56,7 +57,7 @@ export default [
timerDataTopic,
currentTimers.concat({
audio: `${utterance.match(/\d+/)[0]} minutes have passed`,
time: time + utterance.match(/\d+/)[0] * 60,
time: time + parseInt(utterance.match(/\d+/)[0], 10) * 60,
})
),
],
Expand All @@ -75,7 +76,7 @@ export default [
timerDataTopic,
currentTimers.concat({
audio: `${utterance.match(/\d+/)[0]} seconds have passed`,
time: time + utterance.match(/\d+/)[0],
time: time + parseInt(utterance.match(/\d+/)[0], 10),
})
),
],
Expand Down

0 comments on commit 32cb5ca

Please sign in to comment.