11import { Client , IntentsBitField , Message , REST } from "discord.js" ;
22import fs from 'fs' ;
3+ import knex , { Knex } from "knex" ;
34import toml from 'toml' ;
5+ import * as Sentry from '@sentry/node' ;
6+ import { nodeProfilingIntegration } from "@sentry/profiling-node" ;
47
58class DBot extends Client {
69 kogBot : KOGBot ;
@@ -26,8 +29,8 @@ class DBot extends Client {
2629 } ) ;
2730
2831 this . on ( 'messageCreate' , ( message : Message ) => {
29- if ( message . content === 'ping ' ) {
30- message . reply ( 'pong \:D ' ) ;
32+ if ( message . content === 'hi ' ) {
33+ message . reply ( 'hi ' ) ;
3134 }
3235 } ) ;
3336 }
@@ -37,14 +40,49 @@ class DBot extends Client {
3740class KOGBot_Client {
3841 environment ;
3942 ci_workflow : boolean = false ;
43+ debug : boolean = false ;
4044 discord_client : DBot ;
45+ database : Knex ;
46+ sentry = Sentry ;
47+ sentry_environment : string = "production"
4148
4249 constructor ( ) {
50+ if ( process . argv . includes ( '--ci' ) ) {
51+ console . warn ( "Running KOG Bot in CI environment. Production features will not be initialized." ) ;
52+ this . ci_workflow = true ;
53+ }
54+ if ( process . argv . includes ( '--debug' ) ) {
55+ console . warn ( "Running KOG Bot in Debug mode." ) ;
56+ this . sentry_environment = "development" ;
57+ this . debug = true ;
58+ }
59+ // Parse Configuration //
4360 const toml_file = fs . readFileSync ( 'config.toml' , 'utf8' ) . toString ( ) ;
4461 this . environment = toml . parse ( toml_file ) ;
4562
46- this . discord_client = new DBot ( this ) ;
63+ // Hook into the Database //
64+ this . database = knex ( {
65+ client : this . environment . database . client ,
66+ connection : {
67+ host : this . environment . database . host ,
68+ port : this . environment . database . port ,
69+ user : this . environment . database . user ,
70+ password : this . environment . database . password ,
71+ database : this . environment . database . schema
72+ }
73+ } ) ;
4774
75+ // Initialize Sentry //
76+ this . sentry . init ( {
77+ dsn : this . environment . sentry . dsn ,
78+ tracesSampleRate : 1.0 ,
79+ integrations : [
80+ nodeProfilingIntegration ( )
81+ ]
82+ } ) ;
83+ this . sentry . profiler . startProfiler ( ) ;
84+
85+ this . discord_client = new DBot ( this ) ;
4886 }
4987}
5088
0 commit comments