/[sudobot]/trunk/src/index.ts
ViewVC logotype

Annotation of /trunk/src/index.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 362 - (hide annotations)
Mon Jul 29 17:29:47 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: application/typescript
File size: 1647 byte(s)
feat: make the system prefix changable
1 rakin 348 import 'reflect-metadata';
2 rakin 51 import { registerCommands, registerEvents } from './utils/registry';
3     import DiscordClient from './client/Client';
4     import { Intents } from 'discord.js';
5     import { config } from 'dotenv';
6     import { existsSync } from 'fs';
7     import path from 'path';
8 rakin 58 import { registrationEnd, registrationStart } from './utils/debug';
9     import { yellow } from './utils/util';
10 rakin 51
11     if (existsSync(path.join(__dirname, '../.env'))) {
12     config();
13     }
14     else {
15     process.env.ENV = 'prod';
16     }
17    
18 rakin 58 if (process.argv.includes('--prod')) {
19     console.warn(yellow('WARNING: Forcing production mode (--prod option passed)'));
20     process.env.ENV = 'prod';
21     }
22    
23     if (process.argv.includes('--dev')) {
24     console.warn(yellow('WARNING: Forcing development mode (--dev option passed)'));
25     process.env.ENV = 'dev';
26     }
27    
28 rakin 362 console.log(`ENV: ${process.env.SUDO_PREFIX}`);
29    
30 rakin 66 const client = new DiscordClient({
31     partials: ["CHANNEL"],
32     intents: [
33     Intents.FLAGS.GUILDS,
34     Intents.FLAGS.GUILD_MESSAGES,
35     Intents.FLAGS.DIRECT_MESSAGES,
36     Intents.FLAGS.DIRECT_MESSAGE_TYPING,
37     Intents.FLAGS.GUILD_PRESENCES,
38     Intents.FLAGS.GUILD_MEMBERS,
39     Intents.FLAGS.GUILD_BANS,
40     Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
41     Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS,
42     ]
43     }, path.resolve(__dirname, '..'));
44    
45 rakin 51 (async () => {
46 rakin 58 await registrationStart();
47 rakin 51 await registerCommands(client, '../commands');
48 rakin 58 await registrationEnd();
49    
50     await registrationStart();
51 rakin 51 await registerEvents(client, '../events');
52 rakin 58 await registrationEnd();
53    
54 rakin 67 await client.login(process.env.TOKEN);
55 rakin 241 await console.log('test');
56 rakin 362 })();

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26