Skip to content

Commit 57e27aa

Browse files
committed
CommandHandler: Always log the interaction
When issues arise in production, we now might have an idea of what caused it. Also remove the production bool from CommandHandler; it can just retrieve that from `config`.
1 parent b1fc810 commit 57e27aa

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

src/commandHandler.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default class CommandHandler {
2525
private readonly commands: Map<string[], Command>;
2626
private readonly help: string;
2727

28-
constructor(private readonly production: boolean) {
28+
constructor() {
2929
const availableCommands = new Array<string>();
3030

3131
this.commands = new Map(
@@ -70,15 +70,12 @@ export default class CommandHandler {
7070

7171
/** Executes user commands contained in a message if appropriate. */
7272
async handleCommandInteraction(interaction: Interaction): Promise<void> {
73-
if (!this.production) {
74-
const msg = `Buggie bot received ${JSON.stringify(
75-
interaction,
76-
(_, v) => (typeof v === "bigint" ? `${v.toString()}n` : v),
77-
4
78-
)} from '${interaction.user.tag}`;
79-
// await interaction.channel?.send(msg);
80-
console.log(msg);
81-
}
73+
const msg = `Buggie bot received ${JSON.stringify(
74+
interaction,
75+
(_, v) => (typeof v === "bigint" ? `${v.toString()}n` : v),
76+
4
77+
)} from '${interaction.user.tag}`;
78+
console.log(msg);
8279

8380
if (!interaction.isCommand()) throw new Error("Invalid command interaction");
8481

src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import Discord, {
1515
Partials,
1616
} from "discord.js";
1717
import CommandHandler from "@/commandHandler";
18-
import config from "@/config/botConfig";
1918
import { env } from "@/config/env";
2019

2120
process.on("unhandledRejection", reason => {
@@ -31,7 +30,7 @@ const client = new Discord.Client({
3130
partials: [Partials.Message, Partials.Channel, Partials.Reaction],
3231
});
3332

34-
const commandHandler = new CommandHandler(config.production);
33+
const commandHandler = new CommandHandler();
3534

3635
client.once(Events.ClientReady, () => {
3736
if (client.user != null) {

0 commit comments

Comments
 (0)