Skip to content

Commit b3a4184

Browse files
committed
error handling
1 parent e7b866e commit b3a4184

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { logger } from "@sparta/utils/logger";
2+
import { NodeOperatorSubcommands } from "./types";
3+
4+
const commandsCount = {
5+
[NodeOperatorSubcommands.MyStats]: 0,
6+
[NodeOperatorSubcommands.ChainInfo]: 0,
7+
[NodeOperatorSubcommands.Start]: 0,
8+
[NodeOperatorSubcommands.Help]: 0,
9+
};
10+
11+
export function incrementCommandsCount(command: NodeOperatorSubcommands) {
12+
commandsCount[command]++;
13+
logger.debug({ command, count: commandsCount[command] }, "Commands count");
14+
}

tooling/sparta/packages/discord/src/slashCommands/operators/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
import { getValidatorStats } from "./my-info.js";
99
import { registerValidator } from "./register.js";
1010
import { showRegistrationHelp } from "./help.js";
11+
import { incrementCommandsCount } from "../../debug.js";
1112

1213
export default {
1314
data: new SlashCommandBuilder()
@@ -63,15 +64,19 @@ export default {
6364
switch (subcommand) {
6465
case NodeOperatorSubcommands.MyStats:
6566
await getValidatorStats(interaction);
67+
incrementCommandsCount(NodeOperatorSubcommands.MyStats);
6668
break;
6769
case NodeOperatorSubcommands.ChainInfo:
6870
await getChainInfo(interaction);
71+
incrementCommandsCount(NodeOperatorSubcommands.ChainInfo);
6972
break;
7073
case NodeOperatorSubcommands.Start:
7174
await registerValidator(interaction);
75+
incrementCommandsCount(NodeOperatorSubcommands.Start);
7276
break;
7377
case NodeOperatorSubcommands.Help:
7478
await showRegistrationHelp(interaction);
79+
incrementCommandsCount(NodeOperatorSubcommands.Help);
7580
break;
7681
default:
7782
await interaction.editReply({

0 commit comments

Comments
 (0)