From bce23c047530db9118cfc5fff790f939a9eed4e4 Mon Sep 17 00:00:00 2001 From: TheUntraceable Date: Fri, 24 Dec 2021 14:37:02 +0000 Subject: [PATCH 1/8] Move mutes over to Timeouts --- index.js | 52 ++++++++++------------------------------------------ 1 file changed, 10 insertions(+), 42 deletions(-) diff --git a/index.js b/index.js index d1a3c9f..f21ae2f 100644 --- a/index.js +++ b/index.js @@ -42,12 +42,6 @@ const { EventEmitter } = require('events') * @event AntiSpamClient#muteAdd * @property {Discord.GuildMember} member The member that was muted. */ -/** - * Emitted when a member gets unmuted. - * @event AntiSpamClient#muteRemove - * @property {Discord.GuildMember} member The member that was unmuted. - */ - /** * Emitted when a member gets banned. * @event AntiSpamClient#banAdd @@ -71,8 +65,7 @@ const { EventEmitter } = require('events') * @property {number} [maxDuplicatesKick=10] Amount of duplicate messages that trigger a kick. * @property {number} [maxDuplicatesBan=11] Amount of duplicate messages that trigger a ban. * - * @property {string|Discord.Snowflake} [muteRoleName='Muted'] Name or ID of the role that will be added to users if they got muted. - * @property {number} [unMuteTime='0'] Time in minutes to wait until unmuting a user. 0=never. + * @property {number} [unMuteTime='0'] Time in ms to wait until unmuting a user. * @property {string|Discord.Snowflake} [modLogsChannelName='mod-logs'] Name or ID of the channel in which moderation logs will be sent. * @property {boolean} [modLogsEnabled=false] Whether moderation logs are enabled. * @property {string} [modLogsMode='embed'] Whether send moderations logs in an discord embed or normal message! Options: 'embed' or 'message". @@ -84,8 +77,8 @@ const { EventEmitter } = require('events') * * @property {boolean} [errorMessages=true] Whether the bot should send a message in the channel when it doesn't have some required permissions, like it can't kick members. * @property {string} [kickErrorMessage='Could not kick **{user_tag}** because of improper permissions.'] Message that will be sent in the channel when the bot doesn't have enough permissions to kick the member. - * @property {string} [muteErrorMessage='Could not ban **{user_tag}** because of improper permissions.'] Message that will be sent in the channel when the bot doesn't have enough permissions to mute the member (to add the mute role). - * @property {string} [banErrorMessage='Could not mute **{user_tag}** because of improper permissions or the mute role couldn\'t be found.'] Message that will be sent in the channel when the bot doesn't have enough permissions to ban the member. + * @property {string} [banErrorMessage='Could not ban **{user_tag}** because of improper permissions.'] Message that will be sent in the channel when the bot doesn't have enough permissions to mute the member (to add the mute role). + * @property {string} [muteErrorMessage='Could not mute **{user_tag}** because of improper permissions.'] Message that will be sent in the channel when the bot doesn't have enough permissions to ban the member. * * @property {Discord.Snowflake|string[]|IgnoreMemberFunction} [ignoredMembers=[]] Array of member IDs that are ignored. * @property {Discord.Snowflake|string[]|IgnoreRoleFunction} [ignoredRoles=[]] Array of role IDs or role names that are ignored. Members with one of these roles will be ignored. @@ -158,8 +151,7 @@ class AntiSpamClient extends EventEmitter { maxDuplicatesKick: options.maxDuplicatesKick || 10, maxDuplicatesBan: options.maxDuplicatesBan || 11, - muteRoleName: options.muteRoleName || 'Muted', - unMuteTime: options.unMuteTime || 0, + unMuteTime: options.unMuteTime || 300000, modLogsChannelName: options.modLogsChannelName || 'mod-logs', modLogsEnabled: options.modLogsEnabled || false, @@ -173,7 +165,7 @@ class AntiSpamClient extends EventEmitter { errorMessages: options.errorMessages != undefined ? options.errorMessages : true, kickErrorMessage: options.kickErrorMessage || 'Could not kick **{user_tag}** because of improper permissions.', banErrorMessage: options.banErrorMessage || 'Could not ban **{user_tag}** because of improper permissions.', - muteErrorMessage: options.muteErrorMessage || 'Could not mute **{user_tag}** because of improper permissions or the mute role couldn\'t be found.', + muteErrorMessage: options.muteErrorMessage || 'Could not mute **{user_tag}** because of improper permissions.', ignoredMembers: options.ignoredMembers || [], ignoredRoles: options.ignoredRoles || [], @@ -206,7 +198,6 @@ class AntiSpamClient extends EventEmitter { messages: [], warnedUsers: [], kickedUsers: [], - mutedUsers: [], bannedUsers: [] } } @@ -349,12 +340,10 @@ class AntiSpamClient extends EventEmitter { this.clearSpamMessages(spamMessages, message.client) } this.cache.messages = this.cache.messages.filter((u) => u.authorID !== message.author.id) - this.cache.mutedUsers.push(message.author.id) - const role = message.guild.roles.cache.find(role => role.name === this.options.muteRoleName) - const userCanBeMuted = role && message.guild.me.permissions.has('MANAGE_ROLES') && (message.guild.me.roles.highest.position > message.member.roles.highest.position) + const userCanBeMuted = message.guild.me.permissions.has('MODERATE_MEMBERS') && (message.guild.me.roles.highest.position > message.member.roles.highest.position && message.member.id !== message.guild.ownerId) if (!userCanBeMuted) { if (this.options.verbose) { - console.log(`DAntiSpam (kickUser#userNotMutable): ${message.author.tag} (ID: ${message.author.id}) could not be muted, improper permissions or the mute role couldn't be found.`) + console.log(`DAntiSpam (kickUser#userNotMutable): ${message.author.tag} (ID: ${message.author.id}) could not be muted, improper permissions.`) } if (this.options.errorMessages) { await message.channel @@ -367,8 +356,7 @@ class AntiSpamClient extends EventEmitter { } return false } - if (message.member.roles.cache.has(role.id)) return true - await message.member.roles.add(role, 'Spamming') + await message.member.timeout(this.options.unMuteTime, 'Spamming') if (this.options.muteMessage) { await message.channel.send(this.format(this.options.muteMessage, message)).catch(e => { if (this.options.verbose) { @@ -380,7 +368,6 @@ class AntiSpamClient extends EventEmitter { this.log(message, `muted`, message.client) } this.emit('muteAdd', member) - this.timeMute(member, message, role) return true } @@ -533,7 +520,7 @@ class AntiSpamClient extends EventEmitter { } - const userCanBeMuted = options.muteEnabled && !this.cache.mutedUsers.includes(message.author.id) && !sanctioned + const userCanBeMuted = options.muteEnabled && !sanctioned if (userCanBeMuted && (spamMatches.length >= options.muteThreshold)) { this.muteUser(message, member, spamMatches) sanctioned = true @@ -577,7 +564,6 @@ class AntiSpamClient extends EventEmitter { if (isGuildIgnored) return false this.cache.bannedUsers = this.cache.bannedUsers.filter((u) => u !== member.user.id) - this.cache.mutedUsers = this.cache.mutedUsers.filter((u) => u !== member.user.id) this.cache.kickedUsers = this.cache.kickedUsers.filter((u) => u !== member.user.id) this.cache.warnedUsers = this.cache.warnedUsers.filter((u) => u !== member.user.id) @@ -589,23 +575,6 @@ class AntiSpamClient extends EventEmitter { * @param {Discord.GuildMember} member The member to the role from * @returns {Promise} Whether the role has been removed */ - async timeMute(member, message, role) { - const minutestime = this.options.unMuteTime * 60 * 1000 - if(minutestime != 0) { - setTimeout(() => { - member.roles.remove(role) - this.cache.mutedUsers = this.cache.mutedUsers.filter((u) => u !== member.user.id) - if (this.options.modLogsEnabled) { - this.log(message, `unmutted`, message.client) - } - this.emit('muteRemove', member) - return true - }, minutestime) - - }else { - return null; - } - } /** * Reset the cache of this AntiSpam client instance. @@ -615,10 +584,9 @@ class AntiSpamClient extends EventEmitter { messages: [], warnedUsers: [], kickedUsers: [], - mutedUsers: [], bannedUsers: [] } } } -module.exports = AntiSpamClient +module.exports = AntiSpamClient \ No newline at end of file From 7ec0f8cc3358c2c5782f329d4c9ac6c3e1f07db8 Mon Sep 17 00:00:00 2001 From: TheUntraceable Date: Fri, 24 Dec 2021 14:46:10 +0000 Subject: [PATCH 2/8] Update README removing mentions of muteRole --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index abf074f..7eb430f 100644 --- a/README.md +++ b/README.md @@ -45,8 +45,7 @@ const antiSpam = new AntiSpam({ ignoreBots: true, // Ignore bot messages. verbose: true, // Extended Logs from module. ignoredMembers: [], // Array of User IDs that get ignored. - muteRoleName: "Muted", // Name of the role that will be given to muted users! - unMuteTime: 0, // Amount of time (in minutes) a user will be muted for. + unMuteTime: 10, // Amount of time (in minutes) a user will be muted for. removeMessages: true, // If the bot should remove all the spam messages when taking action on a user! modLogsEnabled: false, // If to enable modlogs modLogsChannelName: "mod-logs", // channel to send the modlogs too! @@ -82,8 +81,7 @@ const antiSpam = new AntiSpam({ ignoreBots: true, verbose: true, ignoredMembers: [], - muteRoleName: "Muted", - unMuteTime: 0, + unMuteTime: 10, removeMessages: true, modLogsEnabled: false, modLogsChannelName: "mod-logs", From 8cc91eb1326ede365d312175e0e7bd03b8a2f468 Mon Sep 17 00:00:00 2001 From: TheUntraceable Date: Fri, 24 Dec 2021 14:46:36 +0000 Subject: [PATCH 3/8] Convert unMuteTime to ms for ease --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index f21ae2f..db1f0ff 100644 --- a/index.js +++ b/index.js @@ -151,7 +151,7 @@ class AntiSpamClient extends EventEmitter { maxDuplicatesKick: options.maxDuplicatesKick || 10, maxDuplicatesBan: options.maxDuplicatesBan || 11, - unMuteTime: options.unMuteTime || 300000, + unMuteTime: options.unMuteTime * 60_000 || 300000, modLogsChannelName: options.modLogsChannelName || 'mod-logs', modLogsEnabled: options.modLogsEnabled || false, From 74ac50647d752489c0c19fe824f026d261efa962 Mon Sep 17 00:00:00 2001 From: TheUntraceable Date: Fri, 24 Dec 2021 14:52:03 +0000 Subject: [PATCH 4/8] Change documentation for the unMuteTime property --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index db1f0ff..6a1adf7 100644 --- a/index.js +++ b/index.js @@ -65,7 +65,7 @@ const { EventEmitter } = require('events') * @property {number} [maxDuplicatesKick=10] Amount of duplicate messages that trigger a kick. * @property {number} [maxDuplicatesBan=11] Amount of duplicate messages that trigger a ban. * - * @property {number} [unMuteTime='0'] Time in ms to wait until unmuting a user. + * @property {number} [unMuteTime='0'] Time in minutes to wait until unmuting a user. * @property {string|Discord.Snowflake} [modLogsChannelName='mod-logs'] Name or ID of the channel in which moderation logs will be sent. * @property {boolean} [modLogsEnabled=false] Whether moderation logs are enabled. * @property {string} [modLogsMode='embed'] Whether send moderations logs in an discord embed or normal message! Options: 'embed' or 'message". From 0fc056aee57bce431a1f3abf38c44c218584c3a1 Mon Sep 17 00:00:00 2001 From: TheUntraceable Date: Fri, 24 Dec 2021 14:56:18 +0000 Subject: [PATCH 5/8] Remove muteRole mention --- index.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 9d99122..b22468c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -51,7 +51,6 @@ declare module 'discord-anti-spam' { bannedUsers: Snowflake[]; kickedUsers: Snowflake[]; warnedUsers: Snowflake[]; - mutedUsers: Snowflake[]; }; type AntiSpamOptions = { @@ -81,7 +80,6 @@ declare module 'discord-anti-spam' { kickEnabled?: boolean; banEnabled?: boolean; muteEnabled?: boolean; - muteRoleName?: String; modLogsChannelName?: string; modLogsEnabled?: boolean; removeMessages?: boolean; From 0e05e0131a67f5c476b90c30931cb5da271761d7 Mon Sep 17 00:00:00 2001 From: TheUntraceable Date: Mon, 27 Dec 2021 15:28:41 +0000 Subject: [PATCH 6/8] Add support for individual guilds having seperate options --- index.js | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 6a1adf7..cf40bfa 100644 --- a/index.js +++ b/index.js @@ -200,6 +200,8 @@ class AntiSpamClient extends EventEmitter { kickedUsers: [], bannedUsers: [] } + + this.guildOptions = {} } /** @@ -439,6 +441,17 @@ class AntiSpamClient extends EventEmitter { return true } + /** + * Returns the options for a Guild + * @ignore + * @param {Discord.Guild} guild The guild to get the options for. + * @returns {Object} The options for the guild. + */ + + getOptions (guild) { + return this.guildOptions[guild.id] || this.options + } + /** * Checks a message. * @param {Discord.Message} message The message to check. @@ -449,7 +462,8 @@ class AntiSpamClient extends EventEmitter { * }); */ async message (message) { - const { options } = this + const options = this.getOptions() + if ( !message.guild || message.author.id === message.client.user.id || @@ -571,10 +585,30 @@ class AntiSpamClient extends EventEmitter { } /** - * Removes the muted role from member after specefic time - * @param {Discord.GuildMember} member The member to the role from - * @returns {Promise} Whether the role has been removed + * Add GuildOptions for a guild to use instead of the default options. + * @param {Discord.Guild} guild The guild to add the options for. + * @param {AntiSpamClientOptions} options The options to use for the guild. + * @returns {boolean} Whether the options have been added. */ + addGuildOptions (guild, options) { + const guildId = guild.id + + if (this.guildOptions.has(guildId)) { // Check if the guild already has options + + for (setting, value of options.entries()) { // If they do iterate over the settings and their values + this.guildOptions.guildId[setting] = value // And now write them, this avoids overwriting the value set for options not mentioned. + + } + + return true + + } else { + + this.guildOptions.set(guildId, options) + return true + + } + } /** * Reset the cache of this AntiSpam client instance. From 4b929cd76b94d2245aca7245bf0be60aa6fe6a20 Mon Sep 17 00:00:00 2001 From: TheUntraceable Date: Tue, 28 Dec 2021 15:41:18 +0000 Subject: [PATCH 7/8] Fix error --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index cf40bfa..df60924 100644 --- a/index.js +++ b/index.js @@ -595,7 +595,7 @@ class AntiSpamClient extends EventEmitter { if (this.guildOptions.has(guildId)) { // Check if the guild already has options - for (setting, value of options.entries()) { // If they do iterate over the settings and their values + for ([setting, value] of options.entries()) { // If they do iterate over the settings and their values this.guildOptions.guildId[setting] = value // And now write them, this avoids overwriting the value set for options not mentioned. } From 31a33e1a212b259388d6490525489766417c9c4a Mon Sep 17 00:00:00 2001 From: TheUntraceable Date: Tue, 28 Dec 2021 16:03:46 +0000 Subject: [PATCH 8/8] Update README.md --- README.md | 42 ++++- docs/AntiSpamClient.html | 338 +++++++++++++-------------------------- docs/global.html | 52 +----- docs/index.html | 45 +++++- 4 files changed, 199 insertions(+), 278 deletions(-) diff --git a/README.md b/README.md index 7eb430f..69202f9 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,46 @@ const antiSpam = new AntiSpam({ }); ``` +## Multiple Guild Example +Because of a new update, you may now have multiple guilds having their own options. You will need to store their options in a database or something similar to avoid loss of settings. +```js +const Discord = require("discord.js"); +const client = new Discord.Client({ + intents: [Discord.Intents.FLAGS.GUILDS, Discord.Intents.FLAGS.GUILD_MESSAGES], +}); +const AntiSpam = require("discord-anti-spam"); + +const antiSpam = new AntiSpam({ + warnThreshold: 3, + muteThreshold: 4, + kickThreshold: 7, + banThreshold: 7, + maxInterval: 2000, + warnMessage: "{@user}, Please stop spamming.", + kickMessage: "**{user_tag}** has been kicked for spamming.", + muteMessage: "**{user_tag}** has been muted for spamming.", + banMessage: "**{user_tag}** has been banned for spamming.", + maxDuplicatesWarning: 6, + maxDuplicatesKick: 10, + maxDuplicatesBan: 12, + maxDuplicatesMute: 8, + ignoredPermissions: ["ADMINISTRATOR"], + ignoreBots: true, + verbose: true, + ignoredMembers: [], + unMuteTime: 10, + removeMessages: true, + modLogsEnabled: false, + modLogsChannelName: "mod-logs", + modLogsMode: "embed", +}); // If a guild does not have any separate options, these are the settings they will be using. + +client.on("ready", () => antiSpam.addGuildOptions(client.guilds.fetch("583920432168828938"), {modLogsChannelName: "special-logs"})) +client.on("messageCreate", (message) => antiSpam.message(messageCreate)); +client.login("YOUR_SUPER_SECRET_TOKEN"); +``` + + ## Support Server Join our [Support Server](https://discord.gg/KQgDfGr) where we help you with issues regarding the module. @@ -102,4 +142,4 @@ If you have any bugs or trouble setting the module up, feel free to open an issu Copyright © 2019 [Michael-J-Scofield](https://github.com/Michael-J-Scofield)
This project is MIT licensed. ---- +--- \ No newline at end of file diff --git a/docs/AntiSpamClient.html b/docs/AntiSpamClient.html index 35de5b9..dba3af5 100644 --- a/docs/AntiSpamClient.html +++ b/docs/AntiSpamClient.html @@ -24,7 +24,7 @@
@@ -353,7 +353,7 @@

