From 272cb77f34413f52b01458eff9f8b27a4458df67 Mon Sep 17 00:00:00 2001 From: Rose Date: Wed, 22 May 2024 13:21:48 -0400 Subject: [PATCH] rename variables from old plugin name --- index.tsx | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/index.tsx b/index.tsx index e4c2e10..6a73b6c 100644 --- a/index.tsx +++ b/index.tsx @@ -37,18 +37,18 @@ interface IRPCNotificationCreate { message: Message; } -const CLICKER_RULES_KEY = "[Clicker]-rules"; +const TRIGGER_RULES_KEY = "[soundTrigger]-rules"; -interface ClickerRule { +interface TriggerRule { trigger: string; sound: string; } -let clickerRules = [ +let triggerRules = [ { sound: "", trigger: "", }, -] as ClickerRule[]; +] as TriggerRule[]; interface InputProps { placeholder: string; @@ -71,31 +71,31 @@ function Input({ placeholder, initalValue, onChange }: InputProps) { function RuleInputter({ update }: { update: () => void; }) { async function deleteRule(index: number) { - if (index === clickerRules.length - 1) return; - clickerRules.splice(index, 1); + if (index === triggerRules.length - 1) return; + triggerRules.splice(index, 1); - await DataStore.set(CLICKER_RULES_KEY, clickerRules); + await DataStore.set(TRIGGER_RULES_KEY, triggerRules); update(); } async function modifyRule( newValue: string, index: number, - key: keyof ClickerRule + key: keyof TriggerRule ) { - if (index === clickerRules.length - 1) { - clickerRules.push({ + if (index === triggerRules.length - 1) { + triggerRules.push({ sound: "", trigger: "", }); } - clickerRules[index][key] = newValue; + triggerRules[index][key] = newValue; - if (clickerRules[index].trigger === "" && clickerRules[index].sound === "" && index !== clickerRules.length - 1) { - clickerRules.splice(index, 1); + if (triggerRules[index].trigger === "" && triggerRules[index].sound === "" && index !== triggerRules.length - 1) { + triggerRules.splice(index, 1); } - await DataStore.set(CLICKER_RULES_KEY, clickerRules); + await DataStore.set(TRIGGER_RULES_KEY, triggerRules); update(); } return ( @@ -103,7 +103,7 @@ function RuleInputter({ update }: { update: () => void; }) { Rules - {clickerRules.map((rule, ind) => { + {triggerRules.map((rule, ind) => { return ( @@ -132,7 +132,7 @@ function RuleInputter({ update }: { update: () => void; }) { style={{ background: "none", color: "var(--status-danger)", - ...(ind === clickerRules.length - 1 + ...(ind === triggerRules.length - 1 ? { visibility: "hidden", pointerEvents: "none", @@ -192,7 +192,7 @@ export default definePlugin({ ], settings, async start() { - clickerRules = (await DataStore.get(CLICKER_RULES_KEY)) ?? clickerRules; + triggerRules = (await DataStore.get(TRIGGER_RULES_KEY)) ?? triggerRules; }, flux: { async RPC_NOTIFICATION_CREATE({ type, message }: IRPCNotificationCreate) { @@ -229,9 +229,9 @@ export default definePlugin({ }); async function handleMessage(message: Message) { - let queue = [] as ClickerRule[]; + let queue = [] as TriggerRule[]; - for (const rule of clickerRules) { + for (const rule of triggerRules) { if (!rule.trigger) continue; const regex = new RegExp(rule.trigger, "g"); const count = (message.content.match(regex) ?? []).length;