1- import {
2- ActivityType ,
3- Client ,
4- GatewayIntentBits ,
5- Options ,
6- } from "discord.js" ;
1+ import { ActivityType , Client , GatewayIntentBits , Options } from "discord.js" ;
72import prisma from "../../prisma.config" ;
83import { promises as fs } from "node:fs" ;
94import path from "node:path" ;
@@ -12,108 +7,107 @@ import i18nbackend from "i18next-fs-backend";
127import { readdirSync } from "node:fs" ;
138
149export class SoulKitten extends Client {
10+ public owner : string [ ] ;
11+ public db : typeof prisma ;
1512
16- public owner : string [ ] ;
17- public db : typeof prisma ;
13+ constructor ( ) {
14+ super ( {
15+ makeCache : Options . cacheWithLimits ( {
16+ ApplicationCommandManager : 0 ,
17+ BaseGuildEmojiManager : 0 ,
18+ GuildMemberManager : Number . POSITIVE_INFINITY ,
19+ GuildStickerManager : 0 ,
20+ GuildScheduledEventManager : 0 ,
21+ MessageManager : Number . POSITIVE_INFINITY ,
22+ StageInstanceManager : 0 ,
23+ ThreadManager : 0 ,
24+ ThreadMemberManager : 0 ,
25+ UserManager : 0 ,
26+ } ) ,
27+ intents : [
28+ GatewayIntentBits . Guilds ,
29+ GatewayIntentBits . GuildMessages ,
30+ GatewayIntentBits . MessageContent ,
31+ GatewayIntentBits . GuildMembers ,
32+ GatewayIntentBits . DirectMessages ,
33+ GatewayIntentBits . GuildVoiceStates ,
34+ ] ,
35+ presence : {
36+ status : "idle" ,
37+ activities : [
38+ {
39+ name : "SoulKitten" ,
40+ type : ActivityType . Listening ,
41+ } ,
42+ ] ,
43+ } ,
44+ allowedMentions : {
45+ parse : [ "users" ] ,
46+ repliedUser : false ,
47+ } ,
48+ } ) ;
49+ this . db = prisma ;
50+ this . owner = [ "932678185970192404" ] ;
51+ }
1852
19- constructor ( ) {
20- super ( {
21- makeCache : Options . cacheWithLimits ( {
22- ApplicationCommandManager : 0 ,
23- BaseGuildEmojiManager : 0 ,
24- GuildMemberManager : Number . POSITIVE_INFINITY ,
25- GuildStickerManager : 0 ,
26- GuildScheduledEventManager : 0 ,
27- MessageManager : Number . POSITIVE_INFINITY ,
28- StageInstanceManager : 0 ,
29- ThreadManager : 0 ,
30- ThreadMemberManager : 0 ,
31- UserManager : 0 ,
32- } ) ,
33- intents : [
34- GatewayIntentBits . Guilds ,
35- GatewayIntentBits . GuildMessages ,
36- GatewayIntentBits . MessageContent ,
37- GatewayIntentBits . GuildMembers ,
38- GatewayIntentBits . DirectMessages ,
39- GatewayIntentBits . GuildVoiceStates ,
40- ] ,
41- presence : {
42- status : "idle" ,
43- activities : [
44- {
45- name : "SoulKitten" ,
46- type : ActivityType . Listening ,
47- } ,
48- ] ,
49- } ,
50- allowedMentions : {
51- parse : [ "users" ] ,
52- repliedUser : false ,
53- } ,
54- } ) ;
55- this . db = prisma ;
56- this . owner = [ "932678185970192404" ] ;
57- }
58-
59- async init ( ) {
60- this . register ( ) ;
61- await this . login ( process . env . DISCORD_TOKEN ) ;
62- }
53+ async init ( ) {
54+ this . register ( ) ;
55+ await this . login ( process . env . DISCORD_TOKEN ) ;
56+ }
6357
64- async register ( ) {
65- this . loadLanguage ( ) ;
66- this . loadEvents ( ) ;
67- }
58+ async register ( ) {
59+ this . loadLanguage ( ) ;
60+ this . loadEvents ( ) ;
61+ }
6862
69- async loadEvents ( ) {
70- const readDirRecursively = async ( dir ) => {
71- const files = await fs . readdir ( dir , { withFileTypes : true } ) ;
72- let eventFiles = [ ] ;
63+ async loadEvents ( ) {
64+ const readDirRecursively = async ( dir ) => {
65+ const files = await fs . readdir ( dir , { withFileTypes : true } ) ;
66+ let eventFiles = [ ] ;
7367
74- for ( const file of files ) {
75- const fullPath = path . join ( dir , file . name ) ;
76- if ( file . isDirectory ( ) ) {
77- const subFiles = await readDirRecursively ( fullPath ) ;
78- eventFiles = [ ...eventFiles , ...subFiles ] ;
79- } else if ( file . name . endsWith ( ".ts" ) || file . name . endsWith ( ".js" ) ) {
80- eventFiles . push ( fullPath ) ;
81- }
82- }
83- return eventFiles ;
84- } ;
68+ for ( const file of files ) {
69+ const fullPath = path . join ( dir , file . name ) ;
70+ if ( file . isDirectory ( ) ) {
71+ const subFiles = await readDirRecursively ( fullPath ) ;
72+ eventFiles = [ ...eventFiles , ...subFiles ] ;
73+ } else if ( file . name . endsWith ( ".ts" ) || file . name . endsWith ( ".js" ) ) {
74+ eventFiles . push ( fullPath ) ;
75+ }
76+ }
77+ return eventFiles ;
78+ } ;
8579
86- const eventFiles = await readDirRecursively (
87- path . join ( __dirname , "../events" ) ,
88- ) ;
80+ const eventFiles = await readDirRecursively (
81+ path . join ( __dirname , "../events" ) ,
82+ ) ;
8983
90- for ( const file of eventFiles ) {
91- const event = await this . importFile ( file ) ;
92- this . on ( event . name , event . exec ) ;
93- }
84+ for ( const file of eventFiles ) {
85+ const event = await this . importFile ( file ) ;
86+ this . on ( event . name , event . exec ) ;
9487 }
88+ }
9589
96- async loadLanguage ( ) {
97- await i18next . use ( i18nbackend ) . init ( {
98- backend : {
99- loadPath : "src/locales/{{lng}}/{{ns}}.json" ,
100- } ,
101- defaultNS : "language" ,
102- fallbackLng : "en-US" ,
103- interpolation : {
104- escapeValue : false ,
105- useRawValueToEscape : true ,
106- } ,
107- load : "all" ,
108- ns : [ "language" ] ,
109- preload : readdirSync ( "src/locales" ) ,
110- // debug: true,
111- returnEmptyString : false ,
112- returnObjects : true ,
113- } ) ;
114- }
90+ async loadLanguage ( ) {
91+ await i18next . use ( i18nbackend ) . init ( {
92+ backend : {
93+ loadPath : "src/locales/{{lng}}/{{ns}}.json" ,
94+ } ,
95+ defaultNS : "language" ,
96+ fallbackLng : "en-US" ,
97+ interpolation : {
98+ escapeValue : false ,
99+ useRawValueToEscape : true ,
100+ } ,
101+ load : "all" ,
102+ ns : [ "language" ] ,
103+ preload : readdirSync ( "src/locales" ) ,
104+ // debug: true,
105+ returnEmptyString : false ,
106+ returnObjects : true ,
107+ } ) ;
108+ }
115109
116- async importFile ( file : string ) {
117- return ( await import ( file ) ) ?. default ;
118- }
110+ async importFile ( file : string ) {
111+ return ( await import ( file ) ) ?. default ;
112+ }
119113}
0 commit comments