-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
56 lines (39 loc) · 1.71 KB
/
Copy pathmain.js
File metadata and controls
56 lines (39 loc) · 1.71 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
require('dotenv').config();
const { Client, GatewayIntentBits, Guild, MessageSearchAuthorType } = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
]
});
const fs = require('fs');
client.on('messageCreate', async (message) => {
if (message.author.id == process.env.CLIENT_ID) return;
const guild = client.guilds.cache.get(process.env.GUILD_ID);
if (!guild) return console.log('Guild is nil');
const guildMember = await guild.members.fetch(message.author.id);
const joinedTimestamp = await guildMember.joinedTimestamp;
const messageTimestamp = await message.createdTimestamp;
const differenceUnix = Math.floor((messageTimestamp - joinedTimestamp) / 1000);
console.log(differenceUnix.toString());
if (differenceUnix < 172800) { // 48 Hours
var hours = Math.floor(differenceUnix / 60 / 60);
if (message.attachments.size > 0) {
await message.reply('Possible scam, user has been in the server for ' + hours.toString() + " hours and is sending an image with no text or partial text.");
await message.delete();
return;
}
if (differenceUnix < 86400) {
if (message.content.length > 60) {
await message.reply('Possible scam, user has been in the server for ' + hours.toString() + " hours and is sending an image with no text or partial text.");
await message.delete();
return;
}
}
}
});
client.once('clientReady', async () => {
console.log('I am online beaches');
});
client.login(process.env.DISCORD_TOKEN);