Methods

-

(async) message(message) → {Promise.<boolean>}

+

addGuildOptions(guild, options) → {boolean}

@@ -361,7 +361,7 @@

(async) messag
-

Checks a message.

+

Add GuildOptions for a guild to use instead of the default options.

@@ -436,13 +436,13 @@

Parameters:
- message + guild -Discord.Message +Discord.Guild @@ -453,7 +453,33 @@
Parameters:
-

The message to check.

+

The guild to add the options for.

+ + + + + + + + + options + + + + + +AntiSpamClientOptions + + + + + + + + + + +

The options to use for the guild.

@@ -488,7 +514,7 @@
Returns:
-Promise.<boolean> +boolean
@@ -496,7 +522,7 @@
Returns:
-

Whether the message has triggered a threshold.

+

Whether the options have been added.

@@ -506,13 +532,6 @@
Returns:
-
-
Example
- -
client.on('message', (msg) => {
	antiSpam.message(msg);
});
- -
-
@@ -521,91 +540,7 @@
Example
-

reset()

- - - - - - -
-

Reset the cache of this AntiSpam client instance.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - -

(async) timeMute(member) → {Promise.<boolean>}

+

(async) message(message) → {Promise.<boolean>}

@@ -613,7 +548,7 @@

(async) timeM
-

