From a284d55d5cdf19c2c0735568a78423b965740900 Mon Sep 17 00:00:00 2001 From: MindfulLearner Date: Sun, 20 Jul 2025 17:52:26 +0200 Subject: [PATCH 1/5] honeypot setup --- events/honeypot/honey-pot.js | 84 ++++++++++++++++++++++++++++++++++++ index.js | 22 ++++++++++ 2 files changed, 106 insertions(+) create mode 100644 events/honeypot/honey-pot.js diff --git a/events/honeypot/honey-pot.js b/events/honeypot/honey-pot.js new file mode 100644 index 0000000..f003bde --- /dev/null +++ b/events/honeypot/honey-pot.js @@ -0,0 +1,84 @@ +// create a channel honeypot +// if someone write on it, ban instantly the one that write on it +const { EmbedBuilder } = require('discord.js'); + +const channelHoneypot = '1396509303380381816'; +const channelLog = '1396516358879055962'; + +/** + * + * this function send a embeded message in the channel honeypot + * + */ +const embedTheMessage = (message, channel) => { + const channelHoneypot = message.guild.channels.cache.get(channel); + + const embed = new EmbedBuilder() + .setColor('#ff0000') + .setTitle('Honeypot Alert') + .setDescription(`**User:** ${message.author.tag} (${message.author.id})\n**Message:** ${message.content}`) + .setTimestamp(); + + channelHoneypot.send({ embeds: [embed] }); +}; + +/** + * + * this function send a embeded message in the channel log + * we need this to track how sended the message this + * + */ +const embedTheLog = (message, channel) => { + const channelLog = message.guild.channels.cache.get(channel); + + const embed = new EmbedBuilder() + .setColor('#ff0000') + .setTitle('Honeypot Alert') + .setDescription(`**User:** ${message.author.tag} (${message.author.id})\n**Message:** ${message.content}`) + .setTimestamp(); + + channelLog.send({ embeds: [embed] }); +}; + + +module.exports = { + name: 'messageCreate', + async execute(message) { + + + if (message.channel.id === channelHoneypot) { + + // this perche' se il messaggio e' del bot, non faccio nulla + if (message.author.bot) return; + + try { + + + // send the message in the channel honeypot + embedTheMessage(message, channelHoneypot); + + // Banna l'utente + // await message.member.ban({ + // reason: 'Honeypot triggered - Suspected bot/malicious activity' + // }); + + // log debug + console.log(`Banned user ${message.author.tag} (${message.author.id}) for writing in honeypot channel`); + + // send the message in the channel log + embedTheLog(message, channelLog); + + // eliminiamo il messaggio, + await message.delete(); + + // clearriamo la chat honeypot + const channelHoneypot = message.guild.channels.cache.get(channelHoneypot); + console.log(channelHoneypot); + // channelHoneypot.bulkDelete(5); + + } catch (error) { + console.error('Error in honeypot ban:', error); + } + } + }, +}; diff --git a/index.js b/index.js index 45fe3e2..9467666 100644 --- a/index.js +++ b/index.js @@ -16,6 +16,28 @@ const client = new Client({ client.commands = new Collection(); +// load events +const eventsPath = path.join(__dirname, 'events'); +const eventFolders = fs.readdirSync(eventsPath); + +for (const folder of eventFolders) { + console.log(`Loading events from ${folder}`); + const eventPath = path.join(eventsPath, folder); + const eventFiles = fs.readdirSync(eventPath); + + for (const file of eventFiles) { + console.log(`Loading event ${file}`); + const filePath = path.join(eventPath, file); + const event = require(filePath); + if (event.once) { + client.once(event.name, (...args) => event.execute(...args, client)); + } else { + client.on(event.name, (...args) => event.execute(...args, client)); + } + } +} + +// load commands const foldersPath = path.join(__dirname, 'commands'); const commandFolders = fs.readdirSync(foldersPath); From 210c91af77a4f62c451676e5c36ad5e2cc0920f0 Mon Sep 17 00:00:00 2001 From: MindfulLearner Date: Sun, 20 Jul 2025 17:56:38 +0200 Subject: [PATCH 2/5] cleanup comment --- events/honeypot/honey-pot.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/events/honeypot/honey-pot.js b/events/honeypot/honey-pot.js index f003bde..c88ed8b 100644 --- a/events/honeypot/honey-pot.js +++ b/events/honeypot/honey-pot.js @@ -7,7 +7,7 @@ const channelLog = '1396516358879055962'; /** * - * this function send a embeded message in the channel honeypot + * send a embeded message in the channel honeypot * */ const embedTheMessage = (message, channel) => { @@ -24,7 +24,7 @@ const embedTheMessage = (message, channel) => { /** * - * this function send a embeded message in the channel log + * send a embeded message in the channel log * we need this to track how sended the message this * */ From 96db72e0161cd553d32c1793d8e7d0b08a5c3a1e Mon Sep 17 00:00:00 2001 From: MindfulLearner Date: Sun, 20 Jul 2025 18:52:41 +0200 Subject: [PATCH 3/5] swag --- commands/honeypot/honey-pot-data.js | 38 +++++++++++++++++++++++++ events/honeypot/honey-pot.js | 43 +++++++++++++++++++---------- 2 files changed, 67 insertions(+), 14 deletions(-) create mode 100644 commands/honeypot/honey-pot-data.js diff --git a/commands/honeypot/honey-pot-data.js b/commands/honeypot/honey-pot-data.js new file mode 100644 index 0000000..436ff5f --- /dev/null +++ b/commands/honeypot/honey-pot-data.js @@ -0,0 +1,38 @@ +const { SlashCommandBuilder, PermissionFlagsBits, Client, GatewayIntentBits } = require('discord.js'); + +module.exports = { + data: new SlashCommandBuilder() + .setName('honeypot') + .setDescription('comandi per vedere i dati del honeypot, mostrera, una lista di bannati per il honeypot') + .addSubcommand(subcommand => + subcommand.setName('bannati') + .setDescription('mostra una lista di bannati per il honeypot') + ) + .setDefaultMemberPermissions(PermissionFlagsBits.Administrator), + + + async execute(interaction) { + const subcommand = interaction.options.getSubcommand(); + + if (subcommand === 'bannati') { + + const guild = interaction.guild; + + try { + + const bannati = await guild.bans.fetch(); + const filteredBannati = bannati.filter(member => member.reason === 'Honeypot triggered - Suspected bot/malicious activity'); + + // TODO: to format with embed + const bannatiList = filteredBannati.map(member => member.user.tag).join('\n'); + await interaction.reply(`Lista dei bannati per il honeypot:\n${bannatiList}`); + + const channelLog = interaction.guild.channels.cache.get('1396529523058802838'); + channelLog.send(`Lista dei bannati per il honeypot:\n${bannatiList}, id: ${interaction.guild.id}, timestamp: ${new Date().toISOString()}`); + + } catch (error) { + console.error('Error fetching banned members:', error); + } + } + } +}; diff --git a/events/honeypot/honey-pot.js b/events/honeypot/honey-pot.js index c88ed8b..6493154 100644 --- a/events/honeypot/honey-pot.js +++ b/events/honeypot/honey-pot.js @@ -5,21 +5,36 @@ const { EmbedBuilder } = require('discord.js'); const channelHoneypot = '1396509303380381816'; const channelLog = '1396516358879055962'; +// add emoticon for kill streak, and other things, to refactor because +// it just delete the infomessagehoneypot +const infoHoneypot = (message, channel) => { + const channelMessage = message.client.channels.cache.get(channel); + + const embed = new EmbedBuilder() + .setColor('#ff0000') + .setTitle('⚠️ Honeypot Alert - Info ⚠️') + .setDescription('Benvenuti nel canale Honeypot! Questo canale è progettato per rilevare e gestire attività sospette. Se qualcuno invia un messaggio qui, verrà automaticamente bannato. Si prega di non inviare messaggi in questo canale a meno che non si desideri essere bannati.') + .setTimestamp(); + + channelMessage.send({ embeds: [embed] }); +}; + /** * * send a embeded message in the channel honeypot * */ const embedTheMessage = (message, channel) => { - const channelHoneypot = message.guild.channels.cache.get(channel); + const channelMessage = message.guild.channels.cache.get(channel); const embed = new EmbedBuilder() .setColor('#ff0000') .setTitle('Honeypot Alert') .setDescription(`**User:** ${message.author.tag} (${message.author.id})\n**Message:** ${message.content}`) + .setThumbnail(message.author.displayAvatarURL({ dynamic: true })) .setTimestamp(); - channelHoneypot.send({ embeds: [embed] }); + channelMessage.send({ embeds: [embed] }); }; /** @@ -29,15 +44,16 @@ const embedTheMessage = (message, channel) => { * */ const embedTheLog = (message, channel) => { - const channelLog = message.guild.channels.cache.get(channel); + const channelMessage = message.guild.channels.cache.get(channel); const embed = new EmbedBuilder() .setColor('#ff0000') - .setTitle('Honeypot Alert') + .setTitle('Honeypot Alert - Log') .setDescription(`**User:** ${message.author.tag} (${message.author.id})\n**Message:** ${message.content}`) + .setThumbnail(message.author.displayAvatarURL({ dynamic: true })) .setTimestamp(); - channelLog.send({ embeds: [embed] }); + channelMessage.send({ embeds: [embed] }); }; @@ -57,24 +73,23 @@ module.exports = { // send the message in the channel honeypot embedTheMessage(message, channelHoneypot); - // Banna l'utente + // banna l'utente e assegna il ruolo // await message.member.ban({ // reason: 'Honeypot triggered - Suspected bot/malicious activity' // }); - // log debug - console.log(`Banned user ${message.author.tag} (${message.author.id}) for writing in honeypot channel`); - // send the message in the channel log embedTheLog(message, channelLog); - // eliminiamo il messaggio, + // delete the message await message.delete(); - // clearriamo la chat honeypot - const channelHoneypot = message.guild.channels.cache.get(channelHoneypot); - console.log(channelHoneypot); - // channelHoneypot.bulkDelete(5); + // clear recent messages and show info + const honeypotChannel = message.guild.channels.cache.get(channelHoneypot); + + await honeypotChannel.bulkDelete(10).then(() => { + infoHoneypot(message, channelHoneypot); + }); } catch (error) { console.error('Error in honeypot ban:', error); From d27b37716a065e52c615147938671c3d288d6a94 Mon Sep 17 00:00:00 2001 From: MindfulLearner Date: Sun, 20 Jul 2025 18:56:09 +0200 Subject: [PATCH 4/5] working stuff to do alot of embedeeing stuf --- events/honeypot/honey-pot.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/events/honeypot/honey-pot.js b/events/honeypot/honey-pot.js index 6493154..46e0528 100644 --- a/events/honeypot/honey-pot.js +++ b/events/honeypot/honey-pot.js @@ -7,13 +7,13 @@ const channelLog = '1396516358879055962'; // add emoticon for kill streak, and other things, to refactor because // it just delete the infomessagehoneypot -const infoHoneypot = (message, channel) => { +const infoHoneypot = (message, channel, bannedNumber) => { const channelMessage = message.client.channels.cache.get(channel); const embed = new EmbedBuilder() .setColor('#ff0000') .setTitle('⚠️ Honeypot Alert - Info ⚠️') - .setDescription('Benvenuti nel canale Honeypot! Questo canale è progettato per rilevare e gestire attività sospette. Se qualcuno invia un messaggio qui, verrà automaticamente bannato. Si prega di non inviare messaggi in questo canale a meno che non si desideri essere bannati.') + .setDescription(`Benvenuti nel canale Honeypot! Questo canale è progettato per rilevare e gestire attività sospette. Se qualcuno invia un messaggio qui, verrà automaticamente bannato. Si prega di non inviare messaggi in questo canale a meno che non si desideri essere bannati. \nkillstreak: ${bannedNumber}`) .setTimestamp(); channelMessage.send({ embeds: [embed] }); @@ -84,11 +84,16 @@ module.exports = { // delete the message await message.delete(); + // fetch bannati + const guild = message.guild; + const bannati = await guild.bans.fetch(); + const bannedNumber = bannati.size; + // clear recent messages and show info const honeypotChannel = message.guild.channels.cache.get(channelHoneypot); await honeypotChannel.bulkDelete(10).then(() => { - infoHoneypot(message, channelHoneypot); + infoHoneypot(message, channelHoneypot, bannedNumber); }); } catch (error) { From 6f548a842334e5872d74218e06483a0f4e64c6ba Mon Sep 17 00:00:00 2001 From: MindfulLearner Date: Tue, 22 Jul 2025 02:28:43 +0200 Subject: [PATCH 5/5] working honeypot --- events/honeypot/honey-pot.js | 6 +++--- package-lock.json | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/events/honeypot/honey-pot.js b/events/honeypot/honey-pot.js index 46e0528..0d121c5 100644 --- a/events/honeypot/honey-pot.js +++ b/events/honeypot/honey-pot.js @@ -74,9 +74,9 @@ module.exports = { embedTheMessage(message, channelHoneypot); // banna l'utente e assegna il ruolo - // await message.member.ban({ - // reason: 'Honeypot triggered - Suspected bot/malicious activity' - // }); + await message.member.ban({ + reason: 'Honeypot triggered - Suspected bot/malicious activity' + }); // send the message in the channel log embedTheLog(message, channelLog); diff --git a/package-lock.json b/package-lock.json index deb2114..de85ac6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -419,9 +419,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "24.0.14", - "resolved": "https://registry.npmjs.org/@types/node/-/node-24.0.14.tgz", - "integrity": "sha512-4zXMWD91vBLGRtHK3YbIoFMia+1nqEz72coM42C5ETjnNCa/heoj7NT1G67iAfOqMmcfhuCZ4uNpyz8EjlAejw==", + "version": "24.0.15", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.0.15.tgz", + "integrity": "sha512-oaeTSbCef7U/z7rDeJA138xpG3NuKc64/rZ2qmUFkFJmnMsAPaluIifqyWd8hSSMxyP9oie3dLAqYPblag9KgA==", "license": "MIT", "dependencies": { "undici-types": "~7.8.0"