1 |
|
import 'reflect-metadata'; |
2 |
import { registerCommands, registerEvents } from './utils/registry'; |
import { registerCommands, registerEvents } from './utils/registry'; |
3 |
import DiscordClient from './client/Client'; |
import DiscordClient from './client/Client'; |
4 |
import { Intents } from 'discord.js'; |
import { Intents } from 'discord.js'; |
5 |
import { config } from 'dotenv'; |
import { config } from 'dotenv'; |
6 |
import { existsSync } from 'fs'; |
import { existsSync } from 'fs'; |
7 |
import path from 'path'; |
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({ |
const client = new DiscordClient({ |
31 |
partials: ["CHANNEL"], |
partials: ["CHANNEL"], |
42 |
] |
] |
43 |
}, path.resolve(__dirname, '..')); |
}, path.resolve(__dirname, '..')); |
44 |
|
|
|
if (existsSync(path.join(__dirname, '../.env'))) { |
|
|
config(); |
|
|
} |
|
|
else { |
|
|
process.env.ENV = 'prod'; |
|
|
} |
|
|
|
|
45 |
(async () => { |
(async () => { |
46 |
|
await registrationStart(); |
47 |
await registerCommands(client, '../commands'); |
await registerCommands(client, '../commands'); |
48 |
|
await registrationEnd(); |
49 |
|
|
50 |
|
await registrationStart(); |
51 |
await registerEvents(client, '../events'); |
await registerEvents(client, '../events'); |
|
await client.login(process.env.token); |
|
|
})(); |
|
52 |
|
await registrationEnd(); |
53 |
|
|
54 |
|
await client.login(process.env.TOKEN); |
55 |
|
await console.log('test'); |
56 |
|
})(); |