// Guild subcommands const colors = require('colors'); module.exports = async (interaction, db, client) => { if (interaction.commandName !== 'guild') return; const subcommand = interaction.options.getSubcommand(); switch (subcommand) { case 'autoadd': { const listId = interaction.options.getString('list_id'); const enabled = interaction.options.getBoolean('enabled'); // Check if the guild is joined to the list db.get(`SELECT * FROM guilds WHERE guild_id = ? AND list_id = ?`, [interaction.guild.id, listId], (err, row) => { if (err) { console.error(err); return interaction.reply({ content: '❌ An error occurred while accessing the database.', ephemeral: true }); } if (!row) { return interaction.reply({ content: '❌ This guild is not joined to the specified ban list.', ephemeral: true }); } // Update auto_add setting db.run(`UPDATE guilds SET auto_add = ? WHERE guild_id = ? AND list_id = ?`, [enabled ? 1 : 0, interaction.guild.id, listId], (err) => { if (err) { console.error(err); return interaction.reply({ content: '❌ An error occurred while updating the database.', ephemeral: true }); } interaction.reply({ content: `✅ Auto-add from the ban list has been ${enabled ? 'enabled' : 'disabled'}.`, ephemeral: true }); }); }); } break; case 'autoremove': { const listId = interaction.options.getString('list_id'); const enabled = interaction.options.getBoolean('enabled'); // Check if the guild is joined to the list db.get(`SELECT * FROM guilds WHERE guild_id = ? AND list_id = ?`, [interaction.guild.id, listId], (err, row) => { if (err) { console.error(err); return interaction.reply({ content: '❌ An error occurred while accessing the database.', ephemeral: true }); } if (!row) { return interaction.reply({ content: '❌ This guild is not joined to the specified ban list.', ephemeral: true }); } // Update auto_remove setting db.run(`UPDATE guilds SET auto_remove = ? WHERE guild_id = ? AND list_id = ?`, [enabled ? 1 : 0, interaction.guild.id, listId], (err) => { if (err) { console.error(err); return interaction.reply({ content: '❌ An error occurred while updating the database.', ephemeral: true }); } interaction.reply({ content: `✅ Auto-remove from the ban list has been ${enabled ? 'enabled' : 'disabled'}.`, ephemeral: true }); }); }); } break; case "join": { // then fucking impliment it const listId = interaction.options.getString('list_id'); // Check if the list exists db.get(`SELECT * FROM lists WHERE id = ?`, [listId], (err, list) => { if (err) { console.error(err); return interaction.reply({ content: '❌ An error occurred while accessing the database.', ephemeral: true }); } if (!list) { return interaction.reply({ content: '❌ The specified ban list does not exist.', ephemeral: true }); } // Check if the guild is already joined to the list db.get(`SELECT * FROM guilds WHERE guild_id = ? AND list_id = ?`, [interaction.guild.id, listId], (err, row) => { if (err) { console.error(err); return interaction.reply({ content: '❌ An error occurred while accessing the database.', ephemeral: true }); } if (row) { return interaction.reply({ content: '❌ This guild is already joined to the specified ban list.', ephemeral: true }); } // Join the guild to the list db.run(`INSERT INTO guilds (guild_id, list_id, auto_add, auto_remove) VALUES (?, ?, 0, 0)`, [interaction.guild.id, listId], (err) => { if (err) { console.error(err); return interaction.reply({ content: '❌ An error occurred while updating the database.', ephemeral: true }); } interaction.reply({ content: `✅ This guild has successfully joined the ban list "${list.name}".`, ephemeral: true }); }); }); }); } break; case "leave": { const listId = interaction.options.getString('list_id'); // Check if the guild is joined to the list db.get(`SELECT * FROM guilds WHERE guild_id = ? AND list_id = ?`, [interaction.guild.id, listId], (err, row) => { if (err) { console.error(err); return interaction.reply({ content: '❌ An error occurred while accessing the database.', ephemeral: true }); } if (!row) { return interaction.reply({ content: '❌ This guild is not joined to the specified ban list.', ephemeral: true }); } // Leave the guild from the list db.run(`DELETE FROM guilds WHERE guild_id = ? AND list_id = ?`, [interaction.guild.id, listId], (err) => { if (err) { console.error(err); return interaction.reply({ content: '❌ An error occurred while updating the database.', ephemeral: true }); } interaction.reply({ content: `✅ This guild has successfully left the ban list.`, ephemeral: true }); }); }); } break; case 'sync': { // Manual sync logic to be implemented await interaction.reply({ content: '🔄 Manual sync initiated. (Not yet implemented)', ephemeral: true }); } break; default: await interaction.reply({ content: '❌ Unknown subcommand.', ephemeral: true }); } };