This repository has been archived by the owner on Oct 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
78 lines (62 loc) · 2.63 KB
/
index.js
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const {Client, Collection, MessageEmbed} = require('discord.js')
const client = new Client()
const prefix = '++'
const fs = require("fs");
client.commands = new Collection();
client.aliases = new Collection();
fs.readdir("./commands/", (err, files) => {
if(err) console.log(err)
let jsfile = files.filter(f => f.split(".").pop() === "js")
if(jsfile.length <= 0) {
return console.log("[LOGS] Couldn't Find Commands!");
}
jsfile.forEach((f, i) => {
let pull = require(`./commands/${f}`);
client.commands.set(pull.config.name, pull);
pull.config.aliases.forEach(alias => {
client.aliases.set(alias, pull.config.name)
});
});
});
client.on('ready', () => {
client.user.setActivity(`Looking after ${client.users.cache.size} submariners!`);
console.log('Bot is on.');
})
client.on('message', async message => {
if (!message.content.startsWith(prefix)) return
let messageArray = message.content.split(" ");
let cmd = messageArray[0];
let args = messageArray.slice(1);
let commandfile = client.commands.get(cmd.slice(prefix.length)) || client.commands.get(client.aliases.get(cmd.slice(prefix.length)))
if(commandfile) commandfile.run(client,message,args)
})
client.on('messageUpdate', (oldMessage, newMessage) => {
if (!oldMessage.guild) return;
const oldMessageMention = oldMessage.mentions.members.first()
const newMessageMention = newMessage.mentions.members.first()
if (oldMessageMention && !newMessageMention && oldMessage.author.id !== oldMessageMention.id) {
let embed = new MessageEmbed()
.setColor('#ff6a6a')
.setTitle("Ghost ping detected!")
.addField('**Author**', oldMessage.author)
.addField("**Origional Message**", oldMessage, true)
.addField("**New Message**", newMessage, true)
.addField('**Type**', 'Sender sent a message. Then proceeded to edit the ping out of the message.')
.setTimestamp();
oldMessage.channel.send(embed)
}
})
client.on('messageDelete', message => {
if (!message.guild) return;
if (message.mentions.members.first() && message.mentions.members.first().id != message.author.id) {
let embed = new MessageEmbed()
.setColor('#ff6a6a')
.setTitle("Ghost ping detected!")
.addField('**Sender**', message.author)
.addField("**Message**", message.content)
.addField('**Type**', 'Sender sent a message, and then proceeded to delete it thereafter.')
.setTimestamp();
message.channel.send(embed)
}
})
client.login('token');