refactor(cmd/rank): adding the tsconfig + eslint correction

This commit is contained in:
Raphael 2025-10-14 00:18:06 +02:00 committed by Raphaël
parent eece230bab
commit d9b5d3c17c
3 changed files with 32 additions and 27 deletions

View file

@ -1,5 +1,7 @@
import { EmbedBuilder, MessageFlags, SlashCommandBuilder } from 'discord.js'; import { SlashCommandBuilder } from '@discordjs/builders';
import { prisma } from '../../lib/prisma.ts'; import { EmbedBuilder, MessageFlags } from 'discord.js';
import { prisma } from '@lib/prisma';
import { Guild as GuildPrisma } from '@prisma/client';
import emoji from '../../../assets/emoji.json' assert { type: 'json' }; import emoji from '../../../assets/emoji.json' assert { type: 'json' };
export default { export default {
@ -43,7 +45,7 @@ export default {
} }
catch (err) { catch (err) {
console.error( console.error(
`\t⚠ | Cannot get the database connection!\n\t\t(${err}).`, `\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`,
@ -51,7 +53,7 @@ export default {
}); });
return; return;
} }
let guildData: Guild; let guildData: GuildPrisma;
try { try {
guildData = await prisma.guild.findUnique({ guildData = await prisma.guild.findUnique({
where: { where: {
@ -61,7 +63,7 @@ export default {
} }
catch (err) { catch (err) {
console.error( console.error(
`\t⚠ | Cannot get the database connection!\n\t\t(${err}).`, `\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`,
@ -114,7 +116,7 @@ export default {
} }
catch (err) { catch (err) {
console.error( console.error(
`⚠️ | Error when adding ${target.username} to the buyer list\n\t${err}`, `⚠️ | Error when adding ${target.username} to the buyer list\n\t${err as Error}`,
); );
await interaction.reply({ await interaction.reply({
content: `${emoji.answer.error} | Error when adding ${target.username} to the owner list`, content: `${emoji.answer.error} | Error when adding ${target.username} to the owner list`,
@ -177,7 +179,7 @@ export default {
} }
catch (err) { catch (err) {
console.error( console.error(
`⚠️ | Error when removing ${target.username} to the buyer list\n\t${err}`, `⚠️ | Error when removing ${target.username} to the buyer list\n\t${err as Error}`,
); );
return; return;
} }
@ -219,7 +221,7 @@ export default {
return `- ${user.username} (\`${user.id}\`)\n`; return `- ${user.username} (\`${user.id}\`)\n`;
} }
catch (err) { catch (err) {
console.warn(`⚠️ | ${buyer.id} : ${err}`); console.warn(`⚠️ | ${buyer.id} : ${err as Error}`);
return null; return null;
} }
}), }),
@ -239,7 +241,7 @@ export default {
} }
catch (err) { catch (err) {
console.error( console.error(
`⚠️ | error when fetching infromation from the database: ${err}`, `⚠️ | error when fetching infromation from the database: ${err as Error}`,
); );
await interaction.reply({ await interaction.reply({
content: `${emoji.answer.error} | Cannot fetch the infromation of the database.`, content: `${emoji.answer.error} | Cannot fetch the infromation of the database.`,

View file

@ -1,5 +1,7 @@
import { EmbedBuilder, MessageFlags, SlashCommandBuilder } from 'discord.js'; import { SlashCommandBuilder } from '@discordjs/builders';
import { prisma } from '../../lib/prisma.ts'; import { CommandInteraction, EmbedBuilder, MessageFlags } from 'discord.js';
import { prisma } from '@lib/prisma';
import { Guild as GuildPrisma, User as UserPrima } from '@prisma/client';
import emoji from '../../../assets/emoji.json' assert { type: 'json' }; import emoji from '../../../assets/emoji.json' assert { type: 'json' };
export default { export default {
@ -33,7 +35,7 @@ export default {
), ),
async execute(interaction: CommandInteraction) { async execute(interaction: CommandInteraction) {
const subcommand = interaction.options.getSubcommand(); const subcommand = interaction.options.getSubcommand();
let userData: User; let userData: UserPrima | null;
try { try {
userData = await prisma.user.findUnique({ userData = await prisma.user.findUnique({
where: { where: {
@ -43,7 +45,7 @@ export default {
} }
catch (err) { catch (err) {
console.error( console.error(
`\t⚠ | Cannot get the database connection!\n\t\t(${err}).`, `\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`,
@ -51,7 +53,7 @@ export default {
}); });
return; return;
} }
let guildData: Guild; let guildData: GuildPrisma | null;
try { try {
guildData = await prisma.guild.findUnique({ guildData = await prisma.guild.findUnique({
where: { where: {
@ -61,7 +63,7 @@ export default {
} }
catch (err) { catch (err) {
console.error( console.error(
`\t⚠ | Cannot get the database connection!\n\t\t(${err}).`, `\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`,
@ -107,7 +109,7 @@ export default {
} }
catch (err) { catch (err) {
console.error( console.error(
`⚠️ | Error when adding ${target.username} to the owner list\n\t${err}`, `⚠️ | Error when adding ${target.username} to the owner list\n\t${err as Error}`,
); );
await interaction.reply({ await interaction.reply({
content: `${emoji.answer.error} | Error when adding ${target.username} to the owner list`, content: `${emoji.answer.error} | Error when adding ${target.username} to the owner list`,
@ -163,7 +165,7 @@ export default {
} }
catch (err) { catch (err) {
console.error( console.error(
`⚠️ | Error when removing ${target.username} to the owner list\n\t${err}`, `⚠️ | Error when removing ${target.username} to the owner list\n\t${err as Error}`,
); );
await interaction.reply({ await interaction.reply({
content: `${emoji.answer.error} | Cannot removing the user from the owner list`, content: `${emoji.answer.error} | Cannot removing the user from the owner list`,
@ -209,7 +211,7 @@ export default {
return `- ${user.username} (\`${user.id}\`)\n`; return `- ${user.username} (\`${user.id}\`)\n`;
} }
catch (err) { catch (err) {
console.warn(`⚠️ | ${owner.id} : ${err}`); console.warn(`⚠️ | ${owner.id} : ${err as Error}`);
return null; return null;
} }
}), }),
@ -229,7 +231,7 @@ export default {
} }
catch (err) { catch (err) {
console.error( console.error(
`⚠️ | error when fetching infromation from the database: ${err}`, `⚠️ | error when fetching infromation from the database: ${err as Error}`,
); );
await interaction.reply({ await interaction.reply({
content: `${emoji.answer.error} | Cannot fetch the infromation of the database.`, content: `${emoji.answer.error} | Cannot fetch the infromation of the database.`,

View file

@ -1,5 +1,6 @@
import { CommandInteraction, EmbedBuilder, MessageFlags, SlashCommandBuilder } from 'discord.js'; import { CommandInteraction, EmbedBuilder, MessageFlags } from 'discord.js';
import { prisma } from '../../lib/prisma.ts'; import { SlashCommandBuilder } from '@discordjs/builders';
import { prisma } from '@lib/prisma';
import emoji from '../../../assets/emoji.json' assert { type: 'json' }; import emoji from '../../../assets/emoji.json' assert { type: 'json' };
import { User as UserPrisma } from '@prisma/client'; import { User as UserPrisma } from '@prisma/client';
import { Guild as GuildPrisma } from '@prisma/client'; import { Guild as GuildPrisma } from '@prisma/client';
@ -45,7 +46,7 @@ export default {
} }
catch (err) { catch (err) {
console.error( console.error(
`\t⚠ | Whitelist => Cannot get the database connection!\n\t\t(${err}).`, `\t⚠ | Whitelist => 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`,
@ -63,7 +64,7 @@ export default {
} }
catch (err) { catch (err) {
console.error( console.error(
`\t⚠ | Cannot get the database connection!\n\t\t(${err}).`, `\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`,
@ -113,7 +114,7 @@ export default {
} }
catch (err) { catch (err) {
console.error( console.error(
`⚠️ | Error when adding ${target.username} to the whitelist\n\t${err}`, `⚠️ | Error when adding ${target.username} to the whitelist\n\t${err as Error}`,
); );
await interaction.reply({ await interaction.reply({
content: `${emoji.answer.error} | Error when adding ${target.username} to the whitelist`, content: `${emoji.answer.error} | Error when adding ${target.username} to the whitelist`,
@ -173,7 +174,7 @@ export default {
} }
catch (err) { catch (err) {
console.error( console.error(
`⚠️ | Error when removing ${target.username} to the username\n\t${err}`, `⚠️ | Error when removing ${target.username} to the username\n\t${err as Error}`,
); );
await interaction.reply({ await interaction.reply({
content: `${emoji.answer.error} | Cannot remove ${target.username} from the whitelist`, content: `${emoji.answer.error} | Cannot remove ${target.username} from the whitelist`,
@ -219,7 +220,7 @@ export default {
return `- ${user.username} (\`${user.id}\`)\n`; return `- ${user.username} (\`${user.id}\`)\n`;
} }
catch (err) { catch (err) {
console.warn(`⚠️ | ${whitelist.id} : ${err}`); console.warn(`⚠️ | ${whitelist.id} : ${err as Error}`);
return null; return null;
} }
}), }),
@ -239,7 +240,7 @@ export default {
} }
catch (err) { catch (err) {
console.error( console.error(
`⚠️ | Whitelist => error when fetching infromation from the database: ${err}`, `⚠️ | Whitelist => error when fetching infromation from the database: ${err as Error}`,
); );
await interaction.reply({ await interaction.reply({
content: `${emoji.answer.error} | Cannot fetch the infromation of the database.`, content: `${emoji.answer.error} | Cannot fetch the infromation of the database.`,