From 5b760944720a7def4840522cfd3c47d39df0aac7 Mon Sep 17 00:00:00 2001 From: Mara <mara-li@outlook.fr> Date: Sun, 1 Dec 2024 21:03:26 +0100 Subject: [PATCH] fix: can't delete capa when " - " in name; Now it delete only the first --- src/interactions/edit/dice.ts | 2 +- src/interactions/edit/stats.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/interactions/edit/dice.ts b/src/interactions/edit/dice.ts index fd4cd6f3..43081f9d 100644 --- a/src/interactions/edit/dice.ts +++ b/src/interactions/edit/dice.ts @@ -61,7 +61,7 @@ export async function validateDiceEdit( const values = interaction.fields.getTextInputValue("allDice"); const valuesAsDice = values.split("\n- ").map((dice) => { const [name, value] = dice.split(/ ?: ?/); - return { name: name.replace("- ", "").trim().toLowerCase(), value }; + return { name: name.replace(/^- /, "").trim().toLowerCase(), value }; }); const dices = valuesAsDice.reduce( (acc, { name, value }) => { diff --git a/src/interactions/edit/stats.ts b/src/interactions/edit/stats.ts index f54d6515..f9008727 100644 --- a/src/interactions/edit/stats.ts +++ b/src/interactions/edit/stats.ts @@ -30,7 +30,7 @@ export async function editStats( if (!templateStats || !templateStats.statistics) return; const valuesAsStats = values.split("\n- ").map((stat) => { const [name, value] = stat.split(/ ?: ?/); - return { name: name.replace("- ", "").trim().toLowerCase(), value }; + return { name: name.replace(/^- /, "").trim().toLowerCase(), value }; }); //fusion all stats into an object instead of list const stats = valuesAsStats.reduce(