refactor(commands/utils): now using the new log system

This commit is contained in:
Raphael 2025-10-26 17:50:42 +01:00 committed by Raphaël
parent afb9b13647
commit bdfa9e1c9b

View file

@ -8,6 +8,7 @@ import {
Guild, Guild,
} from 'discord.js'; } from 'discord.js';
import emoji from '../../../assets/emoji.json' assert { type: 'json' }; import emoji from '../../../assets/emoji.json' assert { type: 'json' };
import { log } from '@lib/log';
function getGuildRoles(guild: Guild): string { function getGuildRoles(guild: Guild): string {
const roles = guild.roles.cache const roles = guild.roles.cache
@ -75,9 +76,7 @@ export default {
}); });
} }
catch (err) { catch (err) {
console.error( log.error(err, 'Cannot get the database connection!');
`\t⚠ | Cannot get the database connection!\n\t\t(${err as Error}).`,
);
await interaction.reply({ await interaction.reply({
content: `${emoji.answer.error} | Cannot connect to the database`, content: `${emoji.answer.error} | Cannot connect to the database`,
flags: MessageFlags.Ephemeral, flags: MessageFlags.Ephemeral,
@ -99,9 +98,7 @@ export default {
}); });
} }
catch (err) { catch (err) {
console.error( log.error(err, 'Cannot get the database connection!');
`\t⚠ | Cannot get the database connection!\n\t\t(${err as Error}).`,
);
await interaction.reply({ await interaction.reply({
content: `${emoji.answer.error} | Cannot connect to the database`, content: `${emoji.answer.error} | Cannot connect to the database`,
flags: MessageFlags.Ephemeral, flags: MessageFlags.Ephemeral,
@ -113,7 +110,7 @@ export default {
targetServer = await interaction.guild.members.fetch(targetGlobal.id); targetServer = await interaction.guild.members.fetch(targetGlobal.id);
} }
catch (err) { catch (err) {
console.error(`\t⚠ | Cannot get the targetServer!\n\t\t(${err as Error}).`); log.error(err, 'Cannot get the targetServer!');
await interaction.reply({ await interaction.reply({
content: `${emoji.answer.error} | Cannot get the guild profile of the user`, content: `${emoji.answer.error} | Cannot get the guild profile of the user`,
flags: MessageFlags.Ephemeral, flags: MessageFlags.Ephemeral,
@ -139,12 +136,12 @@ export default {
${targetGlobal.username} ${targetGlobal.username}
**🆔 | ID:** **🆔 | ID:**
${targetGlobal.id} ${targetGlobal.id}
**🔰 | Roles:** **🔰 | Roles:**
${getUserRoles(targetServer)} ${getUserRoles(targetServer)}
**🎖 | Badges:** **🎖 | Badges:**
${getUserBadges(userData)} ${getUserBadges(userData)}
**🍼 | Account Creation:** **🍼 | Account Creation:**
<t:${parseInt(targetGlobal.createdTimestamp / 1000)}:f> (<t:${parseInt(targetGlobal.createdTimestamp / 1000)}:R>) <t:${parseInt(targetGlobal.createdTimestamp / 1000)}:f> (<t:${parseInt(targetGlobal.createdTimestamp / 1000)}:R>)
**🛬 | Server Join:** **🛬 | Server Join:**