🚸 better throw new Error handling

This commit is contained in:
Axel Olausson Holtenäs 2022-05-28 13:02:35 +02:00
parent 518ec431d8
commit ddc43cf509
No known key found for this signature in database
GPG key ID: 7BF6826B76382CBA
2 changed files with 9 additions and 3 deletions

View file

@ -6,6 +6,7 @@ import logger from "@logger";
import deferReply from "@root/helpers/deferReply"; import deferReply from "@root/helpers/deferReply";
import getEmbedConfig from "@helpers/getEmbedConfig"; import getEmbedConfig from "@helpers/getEmbedConfig";
import getCommandMetadata from "@helpers/getCommandMetadata"; import getCommandMetadata from "@helpers/getCommandMetadata";
import capitalizeFirstLetter from "@helpers/capitalizeFirstLetter";
export default async (interaction: CommandInteraction) => { export default async (interaction: CommandInteraction) => {
if (!interaction.isCommand()) return; if (!interaction.isCommand()) return;
@ -89,10 +90,12 @@ export default async (interaction: CommandInteraction) => {
return interaction.editReply({ return interaction.editReply({
embeds: [ embeds: [
new MessageEmbed() new MessageEmbed()
.setTitle("Error") .setTitle(
.setDescription( `[:x:] ${capitalizeFirstLetter(
`There was an error executing the command: **${currentCommand?.data?.name}**.` interaction.options.getSubcommand()
)}`
) )
.setDescription(`${"``"}${error}${"``"}`)
.setColor(errorColor) .setColor(errorColor)
.setTimestamp(new Date()) .setTimestamp(new Date())
.setFooter({ text: footerText, iconURL: footerIcon }), .setFooter({ text: footerText, iconURL: footerIcon }),

View file

@ -0,0 +1,3 @@
export default (text: string): string => {
return text.charAt(0).toUpperCase() + text.slice(1);
};