Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit b4f1ff6

Browse files
committed
chore: Finish adding sentry and allat, time to do actual work.
1 parent 8c4afe1 commit b4f1ff6

File tree

4 files changed

+81
-3
lines changed

4 files changed

+81
-3
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
},
1919
"devDependencies": {
2020
"@sentry/node": "^9.4.0",
21+
"@sentry/profiling-node": "^9.4.0",
2122
"mysql2": "^3.12.0",
2223
"nodemon": "^3.1.9",
2324
"toml": "^3.0.0"

pnpm-lock.yaml

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { Client, IntentsBitField, Message, REST } from "discord.js";
22
import fs from 'fs';
3+
import knex, { Knex } from "knex";
34
import toml from 'toml';
5+
import * as Sentry from '@sentry/node';
6+
import { nodeProfilingIntegration } from "@sentry/profiling-node";
47

58
class 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 {
3740
class 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

Comments
 (0)