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