Skip to content

Commit 2cce5e7

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 f4d6074 commit 2cce5e7

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const client = new Discord.Client({
3131
partials: [Partials.Message, Partials.Channel, Partials.Reaction],
3232
});
3333

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

3636
client.once(Events.ClientReady, () => {
3737
if (client.user != null) {

0 commit comments

Comments
 (0)