Skip to content

Commit 8891b2a

Browse files
authored
Don't update public sheet with pilot if checkout failed (#114)
* Don't update public sheet with pilot if checkout failed * Ensure failures are logged in request log
1 parent 601363c commit 8891b2a

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

src/.DS_Store

6 KB
Binary file not shown.

src/features/raid-bots/request-subcommand.ts

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -50,38 +50,40 @@ Password: ${spoiler(details.password)}
5050
response += `** Please note that ${currentPilot} is marked as the pilot of ${name} and you may not be able to log in. Your name will not be added as the botpilot in the public bot sheet! **\n\n`;
5151
}
5252
response += `The credentials for ${name} have been DM'd to you. Please remember to use \`/bot park\` when you are done!`;
53+
54+
const logMsg = await thread.send("OK");
55+
logMsg.edit(`${status} ${interaction.user} access to ${name}.`);
56+
57+
if (await publicAccounts.isBotPublic(name)) {
58+
try {
59+
const guildUser = await interaction.guild?.members.fetch(
60+
interaction.user.id
61+
);
62+
63+
if (!currentPilot) {
64+
await publicAccounts.updateBotRowDetails(name, {
65+
[BOT_SPREADSHEET_COLUMNS.CurrentPilot]:
66+
guildUser?.user.username || "UNKNOWN USER",
67+
[BOT_SPREADSHEET_COLUMNS.CheckoutTime]: moment().toString(),
68+
});
69+
}
70+
} catch (err) {
71+
throw new Error(
72+
"Failed to update public record, check the configuration"
73+
);
74+
}
75+
}
76+
5377
await interaction.editReply(response);
5478
} catch (err) {
5579
status = "❌ Denied";
80+
const logMsg = await thread.send("OK");
81+
logMsg.edit(`${status} ${interaction.user} access to ${name}.`);
5682

5783
await interaction.editReply(
5884
`You do not have the correct permissions to access ${name}.`
5985
);
6086
}
61-
62-
const logMsg = await thread.send("OK");
63-
logMsg.edit(`${status} ${interaction.user} access to ${name}.`);
64-
65-
// Update public record
66-
if (await publicAccounts.isBotPublic(name)) {
67-
try {
68-
const guildUser = await interaction.guild?.members.fetch(
69-
interaction.user.id
70-
);
71-
72-
if (!currentPilot) {
73-
await publicAccounts.updateBotRowDetails(name, {
74-
[BOT_SPREADSHEET_COLUMNS.CurrentPilot]:
75-
guildUser?.user.username || "UNKNOWN USER",
76-
[BOT_SPREADSHEET_COLUMNS.CheckoutTime]: moment().toString(),
77-
});
78-
}
79-
} catch (err) {
80-
throw new Error(
81-
"Failed to update public record, check the configuration"
82-
);
83-
}
84-
}
8587
}
8688

8789
public get command() {

0 commit comments

Comments
 (0)