Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@devraelfreeze/discordjs-antispam
Advanced tools
A complex module with quick setup and different options to implement anti-spam and auto-moderation features in your bot.
This version of the package will only support discord.js v13
To install this module type the following command in your console:
npm i @devraelfreeze/discordjs-antispam
Options Name | Default Value | Description |
---|---|---|
customGuildOptions | false | Whether to use custom guild options |
unMuteTime | 10 | Time in minutes to wait until unmuting a user. |
modLogsEnabled | false | Whether moderation logs are enabled. |
modLogsChannel | CHANNEL_ID | ID of the channel in which moderation logs will be sent. |
deleteMessagesAfterBanForPastDays | 1 | When a user is banned, their messages sent in the last x days will be deleted. |
verbose | false | Extended logs from module (recommended). |
debug | false | Whether to run the module in debug mode. |
removeMessages | true | Whether to delete user messages after a sanction. |
Options Object Name | Default Value | Description |
---|---|---|
wordsFilter | object | Whether to use words filter system |
wordsFilter.enabled | false | Whether to use links filter system |
wordsFilter.typeSanction | warn | The type of sanction to apply when a member trigger the words filter system |
Options Object Name | Default Value | Description |
---|---|---|
linksFilter | object | Whether to use links filter system |
linksFilter.enabled | false | Whether to use links filter system |
linksFilter.globalLinksFilter | false | Whether to filter global links (all links) |
linksFilter.discordInviteLinksFilter | false | Whether to filter discord invite links |
linksFilter.customLinksFilter | false | Whether to filter custom links per guild |
linksFilter.typeSanction | warn | The type of sanction to apply when a member trigger the links filter system |
Options Object Name | Default Value | Description |
---|---|---|
antispamFilter | object | Whether to use antispam filter system |
enabled | true | Enable / Disable antispam filter system |
thresholds | object | Thresholds Object (See below for Options Object) |
maxDuplicates | object | MaxDuplicates Object (See below for Options Object) |
maxInterval | 3000 | Amount of time (ms) in which messages are considered spam. |
maxDuplicatesInterval | 3000 | Amount of time (ms) in which duplicate messages are considered spam. |
Options Object Name | Default Value | Description |
---|---|---|
thresholds | object | Amount of messages sent in a row that will cause a warning / mute / kick / ban. |
thresholds.warn | 4 | Amount of messages sent in a row that will cause a warning. |
thresholds.mute | 5 | Amount of messages sent in a row that will cause a mute. |
thresholds.kick | 6 | Amount of messages sent in a row that will cause a kick. |
thresholds.ban | 8 | Amount of messages sent in a row that will cause a ban. |
Options Object Name | Default Value | Description |
---|---|---|
maxDuplicates | object | Amount of duplicate messages that trigger a warning / mute / kick / ban. |
maxDuplicates.warn | 4 | Amount of duplicate messages sent in a row that will trigger a warning. |
maxDuplicates.mute | 5 | Amount of duplicate messages sent in a row that will trigger a mute. |
maxDuplicates.kick | 6 | Amount of duplicate messages sent in a row that will trigger a kick. |
maxDuplicates.ban | 8 | Amount of duplicate messages sent in a row that will trigger a ban |
Options Object Name | Default Value | Description |
---|---|---|
message | object | Messages that will be sent when a sanction is applied. |
message.warn | '{@user} has been warned for reason: **{reason}**' | Message that will be sent when someone is warned. |
message.mute | '@{user} has been muted for reason: **{reason}**' | Message that will be sent when someone is muted. |
message.kick | '**{user_tag}** has been kicked for reason: **{reason}**' | Message that will be sent when someone is kicked. |
message.ban | '**{user_tag}** has been banned for reason: **{reason}**' | Message that will be sent when someone is banned. |
message.logs | '{@user} '({user_id})' has been **${action}** for **${reason}** !' | Message logs system (with modLogs Channel & Enabled) |
Options Object Name | Default Value | Description |
---|---|---|
errorMessage | object | Whether the bot should send a message when it doesn't have some required permissions |
errorMessage.enabled | true | Enable / Disable the errorMessage system |
errorMessage.mute | 'Could not mute @{user} because of improper permissions.' | Message that will be sent when the bot doesn't have enough permissions to mute the member |
errorMessage.kick | 'Could not kick @{user} because of improper permissions.' | Message that will be sent when the bot doesn't have enough permissions to kick the member |
errorMessage.ban | 'Could not ban @{user} because of improper permissions.' | Message that will be sent when the bot doesn't have enough permissions to ban the member |
Options Object Name | Default Value | Description |
---|---|---|
ignore | object | Configuration of roles / members / channels / permissions to ignore |
ignore.members | [] | Array of member IDs (or Function) that are ignored. |
ignore.roles | [] | Array of role IDs or role names (or Function) that are ignored. Members with one of these roles will be ignored. |
ignore.channels | [] | Array of channel IDs or channel names (or Function) that are ignored. |
ignore.permissions | [] | Users with at least one of these permissions will be ignored. |
ignore.bots | true | Whether bots should be ignored. |
Options Object Name | Default Value | Description |
---|---|---|
enable | object | Enable / Disable sanction system |
enable.warn | true | Whether to enable warnings. |
enable.mute | true | Whether to enable mutes. |
enable.kick | true | Whether to enable kicks. |
enable.ban | true | Whether to enable bans. |
/** See all options above */
const AntiSpam = require("@devraelfreeze/discordjs-antispam");
const antiSpam = new AntiSpam(client, {
wordsFilter: {
enabled: false,
typeSanction: 'warn', // warn or mute or ban or kick
},
antispamFilter: {
thresholds: {
warn: 4,
mute: 6,
kick: 8,
ban: 10
},
maxDuplicates: {
warn: 4,
mute: 6,
kick: 8,
ban: 10
},
maxInterval: 3000,
maxDuplicatesInterval: 3000,
},
linksFilter: {
enabled: false,
globalLinksFilter: false,
discordInviteLinksFilter: false,
customLinksFilter: false,
typeSanction: 'warn'
},
unMuteTime: 10,
deleteMessagesAfterBanForPastDays: 1,
verbose: true,
debug: false,
removeMessages: true
});
const Discord = require("discord.js");
const client = new Discord.Client({
intents: [Discord.Intents.FLAGS.GUILDS, Discord.Intents.FLAGS.GUILD_MESSAGES,
Discord.Intents.FLAGS.GUILD_MEMBERS, Discord.Intents.FLAGS.GUILDS]
});
const AntiSpam = require("@devraelfreeze/discordjs-antispam");
const antiSpam = new AntiSpam(client, {
/** Options of AntiSpam Client here */
});
client.on("ready", () => console.log(`Logged in as ${client.user.tag}.`));
client.on("messageCreate", async (message) => {
/** Add message in cache */
await antiSpam.addMessagesCache(message); // You must do this if you want to use antispamFilter System
await antiSpam.messageAntiSpam(message);
});
/** Login the bot */
client.login("VERY SECRET TOKEN HERE :)");
const Discord = require("discord.js");
const client = new Discord.Client({
intents: [Discord.Intents.FLAGS.GUILDS, Discord.Intents.FLAGS.GUILD_MESSAGES,
Discord.Intents.FLAGS.GUILD_MEMBERS, Discord.Intents.FLAGS.GUILDS]
});
const AntiSpam = require("@devraelfreeze/discordjs-antispam");
const antiSpam = new AntiSpam(client, {customGuildOptions: true});
client.on("ready", async () => {
console.log(`Logged in as ${client.user.tag}.`)
/** Custom guild options in Object */
const guildId = "123456789012345678";
const guildOptions = {/** Options of AntiSpam */};
await antiSpam.setGuildOptions(guildId, guildOptions);
});
client.on("messageCreate", async (message) => {
await antiSpam.addMessagesCache(message); // You must do this if you want to use antispamFilter System
await antiSpam.addMessagesCache(message);
});
/** Login the bot */
client.login("VERY SECRET TOKEN HERE :)");
/** Declare & Use module with 'messageCreate' event */
client.on("messageCreate", async (message) => {
const contain_words = await antiSpam.messageWordsFilter(message);
if (conatin_words) {
/** Message contain word(s) */
} else {
/** Message doesn't contain word(s) */
}
/** Get array of bad words usages in message
* return : getBadWords = ['bad word', 'bad word', 'bad word'];
*/
const getBadWords = await antiSpam.messageBadWordsUsages(message);
/**
* Add custom word to the list for a guild. You can also use Array of words
* @param {string|Array<string>} word(s) - Words to add
* @param {string} guild_id - ID of the guild
* @returns {Promise<boolean>} true if added or false if not added
*/
const addWord = await antiSpam.addWords('bad word', message.guild.id);
/**
* Remove custom word from the list for a guild. You can also use Array of words
* @param {string|Array<string>} word(s) - Words to remove
* @param {string} guild_id - ID of the guild
* @returns {Promise<boolean>} true if removed or false if not removed.
*/
const removeWord = await antiSpam.removeWords('bad word', message.guild.id);
/**
* Get words list for a guild.
* @param {string} guild_id - ID of the guild
* @returns {Promise<Array<string>>} Array of words
*/
const wordsList = await antiSpam.listWords(message.guild.id);
});
/** Declare & Use module with 'messageCreate' event */
client.on("messageCreate", async (message) => {
const contain_words = await antiSpam.messageLinksFilter(message);
if (conatin_words) {
/** Message contain link(s) */
} else {
/** Message doesn't contain link(s) */
}
/**
* Add link / links for a guild
* @param {string|Array<string>} links - Links to add
* @param {string} guild_id - ID of the guild
* @returns {Promise<boolean>} true if added or false if not added
*/
const addLink = await antiSpam.addLinks('https://discord.gg/123456789', message.guild.id);
/**
* Remove link / links for a guild
* @param {string|Array<string>} links - Links to remove
* @param {string} guild_id - ID of the guild
* @returns {Promise<boolean>} true if removed or false if not removed.
*/
const removeLink = await antiSpam.removeLinks('https://discord.gg/123456789', message.guild.id);
/**
* Get links list for a guild.
* @param {string} guild_id - ID of the guild
* @returns {Promise<Array<string>>} Array of links
*/
const linksList = await antiSpam.listLinks(message.guild.id);
});
Words Filter System
(Can configure the words list to filter)Anti Discord Invites Links System
Anti Links System
(Can configure links to filter)Mass Mentions System
Emojis excessifs System
If you have any bugs or trouble setting the module up, feel free to open an issue on Github Repository
Freeze#0123
If you want to use old version, you can use command
npm i @devraelfreeze/discordjs-antispam@<version>
Copyright © 2022 devRael1
This project is MIT licensed.
This is not an official Discord product. It is not affiliated with or endorsed by Discord Inc.
FAQs
Complex Antispam & AutoMod module for Discord JS v13 & v14
The npm package @devraelfreeze/discordjs-antispam receives a total of 0 weekly downloads. As such, @devraelfreeze/discordjs-antispam popularity was classified as not popular.
We found that @devraelfreeze/discordjs-antispam demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.