1 |
import { readdir } from "fs/promises"; |
2 |
import path from "path"; |
3 |
import { exit } from "process"; |
4 |
import DiscordClient from "../../client/Client"; |
5 |
import BaseCLICommand from "../../utils/structures/BaseCLICommand"; |
6 |
|
7 |
export default class SyncDBCommand extends BaseCLICommand { |
8 |
constructor() { |
9 |
super('syncdb', 'guild'); |
10 |
} |
11 |
|
12 |
async run(client: DiscordClient, argv: string[], args: string[]) { |
13 |
const files = await readdir(path.join(__dirname, '/../../models')); |
14 |
|
15 |
for await (const file of files) { |
16 |
if (file === '..' || file === '.') |
17 |
continue; |
18 |
|
19 |
const { default: model } = await import(path.join(__dirname, '/../../models', file)); |
20 |
await model.sync({ |
21 |
logging: console.log |
22 |
}); |
23 |
} |
24 |
|
25 |
exit(0); |
26 |
} |
27 |
} |