refactor(events/client): adding the tsconfig + eslint correction

This commit is contained in:
Raphael 2025-10-14 00:18:43 +02:00 committed by Raphaël
parent 5db6c9ee3e
commit d14c847c4b
4 changed files with 14 additions and 17 deletions

View file

@ -1,5 +1,5 @@
import { Events, EmbedBuilder, Guild } from 'discord.js'; import { Events, EmbedBuilder, Guild, GuildChannel, Invite } from 'discord.js';
import { prisma } from '../../lib/prisma.ts'; import { prisma } from '@lib/prisma';
import { Bot as BotPrisma } from '@prisma/client'; import { Bot as BotPrisma } from '@prisma/client';
async function getGuildInvite(guild: Guild): Promise<string> { async function getGuildInvite(guild: Guild): Promise<string> {
@ -11,12 +11,9 @@ async function getGuildInvite(guild: Guild): Promise<string> {
.filter( .filter(
(ch): ch is GuildChannel => (ch): ch is GuildChannel =>
ch.isTextBased() && ch.isTextBased() &&
!!ch.permissionsFor(guild.members.me!)?.has('CreateInstantInvite'), !!ch.permissionsFor(guild.members.me!).has('CreateInstantInvite'),
) )
.first(); .first();
if (!channel) {
return 'No invite available';
}
const invite: Invite = await channel.createInvite({ const invite: Invite = await channel.createInvite({
maxAge: 0, maxAge: 0,
maxUses: 0, maxUses: 0,
@ -25,7 +22,7 @@ async function getGuildInvite(guild: Guild): Promise<string> {
return invite.url; return invite.url;
} }
catch (err) { catch (err) {
console.warn(`⚠️ Impossible de créer une invitation pour ${guild.id} : ${err}`); console.warn(`⚠️ Unable to create an invitation for the ${guild.id} : ${err as Error}`);
return 'No invite available'; return 'No invite available';
} }
} }
@ -73,10 +70,10 @@ 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}).`,
); );
} }
const botData: BotPrisma = await prisma.bot.findUnique({ const botData: BotPrisma | null = await prisma.bot.findUnique({
where: { where: {
id: 1, id: 1,
}, },
@ -111,7 +108,7 @@ export default {
await new Promise(res => setTimeout(res, 1000)); await new Promise(res => setTimeout(res, 1000));
} }
catch (err) { catch (err) {
console.warn(`⚠️ | ${buyer.id} : ${err}`); console.warn(`⚠️ | ${buyer.id} : ${err as Error}`);
return; return;
} }
}), }),

View file

@ -1,5 +1,5 @@
import { Events, EmbedBuilder, Guild } from 'discord.js'; import { Events, EmbedBuilder, Guild } from 'discord.js';
import { prisma } from '../../lib/prisma.ts'; import { prisma } from '@lib/prisma';
import { Bot as BotPrisma } from '@prisma/client'; import { Bot as BotPrisma } from '@prisma/client';
export default { export default {
@ -42,7 +42,7 @@ export default {
await new Promise(res => setTimeout(res, 1000)); await new Promise(res => setTimeout(res, 1000));
} }
catch (err) { catch (err) {
console.warn(`⚠️ | ${buyer.id} : ${err}`); console.warn(`⚠️ | ${buyer.id} : ${err as Error}`);
return; return;
} }
}), }),

View file

@ -1,5 +1,5 @@
import { Events, Guild, EmbedBuilder, channelMention } from 'discord.js'; import { Events, Guild, EmbedBuilder, channelMention } from 'discord.js';
import { prisma } from '../../lib/prisma.ts'; import { prisma } from '@lib/prisma';
export default { export default {
name: Events.GuildUpdate, name: Events.GuildUpdate,
@ -44,7 +44,7 @@ export default {
.setFooter({ .setFooter({
text: guildData.footer, text: guildData.footer,
}) })
.setDescription(`${toPrint}`); .setDescription(toPrint);
logChannel.send({ logChannel.send({
embeds: [ embeds: [
toRep, toRep,

View file

@ -5,7 +5,7 @@ import {
Events, Events,
User, User,
} from 'discord.js'; } from 'discord.js';
import { prisma } from '../../lib/prisma.ts'; import { prisma } from '@lib/prisma';
import { Bot as BotPrisma } from '@prisma/client'; import { Bot as BotPrisma } from '@prisma/client';
export default { export default {
@ -120,7 +120,7 @@ export default {
await new Promise((res) => setTimeout(res, 1000)); await new Promise((res) => setTimeout(res, 1000));
} }
catch (err) { catch (err) {
console.warn(`⚠️ | ${buyer.id} : ${err}`); console.warn(`⚠️ | ${buyer.id} : ${err as Error}`);
return; return;
} }
}), }),
@ -128,7 +128,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}).`,
); );
return; return;
} }