/[sudobot]/trunk/src/cli-commands/db/SyncDBCommand.ts
ViewVC logotype

Annotation of /trunk/src/cli-commands/db/SyncDBCommand.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 86 - (hide annotations)
Mon Jul 29 17:28:32 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: application/typescript
File size: 920 byte(s)
Updated the database system
1 rakin 86 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/BannedGuilds";
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(client.rootdir, '/src/models'));
16    
17     for await (const file of files) {
18     if (file === '..' || file === '.')
19     continue;
20    
21     const { default: model } = await import(path.join(client.rootdir, '/src/models', file));
22     await model.sync({
23     logging: console.log
24     });
25     }
26    
27     exit(0);
28     }
29     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26