mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-07 11:07:19 +00:00
refactor: don't create 'name' property in config dynamically
This commit is contained in:
parent
0810dd3f0e
commit
395a750e9d
19 changed files with 86 additions and 154 deletions
|
@ -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],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue