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

This commit is contained in:
Raphael 2025-10-14 00:19:18 +02:00 committed by Raphaël
parent c807c12d01
commit 9735528b2b
4 changed files with 30 additions and 36 deletions

View file

@ -1,5 +1,5 @@
import { Events, EmbedBuilder, Message, Channel, Collection, Snowflake, PartialMessage } from 'discord.js'; import { Events, EmbedBuilder, Message, Channel, Collection, Snowflake, PartialMessage } from 'discord.js';
import { prisma } from '../../lib/prisma.ts'; import { prisma } from '@lib/prisma';
import { Guild as GuildPrisma } from '@prisma/client'; import { Guild as GuildPrisma } from '@prisma/client';
export default { export default {
@ -40,21 +40,19 @@ export default {
text: guildData.footer, text: guildData.footer,
}) })
.setDescription(` .setDescription(`
__Channel:__ ${message.channel} __Channel:__ <#${message.channel.id}> (${message.channel.name})
__Number:__ ${messages.size} __Number:__ ${messages.size}
__Content:__ __Content:__
${description} ${description}
`); `);
const logChannel: Promise<Channel | null> = await message.guild.client.channels const logChannel: Promise<Channel | null> = await message.guild.client.channels
.fetch(guildData.logMsg) .fetch(guildData.logMsg)
.catch((err) => console.error(err)); .catch((err) => { console.error(err); });
if (logChannel) { logChannel.send({
logChannel.send({ embeds: [
embeds: [ log,
log, ],
], });
});
}
} }
}, },
}; };

View file

@ -1,5 +1,5 @@
import { Events, Message } from 'discord.js'; import { Events, Message } from 'discord.js';
import { prisma } from '../../lib/prisma.ts'; import { prisma } from '@lib/prisma';
import { User as UserPrisma } from '@prisma/client'; import { User as UserPrisma } from '@prisma/client';
const xpCooldown: Map<string, number> = new Map<string, number>(); const xpCooldown: Map<string, number> = new Map<string, number>();
@ -18,7 +18,7 @@ export default {
name: Events.MessageCreate, name: Events.MessageCreate,
async execute(message: Message) { async execute(message: Message) {
if (message.author.bot || !message.guildId || !canGainXp(message.author.id)) return; if (message.author.bot || !message.guildId || !canGainXp(message.author.id)) return;
const Author: UserPrisma = await prisma.user.findUnique({ const Author: UserPrisma | null = await prisma.user.findUnique({
where: { id: message.author.id }, where: { id: message.author.id },
}); });
if (!Author) { if (!Author) {
@ -53,7 +53,7 @@ export default {
if (newXp >= requiredXp) { if (newXp >= requiredXp) {
newLevel++; newLevel++;
await message.channel.send( await message.channel.send(
`🎉 | Félicitations ${message.author}, tu es maintenant niveau **${newLevel}** !`, `🎉 | Félicitations <@${message.author.id}>, tu es maintenant niveau **${newLevel}** !`,
); );
} }
console.log(`${message.author.username} | ${newLevel} -> ${newXp} [${requiredXp}]`); console.log(`${message.author.username} | ${newLevel} -> ${newXp} [${requiredXp}]`);

View file

@ -1,5 +1,5 @@
import { Events, EmbedBuilder, Message, Channel } from 'discord.js'; import { Events, EmbedBuilder, Message, Channel } from 'discord.js';
import { prisma } from '../../lib/prisma.ts'; import { prisma } from '@lib/prisma';
import { Guild as GuildPrisma } from '@prisma/client'; import { Guild as GuildPrisma } from '@prisma/client';
export default { export default {
@ -25,19 +25,17 @@ export default {
text: guildData.footer, text: guildData.footer,
}) })
.setDescription(` .setDescription(`
Channel: ${message.channel} __Channel:__ <#${message.channel.id}> (${message.channel.name})
Content: ${message.content ? message.content : '*enable to load the content*'} __Content:__ ${message.content ? message.content : '*enable to load the content*'}
`); `);
const logChannel: Promise<Channel | null> = await message.guild.client.channels const logChannel: Promise<Channel | null> = await message.guild.client.channels
.fetch(guildData.logMsg) .fetch(guildData.logMsg)
.catch((err) => console.error(err)); .catch((err) => { console.error(err); });
if (logChannel) { logChannel.send({
logChannel.send({ embeds: [
embeds: [ log,
log, ],
], });
});
}
} }
}, },
}; };

View file

@ -1,5 +1,5 @@
import { Events, EmbedBuilder, Message, Channel } from 'discord.js'; import { Events, EmbedBuilder, Message, Channel } from 'discord.js';
import { prisma } from '../../lib/prisma.ts'; import { prisma } from '@lib/prisma';
import { Guild as GuildPrisma } from '@prisma/client'; import { Guild as GuildPrisma } from '@prisma/client';
export default { export default {
@ -25,20 +25,18 @@ export default {
text: guildData.footer, text: guildData.footer,
}) })
.setDescription(` .setDescription(`
Channel: ${newMessage.channel} __Channel:__ <#${message.channel.id}> (${message.channel.name})
Before: ${oldMessage.content} __Before:__ ${oldMessage.content}
After: ${newMessage.content} __After:__ ${newMessage.content}
`); `);
const logChannel: Promise<Channel | null> = await newMessage.guild.client.channels const logChannel: Promise<Channel | null> = await newMessage.guild.client.channels
.fetch(guildData.logMsg) .fetch(guildData.logMsg)
.catch((err) => console.error(err)); .catch((err) => { console.error(err); });
if (logChannel) { logChannel.send({
logChannel.send({ embeds: [
embeds: [ log,
log, ],
], });
});
}
} }
}, },
}; };