Nary a Package Missing

    discord-chat-filter

    1.6.5 • Public • Published

    Discord Chat Filter ! LetsGoz

    Module to filter the chat of a discord channel.

    How to set the Chat Filter

    const { ChatFilter } = require("discord-chat-filter") // Requiring the package
    const chatFilter = new ChatFilter(message.content) // Create the chat filter

    Functions

    filterBadWord(['f*ck', 'sh*t']) // => If a member types 'f*ck' or 'sh*t', it will return true
    
    filterLink() // => If a member sends a link, it will return true
    
    filterMention() // => If a member mentions (@everyone, @here, @etc) it will return true
    
    filterCaps() // => If a member sends a lot of caps, it will return true

    Example

    const Discord = require('discord.js'); // Requiring Discord
    const intents = new Discord.Intents(); // Intents => Message.content intent is required
    const client = new Discord.Client({ intents: 32767 }); // Bot
    
    client.on('ready', async () => {
        console.log(`${client.user.username} is online`)
    })
    
    client.on('messageCreate', async (message) => { // Event emitted when a message is created
    
        const { ChatFilter } = require('discord-chat-filter'); // Requiring the package
        const chatFilter = new ChatFilter(message.content); // Creating the Chat Filter
    
        if (message.author.bot) return; // Bot messages are not taken
    
        if (chatFilter.filterBadWord(['f*ck', 'sh*t'])) { // Using the filterBadWord() Method
    	message.delete() // Delete the message
    	message.channel.send('No Badwords.') // Send a warning message
    };
    
        if (chatFilter.filterLink()) { // Using the filterLink() Method
    	message.delete() // Delete the message
    	message.channel.send('No Links.') // Send a warning message
    };
    
        if (chatFilter.filterMention()) { // Using the filterMention() Method
    	message.delete() // Delete the message
    	message.channel.send('No Mentions.') // Send a warning message
    };
    
        if (chatFilter.filterCaps()) { // Using the filterCaps() Method
    	message.delete() // Delete the message
    	message.channel.send('Too many caps.') // Send a warning message
        
    };
    
    });
    
    client.login('YOUR TOKEN')

    How to set the Spam Filter

    const { spamfilter } = require("discord-chat-filter") // Requiring the package
    
    client.on('messageCreate', async (message) => { // Event emitted when a message is created
    
        spamfilter({
            message: message,
            messageCount: 10, // Amount of messages sent in a row that will cause a punishment.
            alertMessage: "Hey, [member], please stop spamming.", // Message to be sent in chat when a user is warned
            punishent: 'mute', // Punishment that will be given to the user who spammed
            maxInterval: 5000, // Amount of time (in milliseconds) in which messages are considered spam.
            ignoredMembers: [], // Ignored members list
            removeMessages: true, // Remove spam messages
            logsChannel: "12345678910", // channel to send the modlogs, put the channel ID.
            muteMessage: '[member] has been muted for `spamming.`', // Message to be sent in chat when a user is muted
            kickMessage: "[member] has been kicked for `spamming`.", // Message to be sent in chat when a user is kicked
            banMessage: "[member] has been banned for `spamming`.", // Message to be sent in chat when a user is banned
            muteErrorMessage: "i can't mute [member].",
            kickeErrorMessage: "i can't kick [member].",
            banErrorMessage: "i can't ban [member].",
        })
    
        })

    Example

    const Discord = require('discord.js'); // Requiring Discord
    const intents = new Discord.Intents(); // Intents => Message.content intent is required
    const client = new Discord.Client({ intents: 32767 }); // Bot
    
    const { spamfilter } = require("discord-chat-filter") // Requiring the package
    
    client.on('ready', async () => {
        console.log(`${client.user.username} is online`)
    })
    
    client.on('messageCreate', async (message) => { // Event emitted when a message is created
    
        if(!message.guild) return;
        
        spamfilter({
            message: message,
            messageCount: 10, // Amount of messages sent in a row that will cause a punishment.
            alertMessage: "Hey, [member], please stop spamming.", // Message to be sent in chat when a user is warned
            punishent: 'mute', // Punishment that will be given to the user who spammed
            maxInterval: 5000, // Amount of time (in milliseconds) in which messages are considered spam.
            ignoredMembers: [], // Ignored members list
            removeMessages: true, // Remove spam messages
            logsChannel: "12345678910", // channel to send the modlogs, put the channel ID.
            muteMessage: '[member] has been muted for `spamming.`', // Message to be sent in chat when a user is muted
            kickMessage: "[member] has been kicked for `spamming`.", // Message to be sent in chat when a user is kicked
            banMessage: "[member] has been banned for `spamming`.", // Message to be sent in chat when a user is banned
            muteErrorMessage: "i can't mute [member].",
            kickeErrorMessage: "i can't kick [member].",
            banErrorMessage: "i can't ban [member].",
        })
    
        });
    
        client.login('YOUR TOKEN')

    Install

    npm i discord-chat-filter

    DownloadsWeekly Downloads

    38

    Version

    1.6.5

    License

    MIT

    Unpacked Size

    361 kB

    Total Files

    5

    Last publish

    Collaborators

    • letsgoz