Browse Source

Update 'index.js'

Valentin Servieres 1 year ago
parent
commit
a79c2bea0e
1 changed files with 103 additions and 101 deletions
  1. 103
    101
      index.js

+ 103
- 101
index.js View File

@@ -1,102 +1,104 @@
1
-/*
2
-Bot Ingénieurs pour demain
3
-Developped by Valentin SERVIERES, if you have any question, you can contact me by Discord MagicTINTIN#4389
4
-- Discord.js version v12 (depreciated)
5
-*/
6
-console.log("Starting...");
7
-const { appID, publicKey, token, prefix } = require('./config/credentials.json');
8
-const fs = require('fs');
9
-const path = require('path');
10
-const Discord = require('discord.js');
11
-const { Client, Intents, MessageEmbed } = require('discord.js');
12
-// Only mandatory for Discord.js v13
13
-const client = new Client({
14
-    intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_BANS, Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS, Intents.FLAGS.GUILD_INTEGRATIONS, Intents.FLAGS.GUILD_WEBHOOKS, Intents.FLAGS.GUILD_INVITES, Intents.FLAGS.GUILD_VOICE_STATES, Intents.FLAGS.GUILD_PRESENCES, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Intents.FLAGS.GUILD_MESSAGE_TYPING, Intents.FLAGS.DIRECT_MESSAGES, Intents.FLAGS.DIRECT_MESSAGE_REACTIONS, Intents.FLAGS.DIRECT_MESSAGE_TYPING],
15
-});
16
-exports.client = client;
17
-
18
-
19
-// --- INITIALIZING BOT ---
20
-config = JSON.parse(fs.readFileSync(path.resolve(`./config/botinfo.json`)));
21
-console.log("config found\ngetting log channel id");
22
-const logch = config.logChannelID
23
-exports.logch = logch;
24
-
25
-// Import functions
26
-const random = require("./functions/random.js");
27
-const logger = require("./functions/logger.js");
28
-const msgcheck = require("./functions/messageCheck.js");
29
-const rolereact = require("./functions/rolereaction.js");
30
-
31
-// Import commands
32
-client.commands = new Discord.Collection();
33
-const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
34
-for (const file of commandFiles) {
35
-    const command = require(`./commands/${file}`);
36
-    client.commands.set(command.name, command);
37
-}
38
-
39
-
40
-client.once('ready', () => {
41
-    // cache message that could be used for reactions
42
-    rolereact.cache();
43
-    console.log('Ready to act !')
44
-    client.user.setActivity(config.activity, { type: 'PLAYING' });
45
-    client.channels.cache.get(logch).send("**❕ BOT ONLINE** - ready to act");
46
-});
47
-// --- END INITIALIZATION ---
48
-
49
-
50
-client.on('message', async message => {
51
-    if (message.author.bot) return
52
-    if (!message.channel.guild) {
53
-        return logger.all(message.author.tag + " a envoyé un mp : " + message.content)
54
-    }
55
-    // For more details see /functions/messageCheck.js
56
-    msgcheck.general(message);
57
-    // Command trigger
58
-    if (!message.content.startsWith(prefix) || message.author.bot) return;
59
-
60
-    const args = message.content.slice(prefix.length).split(/ +/);
61
-    const command = args.shift().toLocaleLowerCase();
62
-
63
-    if (!client.commands.has(command)) return;
64
-
65
-    try {
66
-        client.commands.get(command).execute(message, args);
67
-        logger.all(`🔨 ${message.author.tag} - \`${message}\``)
68
-    } catch (error) {
69
-        console.error(error);
70
-    }
71
-
72
-
73
-});
74
-
75
-
76
-client.on('guildMemberAdd', async member => {
77
-    try {
78
-        logger.all(`🆕 ${member.user.tag} vient d'arriver sur le serveur`);
79
-        // update user file
80
-        msgcheck.memberUpdate(member, "join");
81
-    } catch (err) { console.error(err); }
82
-});
83
-client.on('guildMemberRemove', async member => {
84
-    try {
85
-        logger.all(`❌ ${member.user.tag} vient de quitter le serveur`);
86
-        // update user file
87
-        msgcheck.memberUpdate(member, "left");
88
-    } catch (error) {
89
-
90
-    }
91
-});
92
-
93
-
94
-client.on('messageReactionAdd', (reaction, user) => {
95
-    rolereact.give(reaction, user);
96
-});
97
-client.on('messageReactionRemove', (reaction, user) => {
98
-    rolereact.remove(reaction, user);
99
-});
100
-
101
-
1
+/*
2
+Bot Ingénieurs pour demain
3
+Developped by Valentin SERVIERES, if you have any question, you can contact me by Discord MagicTINTIN#4389
4
+- Discord.js version v12 (depreciated)
5
+*/
6
+console.log("Starting...");
7
+const { appID, publicKey, token, prefix } = require('./config/credentials.json');
8
+const fs = require('fs');
9
+const path = require('path');
10
+const Discord = require('discord.js');
11
+const { Client, Intents, MessageEmbed } = require('discord.js');
12
+// Only mandatory for Discord.js v13
13
+const client = new Client({
14
+    intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_BANS, Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS, Intents.FLAGS.GUILD_INTEGRATIONS, Intents.FLAGS.GUILD_WEBHOOKS, Intents.FLAGS.GUILD_INVITES, Intents.FLAGS.GUILD_VOICE_STATES, Intents.FLAGS.GUILD_PRESENCES, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Intents.FLAGS.GUILD_MESSAGE_TYPING, Intents.FLAGS.DIRECT_MESSAGES, Intents.FLAGS.DIRECT_MESSAGE_REACTIONS, Intents.FLAGS.DIRECT_MESSAGE_TYPING],
15
+});
16
+exports.client = client;
17
+
18
+
19
+// --- INITIALIZING BOT ---
20
+config = JSON.parse(fs.readFileSync(path.resolve(`./config/botinfo.json`)));
21
+console.log("config found\ngetting log channel id");
22
+const logch = config.logChannelID
23
+exports.logch = logch;
24
+
25
+// Import functions
26
+const random = require("./functions/random.js");
27
+const logger = require("./functions/logger.js");
28
+const msgcheck = require("./functions/messageCheck.js");
29
+const rolereact = require("./functions/rolereaction.js");
30
+
31
+// Import commands
32
+client.commands = new Discord.Collection();
33
+const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
34
+for (const file of commandFiles) {
35
+    const command = require(`./commands/${file}`);
36
+    client.commands.set(command.name, command);
37
+}
38
+
39
+
40
+client.once('ready', () => {
41
+    // cache message that could be used for reactions
42
+    rolereact.cache();
43
+    console.log('Ready to act !')
44
+    client.user.setActivity(config.activity, { type: 'PLAYING' });
45
+    client.channels.cache.get(logch).send("**❕ BOT ONLINE** - ready to act");
46
+});
47
+// --- END INITIALIZATION ---
48
+
49
+
50
+client.on('message', async message => {
51
+    if (message.author.bot) return
52
+    if (!message.channel.guild) {
53
+        return logger.all(message.author.tag + " a envoyé un mp : " + message.content)
54
+    }
55
+    // For more details see /functions/messageCheck.js
56
+    msgcheck.general(message);
57
+    // Command trigger
58
+    if (!message.content.startsWith(prefix) || message.author.bot) return;
59
+
60
+    const args = message.content.slice(prefix.length).split(/ +/);
61
+    const command = args.shift().toLocaleLowerCase();
62
+
63
+    if (!client.commands.has(command)) return;
64
+
65
+    try {
66
+        client.commands.get(command).execute(message, args);
67
+        logger.all(`🔨 ${message.author.tag} - \`${message}\``)
68
+    } catch (error) {
69
+        console.error(error);
70
+    }
71
+
72
+
73
+});
74
+
75
+
76
+client.on('guildMemberAdd', async member => {
77
+    try {
78
+        logger.all(`🆕 ${member.user.tag} vient d'arriver sur le serveur`);
79
+        // update user file
80
+        msgcheck.memberUpdate(member, "join");
81
+    } catch (err) { console.error(err); }
82
+});
83
+client.on('guildMemberRemove', async member => {
84
+    try {
85
+        logger.all(`❌ ${member.user.tag} vient de quitter le serveur`);
86
+        // update user file
87
+        msgcheck.memberUpdate(member, "left");
88
+    } catch (error) {
89
+
90
+    }
91
+});
92
+
93
+
94
+client.on('messageReactionAdd', (reaction, user) => {
95
+  	if (user.bot) return
96
+    rolereact.give(reaction, user);
97
+});
98
+client.on('messageReactionRemove', (reaction, user) => {
99
+  	if (user.bot) return
100
+    rolereact.remove(reaction, user);
101
+});
102
+
103
+
102 104
 client.login(token);

Loading…
Cancel
Save