diff --git a/src/commands/administration/deleteCategories.ts b/src/commands/administration/deleteCategories.ts index 3f76b01..253759c 100644 --- a/src/commands/administration/deleteCategories.ts +++ b/src/commands/administration/deleteCategories.ts @@ -8,6 +8,7 @@ import { } from 'discord.js'; import emoji from '../../../assets/emoji.json' assert { type: 'json' }; import { prisma } from '@lib/prisma'; +import { log } from '@lib/log'; import { User as UserPrisma } from '@prisma/client'; export default { @@ -30,13 +31,7 @@ export default { }); } catch (err: unknown) { - if (err instanceof Error) { - console.error(`❌ ${err.name}: ${err.message}`); - console.error(err.stack); - } - else { - console.error('❌ Unknown error:', err); - } + log.error(err, 'Cannot get user data'); await interaction.reply({ content: `${emoji.answer.error} | Cannot connect to the database`, flags: MessageFlags.Ephemeral, @@ -81,10 +76,7 @@ export default { }); } catch (err: unknown) { - const errorMessage = err instanceof Error ? err.message : String(err); - console.error( - `Cannot delete category or its channels:\n\t${errorMessage}`, - ); + log.error(err, 'Cannot delete category or its channels'); await interaction.reply({ content: `${emoji.answer.error} | Failed to delete the category or its channels.`, flags: MessageFlags.Ephemeral, diff --git a/src/commands/administration/join.ts b/src/commands/administration/join.ts index a6552e1..ac6e8ae 100644 --- a/src/commands/administration/join.ts +++ b/src/commands/administration/join.ts @@ -95,7 +95,7 @@ export async function execute(interaction: ChatInputCommandInteraction) { currentGuildData = await prisma.guild.create({ data: { id: guildId } }); } - const mainRow : ActionRowBuilder = createMainRow(currentGuildData); + const mainRow: ActionRowBuilder = createMainRow(currentGuildData); await interaction.reply({ embeds: [getEmbed(currentGuildData)], diff --git a/src/commands/administration/logs.ts b/src/commands/administration/logs.ts index 2e138bf..6eb948c 100644 --- a/src/commands/administration/logs.ts +++ b/src/commands/administration/logs.ts @@ -15,6 +15,7 @@ import { } from 'discord.js'; import emoji from '../../../assets/emoji.json' assert { type: 'json' }; import { Guild, User } from '@prisma/client'; +import { log } from '@lib/log'; export default { data: new SlashCommandBuilder() @@ -62,10 +63,7 @@ export default { }); } catch (err: unknown) { - const errorMessage = err instanceof Error ? err.message : String(err); - console.error( - `\t⚠️ | Cannot get the database connection!\n\t\t(${errorMessage}).`, - ); + log.error(err, 'Cannot get the database connection'); await interaction.reply({ content: `${emoji.answer.error} | Cannot connect to the database`, flags: MessageFlags.Ephemeral, @@ -367,15 +365,11 @@ export default { }); } catch (err: unknown) { - const errorMessage = - err instanceof Error ? err.message : (err as string); await interaction.reply({ content: `${emoji.answer.error} | Cannot suppress the category's channels`, flags: MessageFlags.Ephemeral, }); - console.error( - `Cannot suppress the category's channel:\n\t${errorMessage}`, - ); + log.error(err, 'Cannot suppress the category\'s channels'); return; } await prisma.guild.update({ @@ -396,7 +390,7 @@ export default { break; } default: - console.error(`no choice on logs command ${choice}`); + log.error(new Error(`no choice on logs command ${choice}`), 'Invalid logs command choice'); await interaction.reply({ content: `${emoji.answer.error} | Invalid choice`, flags: MessageFlags.Ephemeral, diff --git a/src/commands/administration/protect.ts b/src/commands/administration/protect.ts index b30f0fd..f6ae0c1 100644 --- a/src/commands/administration/protect.ts +++ b/src/commands/administration/protect.ts @@ -1,4 +1,8 @@ -import { ButtonBuilder, ActionRowBuilder, SlashCommandBuilder } from '@discordjs/builders'; +import { + ButtonBuilder, + ActionRowBuilder, + SlashCommandBuilder, +} from '@discordjs/builders'; import { StringSelectMenuBuilder, ButtonStyle,