-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
65 lines (58 loc) · 1.98 KB
/
index.ts
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
const { Client, Collection, RichEmbed } = require('discord.js');
const { config } = require('dotenv');
const client = new Client({ disableEveryone: true });
client.commands = new Collection();
client.aliases = new Collection();
config({
path: __dirname + '/.env'
});
['command'].forEach(handler => {
require(`./handlers/${handler}`)(client);
});
client.on('ready', () => {
console.log(`Hi, ${client.user.username} is now online!`);
client.user.setPresence({
status: 'online',
game: {
name: 'I'm looking at you.',
type: 'WATCHING'
}
});
});
const newUsers = new Collection();
client.on('guildMemberAdd', (member: any) => {
newUsers.set(member.id, member.user);
member.guild.channels.get('708783015484063897').send( // A changer !
new RichEmbed()
.setColor('#d347a6') // I recommend: https://htmlcolorcodes.com
.setDescription(`Welcome ${member.user.username} 👶`)
.setTitle('Welcome to you !')
);
});
client.on('guildMemberRemove', (member: any) => {
if (newUsers.has(member.id)) newUsers.delete(member.id);
member.guild.channels.get('708783015484063897').send( //// To be modified !
new RichEmbed()
.setColor('#d347a6') // I recommend: https://htmlcolorcodes.com
.setDescription(`${member.user.username} ...`)
.setTitle('He preferred to leave us..')
);
});
client.on('message', async (message: any) => {
const prefix: string = '!!'; // You can change of course.
if (message.author.bot) return;
if (!message.guild) return;
if (!message.content.startsWith(prefix)) return;
if (!message.member)
message.member = await message.guild.fetchMember(message);
const args = message.content
.slice(prefix.length)
.trim()
.split(/ +/g);
const cmd = args.shift().toLowerCase();
if (cmd.length === 0) return;
let command = client.commands.get(cmd);
if (!command) command = client.commands.get(client.aliases.get(cmd));
if (command) command.run(client, message, args);
});
client.login(process.env.TOKEN);