rename to fix

This commit is contained in:
Lou 2025-11-20 21:05:44 +01:00
parent a3836be22d
commit dc547a66f8
7 changed files with 30 additions and 64 deletions

4
db.json Normal file
View file

@ -0,0 +1,4 @@
{
"ignoredChannels": [],
"configs": {}
}

View file

@ -3,9 +3,9 @@ import feurDetector from "./feurDetector.js";
import pingDetector from "./pingDetector.js";
import quoicoubehDetector from "./quoicoubehDetector.js";
import suffixPrefixDetector from "./suffixPrefixDetector.js";
import withPronounDetector from "./withPronounDetector.js"; // Nom aligné
import withPronounDetector from "./withPronounDetector.js";
const firstDetector = new WithPronounDetector(); // Utilisation du bon nom
const firstDetector = new withPronounDetector();
firstDetector
.setNextDetector(new suffixPrefixDetector())

View file

@ -1,8 +1,8 @@
import { Client, GatewayIntentBits, WebhookClient, AuditLogEvent, OAuth2Scopes, Options } from 'discord.js';
import commands from './commands.js';
import firstDetector from './detectors/allDetector.js'; // On importe la chaine de détecteurs
// import commands from './commands.js';
import firstDetector from './detectors/allDetector.js';
const webhookClient = process.env.LOGS_WEBHOOK ? new WebhookClient({ url: process.env.LOGS_WEBHOOK }) : null;
// const webhookClient = process.env.LOGS_WEBHOOK ? new WebhookClient({ url: process.env.LOGS_WEBHOOK }) : null;
const client = new Client({
makeCache: Options.cacheWithLimits({
@ -15,31 +15,7 @@ const client = new Client({
]
});
// Gestion des Logs Guild (Join/Leave)
client.on('guildCreate', async (guild) => {
const logs = await guild.fetchAuditLogs().catch(() => null);
const inviter = logs?.entries
.find((l) => l.action === AuditLogEvent.BotAdd && l.targetId === client.user?.id)?.executor;
webhookClient?.send({
content: `Joined guild:
\`\`\`
name: ${guild.name} (${guild.id})
inviter: ${inviter != null ? ` invited by ${inviter.tag} (${inviter.id})` : ' (unknown inviter)'}
member count: ${guild.memberCount}
\`\`\``
});
});
client.on('guildDelete', async (guild) => {
webhookClient?.send({
content: `Left guild ${guild.name} (${guild.id})`
});
});
// Démarrage
client.on('ready', async () => {
console.log(`Logged in as ${client.user?.tag ?? 'unknown'}`);
@ -61,40 +37,6 @@ client.on('ready', async () => {
'ReadMessageHistory'
]
}));
// Enregistrement des commandes slash
if (client.application) {
await client.application.commands.set([
commands['channel-ignore'].command,
commands['retire-role'].command,
commands['get-config'].command,
commands['set-config'].command,
]);
console.log('Commandes Slash enregistrées.');
}
});
// Gestion des Commandes (/slash)
client.on('interactionCreate', async (interaction) => {
if (!interaction.guild || !interaction.member || !interaction.isChatInputCommand()) {
return;
}
const command = commands[interaction.commandName];
if (command) {
try {
await command.run(interaction);
} catch (error) {
console.error('Erreur commande:', error);
const replyObj = { content: 'Une erreur est survenue.', ephemeral: true };
if (interaction.replied || interaction.deferred) {
await interaction.followUp(replyObj);
} else {
await interaction.reply(replyObj);
}
}
}
});
// Gestion des Messages (Listeners)
@ -140,4 +82,8 @@ client.on('messageUpdate', async (oldMessage, newMessage) => {
await handleMessage(message);
});
client.on(Events.ClientReady, () => {
console.log(`Hello World !`);
});
client.login(process.env.DISCORD_TOKEN);

View file

@ -6,7 +6,7 @@
},
"license": "ISC",
"author": "",
"type": "commonjs",
"type": "module",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"

16
utils/strings.js Normal file
View file

@ -0,0 +1,16 @@
/**
* Nettoie le contenu d'un message pour faciliter la détection.
* - Utilise 'cleanContent' si dispo (remplace les <@123> par @Pseudo)
* - Sinon utilise 'content' brut
* - Retire les espaces superflus au début et à la fin
*/
export function cleanMessageContent(message) {
// Sécurité si le message est vide ou bizarre
if (!message) return "";
// On privilégie cleanContent qui est plus propre pour la lecture humaine
const text = message.cleanContent || message.content || "";
return text.trim();
}