Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions commands/honeypot/honey-pot-data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const { SlashCommandBuilder, PermissionFlagsBits, Client, GatewayIntentBits } = require('discord.js');

Check warning on line 1 in commands/honeypot/honey-pot-data.js

View workflow job for this annotation

GitHub Actions / Build / build (22.x)

'GatewayIntentBits' is assigned a value but never used

Check warning on line 1 in commands/honeypot/honey-pot-data.js

View workflow job for this annotation

GitHub Actions / Build / build (22.x)

'Client' is assigned a value but never used

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);
}
}
}
};
104 changes: 104 additions & 0 deletions events/honeypot/honey-pot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// 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';

// add emoticon for kill streak, and other things, to refactor because
// it just delete the infomessagehoneypot
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. \nkillstreak: ${bannedNumber}`)
.setTimestamp();

channelMessage.send({ embeds: [embed] });
};

/**
*
* send a embeded message in the channel honeypot
*
*/
const embedTheMessage = (message, 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();

channelMessage.send({ embeds: [embed] });
};

/**
*
* send a embeded message in the channel log
* we need this to track how sended the message this
*
*/
const embedTheLog = (message, channel) => {
const channelMessage = message.guild.channels.cache.get(channel);

const embed = new EmbedBuilder()
.setColor('#ff0000')
.setTitle('Honeypot Alert - Log')
.setDescription(`**User:** ${message.author.tag} (${message.author.id})\n**Message:** ${message.content}`)
.setThumbnail(message.author.displayAvatarURL({ dynamic: true }))
.setTimestamp();

channelMessage.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 e assegna il ruolo
await message.member.ban({
reason: 'Honeypot triggered - Suspected bot/malicious activity'
});

// send the message in the channel log
embedTheLog(message, channelLog);

// 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, bannedNumber);
});

} catch (error) {
console.error('Error in honeypot ban:', error);
}
}
},
};
22 changes: 22 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading