mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-02-24 15:35:11 +00:00
fix textreplace migration
This commit is contained in:
parent
8d9e9c49fa
commit
e6188b7cc5
1 changed files with 13 additions and 12 deletions
|
@ -81,12 +81,6 @@ const settings = definePluginSettings({
|
||||||
hidden: true,
|
hidden: true,
|
||||||
description: ""
|
description: ""
|
||||||
},
|
},
|
||||||
migrated: {
|
|
||||||
type: OptionType.BOOLEAN,
|
|
||||||
hidden: true,
|
|
||||||
default: false,
|
|
||||||
description: ""
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function stringToRegex(str: string) {
|
function stringToRegex(str: string) {
|
||||||
|
@ -264,13 +258,20 @@ export default definePlugin({
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
async start() {
|
async start() {
|
||||||
if (!settings.store.migrated) {
|
|
||||||
const stringRules = await DataStore.get(STRING_RULES_KEY) ?? makeEmptyRuleArray();
|
|
||||||
const regexRules = await DataStore.get(REGEX_RULES_KEY) ?? makeEmptyRuleArray();
|
|
||||||
|
|
||||||
settings.store.stringRules = stringRules;
|
if (settings.store.stringRules.length === 0 || settings.store.regexRules.length === 0) {
|
||||||
settings.store.regexRules = regexRules;
|
const stringRules = await DataStore.get(STRING_RULES_KEY);
|
||||||
settings.store.migrated = true;
|
const regexRules = await DataStore.get(REGEX_RULES_KEY);
|
||||||
|
|
||||||
|
if (stringRules != null) {
|
||||||
|
settings.store.stringRules = stringRules;
|
||||||
|
await DataStore.del(STRING_RULES_KEY);
|
||||||
|
} else if (settings.store.stringRules.length === 0) settings.store.stringRules = makeEmptyRuleArray();
|
||||||
|
|
||||||
|
if (regexRules != null) {
|
||||||
|
settings.store.regexRules = regexRules;
|
||||||
|
await DataStore.del(REGEX_RULES_KEY);
|
||||||
|
} else if (settings.store.regexRules.length === 0) settings.store.regexRules = makeEmptyRuleArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.preSend = addPreSendListener((channelId, msg) => {
|
this.preSend = addPreSendListener((channelId, msg) => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue