Skip to content

Commit

Permalink
Don't update public sheet with pilot if checkout failed
Browse files Browse the repository at this point in the history
  • Loading branch information
ebm5025 committed Jun 17, 2024
1 parent 601363c commit 900a90f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
Binary file added src/.DS_Store
Binary file not shown.
48 changes: 24 additions & 24 deletions src/features/raid-bots/request-subcommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,30 @@ Password: ${spoiler(details.password)}
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`;
}
response += `The credentials for ${name} have been DM'd to you. Please remember to use \`/bot park\` when you are done!`;

const logMsg = await thread.send("OK");
logMsg.edit(`${status} ${interaction.user} access to ${name}.`);

if (await publicAccounts.isBotPublic(name)) {
try {
const guildUser = await interaction.guild?.members.fetch(
interaction.user.id
);

if (!currentPilot) {
await publicAccounts.updateBotRowDetails(name, {
[BOT_SPREADSHEET_COLUMNS.CurrentPilot]:
guildUser?.user.username || "UNKNOWN USER",
[BOT_SPREADSHEET_COLUMNS.CheckoutTime]: moment().toString(),
});
}
} catch (err) {
throw new Error(
"Failed to update public record, check the configuration"
);
}
}

await interaction.editReply(response);
} catch (err) {
status = "❌ Denied";
Expand All @@ -58,30 +82,6 @@ Password: ${spoiler(details.password)}
`You do not have the correct permissions to access ${name}.`
);
}

const logMsg = await thread.send("OK");
logMsg.edit(`${status} ${interaction.user} access to ${name}.`);

// Update public record
if (await publicAccounts.isBotPublic(name)) {
try {
const guildUser = await interaction.guild?.members.fetch(
interaction.user.id
);

if (!currentPilot) {
await publicAccounts.updateBotRowDetails(name, {
[BOT_SPREADSHEET_COLUMNS.CurrentPilot]:
guildUser?.user.username || "UNKNOWN USER",
[BOT_SPREADSHEET_COLUMNS.CheckoutTime]: moment().toString(),
});
}
} catch (err) {
throw new Error(
"Failed to update public record, check the configuration"
);
}
}
}

public get command() {
Expand Down

0 comments on commit 900a90f

Please sign in to comment.