/[sudobot]/trunk/src/client/Client.ts
ViewVC logotype

Diff of /trunk/src/client/Client.ts

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 199 by rakin, Mon Jul 29 17:28:59 2024 UTC revision 241 by rakin, Mon Jul 29 17:29:10 2024 UTC
# Line 22  import discordModals from 'discord-modal Line 22  import discordModals from 'discord-modal
22  import SpamFilter from '../automod/SpamFilter';  import SpamFilter from '../automod/SpamFilter';
23  import Verification from '../services/Verification';  import Verification from '../services/Verification';
24  import Welcomer from '../services/Welcomer';  import Welcomer from '../services/Welcomer';
25    import Antijoin from '../automod/Antijoin';
26    import Automute from '../automod/Automute';
27    import ServiceManager from './ServiceManager';
28    import ChannelLockManager from '../services/ChannelLockManager';
29    
30  export default class DiscordClient extends Client {  export default class DiscordClient extends Client {
31      private _commands = new Collection<string, BaseCommand>();      private _commands = new Collection<string, BaseCommand>();
# Line 33  export default class DiscordClient exten Line 37  export default class DiscordClient exten
37    
38      config: Config;      config: Config;
39      db: Database;      db: Database;
     logger: Logger;  
     snippetManager: SnippetManager;  
     afkEngine: AFKEngine;  
     auth: Auth;  
     spamFilter: SpamFilter;  
     messageFilter: MessageFilter;  
     antiraid: AntiRaid;  
     starboard: Starboard;  
40      server: Server;      server: Server;
41      cooldown: Cooldown;      serviceManager: ServiceManager;
42      startupManager: StartupManager;  
43      autoClear: AutoClear;      logger: Logger = {} as Logger;
44      randomStatus: RandomStatus;      snippetManager: SnippetManager = {} as SnippetManager;
45      debugLogger: DebugLogger;      afkEngine: AFKEngine = {} as AFKEngine;
46      verification: Verification;      auth: Auth = {} as Auth;
47      welcomer: Welcomer;      spamFilter: SpamFilter = {} as SpamFilter;
48        messageFilter: MessageFilter = {} as MessageFilter;
49        antiraid: AntiRaid = {} as AntiRaid;
50        starboard: Starboard = {} as Starboard;
51        cooldown: Cooldown = {} as Cooldown;
52        startupManager: StartupManager = {} as StartupManager;
53        autoClear: AutoClear = {} as AutoClear;
54        randomStatus: RandomStatus = {} as RandomStatus;
55        debugLogger: DebugLogger = {} as DebugLogger;
56        verification: Verification = {} as Verification;
57        welcomer: Welcomer = {} as Welcomer;
58        antijoin: Antijoin = {} as Antijoin;
59        automute: Automute = {} as Automute;
60        channelLock: ChannelLockManager = {} as ChannelLockManager;
61    
62        aliases = {
63            automod: path.resolve(__dirname, '..', 'automod'),
64            services: path.resolve(__dirname, '..', 'services'),
65        };
66    
67        services = {
68            "@services/DebugLogger": "debugLogger",
69            "@automod/Logger": "logger",
70            "@services/SnippetManager": "snippetManager",
71            "@services/AFKEngine": "afkEngine",
72            "@services/Auth": "auth",
73            "@automod/SpamFilter": "spamFilter",
74            "@automod/MessageFilter": "messageFilter",
75            "@automod/AntiRaid": "antiraid",
76            "@services/Starboard": "starboard",
77            "@automod/Cooldown": "cooldown",
78            "@services/StartupManager": "startupManager",
79            "@automod/AutoClear": "autoClear",
80            "@services/RandomStatus": "randomStatus",
81            "@services/Verification": "verification",
82            "@services/Welcomer": "welcomer",
83            "@services/ChannelLockManager": "channelLock",
84            "@automod/Antijoin": "antijoin",
85            "@automod/Automute": "automute",
86        };
87    
88      static client: DiscordClient;      static client: DiscordClient;
89    
# Line 56  export default class DiscordClient exten Line 91  export default class DiscordClient exten
91          super({          super({
92              ws: {              ws: {
93                  properties: {                  properties: {
94                      $browser: "Discord iOS"                      browser: "Discord iOS"
95                  }                  }
96              },              },
97              ...options              ...options
98          });          });
99    
100            process.on('uncaughtException', (error, origin) => {
101                console.log('Uncaught', error);
102                this.handleCrash(error, origin).then(() => process.exit(-1)).catch(err => {
103                    console.log(err);
104                    process.exit(-1);
105                });
106            });
107                    
108          console.log('init');                  console.log('init');        
109    
# Line 70  export default class DiscordClient exten Line 113  export default class DiscordClient exten
113    
114          this.config = new Config(this);          this.config = new Config(this);
115          this.db = new Database(path.resolve(rootdir, 'database.db'), this);          this.db = new Database(path.resolve(rootdir, 'database.db'), this);
116          this.logger = new Logger(this);          this.serviceManager = new ServiceManager(this, this.aliases);
117          this.snippetManager = new SnippetManager(this);          this.serviceManager.load(this.services);
118          this.afkEngine = new AFKEngine(this);  
119          this.auth = new Auth(this);          // this.logger = new Logger(this);
120          this.spamFilter = new SpamFilter(this);          // this.snippetManager = new SnippetManager(this);
121          this.messageFilter = new MessageFilter(this);          // this.afkEngine = new AFKEngine(this);
122          this.antiraid = new AntiRaid(this);          // this.auth = new Auth(this);
123          this.starboard = new Starboard(this);          // this.spamFilter = new SpamFilter(this);
124            // this.messageFilter = new MessageFilter(this);
125            // this.antiraid = new AntiRaid(this);
126            // this.starboard = new Starboard(this);
127            // this.cooldown = new Cooldown(this);
128            // this.startupManager = new StartupManager(this);
129            // this.autoClear = new AutoClear(this);
130            // this.randomStatus = new RandomStatus(this);
131            // this.debugLogger = new DebugLogger(this);
132            // this.verification = new Verification(this);
133            // this.welcomer = new Welcomer(this);
134            // this.antijoin = new Antijoin(this);
135            // this.automute = new Automute(this);
136    
137          this.server = new Server(this);          this.server = new Server(this);
         this.cooldown = new Cooldown(this);  
         this.startupManager = new StartupManager(this);  
         this.autoClear = new AutoClear(this);  
         this.randomStatus = new RandomStatus(this);  
         this.debugLogger = new DebugLogger(this);  
         this.verification = new Verification(this);  
         this.welcomer = new Welcomer(this);  
138                    
139          discordModals(this);                  discordModals(this);        
140      }      }
# Line 105  export default class DiscordClient exten Line 154  export default class DiscordClient exten
154      setMessage(msg: Message | Interaction) {      setMessage(msg: Message | Interaction) {
155          this.msg = msg;          this.msg = msg;
156      }      }
157    
158        async handleCrash(error: Error, origin: NodeJS.UncaughtExceptionOrigin) {
159            console.log('here');
160            await this.debugLogger.logToHomeServer(`Uncaught ${error.name}: ${error.message}\n${error.stack}`);
161        }
162  }  }

Legend:
Removed from v.199  
changed lines
  Added in v.241

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26