Removes the muted role from member after specefic time

+

Checks a message.

@@ -688,13 +623,13 @@

Parameters:
- member + message -Discord.GuildMember +Discord.Message @@ -705,7 +640,7 @@
Parameters:
-

The member to the role from

+

The message to check.

@@ -748,7 +683,7 @@
Returns:
-

Whether the role has been removed

+

Whether the message has triggered a threshold.

@@ -758,6 +693,13 @@
Returns:
+
+
Example
+ +
client.on('message', (msg) => {
	antiSpam.message(msg);
});
+ +
+
@@ -766,7 +708,7 @@
Returns:
-

(async) userleave(member) → {Promise.<boolean>}

+

reset()

@@ -774,7 +716,7 @@

(async) user
-

Checks if the user left the server to remove him from the cache!

+

Reset the cache of this AntiSpam client instance.

@@ -824,56 +766,13 @@

(async) user -

Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
member - - -Discord.GuildMember - - - - -

The member to remove from the cache.

- -
@@ -885,83 +784,76 @@
Parameters:
+ + + +
+ + +

(async) userleave(member) → {Promise.<boolean>}

+ + -
-
Returns:
- +
+

Checks if the user left the server to remove him from the cache!

+
-
-
- Type: -
-
- -Promise.<boolean> -
-
-
-

