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