Brozy123 commited on
Commit
208f0fb
·
verified ·
1 Parent(s): c8dca55

Update storage.js

Browse files
Files changed (1) hide show
  1. storage.js +7 -14
storage.js CHANGED
@@ -64,27 +64,21 @@ class StorageManager {
64
  loadAll() {
65
  // Load Guild Settings
66
  const guildSettings = loadJson(GUILD_SETTINGS_FILE, {});
67
- this.data.config = Object.fromEntries(
68
- Object.entries(guildSettings).map(([k, v]) => [parseInt(k), v])
69
- );
70
 
71
  // Load Roles
72
  const roles = loadJson(CONFIG_FILE, {});
73
  this.data.roles = Object.fromEntries(
74
- Object.entries(roles).map(([k, v]) => [parseInt(k), new Set(v)])
75
  );
76
 
77
  // Load Stats
78
  const stats = loadJson(PLAYER_STATS_FILE, {});
79
- this.data.stats = Object.fromEntries(
80
- Object.entries(stats).map(([k, v]) => [parseInt(k), v])
81
- );
82
 
83
  // Load State
84
  const state = loadJson(STATE_FILE, {});
85
- this.data.active_polls = Object.fromEntries(
86
- Object.entries(state.polls || {}).map(([k, v]) => [parseInt(k), v])
87
- );
88
  this.data.processed_messages = new Set(state.processed || []);
89
  this.data.settings = state.settings || {};
90
 
@@ -166,9 +160,8 @@ class StorageManager {
166
  }
167
 
168
  addStat(userId, statType, amount = 1) {
169
- const userIdNum = parseInt(userId);
170
- if (!this.data.stats[userIdNum]) {
171
- this.data.stats[userIdNum] = {
172
  matches: 0,
173
  wins: 0,
174
  losses: 0,
@@ -178,7 +171,7 @@ class StorageManager {
178
  mvps: 0
179
  };
180
  }
181
- this.data.stats[userIdNum][statType] = (this.data.stats[userIdNum][statType] || 0) + amount;
182
  this.save('stats');
183
  }
184
  }
 
64
  loadAll() {
65
  // Load Guild Settings
66
  const guildSettings = loadJson(GUILD_SETTINGS_FILE, {});
67
+ this.data.config = guildSettings;
 
 
68
 
69
  // Load Roles
70
  const roles = loadJson(CONFIG_FILE, {});
71
  this.data.roles = Object.fromEntries(
72
+ Object.entries(roles).map(([k, v]) => [k, new Set(v)])
73
  );
74
 
75
  // Load Stats
76
  const stats = loadJson(PLAYER_STATS_FILE, {});
77
+ this.data.stats = stats;
 
 
78
 
79
  // Load State
80
  const state = loadJson(STATE_FILE, {});
81
+ this.data.active_polls = state.polls || {};
 
 
82
  this.data.processed_messages = new Set(state.processed || []);
83
  this.data.settings = state.settings || {};
84
 
 
160
  }
161
 
162
  addStat(userId, statType, amount = 1) {
163
+ if (!this.data.stats[userId]) {
164
+ this.data.stats[userId] = {
 
165
  matches: 0,
166
  wins: 0,
167
  losses: 0,
 
171
  mvps: 0
172
  };
173
  }
174
+ this.data.stats[userId][statType] = (this.data.stats[userId][statType] || 0) + amount;
175
  this.save('stats');
176
  }
177
  }