-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
74 lines (56 loc) · 1.98 KB
/
index.js
File metadata and controls
74 lines (56 loc) · 1.98 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* @file index.js
* @description Le fichier principal du bot
* @version 0.1.1
* @author RadYio
*/
//importation du module fs
const fs = require('fs');
//importation du module discord.js
const { Client, Collection, Events, GatewayIntentBits } = require('discord.js');
//création d'un nouveau client discord
const client = new Client({ intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMessageTyping,
GatewayIntentBits.MessageContent,
] });
//A changer pour module export
const { Personne, Serveur} = require('./bdd.js');
global.tablePersonne = Personne;
global.tableServeur = Serveur;
//recuperation du token dans le fichier config.json
const { token, channelId } = require('./config.json');
if (!token) {
console.log('Veuillez remplacer le token par le votre dans le fichier config.json');
process.exit();
}
console.log(`Token trouvé: ${token}!`);
//Récupération des commandes
client.commandes = new Collection();
const fichiers_de_commande = fs.readdirSync('./commandes').filter(fichier => fichier.endsWith('.js'));
for (const fichier of fichiers_de_commande) {
const commande = require(`./commandes/${fichier}`);
client.commandes.set(commande.data.name, commande);
}
//Récupération des events
const fichiers_de_event = fs.readdirSync('./events').filter(file => file.endsWith('.js'));
for (const fichier of fichiers_de_event) {
const event = require(`./events/${fichier}`);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {
client.on(event.name, (...args) => event.execute(...args));
}
}
client.on('disconnect', message => {
const channel = client.channels.cache.get(channelId);
channel.send('Je pars avec toutes les fesses! Bye les boloss');
});
//connexion du client bot
client.login(token);