1
- import { readdir } from 'fs/promises' ;
2
- import { join } from 'path' ;
3
1
import {
4
2
GatewayIntentBits ,
5
3
Partials
6
4
} from 'discord.js' ;
7
- import { SapphireClient } from '@sapphire/framework ' ;
5
+ import OverloadClient from './utils/OverloadClient.js ' ;
8
6
import Log from './utils/Log.js' ;
9
7
import { init , Integrations } from '@sentry/node' ;
10
8
import { RewriteFrames } from '@sentry/integrations' ;
11
9
12
10
initializeSentryIO ( ) ;
13
11
14
12
const client = initializeClient ( ) ;
15
- initializeEvents ( ) ;
16
13
17
- client . login ( process . env . DISCORD_BOT_TOKEN ) . catch ( Log . error ) ;
14
+ client . login ( process . env . DISCORD_BOT_TOKEN ) . catch ( error => Log . error ( error ) ) ;
18
15
19
16
function initializeClient ( ) {
20
17
const clientOptions = {
@@ -37,35 +34,7 @@ function initializeClient() {
37
34
Partials . User
38
35
] ,
39
36
} ;
40
- return new SapphireClient ( clientOptions ) ;
41
- }
42
-
43
- // the events handler
44
- async function initializeEvents ( ) {
45
-
46
- client . on ( 'error' , Log . error ) ;
47
-
48
- const eventsPath = new URL ( './events' , import . meta. url ) ;
49
- const eventsArray = await readdir ( eventsPath ) ;
50
- const eventFiles = eventsArray . filter ( file => file . endsWith ( '.js' ) ) ;
51
- // client.events = new Collection();
52
- eventFiles . forEach ( async function ( file ) {
53
- const filePath = join ( eventsPath . toString ( ) , file ) ;
54
- const eventModule = await import ( filePath ) ;
55
- const event = await eventModule . default ;
56
- // client.events.set(event.name, event);
57
- try {
58
- if ( event . once ) {
59
- client . once ( event . name , ( ...args ) => event . execute ( ...args , client ) ) ;
60
- } else {
61
- client . on ( event . name , ( ...args ) => event . execute ( ...args , client ) ) ;
62
- }
63
- } catch ( e ) {
64
- // eslint-disable-next-line no-console
65
- console . error ( 'events error:' , e ) ;
66
- }
67
- } ) ;
68
- return client . events ;
37
+ return new OverloadClient ( clientOptions ) ;
69
38
}
70
39
71
40
// Sentry setup
0 commit comments