Skip to content

Commit e7b866e

Browse files
committed
error handling
1 parent feead9e commit e7b866e

File tree

3 files changed

+11
-20
lines changed

3 files changed

+11
-20
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ async function execute(
4141
interaction: ChatInputCommandInteraction
4242
): Promise<string | undefined> {
4343
try {
44+
await interaction.deferReply({ flags: MessageFlags.Ephemeral });
45+
4446
const subcommand = interaction.options.getSubcommand();
4547

4648
switch (subcommand) {
@@ -63,9 +65,8 @@ async function execute(
6365
logger.error(error, "Error executing human passport command");
6466

6567
if (!interaction.replied && !interaction.deferred) {
66-
await interaction.reply({
68+
await interaction.editReply({
6769
content: "An error occurred while processing your command.",
68-
flags: MessageFlags.Ephemeral,
6970
});
7071
}
7172

tooling/sparta/packages/discord/src/slashCommands/humans/status.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,9 @@ export async function handleStatusCommand(
4747
const user = userResponse.data.user;
4848

4949
if (!user) {
50-
await interaction.reply({
50+
await interaction.editReply({
5151
content:
5252
"You haven't initiated verification yet. Use `/human verify` to get started.",
53-
flags: MessageFlags.Ephemeral,
5453
});
5554
return;
5655
}
@@ -116,25 +115,22 @@ export async function handleStatusCommand(
116115
verifyButton
117116
);
118117

119-
await interaction.reply({
118+
await interaction.editReply({
120119
embeds: [embed],
121120
components: [row],
122-
flags: MessageFlags.Ephemeral,
123121
});
124122
return;
125123
}
126124

127-
await interaction.reply({
125+
await interaction.editReply({
128126
embeds: [embed],
129-
flags: MessageFlags.Ephemeral,
130127
});
131128
} catch (error: any) {
132129
logger.error(error, "Error handling passport status command");
133130

134-
await interaction.reply({
131+
await interaction.editReply({
135132
content:
136133
"An error occurred while checking your verification status.",
137-
flags: MessageFlags.Ephemeral,
138134
});
139135
}
140136
}

tooling/sparta/packages/discord/src/slashCommands/humans/verify.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ export async function handleVerifyCommand(
3434
interaction: ChatInputCommandInteraction
3535
): Promise<void> {
3636
try {
37-
await interaction.deferReply({ flags: MessageFlags.Ephemeral });
38-
3937
const userId = interaction.user.id;
4038
const interactionToken = interaction.token;
4139
const verificationId = randomUUID();
@@ -145,10 +143,9 @@ export async function handleVerifyCommand(
145143
logger.error(
146144
"VITE_APP_API_URL environment variable is not set!"
147145
);
148-
await interaction.reply({
146+
await interaction.editReply({
149147
content:
150148
"Configuration error. Please contact an administrator.",
151-
flags: MessageFlags.Ephemeral,
152149
});
153150
return;
154151
}
@@ -166,10 +163,9 @@ export async function handleVerifyCommand(
166163
);
167164

168165
// Send the embed and button to the user
169-
await interaction.reply({
166+
await interaction.editReply({
170167
embeds: [embed],
171168
components: [row],
172-
flags: MessageFlags.Ephemeral,
173169
});
174170

175171
logger.info(
@@ -179,19 +175,17 @@ export async function handleVerifyCommand(
179175
} catch (error: any) {
180176
logger.error(error, "Error handling passport verify command");
181177

182-
await interaction.reply({
178+
await interaction.editReply({
183179
content:
184180
"An error occurred while creating your verification session. Please try again later.",
185-
flags: MessageFlags.Ephemeral,
186181
});
187182
}
188183
} catch (error: any) {
189184
logger.error(error, "Error handling passport verify command");
190185

191-
await interaction.reply({
186+
await interaction.editReply({
192187
content:
193188
"An error occurred while creating your verification session. Please try again later.",
194-
flags: MessageFlags.Ephemeral,
195189
});
196190
}
197191
}

0 commit comments

Comments
 (0)