-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
110 lines (90 loc) · 2.88 KB
/
app.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// Calling Packages
const Discord = require('discord.js');
const client = new Discord.Client();
const fs = require('fs')
const tools = require('./functions.js');
// Global Settings
const prefix = '~';
client.on('message', message => {
let args = message.content.slice(prefix.length).trim().split(" ");
let cmd = args.shift().toLowerCase();
let mentioned = false;
// Check if the bot was mentioned.
if (message.content.toString().trim().startsWith(`<@${client.user.id}>`)) {
mentioned = true;
cmd = 'mentioned';
}
// Aliases
if (cmd === 'percentage') cmd = '%';
if (cmd === 'perc') cmd = '%';
if (cmd === 'statistics') cmd = 'stats';
if (cmd === 'similar') cmd = 'similarity';
if (cmd === 'help') cmd = 'commands';
if (cmd === 'add') cmd = 'sum';
if (cmd === 'chat') cmd = 'mentioned';
if (cmd === 'commandslink') cmd = 'cmdlink';
if (message.author.bot) return;
if (!message.content.startsWith(prefix) && !mentioned) return;
try {
let commandFile = require(`./commands/${cmd}.js`);
commandFile.run(client, message, args, tools);
} catch (e) {
if (!e.message.startsWith("Cannot find module"))
console.log(e.message);
} finally {
console.log(`${message.author.username} ran '${cmd}' in ${message.guild.name}`);
}
});
client.on('ready', () => {
console.log('Bot started.');
client.user.setGame(`discord.me/TheInn`);
});
client.on('guildCreate', guild => {
try {
client.guilds.get('374080288269008896').channels.get('376070966230384640').send({
embed: {
description: `**Joined Guild: ${guild.name}**`,
color: 0x93c47d,
thumbnail: {
url: guild.iconURL
},
fields: [{
name: `Members`,
value: guild.memberCount
},
{
name: `Channels`,
value: guild.channels.size
}
]
}
});
} catch (e) {
console.log(e.message);
}
});
client.on('guildDelete', guild => {
try {
client.guilds.get('374080288269008896').channels.get('376070966230384640').send({
embed: {
description: `**Left Guild: ${guild.name}**`,
color: 0xe06666,
thumbnail: {
url: guild.iconURL
},
fields: [{
name: `Members`,
value: guild.memberCount
},
{
name: `Channels`,
value: guild.channels.size
}
],
}
});
} catch (e) {
console.log(e.message);
}
});
client.login('token');