| 70 | } |
| 71 | |
| 72 | async setup() { |
| 73 | const existingCommands = (this.connection.prepare("SELECT command FROM counts").all() as { command: string }[]).map( |
| 74 | (x) => x.command, |
| 75 | ); |
| 76 | const commandNames = [...commands.keys(), ...messageCommands.keys(), ...userCommands.keys()]; |
| 77 | for (const command of commandNames) { |
| 78 | if (!existingCommands.includes(command)) { |
| 79 | this.connection.prepare("INSERT INTO counts (command, count) VALUES (?, ?)").run(command, 0); |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | async stop() { |
| 85 | this.connection.close(); |