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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 86 by rakin, Mon Jul 29 17:28:32 2024 UTC revision 344 by rakin, Mon Jul 29 17:29:40 2024 UTC
# Line 1  Line 1 
1  import { readdir } from "fs/promises";  import { readdir } from "fs/promises";
2  import path from "path";  import path from "path";
3  import { exit } from "process";  import { exit } from "process";
 import readline from "readline";  
4  import DiscordClient from "../../client/Client";  import DiscordClient from "../../client/Client";
 import BannedGuild from "../../models/BannedGuilds";  
5  import BaseCLICommand from "../../utils/structures/BaseCLICommand";  import BaseCLICommand from "../../utils/structures/BaseCLICommand";
6    
7  export default class SyncDBCommand extends BaseCLICommand {  export default class SyncDBCommand extends BaseCLICommand {
# Line 12  export default class SyncDBCommand exten Line 10  export default class SyncDBCommand exten
10      }      }
11    
12      async run(client: DiscordClient, argv: string[], args: string[]) {      async run(client: DiscordClient, argv: string[], args: string[]) {
13          const files = await readdir(path.join(client.rootdir, '/src/models'));          const files = await readdir(path.join(__dirname, '/../../models'));
14    
15          for await (const file of files) {          for await (const file of files) {
16              if (file === '..' || file === '.')              if (file === '..' || file === '.')
17                  continue;                  continue;
18                            
19              const { default: model } = await import(path.join(client.rootdir, '/src/models', file));              const { default: model } = await import(path.join(__dirname, '/../../models', file));
20              await model.sync({              await model.sync({
21                  logging: console.log                  logging: console.log
22              });              });

Legend:
Removed from v.86  
changed lines
  Added in v.344

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26