rename to fix
This commit is contained in:
parent
a3836be22d
commit
dc547a66f8
7 changed files with 30 additions and 64 deletions
68
index.js
68
index.js
|
|
@ -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);
|
||||
Loading…
Add table
Add a link
Reference in a new issue