-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
61 lines (55 loc) · 2.94 KB
/
index.js
File metadata and controls
61 lines (55 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
require('dotenv').config()
const fs = require('fs');
const Discord = require('discord.js');
const client = new Discord.Client();
const DiscordAntiSpam = require('discord-anti-spam');
const AntiSpam = new DiscordAntiSpam({
warnThreshold: 4, // Amount of messages sent in a row that will cause a warning.
banThreshold: 7, // Amount of messages sent in a row that will cause a ban
maxInterval: 3000, // Amount of time (in ms) in which messages are cosidered spam.
warnMessage: ("{@user}, Can you don't?.", { files: ['./img/Pogweird.png'] }),// Message will be sent in chat upon warning.
banMessage: ("**{user_tag}** has been banned for spamming.", { files: ['./img/Pogweird.png'] }), // Message will be sent in chat upon banning.
maxDuplicatesWarning: 4, // Amount of same messages sent that will be considered as duplicates that will cause a warning.
maxDuplicatesBan: 8, // Amount of same messages sent that will be considered as duplicates that will cause a ban.
deleteMessagesAfterBanForPastDays: 1, // Amount of days in which old messages will be deleted. (1-7)
ignoredUsers: [], // array of ignored user ids
ignoredGuilds: [], // array of ignored guild ids
exemptPermissions: [], // Bypass users with at least one of these permissions
ignoreBots: true, // Ignore bot messages
verbose: false, // Extended Logs from module
client: client, // Client is your Discord.Client and is a required option.
ignoredUsers: [], // Array of string user IDs that are ignored
ignoredGuilds: [] // Array of string Guild IDs that are ignored
});
AntiSpam.on("warnEmit", (member) => console.log(`Attempt to warn ${member.user.tag}.`));
AntiSpam.on("warnAdd", (member) => console.log(`${member.user.tag} has been warned.`));
AntiSpam.on("banEmit", (member) => console.log(`Attempt to ban ${member.user.tag}.`));
AntiSpam.on("banAdd", (member) => console.log(`${member.user.tag} has been banned.`));
AntiSpam.on("dataReset", () => console.log("Module cache has been cleared."));
function date() {
var today = new Date();
var h = String(today.getHours()).padStart(2, '0');
var m = String(today.getMinutes()).padStart(2, '0');
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0');
var yyyy = today.getFullYear();
today = mm + '-' + dd + '-' + yyyy;
return today;
}
client.on("message", (msg) => {
AntiSpam.message(msg);
})
client.on("message", (msg) => {
const CreateFiles = fs.createWriteStream('./logs/log' + date() + '.txt', {
flags: 'a'
})
CreateFiles.write(msg.createdAt + "," + msg.author.id + "," + msg.author.username + "," + msg.content + '\r\n')
})
fs.readdir('./events/', (err, files) => {
files.forEach(file => {
const eventHandler = require(`./events/${file}`)
const eventName = file.split('.')[0]
client.on(eventName, (...args) => eventHandler(client, ...args))
})
})
client.login(process.env.BOT_TOKEN);