Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { Client, GatewayIntentBits, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, ModalBuilder, TextInputBuilder, TextInputStyle, InteractionType } = require('discord.js');
- const axios = require('axios');
- require('dotenv').config();
- const client = new Client({
- intents: [
- GatewayIntentBits.Guilds,
- GatewayIntentBits.GuildMessages,
- GatewayIntentBits.MessageContent
- ]
- });
- const LOG_CHANNEL_ID = "YOUR_LOG_CHANNEL_ID";
- async function checkProfanity(text) {
- try {
- const response = await axios.get(`https://www.purgomalum.com/service/containsprofanity?text=${encodeURIComponent(text)}`);
- return response.data === "true";
- } catch (error) {
- console.error('Error checking profanity:', error);
- return false;
- }
- }
- client.once('ready', () => {
- console.log(`Bot is online and ready!`);
- });
- client.on('messageCreate', async (message) => {
- if (message.author.bot) return;
- const isProfane = await checkProfanity(message.content);
- if (isProfane) {
- await message.delete();
- await message.channel.send({
- embeds: [
- new EmbedBuilder()
- .setColor("#FE424D")
- .setTitle("🚨 Profane Language Detected")
- .setAuthor({ name: "AutoMod", iconURL: "https://media.discordapp.net/attachments/1284126131800244367/1299779497029271675/offline.png" })
- .setDescription("Your message contains prohibited language and has been removed.")
- ],
- components: [
- new ActionRowBuilder().addComponents(
- new ButtonBuilder()
- .setCustomId('appeal')
- .setLabel("Appeal")
- .setStyle(ButtonStyle.Danger)
- )
- ],
- ephemeral: true
- });
- console.log(`Profane message deleted.`);
- }
- });
- client.on('interactionCreate', async interaction => {
- if (interaction.isButton() && interaction.customId === 'appeal') {
- const appealModal = new ModalBuilder()
- .setCustomId('appeal_modal')
- .setTitle('Appeal Your Message');
- const appealInput = new TextInputBuilder()
- .setCustomId('appeal_reason')
- .setLabel("Reason for Appeal")
- .setStyle(TextInputStyle.Paragraph)
- .setPlaceholder("Explain why your message should not have been flagged.")
- .setRequired(true);
- appealModal.addComponents(new ActionRowBuilder().addComponents(appealInput));
- await interaction.showModal(appealModal);
- }
- if (interaction.type === InteractionType.ModalSubmit && interaction.customId === 'appeal_modal') {
- const appealReason = interaction.fields.getTextInputValue('appeal_reason');
- const logChannel = await client.channels.fetch(LOG_CHANNEL_ID);
- if (logChannel) {
- await logChannel.send({
- embeds: [
- new EmbedBuilder()
- .setColor("#FFD700")
- .setTitle("📝 New Appeal Submitted")
- .setAuthor({ name: interaction.user.tag, iconURL: interaction.user.displayAvatarURL() })
- .addFields(
- { name: "User ID", value: interaction.user.id, inline: true },
- { name: "Appeal Reason", value: appealReason }
- )
- .setTimestamp()
- ]
- });
- }
- await interaction.reply({
- content: "Thank you for submitting your appeal. Our team will review it shortly.",
- ephemeral: true
- });
- }
- });
- client.login(process.env.DISCORD_TOKEN);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement