forked from JulesZYTB/BloumeGen-Bot-V18-By-JulesZ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
98 lines (80 loc) · 2.95 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// npmjs packages
const Discord = require('discord.js');
const fs = require('fs');
// configuration
const config = require('./config.json');
// create client
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
// const commands
client.commands = new Discord.Collection();
// load commands
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
// const commands
for (const file of commandFiles) {
// read command file
const command = require(`./commands/${file}`);
// set the command
client.commands.set(command.name, command);
};
// login with token
client.login(config.token)
// ready event
client.once('ready', () => {
// write to console
console.log(`${client.user.tag}`);
// set activity
client.user.setPresence({ activity: { name: "BloumeGen https://manager.bloume-gen.tk/", type: 1, url: "https://manager.bloume-gen.tk"}})
});
// message event // command handling
client.on('message', (message) => {
// command without prefix
if (!message.content.startsWith(config.prefix)) {
// cancel
return;
};
// if a bot execute a command
if (message.author.bot) {
// cancel
return;
};
// get the args
const args = message.content.slice(config.prefix.length).trim().split(/ +/);
// const command
const command = args.shift().toLowerCase();
// if not match
if (!client.commands.has(command)) {
// send message to channel
};
// try to executing the command
try {
if(!message.member.roles.cache.has(config.VIP_ID)){
// get command
const embed = new Discord.MessageEmbed()
.setTitle(message.author.username)
.setThumbnail(message.author.displayAvatarURL({ dynamic: true, size: 64 }))
.addField("Auteur du message ",`<@${message.author.id}>`,true)
.addField("L'auteur est VIP ?","`Non`",true)
.addField("Commande exécutée",`\`${message.content}\``,false)
.setColor(0x000FF)
.setDescription(`Quelqu'un viens D'utilisé la commande ${command} !`)
client.channels.cache.get(`${config.logs}`).send(embed)
}
else if(message.member.roles.cache.has(config.VIP_ID)){
const embed = new Discord.MessageEmbed()
.setTitle(message.author.username)
.setThumbnail(message.author.displayAvatarURL({ dynamic: true, size: 64 }))
.addField("Auteur du message ",`<@${message.author.id}>`,true)
.addField("L'auteur est VIP ?","`Oui`",true)
.addField("Commande exécutée",`\`${message.content}\``,false)
.setColor(0x000FF)
.setDescription(`Quelqu'un viens D'utilisé la commande ${command} !`)
client.channels.cache.get(`${config.logs}`).send(embed)
}
client.commands.get(command).execute(client, message, args);
// if error
} catch (error) {
console.log(error)
// go config les logs hien sinon ca marche pas!
};
});