Advertisement
spiralvibes

Made By ZayDocs | Maverick Team

Oct 26th, 2024
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { Client, GatewayIntentBits, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, ModalBuilder, TextInputBuilder, TextInputStyle, InteractionType } = require('discord.js');
  2. const axios = require('axios');
  3. require('dotenv').config();
  4.  
  5. const client = new Client({
  6.   intents: [
  7.     GatewayIntentBits.Guilds,
  8.     GatewayIntentBits.GuildMessages,
  9.     GatewayIntentBits.MessageContent,
  10.     GatewayIntentBits.AutoModerationConfiguration,
  11.     GatewayIntentBits.AutoModerationExecution
  12.   ]
  13. });
  14.  
  15. const LOG_CHANNEL_ID = "YOUR_LOG_CHANNEL_ID";
  16.  
  17. async function checkProfanity(text) {
  18.   try {
  19.     const response = await axios.get('https://www.purgomalum.com/service/containsprofanity', {
  20.       params: { text }
  21.     });
  22.     return response.data === true;
  23.   } catch (error) {
  24.     console.error('Error checking profanity:', error);
  25.     return false;
  26.   }
  27. }
  28.  
  29. client.once('ready', () => {
  30.   console.log(`Bot is online and ready!`);
  31. });
  32.  
  33. client.on('messageCreate', async (message) => {
  34.   if (message.author.bot) return;
  35.  
  36.   const isProfane = await checkProfanity(message.content);
  37.   if (isProfane) {
  38.     await message.reply({
  39.       embeds: [
  40.         new EmbedBuilder()
  41.           .setColor("#FE424D")
  42.           .setTitle("🚨 Profane Language Detected")
  43.           .setAuthor({ name: "AutoMod", iconURL: "https://media.discordapp.net/attachments/1284126131800244367/1299779497029271675/offline.png" })
  44.           .setDescription("Your message contains prohibited language and has been removed.")
  45.       ],
  46.       components: [
  47.         new ActionRowBuilder().addComponents(
  48.           new ButtonBuilder()
  49.             .setCustomId('appeal')
  50.             .setLabel("Appeal")
  51.             .setStyle(ButtonStyle.Danger)
  52.         )
  53.       ]
  54.     });
  55.     await message.delete();
  56.     console.log(`Message deleted due to profanity.`);
  57.   }
  58. });
  59.  
  60. client.on('interactionCreate', async interaction => {
  61.   if (interaction.isButton() && interaction.customId === 'appeal') {
  62.     const appealModal = new ModalBuilder()
  63.       .setCustomId('appeal_modal')
  64.       .setTitle('Appeal Your Message');
  65.  
  66.     const appealInput = new TextInputBuilder()
  67.       .setCustomId('appeal_reason')
  68.       .setLabel("Reason for Appeal")
  69.       .setStyle(TextInputStyle.Paragraph)
  70.       .setPlaceholder("Explain why your message should not have been flagged.")
  71.       .setRequired(true);
  72.  
  73.     appealModal.addComponents(new ActionRowBuilder().addComponents(appealInput));
  74.     await interaction.showModal(appealModal);
  75.   }
  76.  
  77.   if (interaction.type === InteractionType.ModalSubmit && interaction.customId === 'appeal_modal') {
  78.     const appealReason = interaction.fields.getTextInputValue('appeal_reason');
  79.     const logChannel = await client.channels.fetch(LOG_CHANNEL_ID);
  80.  
  81.     if (logChannel) {
  82.       await logChannel.send({
  83.         embeds: [
  84.           new EmbedBuilder()
  85.             .setColor("#FFD700")
  86.             .setTitle("📝 New Appeal Submitted")
  87.             .setAuthor({ name: interaction.user.tag, iconURL: interaction.user.displayAvatarURL() })
  88.             .addFields(
  89.               { name: "User ID", value: interaction.user.id, inline: true },
  90.               { name: "Appeal Reason", value: appealReason }
  91.             )
  92.             .setTimestamp()
  93.         ]
  94.       });
  95.     }
  96.  
  97.     await interaction.reply({
  98.       content: "Thank you for submitting your appeal. Our team will review it shortly.",
  99.       ephemeral: true
  100.     });
  101.   }
  102. });
  103.  
  104. client.login(process.env.DISCORD_TOKEN);
  105.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement