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,
|
||||
description: ""
|
||||
},
|
||||
migrated: {
|
||||
type: OptionType.BOOLEAN,
|
||||
hidden: true,
|
||||
default: false,
|
||||
description: ""
|
||||
}
|
||||
});
|
||||
|
||||
function stringToRegex(str: string) {
|
||||
|
@ -264,13 +258,20 @@ export default definePlugin({
|
|||
settings,
|
||||
|
||||
async start() {
|
||||
if (!settings.store.migrated) {
|
||||
const stringRules = await DataStore.get(STRING_RULES_KEY) ?? makeEmptyRuleArray();
|
||||
const regexRules = await DataStore.get(REGEX_RULES_KEY) ?? makeEmptyRuleArray();
|
||||
|
||||
if (settings.store.stringRules.length === 0 || settings.store.regexRules.length === 0) {
|
||||
const stringRules = await DataStore.get(STRING_RULES_KEY);
|
||||
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;
|
||||
settings.store.migrated = true;
|
||||
await DataStore.del(REGEX_RULES_KEY);
|
||||
} else if (settings.store.regexRules.length === 0) settings.store.regexRules = makeEmptyRuleArray();
|
||||
}
|
||||
|
||||
this.preSend = addPreSendListener((channelId, msg) => {
|
||||
|
|
Loading…
Add table
Reference in a new issue