Whether the member has been removed

-
+
-
+ + + + -
-
Example
+ -
client.on('guildMemberRemove', (member) => {
	antiSpam.userleave(member);
});
+ -
+ -
- -

Events

- - -
+ -

banAdd

+ + -
-

Emitted when a member gets banned.

-
-
Properties:
+
Parameters:
- +
@@ -999,11 +891,12 @@
Properties:
- + - -

The member that was banned.

+

The member to remove from the cache.

+ +
@@ -1011,68 +904,63 @@
Properties:
-
- - - - - - - - - - - - +
+
Returns:
- + - +
+
+ Type: +
+
+ +Promise.<boolean> - - +
+
+

Whether the member has been removed

+
+ +
+
+
Example
+
client.on('guildMemberRemove', (member) => {
	antiSpam.userleave(member);
});
+
+
+ + + + +

Events

- - - - - - - - - - - - - -
@@ -1080,7 +968,7 @@
Properties:
-

kickAdd

+

banAdd

@@ -1088,7 +976,7 @@

kickAdd

-

Emitted when a member gets kicked.

+

Emitted when a member gets banned.

@@ -1137,7 +1025,7 @@
Properties:
-

The member that was kicked.

+

The member that was banned.

@@ -1218,7 +1106,7 @@
Properties:
-

