2021-03-14 11:09:02 +01:00

1784 lines
24 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>AntiSpam - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<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">
<link rel="icon"
type="image/png"
href="img/antispam.png">
</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="AntiSpam.html">AntiSpam</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="AntiSpam.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="AntiSpam.html#reset">reset</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="AntiSpam.html#event:error">error</a></span></li><li class="nav-heading"><span class="nav-item-type type-event">E</span><span class="nav-item-name"><a href="AntiSpam.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="AntiSpam.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="AntiSpam.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="AntiSpam.html#event:warnAdd">warnAdd</a></span></li><li class="nav-heading"><span class="nav-item-type type-event">E</span><span class="nav-item-name"><a href="AntiSpam.html#event:spamThresholdBan">spamThresholdBan</a></span></li><li class="nav-heading"><span class="nav-item-type type-event">E</span><span class="nav-item-name"><a href="AntiSpam.html#event:spamThresholdKick">spamThresholdKick</a></span></li><li class="nav-heading"><span class="nav-item-type type-event">E</span><span class="nav-item-name"><a href="AntiSpam.html#event:spamThresholdMute">spamThresholdMute</a></span></li><li class="nav-heading"><span class="nav-item-type type-event">E</span><span class="nav-item-name"><a href="AntiSpam.html#event:spamThresholdWarn">spamThresholdWarn</a></span></li><li class="nav-heading"><a href="global.html">Globals</a></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#format">format</a></span></li>
</nav>
<div id="main">
<h1 class="page-title">AntiSpam</h1>
<section>
<header>
<h2>AntiSpam</h2>
<div class="class-description"><p>Anti Spam instance.</p></div>
</header>
<article>
<div class="container-overview">
<div class="section-method">
<h2>Constructor</h2>
<h4 class="name" id="AntiSpam"><span class="type-signature"></span>new AntiSpam<span class="signature">(options<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<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>data</code></td>
<td class="type">
<span class="param-type"><code><a href="global.html#AntiSpamData">AntiSpamData</a></code></span>
</td>
<td class="description last"><p>Anti Spam cache data.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
</dl>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type"><code><a href="global.html#AntiSpamOptions">AntiSpamOptions</a></code></span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">
<p>Client options.</p>
</td>
</tr>
</tbody>
</table>
<div class="section-examples">
<h5>Example</h5>
<pre class="prettyprint"><code>
const antiSpam = new AntiSpam({
warnThreshold: 3, // Amount of messages sent in a row that will cause a warning.
muteThreshold: 4, // Amount of messages sent in a row that will cause a mute
kickThreshold: 7, // Amount of messages sent in a row that will cause a kick.
banThreshold: 7, // Amount of messages sent in a row that will cause a ban.
maxInterval: 2000, // Amount of time (in milliseconds) in which messages are considered spam.
warnMessage: '{@user}, Please stop spamming.', // Message that will be sent in chat upon warning a user.
kickMessage: '**{user_tag}** has been kicked for spamming.', // Message that will be sent in chat upon kicking a user.
muteMessage: '**{user_tag}** has been muted for spamming.',// Message that will be sent in chat upon muting a user.
banMessage: '**{user_tag}** has been banned for spamming.', // Message that will be sent in chat upon banning a user.
maxDuplicatesWarning: 7, // Amount of duplicate messages that trigger a warning.
maxDuplicatesKick: 10, // Amount of duplicate messages that trigger a warning.
maxDuplicatesBan: 12, // Amount of duplicate messages that trigger a warning.
exemptPermissions: [ 'ADMINISTRATOR'], // Bypass users with any of these permissions.
ignoreBots: true, // Ignore bot messages.
verbose: true, // Extended Logs from module.
ignoredUsers: [], // Array of User IDs that get ignored.
muteRoleName: "Muted", // Name of the role that will be given to muted users!
removeMessages: true // If the bot should remove all the spam messages when taking action on a user!
// And many more options... See the documentation.
});
</code></pre>
</div>
</div>
</div>
<h3 class="subsection-title">Methods</h3>
<div class="section-method">
<h4 class="name" id="message"><span class="type-signature">(async) </span>message<span class="signature">(message)</span><span class="type-signature"> &rarr; {Promise.&lt;boolean>}</span></h4>
<div class="description">
<p>Checks a message.</p>
</div>
<dl class="details">
</dl>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>message</code></td>
<td class="type">
<span class="param-type"><code>Message</code></span>
</td>
<td class="description last">
<p>The message to check.</p>
</td>
</tr>
</tbody>
</table>
<div class="section-returns">
<h5>Returns:</h5>
<dl class="param-type">
<dt>
Type:
</dt>
<dd>
<span class="param-type"><code>Promise.&lt;boolean></code></span>
</dd>
</dl>
<div class="param-desc">
<p>Whether the message has triggered a threshold.</p>
</div>
</div>
<div class="section-examples">
<h5>Example</h5>
<pre class="prettyprint"><code>client.on('message', (msg) => {
antiSpam.message(msg);
});</code></pre>
</div>
</div>
<div class="section-method">
<h4 class="name" id="reset"><span class="type-signature">(private) </span>reset<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="global.html#AntiSpamData">AntiSpamData</a>}</span></h4>
<div class="description">
<p>Resets the cache data of the Anti Spam instance.</p>
</div>
<dl class="details">
</dl>
<div class="section-returns">
<h5>Returns:</h5>
<dl class="param-type">
<dt>
Type:
</dt>
<dd>
<span class="param-type"><code><a href="global.html#AntiSpamData">AntiSpamData</a></code></span>
</dd>
</dl>
<div class="param-desc">
<p>The cache that was just cleared.</p>
</div>
</div>
<div class="section-examples">
<h5>Example</h5>
<pre class="prettyprint"><code>const data = antiSpam.reset();
console.log(`Cleared a total of ${data.messageCache.length} cached messages.`);</code></pre>
</div>
</div>
<h3 class="subsection-title">Events</h3>
<div class="section-method">
<h4 class="name" id="event:error">error</h4>
<div class="description">
<p>Emitted when the bot could not kick or ban a member.</p>
</div>
<dl class="details">
</dl>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>message</code></td>
<td class="type">
<span class="param-type"><code>Message</code></span>
</td>
<td class="description last">
<p>The Discord message</p>
</td>
</tr>
<tr>
<td class="name"><code>error</code></td>
<td class="type">
<span class="param-type"><code>error</code></span>
</td>
<td class="description last">
<p>The error</p>
</td>
</tr>
<tr>
<td class="name"><code>type</code></td>
<td class="type">
<span class="param-type"><code>string</code></span>
</td>
<td class="description last">
<p>The sanction type: 'kick' or 'ban' or 'mute' or 'warn'</p>
</td>
</tr>
</tbody>
</table>
<div class="section-examples">
<h5>Example</h5>
<pre class="prettyprint"><code>antiSpam.on("error", (message, error, type) => {
console.log(`${message.author.tag} couldn't receive the sanction '${type}', error: ${error}`);
});</code></pre>
</div>
</div>
<div class="section-method">
<h4 class="name" id="event:banAdd">banAdd</h4>
<div class="description">
<p>Emitted when a member is banned.</p>
</div>
<dl class="details">
</dl>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>member</code></td>
<td class="type">
<span class="param-type"><code>GuildMember</code></span>
</td>
<td class="description last">
<p>The banned member.</p>
</td>
</tr>
</tbody>
</table>
<div class="section-examples">
<h5>Example</h5>
<pre class="prettyprint"><code>antiSpam.on("banAdd", (member) => console.log(`${member.user.tag} has been banned.`));</code></pre>
</div>
</div>
<div class="section-method">
<h4 class="name" id="event:kickAdd">kickAdd</h4>
<div class="description">
<p>Emitted when a member is kicked.</p>
</div>
<dl class="details">
</dl>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>member</code></td>
<td class="type">
<span class="param-type"><code>GuildMember</code></span>
</td>
<td class="description last">
<p>The kicked member.</p>
</td>
</tr>
</tbody>
</table>
<div class="section-examples">
<h5>Example</h5>
<pre class="prettyprint"><code>antiSpam.on("kickAdd", (member) => console.log(`${member.user.tag} has been kicked.`));</code></pre>
</div>
</div>
<div class="section-method">
<h4 class="name" id="event:muteAdd">muteAdd</h4>
<div class="description">
<p>Emitted when a member is muted.</p>
</div>
<dl class="details">
</dl>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>member</code></td>
<td class="type">
<span class="param-type"><code>GuildMember</code></span>
</td>
<td class="description last">
<p>The muted member.</p>
</td>
</tr>
</tbody>
</table>
<div class="section-examples">
<h5>Example</h5>
<pre class="prettyprint"><code>antiSpam.on("muteAdd", (member) => console.log(`${member.user.tag} has been muted.`));</code></pre>
</div>
</div>
<div class="section-method">
<h4 class="name" id="event:warnAdd">warnAdd</h4>
<div class="description">
<p>Emitted when a member is warned.</p>
</div>
<dl class="details">
</dl>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>member</code></td>
<td class="type">
<span class="param-type"><code>GuildMember</code></span>
</td>
<td class="description last">
<p>The warned member.</p>
</td>
</tr>
</tbody>
</table>
<div class="section-examples">
<h5>Example</h5>
<pre class="prettyprint"><code>antiSpam.on("warnAdd", (member) => console.log(`${member.user.tag} has been warned.`));</code></pre>
</div>
</div>
<div class="section-method">
<h4 class="name" id="event:spamThresholdBan">spamThresholdBan</h4>
<div class="description">
<p>Emitted when a member reaches the ban threshold.</p>
</div>
<dl class="details">
</dl>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>member</code></td>
<td class="type">
<span class="param-type"><code>GuildMember</code></span>
</td>
<td class="description last">
<p>The member who reached the ban threshold.</p>
</td>
</tr>
<tr>
<td class="name"><code>duplicate</code></td>
<td class="type">
<span class="param-type"><code>boolean</code></span>
</td>
<td class="description last">
<p>Whether the member reached the ban threshold by spamming the same message.</p>
</td>
</tr>
</tbody>
</table>
<div class="section-examples">
<h5>Example</h5>
<pre class="prettyprint"><code>antiSpam.on("spamThresholdBan", (member) => console.log(`${member.user.tag} has reached the ban threshold.`));</code></pre>
</div>
</div>
<div class="section-method">
<h4 class="name" id="event:spamThresholdKick">spamThresholdKick</h4>
<div class="description">
<p>Emitted when a member reaches the kick threshold.</p>
</div>
<dl class="details">
</dl>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>member</code></td>
<td class="type">
<span class="param-type"><code>GuildMember</code></span>
</td>
<td class="description last">
<p>The member who reached the kick threshold.</p>
</td>
</tr>
<tr>
<td class="name"><code>duplicate</code></td>
<td class="type">
<span class="param-type"><code>boolean</code></span>
</td>
<td class="description last">
<p>Whether the member reached the kick threshold by spamming the same message.</p>
</td>
</tr>
</tbody>
</table>
<div class="section-examples">
<h5>Example</h5>
<pre class="prettyprint"><code>antiSpam.on("spamThresholdKick", (member) => console.log(`${member.user.tag} has reached the kick threshold.`));</code></pre>
</div>
</div>
<div class="section-method">
<h4 class="name" id="event:spamThresholdMute">spamThresholdMute</h4>
<div class="description">
<p>Emitted when a member reaches the mute threshold.</p>
</div>
<dl class="details">
</dl>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>member</code></td>
<td class="type">
<span class="param-type"><code>GuildMember</code></span>
</td>
<td class="description last">
<p>The member who reached the mute threshold.</p>
</td>
</tr>
<tr>
<td class="name"><code>duplicate</code></td>
<td class="type">
<span class="param-type"><code>boolean</code></span>
</td>
<td class="description last">
<p>Whether the member reached the mute threshold by spamming the same message.</p>
</td>
</tr>
</tbody>
</table>
<div class="section-examples">
<h5>Example</h5>
<pre class="prettyprint"><code>antiSpam.on("spamThresholdWarn", (member) => console.log(`${member.user.tag} has reached the warn threshold.`));</code></pre>
</div>
</div>
<div class="section-method">
<h4 class="name" id="event:spamThresholdWarn">spamThresholdWarn</h4>
<div class="description">
<p>Emitted when a member reaches the warn threshold.</p>
</div>
<dl class="details">
</dl>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>member</code></td>
<td class="type">
<span class="param-type"><code>GuildMember</code></span>
</td>
<td class="description last">
<p>The member who reached the warn threshold.</p>
</td>
</tr>
<tr>
<td class="name"><code>duplicate</code></td>
<td class="type">
<span class="param-type"><code>boolean</code></span>
</td>
<td class="description last">
<p>Whether the member reached the warn threshold by spamming the same message.</p>
</td>
</tr>
</tbody>
</table>
<div class="section-examples">
<h5>Example</h5>
<pre class="prettyprint"><code>antiSpam.on("spamThresholdWarn", (member) => console.log(`${member.user.tag} has reached the warn threshold.`));</code></pre>
</div>
</div>
</article>
</section>
</div>
<br class="clear">
<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> using the Minami theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>