Use raw metadata for set effect command

This commit is contained in:
Cohee
2024-06-24 01:28:37 +03:00
parent 14879af678
commit 893f4f3ed6

View File

@@ -585,12 +585,6 @@ class WorldInfoTimedEffects {
return; return;
} }
const currentState = this.isEffectActive(type, entry);
if (currentState === newState) {
return;
}
const key = this.#getEntryKey(entry); const key = this.#getEntryKey(entry);
delete chat_metadata.timedWorldInfo[type][key]; delete chat_metadata.timedWorldInfo[type][key];
@@ -1106,7 +1100,7 @@ function registerWorldInfoSlashCommands() {
} }
const getNewEffectState = () => { const getNewEffectState = () => {
const currentState = timedEffects.isEffectActive(effect, entry); const currentState = !!timedEffects.getEffectMetadata(effect, entry);
if (['toggle', 't', ''].includes(value.trim().toLowerCase())) { if (['toggle', 't', ''].includes(value.trim().toLowerCase())) {
return !currentState; return !currentState;
@@ -1123,12 +1117,10 @@ function registerWorldInfoSlashCommands() {
return currentState; return currentState;
}; };
timedEffects.checkTimedEffects();
const newEffectState = getNewEffectState(); const newEffectState = getNewEffectState();
timedEffects.setTimedEffect(effect, entry, newEffectState); timedEffects.setTimedEffect(effect, entry, newEffectState);
await saveMetadata(); await saveMetadata();
timedEffects.cleanUp();
toastr.success(`Timed effect "${effect}" for entry ${entry.uid} is now ${newEffectState ? 'active' : 'inactive'}`); toastr.success(`Timed effect "${effect}" for entry ${entry.uid} is now ${newEffectState ? 'active' : 'inactive'}`);
return ''; return '';