muteAdd

+

kickAdd

@@ -1226,7 +1114,7 @@

muteAdd

-

Emitted when a member gets muted.

+

Emitted when a member gets kicked.

@@ -1275,7 +1163,7 @@
Properties:
-

The member that was muted.

+

The member that was kicked.

@@ -1356,7 +1244,7 @@
Properties:
-

muteRemove

+

muteAdd

@@ -1364,7 +1252,7 @@

muteRemove

-

Emitted when a member gets unmuted.

+

Emitted when a member gets muted.

@@ -1413,7 +1301,7 @@
Properties:
-

The member that was unmuted.

+

The member that was muted.

diff --git a/docs/global.html b/docs/global.html index 9929967..8a0ee09 100644 --- a/docs/global.html +++ b/docs/global.html @@ -24,7 +24,7 @@
@@ -760,48 +760,6 @@
Properties:
- - - muteRoleName - - - - - -string -| - -Discord.Snowflake - - - - - - - - - <optional>
- - - - - - - - - - 'Muted' - - - - -

Name or ID of the role that will be added to users if they got muted.

- - - - - - unMuteTime @@ -834,7 +792,7 @@
Properties:
-

Time in minutes to wait until unmuting a user. 0=never.

+

Time in minutes to wait until unmuting a user.

@@ -1209,7 +1167,7 @@
Properties:
- muteErrorMessage + banErrorMessage @@ -1248,7 +1206,7 @@
Properties:
- banErrorMessage + muteErrorMessage @@ -1273,7 +1231,7 @@
Properties:
- 'Could not mute **{user_tag}** because of improper permissions or the mute role couldn\'t be found.' + 'Could not mute **{user_tag}** because of improper permissions.' diff --git a/docs/index.html b/docs/index.html index c9fd1be..70ecb69 100644 --- a/docs/index.html +++ b/docs/index.html @@ -24,7 +24,7 @@
@@ -83,8 +83,7 @@

