3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-07-07 02:57:20 +00:00

refactor: don't create 'name' property in config dynamically

This commit is contained in:
Dragory 2024-11-10 13:47:40 +02:00
parent 0810dd3f0e
commit 395a750e9d
No known key found for this signature in database
19 changed files with 86 additions and 154 deletions

View file

@ -97,20 +97,20 @@ export const CountersPlugin = guildPlugin<CountersPluginType>()({
// Initialize and store the IDs of each of the counters internally
state.counterIds = {};
const config = pluginData.config.get();
for (const counter of Object.values(config.counters)) {
const dbCounter = await state.counters.findOrCreateCounter(counter.name, counter.per_channel, counter.per_user);
state.counterIds[counter.name] = dbCounter.id;
for (const [counterName, counter] of Object.entries(config.counters)) {
const dbCounter = await state.counters.findOrCreateCounter(counterName, counter.per_channel, counter.per_user);
state.counterIds[counterName] = dbCounter.id;
const thisCounterTriggers: CounterTrigger[] = [];
state.counterTriggersByCounterId.set(dbCounter.id, thisCounterTriggers);
// Initialize triggers
for (const trigger of values(counter.triggers)) {
for (const [triggerName, trigger] of Object.entries(counter.triggers)) {
const parsedCondition = parseCounterConditionString(trigger.condition)!;
const parsedReverseCondition = parseCounterConditionString(trigger.reverse_condition)!;
const counterTrigger = await state.counters.initCounterTrigger(
dbCounter.id,
trigger.name,
triggerName,
parsedCondition[0],
parsedCondition[1],
parsedReverseCondition[0],