Skip to content

Commit

Permalink
shows errors for generating delivery invite, only allows delivering 1…
Browse files Browse the repository at this point in the history
… order at a time
  • Loading branch information
mrhappyma committed Dec 29, 2024
1 parent aac1d44 commit c33f3b4
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/orders/updateStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ const updateOrderStatus = async (
//TODO: more packing logic could be moved here
break;
case orderStatus.DELIVERING:
if (active.length > 0)
throw new Error(
`You are already ${verb}ing order #**${active[0].id}**! One at a time please, go finish that one first!`
);
if (order.status == orderStatus.DELIVERING)
throw new Error(
"Too slow- somebody's already started delivering this order"
Expand Down Expand Up @@ -176,13 +180,17 @@ const updateOrderStatus = async (
try {
var guild = await bot.client.guilds.fetch(order.guildId);
} catch (e) {
throw new Error(
`Failed to fetch guild! This usually means the bot was kicked, and if so just reject the order. Here's the error:\n\`\`\`${e}\`\`\``
);
return {
success: false,
message: `Failed to fetch guild! This usually means the bot was kicked, and if so just reject the order. Here's the error:\n\`\`\`${e}\`\`\``,
};
}
const targetChannel = guild.channels.cache.get(order.channelId);
if (!targetChannel?.isTextBased() || targetChannel.isThread())
throw new Error("Failed to fetch order channel");
return {
success: false,
message: "Failed to fetch order channel",
};
try {
var invite = await targetChannel.createInvite({
maxAge: 3600,
Expand All @@ -191,9 +199,10 @@ const updateOrderStatus = async (
reason: `Order #${id} delivery invite`,
});
} catch (e) {
throw new Error(
`Failed to create the invite! Here's the error:\n\`\`\`${e}\`\`\``
);
return {
success: false,
message: `Failed to create the invite! Here's the error:\n\`\`\`${e}\`\`\``,
};
}
const deliveringActionRow =
new ActionRowBuilder<ButtonBuilder>().addComponents([
Expand Down

0 comments on commit c33f3b4

Please sign in to comment.