Example

ignoreBots: true, // Ignore bot messages. verbose: true, // Extended Logs from module. ignoredMembers: [], // Array of User IDs that get ignored. - muteRoleName: "Muted", // Name of the role that will be given to muted users! - unMuteTime: 0, // Amount of time (in minutes) a user will be muted for. + unMuteTime: 10, // Amount of time (in minutes) a user will be muted for. removeMessages: true, // If the bot should remove all the spam messages when taking action on a user! modLogsEnabled: false, // If to enable modlogs modLogsChannelName: "mod-logs", // channel to send the modlogs too! @@ -117,14 +116,50 @@

Example (As a direct copy template without explanations)

ignoreBots: true, verbose: true, ignoredMembers: [], - muteRoleName: "Muted", - muteTime: 0, + unMuteTime: 10, removeMessages: true, modLogsEnabled: false, modLogsChannelName: "mod-logs", modLogsMode: "embed", }); +

Multiple Guild Example

+

Because of a new update, you may now have multiple guilds having their own options. You will need to store their options in a database or something similar to avoid loss of settings.

+
const Discord = require("discord.js");
+const client = new Discord.Client({
+  intents: [Discord.Intents.FLAGS.GUILDS, Discord.Intents.FLAGS.GUILD_MESSAGES],
+});
+const AntiSpam = require("discord-anti-spam");
+
+const antiSpam = new AntiSpam({
+  warnThreshold: 3,
+  muteThreshold: 4,
+  kickThreshold: 7,
+  banThreshold: 7,
+  maxInterval: 2000,
+  warnMessage: "{@user}, Please stop spamming.",
+  kickMessage: "**{user_tag}** has been kicked for spamming.",
+  muteMessage: "**{user_tag}** has been muted for spamming.",
+  banMessage: "**{user_tag}** has been banned for spamming.",
+  maxDuplicatesWarning: 6,
+  maxDuplicatesKick: 10,
+  maxDuplicatesBan: 12,
+  maxDuplicatesMute: 8,
+  ignoredPermissions: ["ADMINISTRATOR"],
+  ignoreBots: true,
+  verbose: true,
+  ignoredMembers: [],
+  unMuteTime: 10,
+  removeMessages: true,
+  modLogsEnabled: false,
+  modLogsChannelName: "mod-logs",
+  modLogsMode: "embed",
+}); // If a guild does not have any separate options, these are the settings they will be using.
+
+client.on("ready", () => antiSpam.addGuildOptions(client.guilds.fetch("583920432168828938"), {modLogsChannelName: "special-logs"}))
+client.on("messageCreate", (message) => antiSpam.message(messageCreate));
+client.login("YOUR_SUPER_SECRET_TOKEN");
+

Support Server

Join our Support Server where we help you with issues regarding the module.

Bug Reports