discord-spamchecker

A package that allow your bot to determine user is/isn't spamming messages

Usage no npm install needed!

<script type="module">
  import discordSpamchecker from 'https://cdn.skypack.dev/discord-spamchecker';
</script>

README

discord-spamchecker

A package that allow your bot to determine user is/isn't spamming messages


install

type npm install discord-spamchecker to install this package


usage



definition

type this in the file:

const SpamChecker = require('discord-spamchecker');
const checker = new SpamChecker();




check message

inside your bot message event:

client.on("message", message => {
    const result = checker.check(message.author.id, message.guild.id, message);
    if(result === true) {
        console.log(message.author.tag + " is spamming message");
    }
})




getconfig

to get the config,use:

checker.getConfig(GUILD_ID);




update config

to update the config,use:

checker.updateConfig(CONFIG_KEY, VALUE, GUILD_ID);



CONFIG_KEY:

MSG_TIME_DIFF(milliseconds)

The collected data of the user you check will delete if : msg's_createdTimestamp_you_check - createdTimestamp_of_last_msg > MSG_TIME_DIFF
* 2500 <= MSG_TIME_DIFF <= 10000

TIMER_TIMEOUT(milliseconds)

The collected data of the user will be auto delete if : current_time - the_time_of_create_user_data > TIMER_TIMEOUT
* 5000 <= TIMER_TIMEOUT <= 20000

MSG_LIMIT

The user will be determined as spamming if : message_counter_of_user > MSG_LIMIT
* 5 <= MSG_LIMIT <= 10




reset config

to reset the config,use:

checker.resetConfig(GUILD_ID);




delete data

delete the data of a guild

to delete the data of a guild,use:

checker.deleteGuildData(GUILD_ID);

delete the data of a user

to delete the data of a user,use:

checker.deleteUserData(GUILD_ID, USER_ID);

get data

get the data of a guild

to get the data of a guild,use:

checker.getGuildData(GUILD_ID);

get the data of a user

to get the data of a user,use:

checker.getUserData(GUILD_ID, USER_ID);