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

Contents of /trunk/src/index.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 362 - (show 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 import 'reflect-metadata';
2 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 import { registrationEnd, registrationStart } from './utils/debug';
9 import { yellow } from './utils/util';
10
11 if (existsSync(path.join(__dirname, '../.env'))) {
12 config();
13 }
14 else {
15 process.env.ENV = 'prod';
16 }
17
18 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 console.log(`ENV: ${process.env.SUDO_PREFIX}`);
29
30 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 (async () => {
46 await registrationStart();
47 await registerCommands(client, '../commands');
48 await registrationEnd();
49
50 await registrationStart();
51 await registerEvents(client, '../events');
52 await registrationEnd();
53
54 await client.login(process.env.TOKEN);
55 await console.log('test');
56 })();

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26