feat(commands): improve error feedback for use command
This commit is contained in:
@@ -7,6 +7,7 @@ import { inventory, items } from "@/db/schema";
|
|||||||
import { eq, and, like } from "drizzle-orm";
|
import { eq, and, like } from "drizzle-orm";
|
||||||
import { DrizzleClient } from "@/lib/DrizzleClient";
|
import { DrizzleClient } from "@/lib/DrizzleClient";
|
||||||
import type { ItemUsageData } from "@/lib/types";
|
import type { ItemUsageData } from "@/lib/types";
|
||||||
|
import { UserError } from "@/lib/errors";
|
||||||
|
|
||||||
export const use = createCommand({
|
export const use = createCommand({
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
@@ -53,7 +54,12 @@ export const use = createCommand({
|
|||||||
await interaction.editReply({ embeds: [embed] });
|
await interaction.editReply({ embeds: [embed] });
|
||||||
|
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
await interaction.editReply({ embeds: [createErrorEmbed(error.message)] });
|
if (error instanceof UserError) {
|
||||||
|
await interaction.editReply({ embeds: [createErrorEmbed(error.message)] });
|
||||||
|
} else {
|
||||||
|
console.error("Error using item:", error);
|
||||||
|
await interaction.editReply({ embeds: [createErrorEmbed("An unexpected error occurred while using the item.")] });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
autocomplete: async (interaction) => {
|
autocomplete: async (interaction) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user