rename variables from old plugin name
This commit is contained in:
parent
a83285a4c7
commit
272cb77f34
1 changed files with 19 additions and 19 deletions
38
index.tsx
38
index.tsx
|
|
@ -37,18 +37,18 @@ interface IRPCNotificationCreate {
|
||||||
message: Message;
|
message: Message;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CLICKER_RULES_KEY = "[Clicker]-rules";
|
const TRIGGER_RULES_KEY = "[soundTrigger]-rules";
|
||||||
|
|
||||||
interface ClickerRule {
|
interface TriggerRule {
|
||||||
trigger: string;
|
trigger: string;
|
||||||
sound: string;
|
sound: string;
|
||||||
}
|
}
|
||||||
let clickerRules = [
|
let triggerRules = [
|
||||||
{
|
{
|
||||||
sound: "",
|
sound: "",
|
||||||
trigger: "",
|
trigger: "",
|
||||||
},
|
},
|
||||||
] as ClickerRule[];
|
] as TriggerRule[];
|
||||||
|
|
||||||
interface InputProps {
|
interface InputProps {
|
||||||
placeholder: string;
|
placeholder: string;
|
||||||
|
|
@ -71,31 +71,31 @@ function Input({ placeholder, initalValue, onChange }: InputProps) {
|
||||||
|
|
||||||
function RuleInputter({ update }: { update: () => void; }) {
|
function RuleInputter({ update }: { update: () => void; }) {
|
||||||
async function deleteRule(index: number) {
|
async function deleteRule(index: number) {
|
||||||
if (index === clickerRules.length - 1) return;
|
if (index === triggerRules.length - 1) return;
|
||||||
clickerRules.splice(index, 1);
|
triggerRules.splice(index, 1);
|
||||||
|
|
||||||
await DataStore.set(CLICKER_RULES_KEY, clickerRules);
|
await DataStore.set(TRIGGER_RULES_KEY, triggerRules);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function modifyRule(
|
async function modifyRule(
|
||||||
newValue: string,
|
newValue: string,
|
||||||
index: number,
|
index: number,
|
||||||
key: keyof ClickerRule
|
key: keyof TriggerRule
|
||||||
) {
|
) {
|
||||||
if (index === clickerRules.length - 1) {
|
if (index === triggerRules.length - 1) {
|
||||||
clickerRules.push({
|
triggerRules.push({
|
||||||
sound: "",
|
sound: "",
|
||||||
trigger: "",
|
trigger: "",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
clickerRules[index][key] = newValue;
|
triggerRules[index][key] = newValue;
|
||||||
|
|
||||||
if (clickerRules[index].trigger === "" && clickerRules[index].sound === "" && index !== clickerRules.length - 1) {
|
if (triggerRules[index].trigger === "" && triggerRules[index].sound === "" && index !== triggerRules.length - 1) {
|
||||||
clickerRules.splice(index, 1);
|
triggerRules.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
await DataStore.set(CLICKER_RULES_KEY, clickerRules);
|
await DataStore.set(TRIGGER_RULES_KEY, triggerRules);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
|
@ -103,7 +103,7 @@ function RuleInputter({ update }: { update: () => void; }) {
|
||||||
<Forms.FormDivider />
|
<Forms.FormDivider />
|
||||||
<Forms.FormTitle tag="h4">Rules</Forms.FormTitle>
|
<Forms.FormTitle tag="h4">Rules</Forms.FormTitle>
|
||||||
<Flex flexDirection="column" style={{ gap: "0.5em" }}>
|
<Flex flexDirection="column" style={{ gap: "0.5em" }}>
|
||||||
{clickerRules.map((rule, ind) => {
|
{triggerRules.map((rule, ind) => {
|
||||||
return (
|
return (
|
||||||
<React.Fragment key={`${rule.trigger}-${ind}`}>
|
<React.Fragment key={`${rule.trigger}-${ind}`}>
|
||||||
<Flex flexDirection="row" style={{ gap: "0.5em" }}>
|
<Flex flexDirection="row" style={{ gap: "0.5em" }}>
|
||||||
|
|
@ -132,7 +132,7 @@ function RuleInputter({ update }: { update: () => void; }) {
|
||||||
style={{
|
style={{
|
||||||
background: "none",
|
background: "none",
|
||||||
color: "var(--status-danger)",
|
color: "var(--status-danger)",
|
||||||
...(ind === clickerRules.length - 1
|
...(ind === triggerRules.length - 1
|
||||||
? {
|
? {
|
||||||
visibility: "hidden",
|
visibility: "hidden",
|
||||||
pointerEvents: "none",
|
pointerEvents: "none",
|
||||||
|
|
@ -192,7 +192,7 @@ export default definePlugin({
|
||||||
],
|
],
|
||||||
settings,
|
settings,
|
||||||
async start() {
|
async start() {
|
||||||
clickerRules = (await DataStore.get(CLICKER_RULES_KEY)) ?? clickerRules;
|
triggerRules = (await DataStore.get(TRIGGER_RULES_KEY)) ?? triggerRules;
|
||||||
},
|
},
|
||||||
flux: {
|
flux: {
|
||||||
async RPC_NOTIFICATION_CREATE({ type, message }: IRPCNotificationCreate) {
|
async RPC_NOTIFICATION_CREATE({ type, message }: IRPCNotificationCreate) {
|
||||||
|
|
@ -229,9 +229,9 @@ export default definePlugin({
|
||||||
});
|
});
|
||||||
|
|
||||||
async function handleMessage(message: Message) {
|
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;
|
if (!rule.trigger) continue;
|
||||||
const regex = new RegExp(rule.trigger, "g");
|
const regex = new RegExp(rule.trigger, "g");
|
||||||
const count = (message.content.match(regex) ?? []).length;
|
const count = (message.content.match(regex) ?? []).length;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue