@@ -4,80 +4,80 @@ import { loadCommands, interactionCreateHandler } from "./handlers/InteractionCr
44import { messageHandler } from "./handlers/MessageHandler.js" ;
55import { deleteButtonHandler } from "./utils/CommandUtils.js" ;
66import {
7- ActivityType ,
8- Client ,
9- Collection ,
10- GatewayIntentBits ,
11- Interaction ,
12- LimitedCollection ,
13- Partials
7+ ActivityType ,
8+ Client ,
9+ Collection ,
10+ GatewayIntentBits ,
11+ Interaction ,
12+ LimitedCollection ,
13+ Partials
1414} from "discord.js" ;
1515
1616( async function ( ) {
17- const context : MyContext = {
18- client : new Client ( {
19- intents : [
20- GatewayIntentBits . Guilds ,
21- GatewayIntentBits . GuildMessages
22- ] ,
23- presence : {
24- activities : [ { type : ActivityType . Playing , name : "Read the docs" } ] ,
25- status : "online" ,
26- } ,
27- // For DMs, a partial channel object is received, in order to
28- // receive dms, Partials.Channel must be activated
29- partials : [
30- Partials . Channel
31- ] ,
32- makeCache : ( manager ) => {
33- //! Disabling these caches will break djs functionality
34- const unsupportedCaches = [
35- "GuildManager" ,
36- "ChannelManager" ,
37- "GuildChannelManager" ,
38- "RoleManager" ,
39- "PermissionOverwriteManager" ,
40- ] ;
41- if ( unsupportedCaches . includes ( manager . name ) ) return new Collection ( ) ;
42- // Disable every supported cache
43- return new LimitedCollection ( { maxSize : 0 } ) ;
44- } ,
45- } ) ,
46- commands : {
47- buttons : new Collection ( ) ,
48- selectMenus : new Collection ( ) ,
49- slashCommands : new Collection ( ) ,
50- } ,
51- cooldownCounter : new Collection ( ) ,
52- } ;
53- const docsBot = context . client ;
54- await loadCommands ( context ) ;
55- // Add delete button handler
56- context . commands . buttons . set ( "deletebtn" , { custom_id : "deletebtn" , run : deleteButtonHandler } ) ;
17+ const context : MyContext = {
18+ client : new Client ( {
19+ intents : [
20+ GatewayIntentBits . Guilds ,
21+ GatewayIntentBits . GuildMessages
22+ ] ,
23+ presence : {
24+ activities : [ { type : ActivityType . Playing , name : "Read the docs" } ] ,
25+ status : "online" ,
26+ } ,
27+ // For DMs, a partial channel object is received, in order to
28+ // receive dms, Partials.Channel must be activated
29+ partials : [
30+ Partials . Channel
31+ ] ,
32+ makeCache : ( manager ) => {
33+ //! Disabling these caches will break djs functionality
34+ const unsupportedCaches = [
35+ "GuildManager" ,
36+ "ChannelManager" ,
37+ "GuildChannelManager" ,
38+ "RoleManager" ,
39+ "PermissionOverwriteManager" ,
40+ ] ;
41+ if ( unsupportedCaches . includes ( manager . name ) ) return new Collection ( ) ;
42+ // Disable every supported cache
43+ return new LimitedCollection ( { maxSize : 0 } ) ;
44+ } ,
45+ } ) ,
46+ commands : {
47+ buttons : new Collection ( ) ,
48+ selectMenus : new Collection ( ) ,
49+ slashCommands : new Collection ( ) ,
50+ } ,
51+ cooldownCounter : new Collection ( ) ,
52+ } ;
53+ const docsBot = context . client ;
54+ await loadCommands ( context ) ;
55+ // Add delete button handler
56+ context . commands . buttons . set ( "deletebtn" , { custom_id : "deletebtn" , run : deleteButtonHandler } ) ;
5757
58- docsBot . on ( "error" , console . error ) ;
59- docsBot . on ( "warn" , console . warn ) ;
58+ docsBot . on ( "error" , console . error ) ;
59+ docsBot . on ( "warn" , console . warn ) ;
6060
61- docsBot . once ( "ready" , ( client ) => {
62- console . info ( `Logged in as ${ client . user . tag } (${ client . user . id } )` ) ;
63- } ) ;
61+ docsBot . once ( "ready" , ( client ) => {
62+ console . info ( `Logged in as ${ client . user . tag } (${ client . user . id } )` ) ;
63+ } ) ;
6464
65- docsBot . on ( "messageCreate" , messageHandler ) ;
66- docsBot . on ( "interactionCreate" , ( interaction : Interaction < "cached" > ) => {
67- interactionCreateHandler ( context , interaction ) ;
68- } ) ;
65+ docsBot . on ( "messageCreate" , messageHandler ) ;
66+ docsBot . on ( "interactionCreate" , ( interaction : Interaction < "cached" > ) => {
67+ interactionCreateHandler ( context , interaction ) ;
68+ } ) ;
6969
70- docsBot . login ( process . env . TOKEN ) ;
70+ docsBot . login ( process . env . TOKEN ) ;
7171} ) ( ) ;
7272
7373process . on ( "unhandledRejection" , async ( err ) => {
74- console . error ( "Top Level Unhandled Promise Rejection:\n" , err ) ;
74+ console . error ( "Top Level Unhandled Promise Rejection:\n" , err ) ;
7575} ) ;
7676
7777process . on ( "uncaughtException" , async ( err ) => {
78- console . error ( "Top Level Uncaught Promise Exception:\n" , err ) ;
78+ console . error ( "Top Level Uncaught Promise Exception:\n" , err ) ;
7979} ) ;
8080
8181process . on ( "uncaughtExceptionMonitor" , async ( err ) => {
82- console . error ( "Top Level Uncaught Promise Exception (Monitor):\n" , err ) ;
82+ console . error ( "Top Level Uncaught Promise Exception (Monitor):\n" , err ) ;
8383} ) ;
0 commit comments