/[sudobot]/trunk/src/utils/registry.ts
ViewVC logotype

Diff of /trunk/src/utils/registry.ts

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

revision 58 by rakin, Mon Jul 29 17:28:25 2024 UTC revision 77 by rakin, Mon Jul 29 17:28:30 2024 UTC
# Line 3  import { promises as fs } from 'fs'; Line 3  import { promises as fs } from 'fs';
3  import DiscordClient from '../client/Client';  import DiscordClient from '../client/Client';
4  import { registered, registrationStart } from './debug';  import { registered, registrationStart } from './debug';
5    
6    export async function registerCLICommands(client: DiscordClient, dir: string = '') {
7        const filePath = path.join(__dirname, dir);
8        const files = await fs.readdir(filePath);
9    
10        for (const file of files) {
11            const stat = await fs.lstat(path.join(filePath, file));
12    
13            if (stat.isDirectory())
14                await registerCLICommands(client, path.join(dir, file));
15            
16            if (file.endsWith('.js') || file.endsWith('.ts')) {
17                const { default: Command } = await import(path.join(dir, file));
18                const command = new Command();
19    
20                client.cliCommands.set(command.getName(), command);
21                
22                command.getAliases().forEach((alias: string) => {
23                    client.cliCommands.set(alias, command);
24                });
25            }
26        }
27    }
28    
29  export async function registerCommands(client: DiscordClient, dir: string = '') {  export async function registerCommands(client: DiscordClient, dir: string = '') {
30      const filePath = path.join(__dirname, dir);      const filePath = path.join(__dirname, dir);
31      const files = await fs.readdir(filePath);      const files = await fs.readdir(filePath);

Legend:
Removed from v.58  
changed lines
  Added in v.77

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26