UNPKG

discord-anti-spam

Version:

An easy to setup package that help you integration of anti-spam feature in your discord bot.

2,799 lines (898 loc) 56 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1"> <title>Global - Documentation</title> <script src="scripts/prettify/prettify.js"></script> <script src="scripts/prettify/lang-css.js"></script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <input type="checkbox" id="nav-trigger" class="nav-trigger" /> <label for="nav-trigger" class="navicon-button x"> <div class="navicon"></div> </label> <label for="nav-trigger" class="overlay"></label> <nav> <li class="nav-link nav-home-link"><a href="index.html">Home</a></li><li class="nav-heading">Classes</li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="AntiSpamClient.html">AntiSpamClient</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="AntiSpamClient.html#message">message</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="AntiSpamClient.html#reset">reset</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="AntiSpamClient.html#userleave">userleave</a></span></li><li class="nav-heading">Events</li><li class="nav-heading"><span class="nav-item-type type-event">E</span><span class="nav-item-name"><a href="AntiSpamClient.html#event:banAdd">banAdd</a></span></li><li class="nav-heading"><span class="nav-item-type type-event">E</span><span class="nav-item-name"><a href="AntiSpamClient.html#event:kickAdd">kickAdd</a></span></li><li class="nav-heading"><span class="nav-item-type type-event">E</span><span class="nav-item-name"><a href="AntiSpamClient.html#event:muteAdd">muteAdd</a></span></li><li class="nav-heading"><span class="nav-item-type type-event">E</span><span class="nav-item-name"><a href="AntiSpamClient.html#event:warnAdd">warnAdd</a></span></li><li class="nav-heading"><a href="global.html">Globals</a></li> </nav> <div id="main"> <h1 class="page-title">Global</h1> <section> <header> <h2> </h2> </header> <article> <div class="container-overview"> <dl class="details"> </dl> </div> <h3 class="subsection-title">Type Definitions</h3> <div class="section-members"> <h4 class="name" id="AntiSpamCache">AntiSpamCache</h4> <div class="description"> <p>Cache data for the AntiSpamClient</p> </div> <h5 class="subsection-title">Properties:</h5> <table class="props"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>warnedUsers</code></td> <td class="type"> <span class="param-type"><code>Array.&lt;Discord.Snowflake></code></span> </td> <td class="description last"><p>Array of warned users.</p></td> </tr> <tr> <td class="name"><code>kickedUsers</code></td> <td class="type"> <span class="param-type"><code>Array.&lt;Discord.Snowflake></code></span> </td> <td class="description last"><p>Array of kicked users.</p></td> </tr> <tr> <td class="name"><code>mutedUsers</code></td> <td class="type"> <span class="param-type"><code>Array.&lt;Discord.Snowflake></code></span> </td> <td class="description last"><p>Array of muted users.</p></td> </tr> <tr> <td class="name"><code>bannedUsers</code></td> <td class="type"> <span class="param-type"><code>Array.&lt;Discord.Snowflake></code></span> </td> <td class="description last"><p>Array of banned users.</p></td> </tr> <tr> <td class="name"><code>messages</code></td> <td class="type"> <span class="param-type"><code>Array.&lt;<a href="global.html#CachedMessage">CachedMessage</a>></code></span> </td> <td class="description last"><p>Array of cached messages, used to detect spam.</p></td> </tr> </tbody> </table> <dl class="details"> </dl> </div> <div class="section-members"> <h4 class="name" id="AntiSpamClientOptions">AntiSpamClientOptions</h4> <div class="description"> <p>Options for the AntiSpam client</p> </div> <h5 class="subsection-title">Properties:</h5> <table class="props"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>warnThreshold</code></td> <td class="type"> <span class="param-type"><code>number</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 3 </td> <td class="description last"><p>Amount of messages sent in a row that will cause a warning.</p></td> </tr> <tr> <td class="name"><code>muteThreshold</code></td> <td class="type"> <span class="param-type"><code>number</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 4 </td> <td class="description last"><p>Amount of messages sent in a row that will cause a mute.</p></td> </tr> <tr> <td class="name"><code>kickThreshold</code></td> <td class="type"> <span class="param-type"><code>number</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 5 </td> <td class="description last"><p>Amount of messages sent in a row that will cause a kick.</p></td> </tr> <tr> <td class="name"><code>banThreshold</code></td> <td class="type"> <span class="param-type"><code>number</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 7 </td> <td class="description last"><p>Amount of messages sent in a row that will cause a ban.</p></td> </tr> <tr> <td class="name"><code>maxInterval</code></td> <td class="type"> <span class="param-type"><code>number</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 2000 </td> <td class="description last"><p>Amount of time (ms) in which messages are considered spam.</p></td> </tr> <tr> <td class="name"><code>maxDuplicatesInterval</code></td> <td class="type"> <span class="param-type"><code>number</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 2000 </td> <td class="description last"><p>Amount of time (ms) in which duplicate messages are considered spam.</p></td> </tr> <tr> <td class="name"><code>maxDuplicatesWarn</code></td> <td class="type"> <span class="param-type"><code>number</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 7 </td> <td class="description last"><p>Amount of duplicate messages that trigger a warning.</p></td> </tr> <tr> <td class="name"><code>maxDuplicatesMute</code></td> <td class="type"> <span class="param-type"><code>number</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 9 </td> <td class="description last"><p>Amount of duplicate messages that trigger a mute.</p></td> </tr> <tr> <td class="name"><code>maxDuplicatesKick</code></td> <td class="type"> <span class="param-type"><code>number</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 10 </td> <td class="description last"><p>Amount of duplicate messages that trigger a kick.</p></td> </tr> <tr> <td class="name"><code>maxDuplicatesBan</code></td> <td class="type"> <span class="param-type"><code>number</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 11 </td> <td class="description last"><p>Amount of duplicate messages that trigger a ban.</p></td> </tr> <tr> <td class="name"><code>unMuteTime</code></td> <td class="type"> <span class="param-type"><code>number</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> '0' </td> <td class="description last"><p>Time in minutes to wait until unmuting a user.</p></td> </tr> <tr> <td class="name"><code>modLogsChannel</code></td> <td class="type"> <span class="param-type"><code>string</code></span> | <span class="param-type"><code>Discord.Snowflake</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'mod-logs' </td> <td class="description last"><p>Name or ID of the channel in which moderation logs will be sent.</p></td> </tr> <tr> <td class="name"><code>modLogsEnabled</code></td> <td class="type"> <span class="param-type"><code>boolean</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> false </td> <td class="description last"><p>Whether moderation logs are enabled.</p></td> </tr> <tr> <td class="name"><code>modLogsMode</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'embed' </td> <td class="description last"><p>Whether send moderations logs in an discord embed or normal message! Options: 'embed' or 'message&quot;.</p></td> </tr> <tr> <td class="name"><code>warnMessage</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> '{@user}, Please stop spamming.' </td> <td class="description last"><p>Message that will be sent in the channel when someone is warned.</p></td> </tr> <tr> <td class="name"><code>kickMessage</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> '**{user_tag}** has been kicked for spamming.' </td> <td class="description last"><p>Message that will be sent in the channel when someone is kicked.</p></td> </tr> <tr> <td class="name"><code>muteMessage</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> '**{user_tag}** has been muted for spamming.' </td> <td class="description last"><p>Message that will be sent in the channel when someone is muted.</p></td> </tr> <tr> <td class="name"><code>banMessage</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> '**{user_tag}** has been banned for spamming.' </td> <td class="description last"><p>Message that will be sent in the channel when someone is banned.</p></td> </tr> <tr> <td class="name"><code>actionInEmbed</code></td> <td class="type"> <span class="param-type"><code>boolean</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> false </td> <td class="description last"><p>Whether the action message will be sent in an embed or not.</p></td> </tr> <tr> <td class="name"><code>actionEmbedIn</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> "channel" </td> <td class="description last"><p>Whether the action message will be sent in the channel or dm. Options: 'channel' or 'dm'.</p></td> </tr> <tr> <td class="name"><code>actionEmbedColor</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> '#ff0000' </td> <td class="description last"><p>Color of the embeds of the action message.</p></td> </tr> <tr> <td class="name"><code>embedFooterIconURL</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'https://raw.githubusercontent.com/Michael-J-Scofield/discord-anti-spam/master/docs/img/antispam.png' </td> <td class="description last"><p>Footer icon of the embed of the action message.</p></td> </tr> <tr> <td class="name"><code>embedTitleIconURL</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'https://raw.githubusercontent.com/Michael-J-Scofield/discord-anti-spam/master/docs/img/antispam.png' </td> <td class="description last"><p>Icon of the embeds of the action message.</p></td> </tr> <tr> <td class="name"><code>warnEmbedTitle</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'User has been warned' </td> <td class="description last"><p>Title of the embeds of the action message.</p></td> </tr> <tr> <td class="name"><code>kickEmbedTitle</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'User has been kicked' </td> <td class="description last"><p>Title of the embed of the warn message.</p></td> </tr> <tr> <td class="name"><code>muteEmbedTitle</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'User has been muted' </td> <td class="description last"><p>Title of the embed of the mute message.</p></td> </tr> <tr> <td class="name"><code>banEmbedTitle</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'User has been banned' </td> <td class="description last"><p>Title of the embed of the ban message.</p></td> </tr> <tr> <td class="name"><code>warnEmbedDescription</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'You have been warned for spamming.' </td> <td class="description last"><p>Description of the embed of the warn message.</p></td> </tr> <tr> <td class="name"><code>kickEmbedDescription</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'You have been kicked for spamming.' </td> <td class="description last"><p>Description of the embed of the kick message.</p></td> </tr> <tr> <td class="name"><code>muteEmbedDescription</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'You have been muted for spamming.' </td> <td class="description last"><p>Description of the embed of the mute message.</p></td> </tr> <tr> <td class="name"><code>banEmbedDescription</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'You have been banned for spamming.' </td> <td class="description last"><p>Description of the embed of the ban message.</p></td> </tr> <tr> <td class="name"><code>warnEmbedFooter</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'You have been warned.' </td> <td class="description last"><p>Footer of the embed of the warn message.</p></td> </tr> <tr> <td class="name"><code>kickEmbedFooter</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'You have been kicked.' </td> <td class="description last"><p>Footer of the embed of the kick message.</p></td> </tr> <tr> <td class="name"><code>muteEmbedFooter</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'You have been muted.' </td> <td class="description last"><p>Footer of the embed of the mute message.</p></td> </tr> <tr> <td class="name"><code>banEmbedFooter</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'You have been banned.' </td> <td class="description last"><p>Footer of the embed of the ban message.</p></td> </tr> <tr> <td class="name"><code>errorMessages</code></td> <td class="type"> <span class="param-type"><code>boolean</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> true </td> <td class="description last"><p>Whether the bot should send a message in the channel when it doesn't have some required permissions, like it can't kick members.</p></td> </tr> <tr> <td class="name"><code>kickErrorMessage</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'Could not kick **{user_tag}** because of improper permissions.' </td> <td class="description last"><p>Message that will be sent in the channel when the bot doesn't have enough permissions to kick the member.</p></td> </tr> <tr> <td class="name"><code>banErrorMessage</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'Could not ban **{user_tag}** because of improper permissions.' </td> <td class="description last"><p>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).</p></td> </tr> <tr> <td class="name"><code>muteErrorMessage</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 'Could not mute **{user_tag}** because of improper permissions.' </td> <td class="description last"><p>Message that will be sent in the channel when the bot doesn't have enough permissions to ban the member.</p></td> </tr> <tr> <td class="name"><code>ignoredMembers</code></td> <td class="type"> <span class="param-type"><code>Discord.Snowflake</code></span> | <span class="param-type"><code>Array.&lt;string></code></span> | <span class="param-type"><code><a href="global.html#IgnoreMemberFunction">IgnoreMemberFunction</a></code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> [] </td> <td class="description last"><p>Array of member IDs that are ignored.</p></td> </tr> <tr> <td class="name"><code>ignoredRoles</code></td> <td class="type"> <span class="param-type"><code>Discord.Snowflake</code></span> | <span class="param-type"><code>Array.&lt;string></code></span> | <span class="param-type"><code><a href="global.html#IgnoreRoleFunction">IgnoreRoleFunction</a></code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> [] </td> <td class="description last"><p>Array of role IDs or role names that are ignored. Members with one of these roles will be ignored.</p></td> </tr> <tr> <td class="name"><code>ignoredGuilds</code></td> <td class="type"> <span class="param-type"><code>Discord.Snowflake</code></span> | <span class="param-type"><code>Array.&lt;string></code></span> | <span class="param-type"><code><a href="global.html#IgnoreGuildFunction">IgnoreGuildFunction</a></code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> [] </td> <td class="description last"><p>Array of guild IDs or guild names that are ignored.</p></td> </tr> <tr> <td class="name"><code>ignoredChannels</code></td> <td class="type"> <span class="param-type"><code>Discord.Snowflake</code></span> | <span class="param-type"><code>Array.&lt;string></code></span> | <span class="param-type"><code><a href="global.html#IgnoreChannelFunction">IgnoreChannelFunction</a></code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> [] </td> <td class="description last"><p>Array of channel IDs or channel names that are ignored.</p></td> </tr> <tr> <td class="name"><code>ignoredPermissions</code></td> <td class="type"> <span class="param-type"><code>Array.&lt;Discord.PermissionString></code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> [] </td> <td class="description last"><p>Users with at least one of these permissions will be ignored. Please use the PermissionFlagsBits function. (https://discord.js.org/#/docs/discord.js/main/class/PermissionsBitField?scrollTo=s-Flags)</p></td> </tr> <tr> <td class="name"><code>ignoreBots</code></td> <td class="type"> <span class="param-type"><code>boolean</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> true </td> <td class="description last"><p>Whether bots should be ignored.</p></td> </tr> <tr> <td class="name"><code>warnEnabled</code></td> <td class="type"> <span class="param-type"><code>boolean</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> true </td> <td class="description last"><p>Whether warn sanction is enabled.</p></td> </tr> <tr> <td class="name"><code>kickEnabled</code></td> <td class="type"> <span class="param-type"><code>boolean</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> true </td> <td class="description last"><p>Whether kick sanction is enabled.</p></td> </tr> <tr> <td class="name"><code>muteEnabled</code></td> <td class="type"> <span class="param-type"><code>boolean</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> true </td> <td class="description last"><p>Whether mute sanction is enabled.</p></td> </tr> <tr> <td class="name"><code>banEnabled</code></td> <td class="type"> <span class="param-type"><code>boolean</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> true </td> <td class="description last"><p>Whether ban sanction is enabled.</p></td> </tr> <tr> <td class="name"><code>deleteMessagesAfterBanForPastDays</code></td> <td class="type"> <span class="param-type"><code>number</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 1 </td> <td class="description last"><p>When a user is banned, their messages sent in the last x days will be deleted.</p></td> </tr> <tr> <td class="name"><code>verbose</code></td> <td class="type"> <span class="param-type"><code>boolean</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> true </td> <td class="description last"><p>Extended logs from module (recommended).</p></td> </tr> <tr> <td class="name"><code>debug</code></td> <td class="type"> <span class="param-type"><code>boolean</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> false </td> <td class="description last"><p>Whether to run the module in debug mode.</p></td> </tr> <tr> <td class="name"><code>removeMessages</code></td> <td class="type"> <span class="param-type"><code>boolean</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> true </td> <td class="description last"><p>Whether to delete user messages after a sanction.</p></td> </tr> <tr> <td class="name"><code>MultipleSanctions</code></td> <td class="type"> <span class="param-type"><code>boolean</code></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> false </td> <td class="description last"><p>Whether to run sanctions multiple times</p></td> </tr> </tbody> </table> <dl class="details"> </dl> </div> <div class="section-members"> <h4 class="name" id="CachedMessage">CachedMessage</h4> <div class="description"> <p>Cached message.</p> </div> <h5 class="subsection-title">Properties:</h5> <table class="props"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>messageID</code></td> <td class="type"> <span class="param-type"><code>Discord.Snowflake</code></span> </td> <td class="description last"><p>The ID of the message.</p></td> </tr> <tr> <td class="name"><code>guildID</code></td> <td class="type"> <span class="param-type"><code>Discord.Snowflake</code></span> </td> <td class="description last"><p>The ID of the guild where the message was sent.</p></td> </tr> <tr> <td class="name"><code>authorID</code></td> <td class="type"> <span class="param-type"><code>Discord.Snowflake</code></span> </td> <td class="description last"><p>The ID of the author of the message.</p></td> </tr> <tr> <td class="name"><code>channelID</code></td> <td class="type"> <span class="param-type"><code>Discord.Snowflake</code></span> </td> <td class="description last"><p>The ID of the channel of the message.</p></td> </tr> <tr> <td class="name"><code>content</code></td> <td class="type"> <span class="param-type"><code>string</code></span> </td> <td class="description last"><p>The content of the message.</p></td> </tr> <tr> <td class="name"><code>sentTimestamp</code></td> <td class="type"> <span class="param-type"><code>number</code></span> </td> <td class="description last"><p>The timestamp the message was sent.</p></td> </tr> </tbody> </table> <dl class="details"> </dl> </div> <div class="section-method"> <h4 class="name" id="IgnoreChannelFun