Browse Source

first commit

ALC-ProduXion 9 months ago
parent
commit
68718fc865
100 changed files with 7944 additions and 0 deletions
  1. 19
    0
      commands/del.js
  2. 11
    0
      commands/help.js
  3. 219
    0
      commands/message.js
  4. 13
    0
      config/badwords.json
  5. 7
    0
      config/botinfo.json
  6. 6
    0
      config/credentials.json
  7. 1
    0
      data/users/348848036031758337.json
  8. 1
    0
      data/users/444579657279602699.json
  9. 1
    0
      data/users/931995381590548501.json
  10. 22
    0
      functions/logger.js
  11. 125
    0
      functions/messageCheck.js
  12. 22
    0
      functions/random.js
  13. 83
    0
      functions/rolereaction.js
  14. 102
    0
      index.js
  15. 1
    0
      node_modules/.bin/color-support
  16. 1
    0
      node_modules/.bin/detect-libc
  17. 17
    0
      node_modules/.bin/detect-libc.cmd
  18. 28
    0
      node_modules/.bin/detect-libc.ps1
  19. 1
    0
      node_modules/.bin/mkdirp
  20. 17
    0
      node_modules/.bin/mkdirp.cmd
  21. 28
    0
      node_modules/.bin/mkdirp.ps1
  22. 17
    0
      node_modules/.bin/needle.cmd
  23. 28
    0
      node_modules/.bin/needle.ps1
  24. 1
    0
      node_modules/.bin/node-pre-gyp
  25. 17
    0
      node_modules/.bin/node-pre-gyp.cmd
  26. 28
    0
      node_modules/.bin/node-pre-gyp.ps1
  27. 1
    0
      node_modules/.bin/nopt
  28. 17
    0
      node_modules/.bin/nopt.cmd
  29. 28
    0
      node_modules/.bin/nopt.ps1
  30. 1
    0
      node_modules/.bin/npm
  31. 17
    0
      node_modules/.bin/npm.cmd
  32. 28
    0
      node_modules/.bin/npm.ps1
  33. 1
    0
      node_modules/.bin/npx
  34. 17
    0
      node_modules/.bin/npx.cmd
  35. 28
    0
      node_modules/.bin/npx.ps1
  36. 17
    0
      node_modules/.bin/rc.cmd
  37. 28
    0
      node_modules/.bin/rc.ps1
  38. 1
    0
      node_modules/.bin/rimraf
  39. 17
    0
      node_modules/.bin/rimraf.cmd
  40. 28
    0
      node_modules/.bin/rimraf.ps1
  41. 1
    0
      node_modules/.bin/semver
  42. 17
    0
      node_modules/.bin/semver.cmd
  43. 28
    0
      node_modules/.bin/semver.ps1
  44. 3334
    0
      node_modules/.package-lock.json
  45. 190
    0
      node_modules/@discordjs/collection/LICENSE
  46. 3
    0
      node_modules/@discordjs/collection/README.md
  47. 319
    0
      node_modules/@discordjs/collection/dist/index.d.ts
  48. 392
    0
      node_modules/@discordjs/collection/dist/index.js
  49. 53
    0
      node_modules/@discordjs/collection/package.json
  50. 19
    0
      node_modules/@discordjs/form-data/License
  51. 353
    0
      node_modules/@discordjs/form-data/Readme.md
  52. 61
    0
      node_modules/@discordjs/form-data/index.d.ts
  53. 2
    0
      node_modules/@discordjs/form-data/lib/browser.js
  54. 497
    0
      node_modules/@discordjs/form-data/lib/form_data.js
  55. 10
    0
      node_modules/@discordjs/form-data/lib/populate.js
  56. 68
    0
      node_modules/@discordjs/form-data/package.json
  57. 190
    0
      node_modules/@discordjs/rest/LICENSE
  58. 3
    0
      node_modules/@discordjs/rest/README.md
  59. 7
    0
      node_modules/@discordjs/rest/dist/index.d.ts
  60. 1
    0
      node_modules/@discordjs/rest/dist/index.d.ts.map
  61. 10
    0
      node_modules/@discordjs/rest/dist/index.js
  62. 1
    0
      node_modules/@discordjs/rest/dist/index.js.map
  63. 94
    0
      node_modules/@discordjs/rest/dist/lib/CDN.d.ts
  64. 1
    0
      node_modules/@discordjs/rest/dist/lib/CDN.d.ts.map
  65. 132
    0
      node_modules/@discordjs/rest/dist/lib/CDN.js
  66. 1
    0
      node_modules/@discordjs/rest/dist/lib/CDN.js.map
  67. 140
    0
      node_modules/@discordjs/rest/dist/lib/REST.d.ts
  68. 1
    0
      node_modules/@discordjs/rest/dist/lib/REST.d.ts.map
  69. 73
    0
      node_modules/@discordjs/rest/dist/lib/REST.js
  70. 1
    0
      node_modules/@discordjs/rest/dist/lib/REST.js.map
  71. 142
    0
      node_modules/@discordjs/rest/dist/lib/RequestManager.d.ts
  72. 1
    0
      node_modules/@discordjs/rest/dist/lib/RequestManager.d.ts.map
  73. 184
    0
      node_modules/@discordjs/rest/dist/lib/RequestManager.js
  74. 1
    0
      node_modules/@discordjs/rest/dist/lib/RequestManager.js.map
  75. 42
    0
      node_modules/@discordjs/rest/dist/lib/errors/DiscordAPIError.d.ts
  76. 1
    0
      node_modules/@discordjs/rest/dist/lib/errors/DiscordAPIError.d.ts.map
  77. 66
    0
      node_modules/@discordjs/rest/dist/lib/errors/DiscordAPIError.js
  78. 1
    0
      node_modules/@discordjs/rest/dist/lib/errors/DiscordAPIError.js.map
  79. 18
    0
      node_modules/@discordjs/rest/dist/lib/errors/HTTPError.d.ts
  80. 1
    0
      node_modules/@discordjs/rest/dist/lib/errors/HTTPError.d.ts.map
  81. 24
    0
      node_modules/@discordjs/rest/dist/lib/errors/HTTPError.js
  82. 1
    0
      node_modules/@discordjs/rest/dist/lib/errors/HTTPError.js.map
  83. 6
    0
      node_modules/@discordjs/rest/dist/lib/handlers/IHandler.d.ts
  84. 1
    0
      node_modules/@discordjs/rest/dist/lib/handlers/IHandler.d.ts.map
  85. 3
    0
      node_modules/@discordjs/rest/dist/lib/handlers/IHandler.js
  86. 1
    0
      node_modules/@discordjs/rest/dist/lib/handlers/IHandler.js.map
  87. 66
    0
      node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.d.ts
  88. 1
    0
      node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.d.ts.map
  89. 206
    0
      node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.js
  90. 1
    0
      node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.js.map
  91. 15
    0
      node_modules/@discordjs/rest/dist/lib/utils/constants.d.ts
  92. 1
    0
      node_modules/@discordjs/rest/dist/lib/utils/constants.d.ts.map
  93. 28
    0
      node_modules/@discordjs/rest/dist/lib/utils/constants.js
  94. 1
    0
      node_modules/@discordjs/rest/dist/lib/utils/constants.js.map
  95. 7
    0
      node_modules/@discordjs/rest/dist/lib/utils/utils.d.ts
  96. 1
    0
      node_modules/@discordjs/rest/dist/lib/utils/utils.d.ts.map
  97. 15
    0
      node_modules/@discordjs/rest/dist/lib/utils/utils.js
  98. 1
    0
      node_modules/@discordjs/rest/dist/lib/utils/utils.js.map
  99. 61
    0
      node_modules/@discordjs/rest/package.json
  100. 0
    0
      node_modules/@mapbox/node-pre-gyp/CHANGELOG.md

+ 19
- 0
commands/del.js View File

@@ -0,0 +1,19 @@
1
+module.exports = {
2
+    name: 'del',
3
+    description: 'Delete message',
4
+    execute(message, args) {
5
+        if (args[0]) {
6
+            const amount = parseInt(args[0]) + 1;
7
+            if (isNaN(amount)) {
8
+                return message.reply('Ce n\'est pas un nombre valide !');
9
+            }
10
+            else if (amount <= 1 || amount > 100) {
11
+                return message.reply('Ce n\'est pas un nombre valide ! (entre 1 et 99)');
12
+            }
13
+            message.channel.bulkDelete(amount)
14
+                .then(messages => {
15
+                    console.log(`${messages.size - 1} messages supprimés par ${message.author.username} sur ${message.guild.name} dans ${message.channel.name}`);
16
+                });
17
+        } else { message.reply("Merci d'indiquer le nombre de messages à supprimer"); }
18
+    }
19
+}

+ 11
- 0
commands/help.js View File

@@ -0,0 +1,11 @@
1
+module.exports = {
2
+    name: 'help',
3
+    description: 'Obtenir la liste des commandes disponibles',
4
+    execute(message) {
5
+        if (message.member.hasPermission("BAN_MEMBERS")) {
6
+            message.channel.send(`Voici les commandes disponibles en tant qu'administrateur :
7
+> \`.message\` - permet de gérer les messages classiques envoyés par le bot
8
+> \`.del n\` - permet de supprimer les n derniers messages envoyés`)
9
+        }
10
+    }
11
+}

+ 219
- 0
commands/message.js View File

@@ -0,0 +1,219 @@
1
+const fs = require('fs');
2
+const path = require('path');
3
+const { client, logch } = require("../index.js");
4
+
5
+module.exports = {
6
+    name: 'message',
7
+    description: "Permet d'envoyer des messages avec le bot",
8
+    execute(message, args) {
9
+
10
+        // Prompt help
11
+        if (!args[0] || args[0] == "help" || args[0] == "h") {
12
+            message.channel.send(`
13
+            Aide à propos de \`.message\` :
14
+Pour utiliser la commande il vous suffit d'utiliser un des arguments suivants : 
15
+> list *liste l'ensemble des messages envoyés par le bot en indiquant l'ID du message*
16
+> send ChannelID/nomDuChannel le message que vous souhaitez envoyer
17
+> edit MessageID (trouvable grâce à l'argument list) nouveau contenu du message
18
+> add MessageID 🙂 @Role *ajoute la réaction 🙂 en dessous du message et donne le @Role à ceux qui cliquent dessus*
19
+> rem MessageID 🙂 *supprime la réaction 🙂 en dessous du message*
20
+> delete MessageID *supprime le message choisi (IRREVERSIBLE)*`);
21
+        }
22
+
23
+        // list messages
24
+        else if (args[0] == "list") {
25
+            const listMsg = fs.readdirSync(`./data/messages/`).filter(file => file.endsWith('.json'));
26
+            console.log(listMsg);
27
+            if (listMsg.length == 0) {
28
+                console.log("pas de messages envoyés");
29
+                return message.channel.send("Aucun message n'a été envoyé via le bot");
30
+            }
31
+            nbMessages = 0;
32
+            messagetosend = "Liste des messages envoyés via le bot :\n";
33
+            for (const msg of listMsg) {
34
+                if (messagetosend.length >= 1400) {
35
+                    message.channel.send(messagetosend);
36
+                    messagetosend = "";
37
+                }
38
+                msgFileContent = JSON.parse(fs.readFileSync(path.resolve(`./data/messages/${msg}`)));
39
+                if (!msgFileContent.deleted) {
40
+                    nbMessages += 1;
41
+                    messagetosend += ` - ${msgFileContent.id} dans <#${msgFileContent.channelid}> : *"${msgFileContent.content.slice(0, 30)}..."*\n`
42
+                }
43
+            }
44
+            messagetosend += `${nbMessages} message(s) ont été envoyés via le bot`
45
+            message.channel.send(messagetosend)
46
+        }
47
+
48
+        // send message
49
+        else if (args[0] == "send") {
50
+            if (!args[2]) return message.channel.send("Merci de vérifier d'entrer un channel et un message à envoyer (.message help)")
51
+
52
+            // Check if this channel exists
53
+            channeltosendname = message.guild.channels.cache.find(channel => channel.name.toLowerCase() == args[1])
54
+            channeltosendid = client.channels.cache.get(args[1]);
55
+            if (channeltosendname) {
56
+                channeltosend = channeltosendname;
57
+            }
58
+            else if (channeltosendid) {
59
+                channeltosend = channeltosendid;
60
+            }
61
+            else return message.channel.send("Merci de vérifier d'avoir entré un nom de channel (ou ID) valide")
62
+
63
+            actualtimestamp = + new Date();
64
+            args.splice(0, 2);
65
+            messagecontent = args.join(" ");
66
+            channeltosend.send(messagecontent).then(sent => {
67
+                messageinfo = {
68
+                    id: `${sent.channel.id}o${sent.id}`,
69
+                    deleted: false,
70
+                    channelid: sent.channel.id,
71
+                    content: messagecontent,
72
+                    created: actualtimestamp,
73
+                    lastChange: actualtimestamp,
74
+                    reactnumber: 0
75
+                }
76
+                const jsonStringmsg = JSON.stringify(messageinfo);
77
+                fs.writeFile(`./data/messages/${sent.channel.id}o${sent.id}.json`, jsonStringmsg, err => {
78
+                    if (err) {
79
+                        console.log(`Error writing message`, err)
80
+                    } else {
81
+                        console.log(`Successfully wrote message`)
82
+                    }
83
+                });
84
+                message.react("✅");
85
+                message.channel.send("Message envoyé.")
86
+            });
87
+        }
88
+
89
+        // edit message
90
+        else if (args[0] == "edit") {
91
+            if (!args[2]) return message.channel.send("Merci de vérifier d'entrer un id de message correct et un nouveau message(.message help)");
92
+            try {
93
+                idChMsg = args[1].split(/\o+/);
94
+                argsmessage = args.slice(0);
95
+                argsmessage.splice(0, 2);
96
+                newcontent = argsmessage.join(" ");
97
+                client.channels.cache.get(idChMsg[0]).messages.fetch(idChMsg[1]).then(msg => msg.edit(newcontent));
98
+                // update message file
99
+                updatemsg = JSON.parse(fs.readFileSync(path.resolve(`./data/messages/${args[1]}.json`)));
100
+                actualtimestamp = + new Date();
101
+                updatemsg.content = newcontent;
102
+                updatemsg.lastChange = actualtimestamp;
103
+                const jsonStringmsg = JSON.stringify(updatemsg);
104
+                fs.writeFile(`./data/messages/${args[1]}.json`, jsonStringmsg, err => {
105
+                    if (err) {
106
+                        console.log(`Error writing message`, err)
107
+                    } else {
108
+                        console.log(`Successfully wrote message`)
109
+                    }
110
+                })
111
+                message.react("✅");
112
+                message.channel.send("Message modifié.")
113
+            } catch (err) {
114
+                console.error(err);
115
+                return message.channel.send("Merci de vérifier d'entrer un id de message correct (.message list)");
116
+            }
117
+        }
118
+
119
+        // delete message
120
+        else if (args[0] == "delete" || args[0] == "del") {
121
+            if (!args[1]) return message.channel.send("Merci de vérifier d'entrer un id de message correct (.message help)");
122
+            try {
123
+                idChMsg = args[1].split(/\o+/);
124
+                client.channels.cache.get(idChMsg[0]).messages.fetch(idChMsg[1]).then(msg => msg.delete());
125
+                // update message file
126
+                updatemsg = JSON.parse(fs.readFileSync(path.resolve(`./data/messages/${args[1]}.json`)));
127
+                updatemsg.deleted = true;
128
+                actualtimestamp = + new Date();
129
+                updatemsg.lastChange = actualtimestamp;
130
+                const jsonStringmsg = JSON.stringify(updatemsg);
131
+                fs.writeFile(`./data/messages/${args[1]}.json`, jsonStringmsg, err => {
132
+                    if (err) {
133
+                        console.log(`Error writing message`, err)
134
+                    } else {
135
+                        console.log(`Successfully wrote message`)
136
+                    }
137
+                })
138
+                message.react("✅");
139
+                message.channel.send("Message supprimé.")
140
+            } catch (err) {
141
+                console.error(err);
142
+                return message.channel.send("Merci de vérifier d'entrer un id de message correct (.message list)");
143
+            }
144
+        }
145
+
146
+        // add reaction
147
+        else if (args[0] == "add") {
148
+            if (!args[2]) return message.channel.send("Merci de mettre une emote valide");
149
+            try {
150
+                idChMsg = args[1].split(/\o+/);
151
+                client.channels.cache.get(idChMsg[0]).messages.fetch(idChMsg[1]).then(msg => msg.react(args[2]));
152
+                // update message file
153
+                updatemsg = JSON.parse(fs.readFileSync(path.resolve(`./data/messages/${args[1]}.json`)));
154
+                updatemsg.reactnumber += 1;
155
+                eval(`updatemsg.emoj${updatemsg.reactnumber} = args[2];`);
156
+                if (args[3] && args[3].length > 0) {
157
+                    roleID = args[3].replace('<@&', '').replace('>', '');
158
+                    rolefound = message.guild.roles.cache.find(r => r.id == roleID);
159
+                    if (rolefound) {
160
+                        eval(`updatemsg.action${updatemsg.reactnumber} = roleID;`);
161
+                    }
162
+                    else {
163
+                        message.channel.send("Ceci n'est pas un rôle, l'emoj n'a donc été associé à aucun rôle");
164
+                        eval(`updatemsg.action${updatemsg.reactnumber} = "none";`);
165
+                    }
166
+                }
167
+                else {
168
+                    message.channel.send("Vous n'avez pas précisé de rôle, l'emoj n'a donc été associé à aucun rôle");
169
+                    eval(`updatemsg.action${updatemsg.reactnumber} = "none";`);
170
+                }
171
+                actualtimestamp = + new Date();
172
+                updatemsg.lastChange = actualtimestamp;
173
+                const jsonStringmsg = JSON.stringify(updatemsg);
174
+                fs.writeFile(`./data/messages/${args[1]}.json`, jsonStringmsg, err => {
175
+                    if (err) {
176
+                        console.log(`Error writing message`, err)
177
+                    } else {
178
+                        console.log(`Successfully wrote message`)
179
+                    }
180
+                })
181
+                message.react("✅");
182
+                message.channel.send("Réaction ajoutée.")
183
+            } catch (err) {
184
+                console.error(err);
185
+                return message.channel.send("Merci de vérifier d'entrer un id de message correct (.message list) et/ou une emote valide");
186
+            }
187
+        }
188
+
189
+        // remove reaction
190
+        else if (args[0] == "rem") {
191
+            if (!args[2]) return message.channel.send("Merci de mettre une emote valide");
192
+            try {
193
+                idChMsg = args[1].split(/\o+/);
194
+                client.channels.cache.get(idChMsg[0]).messages.fetch(idChMsg[1]).then(msg => msg.reactions.cache.find(reaction => reaction.emoji.name == args[2]).remove());
195
+                // update message file
196
+                updatemsg = JSON.parse(fs.readFileSync(path.resolve(`./data/messages/${args[1]}.json`)));
197
+                for (let index = 1; index < updatemsg.reactnumber + 1; index++) {
198
+                    eval(`if (updatemsg.emoj${index} == args[2]) updatemsg.emoj${index} = "Deleted"`);
199
+                }
200
+
201
+                actualtimestamp = + new Date();
202
+                updatemsg.lastChange = actualtimestamp;
203
+                const jsonStringmsg = JSON.stringify(updatemsg);
204
+                fs.writeFile(`./data/messages/${args[1]}.json`, jsonStringmsg, err => {
205
+                    if (err) {
206
+                        console.log(`Error writing message`, err)
207
+                    } else {
208
+                        console.log(`Successfully wrote message`)
209
+                    }
210
+                })
211
+                message.react("✅");
212
+                message.channel.send("Réaction supprimée.")
213
+            } catch (err) {
214
+                console.error(err);
215
+                return message.channel.send("Merci de vérifier d'entrer un id de message correct (.message list) et/ou une emote valide");
216
+            }
217
+        }
218
+    }
219
+}

+ 13
- 0
config/badwords.json View File

@@ -0,0 +1,13 @@
1
+[
2
+    "pute",
3
+    "pétasse",
4
+    "connard",
5
+    "couillon",
6
+    "fuck",
7
+    "fdp",
8
+    "free nitro",
9
+    "gift",
10
+    "enculé",
11
+    "fils de pute",
12
+    "teubé"
13
+]

+ 7
- 0
config/botinfo.json View File

@@ -0,0 +1,7 @@
1
+{
2
+    "activity": "Agir ensemble",
3
+    "logChannelID": "963136429779734578",
4
+    "mpChannelID": "963136429779734578",
5
+    "presentationChannelID": "962010843451629618",
6
+    "memberRoleID": "964536803510059048"
7
+}

+ 6
- 0
config/credentials.json View File

@@ -0,0 +1,6 @@
1
+{
2
+    "appID": "962013583074533496",
3
+    "publicKey": "f3b1f4961bb002f64e7cade37aa3a3e3ef453e43f32f84779dd4e0872cd97984",
4
+    "prefix": ".",
5
+    "token": "LoL t'as cru que je laisserais le token ?"
6
+}

+ 1
- 0
data/users/348848036031758337.json View File

@@ -0,0 +1 @@
1
+{"id":"348848036031758337","hasleft":false,"join":1650044362737,"left":0}

+ 1
- 0
data/users/444579657279602699.json View File

@@ -0,0 +1 @@
1
+{"id":"444579657279602699","hasleft":false,"join":1650041746012,"firstMsgDate":1650041746012,"left":0}

+ 1
- 0
data/users/931995381590548501.json View File

@@ -0,0 +1 @@
1
+{"id":"931995381590548501","hasleft":false,"join":1650043735089,"left":0}

+ 22
- 0
functions/logger.js View File

@@ -0,0 +1,22 @@
1
+const { client, logch } = require("../index.js")
2
+
3
+module.exports = {
4
+    // log in discord channel & console
5
+    all: function (ttolog) {
6
+        console.log(ttolog);
7
+        try {
8
+            client.channels.cache.get(logch).send(ttolog);
9
+        } catch (error) {
10
+            console.error(error);
11
+        }
12
+    },
13
+
14
+    // log only in discord channel
15
+    channel: function (ttolog) {
16
+        try {
17
+            client.channels.cache.get(logch).send(ttolog);
18
+        } catch (error) {
19
+            console.error(error);
20
+        }
21
+    },
22
+};

+ 125
- 0
functions/messageCheck.js View File

@@ -0,0 +1,125 @@
1
+const fs = require('fs');
2
+const path = require('path');
3
+const { client, logch } = require("../index.js");
4
+const logger = require("./logger.js");
5
+
6
+const botconfig = JSON.parse(fs.readFileSync(path.resolve(`./config/botinfo.json`)));
7
+let memberRoleID = botconfig.memberRoleID
8
+const badwords = JSON.parse(fs.readFileSync(path.resolve(`./config/badwords.json`)));
9
+
10
+
11
+function checkBadwords(msg) {
12
+    badwordlist = badwords.filter(word => msg.content.includes(word));
13
+    return badwordlist;
14
+}
15
+
16
+
17
+module.exports = {
18
+    // Check general properties of message
19
+    general: function (message) {
20
+        fs.stat(`./data/users/${message.author.id}.json`, function (err, stat) {
21
+            if (err == null) {
22
+                // Check if the message is safe for community
23
+                suspiciousWords = checkBadwords(message);
24
+                if (suspiciousWords.length > 0) {
25
+                    logger.all(`${message.author.tag} a dit ${suspiciousWords.toString()} dans ${message.channel.name}`);
26
+                }
27
+
28
+
29
+            } else if (err.code === 'ENOENT') {
30
+                // If it is the first message of the member we give him member role except if his messages contains suspicious words
31
+                suspiciousWords = checkBadwords(message);
32
+                if (suspiciousWords.length > 0) {
33
+                    return logger.all(`${message.author.tag} a dit ${suspiciousWords.toString()} dans ${message.channel.name}`);
34
+                }
35
+                actualtimestamp = + new Date();
36
+                usrinfo = {
37
+                    id: message.author.id,
38
+                    hasleft: false,
39
+                    join: actualtimestamp,
40
+                    left: 0
41
+                }
42
+                const jsonStringusr = JSON.stringify(usrinfo);
43
+                fs.writeFile(`./data/users/${message.author.id}.json`, jsonStringusr, err => {
44
+                    if (err) {
45
+                        console.log(`Error writing user profile`, err)
46
+                    } else {
47
+                        console.log(`Successfully wrote user profile`)
48
+                    }
49
+                });
50
+
51
+                memberRole = message.guild.roles.cache.find(role => role.id == memberRoleID);
52
+                message.member.roles.add(memberRole);
53
+
54
+
55
+            } else {
56
+                console.log('Error: ', err.code);
57
+            }
58
+        });
59
+    },
60
+
61
+
62
+    // Update profile
63
+    memberUpdate: function (member, event) {
64
+        fs.stat(`./data/users/${member.user.id}.json`, function (err, stat) {
65
+            actualtimestamp = + new Date();
66
+            if (err == null) {
67
+                oldusrinfo = JSON.parse(fs.readFileSync(path.resolve(`./data/users/${member.user.id}.json`)));
68
+                if (event == "join") {
69
+                    joininfo = actualtimestamp;
70
+                    leftinfo = oldusrinfo.left;
71
+                    hasleftinfo = false;
72
+                    memberRole = member.guild.roles.cache.find(role => role.id == memberRoleID);
73
+                    member.roles.add(memberRole);
74
+
75
+                } else if (event == "left") {
76
+                    leftinfo = actualtimestamp;
77
+                    joininfo = oldusrinfo.join;
78
+                    hasleftinfo = true;
79
+                }
80
+                usrinfo = {
81
+                    id: member.user.id,
82
+                    hasleft: hasleftinfo,
83
+                    join: joininfo,
84
+                    left: leftinfo,
85
+                }
86
+                const jsonStringusr = JSON.stringify(usrinfo);
87
+                fs.writeFile(`./data/users/${member.user.id}.json`, jsonStringusr, err => {
88
+                    if (err) {
89
+                        console.log(`Error writing user profile`, err)
90
+                    } else {
91
+                        console.log(`Successfully wrote user profile`)
92
+                    }
93
+                });
94
+
95
+
96
+            } else if (err.code === 'ENOENT') {
97
+
98
+                if (event == "join") {
99
+                    return logger.all("Il doit donc se présenter dans le channel 👋-présentation");
100
+                } else if (event == "left") {
101
+                    leftinfo = actualtimestamp;
102
+                    joininfo = 0;
103
+                    hasleftinfo = true;
104
+                }
105
+                usrinfo = {
106
+                    id: member.user.id,
107
+                    hasleft: hasleftinfo,
108
+                    join: joininfo,
109
+                    left: leftinfo,
110
+                }
111
+                const jsonStringusr = JSON.stringify(usrinfo);
112
+                fs.writeFile(`./data/users/${member.user.id}.json`, jsonStringusr, err => {
113
+                    if (err) {
114
+                        console.log(`Error writing user profile`, err)
115
+                    } else {
116
+                        console.log(`Successfully wrote user profile`)
117
+                    }
118
+                });
119
+
120
+            } else {
121
+                console.log('Error: ', err.code);
122
+            }
123
+        });
124
+    }
125
+}

+ 22
- 0
functions/random.js View File

@@ -0,0 +1,22 @@
1
+const { client, logch } = require("../index.js")
2
+module.exports = {
3
+    // log in discord channel & console
4
+    string: function (myLength) {
5
+        const chars =
6
+            "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890";
7
+        const randomArray = Array.from(
8
+            { length: myLength },
9
+            (v, k) => chars[Math.floor(Math.random() * chars.length)]
10
+        );
11
+
12
+        const randomString = randomArray.join("");
13
+        return randomString;
14
+    },
15
+
16
+    // log only in discord channel
17
+    int: function (min, max) {
18
+        min = Math.ceil(min);
19
+        max = Math.floor(max);
20
+        return Math.floor(Math.random() * (max - min)) + min;
21
+    },
22
+};

+ 83
- 0
functions/rolereaction.js View File

@@ -0,0 +1,83 @@
1
+const fs = require('fs');
2
+const path = require('path');
3
+const { client, logch } = require("../index.js");
4
+const logger = require("./logger.js");
5
+
6
+module.exports = {
7
+    // cache messages
8
+    cache: function () {
9
+        console.log("Caching messages...");
10
+        const msgFiles = fs.readdirSync('./data/messages/').filter(file => file.endsWith('.json'));
11
+        for (const file of msgFiles) {
12
+            idChMsg = file.replace('.json', '').split(/\o+/);
13
+            console.log(idChMsg);
14
+            try {
15
+                client.channels.cache.get(idChMsg[0]).messages.fetch(idChMsg[1])
16
+            } catch (error) {
17
+                console.error(error);
18
+            }
19
+
20
+        }
21
+    },
22
+
23
+    // give a role
24
+    give: function (reaction, user) {
25
+        fileMessage = `${reaction.message.channel.id}o${reaction.message.id}`;
26
+        fs.stat(`./data/messages/${fileMessage}.json`, function (err, stat) {
27
+            if (err == null) {
28
+                try {
29
+                    member = reaction.message.guild.members.cache.find(mem => mem.user.id == user.id);
30
+                    msginfo = JSON.parse(fs.readFileSync(path.resolve(`./data/messages/${fileMessage}.json`)));
31
+                    for (let index = 1; index < msginfo.reactnumber + 1; index++) {
32
+                        eval(`
33
+                        if (msginfo.action${index} && msginfo.emoj${index} == reaction.emoji.name && msginfo.action${index} != "none") {
34
+                            
35
+                            roleactionID = msginfo.action${index};
36
+                            console.log(roleactionID);
37
+                            memberRole = reaction.message.guild.roles.cache.find(role => role.id == roleactionID);
38
+                            member.roles.add(memberRole);
39
+                            logger.all(user.tag + " a obtenu le rôle par réaction : " + memberRole.name);
40
+                        }`);
41
+                    }
42
+
43
+                } catch (err) {
44
+                    console.error(err);
45
+                }
46
+
47
+            } else {
48
+                null;
49
+                //console.log('Error: ', err.code);
50
+            }
51
+        });
52
+    },
53
+
54
+    // give a role
55
+    remove: function (reaction, user) {
56
+        fileMessage = `${reaction.message.channel.id}o${reaction.message.id}`;
57
+        fs.stat(`./data/messages/${fileMessage}.json`, function (err, stat) {
58
+            if (err == null) {
59
+                try {
60
+                    member = reaction.message.guild.members.cache.find(mem => mem.user.id == user.id);
61
+                    msginfo = JSON.parse(fs.readFileSync(path.resolve(`./data/messages/${fileMessage}.json`)));
62
+                    for (let index = 1; index < msginfo.reactnumber + 1; index++) {
63
+                        eval(`
64
+                        if (msginfo.action${index} && msginfo.emoj${index} == reaction.emoji.name && msginfo.action${index} != "none") {
65
+                            
66
+                            roleactionID = msginfo.action${index};
67
+                            console.log(roleactionID);
68
+                            memberRole = reaction.message.guild.roles.cache.find(role => role.id == roleactionID);
69
+                            member.roles.remove(memberRole);
70
+                            logger.all(user.tag + " a enlevé son rôle par réaction : " + memberRole.name);
71
+                        }`);
72
+                    }
73
+                } catch (err) {
74
+                    console.error(err);
75
+                }
76
+
77
+            } else {
78
+                null;
79
+                //console.log('Error: ', err.code);
80
+            }
81
+        });
82
+    },
83
+}

+ 102
- 0
index.js View File

@@ -0,0 +1,102 @@
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
+
102
+client.login(token);

+ 1
- 0
node_modules/.bin/color-support View File

@@ -0,0 +1 @@
1
+../color-support/bin.js

+ 1
- 0
node_modules/.bin/detect-libc View File

@@ -0,0 +1 @@
1
+../detect-libc/bin/detect-libc.js

+ 17
- 0
node_modules/.bin/detect-libc.cmd View File

@@ -0,0 +1,17 @@
1
+@ECHO off
2
+GOTO start
3
+:find_dp0
4
+SET dp0=%~dp0
5
+EXIT /b
6
+:start
7
+SETLOCAL
8
+CALL :find_dp0
9
+
10
+IF EXIST "%dp0%\node.exe" (
11
+  SET "_prog=%dp0%\node.exe"
12
+) ELSE (
13
+  SET "_prog=node"
14
+  SET PATHEXT=%PATHEXT:;.JS;=;%
15
+)
16
+
17
+endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%"  "%dp0%\..\detect-libc\bin\detect-libc.js" %*

+ 28
- 0
node_modules/.bin/detect-libc.ps1 View File

@@ -0,0 +1,28 @@
1
+#!/usr/bin/env pwsh
2
+$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3
+
4
+$exe=""
5
+if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6
+  # Fix case when both the Windows and Linux builds of Node
7
+  # are installed in the same directory
8
+  $exe=".exe"
9
+}
10
+$ret=0
11
+if (Test-Path "$basedir/node$exe") {
12
+  # Support pipeline input
13
+  if ($MyInvocation.ExpectingInput) {
14
+    $input | & "$basedir/node$exe"  "$basedir/../detect-libc/bin/detect-libc.js" $args
15
+  } else {
16
+    & "$basedir/node$exe"  "$basedir/../detect-libc/bin/detect-libc.js" $args
17
+  }
18
+  $ret=$LASTEXITCODE
19
+} else {
20
+  # Support pipeline input
21
+  if ($MyInvocation.ExpectingInput) {
22
+    $input | & "node$exe"  "$basedir/../detect-libc/bin/detect-libc.js" $args
23
+  } else {
24
+    & "node$exe"  "$basedir/../detect-libc/bin/detect-libc.js" $args
25
+  }
26
+  $ret=$LASTEXITCODE
27
+}
28
+exit $ret

+ 1
- 0
node_modules/.bin/mkdirp View File

@@ -0,0 +1 @@
1
+../mkdirp/bin/cmd.js

+ 17
- 0
node_modules/.bin/mkdirp.cmd View File

@@ -0,0 +1,17 @@
1
+@ECHO off
2
+GOTO start
3
+:find_dp0
4
+SET dp0=%~dp0
5
+EXIT /b
6
+:start
7
+SETLOCAL
8
+CALL :find_dp0
9
+
10
+IF EXIST "%dp0%\node.exe" (
11
+  SET "_prog=%dp0%\node.exe"
12
+) ELSE (
13
+  SET "_prog=node"
14
+  SET PATHEXT=%PATHEXT:;.JS;=;%
15
+)
16
+
17
+endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%"  "%dp0%\..\mkdirp\bin\cmd.js" %*

+ 28
- 0
node_modules/.bin/mkdirp.ps1 View File

@@ -0,0 +1,28 @@
1
+#!/usr/bin/env pwsh
2
+$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3
+
4
+$exe=""
5
+if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6
+  # Fix case when both the Windows and Linux builds of Node
7
+  # are installed in the same directory
8
+  $exe=".exe"
9
+}
10
+$ret=0
11
+if (Test-Path "$basedir/node$exe") {
12
+  # Support pipeline input
13
+  if ($MyInvocation.ExpectingInput) {
14
+    $input | & "$basedir/node$exe"  "$basedir/../mkdirp/bin/cmd.js" $args
15
+  } else {
16
+    & "$basedir/node$exe"  "$basedir/../mkdirp/bin/cmd.js" $args
17
+  }
18
+  $ret=$LASTEXITCODE
19
+} else {
20
+  # Support pipeline input
21
+  if ($MyInvocation.ExpectingInput) {
22
+    $input | & "node$exe"  "$basedir/../mkdirp/bin/cmd.js" $args
23
+  } else {
24
+    & "node$exe"  "$basedir/../mkdirp/bin/cmd.js" $args
25
+  }
26
+  $ret=$LASTEXITCODE
27
+}
28
+exit $ret

+ 17
- 0
node_modules/.bin/needle.cmd View File

@@ -0,0 +1,17 @@
1
+@ECHO off
2
+GOTO start
3
+:find_dp0
4
+SET dp0=%~dp0
5
+EXIT /b
6
+:start
7
+SETLOCAL
8
+CALL :find_dp0
9
+
10
+IF EXIST "%dp0%\node.exe" (
11
+  SET "_prog=%dp0%\node.exe"
12
+) ELSE (
13
+  SET "_prog=node"
14
+  SET PATHEXT=%PATHEXT:;.JS;=;%
15
+)
16
+
17
+endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%"  "%dp0%\..\needle\bin\needle" %*

+ 28
- 0
node_modules/.bin/needle.ps1 View File

@@ -0,0 +1,28 @@
1
+#!/usr/bin/env pwsh
2
+$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3
+
4
+$exe=""
5
+if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6
+  # Fix case when both the Windows and Linux builds of Node
7
+  # are installed in the same directory
8
+  $exe=".exe"
9
+}
10
+$ret=0
11
+if (Test-Path "$basedir/node$exe") {
12
+  # Support pipeline input
13
+  if ($MyInvocation.ExpectingInput) {
14
+    $input | & "$basedir/node$exe"  "$basedir/../needle/bin/needle" $args
15
+  } else {
16
+    & "$basedir/node$exe"  "$basedir/../needle/bin/needle" $args
17
+  }
18
+  $ret=$LASTEXITCODE
19
+} else {
20
+  # Support pipeline input
21
+  if ($MyInvocation.ExpectingInput) {
22
+    $input | & "node$exe"  "$basedir/../needle/bin/needle" $args
23
+  } else {
24
+    & "node$exe"  "$basedir/../needle/bin/needle" $args
25
+  }
26
+  $ret=$LASTEXITCODE
27
+}
28
+exit $ret

+ 1
- 0
node_modules/.bin/node-pre-gyp View File

@@ -0,0 +1 @@
1
+../@mapbox/node-pre-gyp/bin/node-pre-gyp

+ 17
- 0
node_modules/.bin/node-pre-gyp.cmd View File

@@ -0,0 +1,17 @@
1
+@ECHO off
2
+GOTO start
3
+:find_dp0
4
+SET dp0=%~dp0
5
+EXIT /b
6
+:start
7
+SETLOCAL
8
+CALL :find_dp0
9
+
10
+IF EXIST "%dp0%\node.exe" (
11
+  SET "_prog=%dp0%\node.exe"
12
+) ELSE (
13
+  SET "_prog=node"
14
+  SET PATHEXT=%PATHEXT:;.JS;=;%
15
+)
16
+
17
+endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%"  "%dp0%\..\node-pre-gyp\bin\node-pre-gyp" %*

+ 28
- 0
node_modules/.bin/node-pre-gyp.ps1 View File

@@ -0,0 +1,28 @@
1
+#!/usr/bin/env pwsh
2
+$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3
+
4
+$exe=""
5
+if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6
+  # Fix case when both the Windows and Linux builds of Node
7
+  # are installed in the same directory
8
+  $exe=".exe"
9
+}
10
+$ret=0
11
+if (Test-Path "$basedir/node$exe") {
12
+  # Support pipeline input
13
+  if ($MyInvocation.ExpectingInput) {
14
+    $input | & "$basedir/node$exe"  "$basedir/../node-pre-gyp/bin/node-pre-gyp" $args
15
+  } else {
16
+    & "$basedir/node$exe"  "$basedir/../node-pre-gyp/bin/node-pre-gyp" $args
17
+  }
18
+  $ret=$LASTEXITCODE
19
+} else {
20
+  # Support pipeline input
21
+  if ($MyInvocation.ExpectingInput) {
22
+    $input | & "node$exe"  "$basedir/../node-pre-gyp/bin/node-pre-gyp" $args
23
+  } else {
24
+    & "node$exe"  "$basedir/../node-pre-gyp/bin/node-pre-gyp" $args
25
+  }
26
+  $ret=$LASTEXITCODE
27
+}
28
+exit $ret

+ 1
- 0
node_modules/.bin/nopt View File

@@ -0,0 +1 @@
1
+../nopt/bin/nopt.js

+ 17
- 0
node_modules/.bin/nopt.cmd View File

@@ -0,0 +1,17 @@
1
+@ECHO off
2
+GOTO start
3
+:find_dp0
4
+SET dp0=%~dp0
5
+EXIT /b
6
+:start
7
+SETLOCAL
8
+CALL :find_dp0
9
+
10
+IF EXIST "%dp0%\node.exe" (
11
+  SET "_prog=%dp0%\node.exe"
12
+) ELSE (
13
+  SET "_prog=node"
14
+  SET PATHEXT=%PATHEXT:;.JS;=;%
15
+)
16
+
17
+endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%"  "%dp0%\..\nopt\bin\nopt.js" %*

+ 28
- 0
node_modules/.bin/nopt.ps1 View File

@@ -0,0 +1,28 @@
1
+#!/usr/bin/env pwsh
2
+$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3
+
4
+$exe=""
5
+if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6
+  # Fix case when both the Windows and Linux builds of Node
7
+  # are installed in the same directory
8
+  $exe=".exe"
9
+}
10
+$ret=0
11
+if (Test-Path "$basedir/node$exe") {
12
+  # Support pipeline input
13
+  if ($MyInvocation.ExpectingInput) {
14
+    $input | & "$basedir/node$exe"  "$basedir/../nopt/bin/nopt.js" $args
15
+  } else {
16
+    & "$basedir/node$exe"  "$basedir/../nopt/bin/nopt.js" $args
17
+  }
18
+  $ret=$LASTEXITCODE
19
+} else {
20
+  # Support pipeline input
21
+  if ($MyInvocation.ExpectingInput) {
22
+    $input | & "node$exe"  "$basedir/../nopt/bin/nopt.js" $args
23
+  } else {
24
+    & "node$exe"  "$basedir/../nopt/bin/nopt.js" $args
25
+  }
26
+  $ret=$LASTEXITCODE
27
+}
28
+exit $ret

+ 1
- 0
node_modules/.bin/npm View File

@@ -0,0 +1 @@
1
+../npm/bin/npm-cli.js

+ 17
- 0
node_modules/.bin/npm.cmd View File

@@ -0,0 +1,17 @@
1
+@ECHO off
2
+GOTO start
3
+:find_dp0
4
+SET dp0=%~dp0
5
+EXIT /b
6
+:start
7
+SETLOCAL
8
+CALL :find_dp0
9
+
10
+IF EXIST "%dp0%\node.exe" (
11
+  SET "_prog=%dp0%\node.exe"
12
+) ELSE (
13
+  SET "_prog=node"
14
+  SET PATHEXT=%PATHEXT:;.JS;=;%
15
+)
16
+
17
+endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%"  "%dp0%\..\npm\bin\npm-cli.js" %*

+ 28
- 0
node_modules/.bin/npm.ps1 View File

@@ -0,0 +1,28 @@
1
+#!/usr/bin/env pwsh
2
+$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3
+
4
+$exe=""
5
+if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6
+  # Fix case when both the Windows and Linux builds of Node
7
+  # are installed in the same directory
8
+  $exe=".exe"
9
+}
10
+$ret=0
11
+if (Test-Path "$basedir/node$exe") {
12
+  # Support pipeline input
13
+  if ($MyInvocation.ExpectingInput) {
14
+    $input | & "$basedir/node$exe"  "$basedir/../npm/bin/npm-cli.js" $args
15
+  } else {
16
+    & "$basedir/node$exe"  "$basedir/../npm/bin/npm-cli.js" $args
17
+  }
18
+  $ret=$LASTEXITCODE
19
+} else {
20
+  # Support pipeline input
21
+  if ($MyInvocation.ExpectingInput) {
22
+    $input | & "node$exe"  "$basedir/../npm/bin/npm-cli.js" $args
23
+  } else {
24
+    & "node$exe"  "$basedir/../npm/bin/npm-cli.js" $args
25
+  }
26
+  $ret=$LASTEXITCODE
27
+}
28
+exit $ret

+ 1
- 0
node_modules/.bin/npx View File

@@ -0,0 +1 @@
1
+../npm/bin/npx-cli.js

+ 17
- 0
node_modules/.bin/npx.cmd View File

@@ -0,0 +1,17 @@
1
+@ECHO off
2
+GOTO start
3
+:find_dp0
4
+SET dp0=%~dp0
5
+EXIT /b
6
+:start
7
+SETLOCAL
8
+CALL :find_dp0
9
+
10
+IF EXIST "%dp0%\node.exe" (
11
+  SET "_prog=%dp0%\node.exe"
12
+) ELSE (
13
+  SET "_prog=node"
14
+  SET PATHEXT=%PATHEXT:;.JS;=;%
15
+)
16
+
17
+endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%"  "%dp0%\..\npm\bin\npx-cli.js" %*

+ 28
- 0
node_modules/.bin/npx.ps1 View File

@@ -0,0 +1,28 @@
1
+#!/usr/bin/env pwsh
2
+$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3
+
4
+$exe=""
5
+if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6
+  # Fix case when both the Windows and Linux builds of Node
7
+  # are installed in the same directory
8
+  $exe=".exe"
9
+}
10
+$ret=0
11
+if (Test-Path "$basedir/node$exe") {
12
+  # Support pipeline input
13
+  if ($MyInvocation.ExpectingInput) {
14
+    $input | & "$basedir/node$exe"  "$basedir/../npm/bin/npx-cli.js" $args
15
+  } else {
16
+    & "$basedir/node$exe"  "$basedir/../npm/bin/npx-cli.js" $args
17
+  }
18
+  $ret=$LASTEXITCODE
19
+} else {
20
+  # Support pipeline input
21
+  if ($MyInvocation.ExpectingInput) {
22
+    $input | & "node$exe"  "$basedir/../npm/bin/npx-cli.js" $args
23
+  } else {
24
+    & "node$exe"  "$basedir/../npm/bin/npx-cli.js" $args
25
+  }
26
+  $ret=$LASTEXITCODE
27
+}
28
+exit $ret

+ 17
- 0
node_modules/.bin/rc.cmd View File

@@ -0,0 +1,17 @@
1
+@ECHO off
2
+GOTO start
3
+:find_dp0
4
+SET dp0=%~dp0
5
+EXIT /b
6
+:start
7
+SETLOCAL
8
+CALL :find_dp0
9
+
10
+IF EXIST "%dp0%\node.exe" (
11
+  SET "_prog=%dp0%\node.exe"
12
+) ELSE (
13
+  SET "_prog=node"
14
+  SET PATHEXT=%PATHEXT:;.JS;=;%
15
+)
16
+
17
+endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%"  "%dp0%\..\rc\cli.js" %*

+ 28
- 0
node_modules/.bin/rc.ps1 View File

@@ -0,0 +1,28 @@
1
+#!/usr/bin/env pwsh
2
+$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3
+
4
+$exe=""
5
+if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6
+  # Fix case when both the Windows and Linux builds of Node
7
+  # are installed in the same directory
8
+  $exe=".exe"
9
+}
10
+$ret=0
11
+if (Test-Path "$basedir/node$exe") {
12
+  # Support pipeline input
13
+  if ($MyInvocation.ExpectingInput) {
14
+    $input | & "$basedir/node$exe"  "$basedir/../rc/cli.js" $args
15
+  } else {
16
+    & "$basedir/node$exe"  "$basedir/../rc/cli.js" $args
17
+  }
18
+  $ret=$LASTEXITCODE
19
+} else {
20
+  # Support pipeline input
21
+  if ($MyInvocation.ExpectingInput) {
22
+    $input | & "node$exe"  "$basedir/../rc/cli.js" $args
23
+  } else {
24
+    & "node$exe"  "$basedir/../rc/cli.js" $args
25
+  }
26
+  $ret=$LASTEXITCODE
27
+}
28
+exit $ret

+ 1
- 0
node_modules/.bin/rimraf View File

@@ -0,0 +1 @@
1
+../rimraf/bin.js

+ 17
- 0
node_modules/.bin/rimraf.cmd View File

@@ -0,0 +1,17 @@
1
+@ECHO off
2
+GOTO start
3
+:find_dp0
4
+SET dp0=%~dp0
5
+EXIT /b
6
+:start
7
+SETLOCAL
8
+CALL :find_dp0
9
+
10
+IF EXIST "%dp0%\node.exe" (
11
+  SET "_prog=%dp0%\node.exe"
12
+) ELSE (
13
+  SET "_prog=node"
14
+  SET PATHEXT=%PATHEXT:;.JS;=;%
15
+)
16
+
17
+endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%"  "%dp0%\..\rimraf\bin.js" %*

+ 28
- 0
node_modules/.bin/rimraf.ps1 View File

@@ -0,0 +1,28 @@
1
+#!/usr/bin/env pwsh
2
+$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3
+
4
+$exe=""
5
+if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6
+  # Fix case when both the Windows and Linux builds of Node
7
+  # are installed in the same directory
8
+  $exe=".exe"
9
+}
10
+$ret=0
11
+if (Test-Path "$basedir/node$exe") {
12
+  # Support pipeline input
13
+  if ($MyInvocation.ExpectingInput) {
14
+    $input | & "$basedir/node$exe"  "$basedir/../rimraf/bin.js" $args
15
+  } else {
16
+    & "$basedir/node$exe"  "$basedir/../rimraf/bin.js" $args
17
+  }
18
+  $ret=$LASTEXITCODE
19
+} else {
20
+  # Support pipeline input
21
+  if ($MyInvocation.ExpectingInput) {
22
+    $input | & "node$exe"  "$basedir/../rimraf/bin.js" $args
23
+  } else {
24
+    & "node$exe"  "$basedir/../rimraf/bin.js" $args
25
+  }
26
+  $ret=$LASTEXITCODE
27
+}
28
+exit $ret

+ 1
- 0
node_modules/.bin/semver View File

@@ -0,0 +1 @@
1
+../semver/bin/semver.js

+ 17
- 0
node_modules/.bin/semver.cmd View File

@@ -0,0 +1,17 @@
1
+@ECHO off
2
+GOTO start
3
+:find_dp0
4
+SET dp0=%~dp0
5
+EXIT /b
6
+:start
7
+SETLOCAL
8
+CALL :find_dp0
9
+
10
+IF EXIST "%dp0%\node.exe" (
11
+  SET "_prog=%dp0%\node.exe"
12
+) ELSE (
13
+  SET "_prog=node"
14
+  SET PATHEXT=%PATHEXT:;.JS;=;%
15
+)
16
+
17
+endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%"  "%dp0%\..\semver\bin\semver" %*

+ 28
- 0
node_modules/.bin/semver.ps1 View File

@@ -0,0 +1,28 @@
1
+#!/usr/bin/env pwsh
2
+$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3
+
4
+$exe=""
5
+if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6
+  # Fix case when both the Windows and Linux builds of Node
7
+  # are installed in the same directory
8
+  $exe=".exe"
9
+}
10
+$ret=0
11
+if (Test-Path "$basedir/node$exe") {
12
+  # Support pipeline input
13
+  if ($MyInvocation.ExpectingInput) {
14
+    $input | & "$basedir/node$exe"  "$basedir/../semver/bin/semver" $args
15
+  } else {
16
+    & "$basedir/node$exe"  "$basedir/../semver/bin/semver" $args
17
+  }
18
+  $ret=$LASTEXITCODE
19
+} else {
20
+  # Support pipeline input
21
+  if ($MyInvocation.ExpectingInput) {
22
+    $input | & "node$exe"  "$basedir/../semver/bin/semver" $args
23
+  } else {
24
+    & "node$exe"  "$basedir/../semver/bin/semver" $args
25
+  }
26
+  $ret=$LASTEXITCODE
27
+}
28
+exit $ret

+ 3334
- 0
node_modules/.package-lock.json
File diff suppressed because it is too large
View File


+ 190
- 0
node_modules/@discordjs/collection/LICENSE View File

@@ -0,0 +1,190 @@
1
+                                 Apache License
2
+                           Version 2.0, January 2004
3
+                        http://www.apache.org/licenses/
4
+
5
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+   1. Definitions.
8
+
9
+      "License" shall mean the terms and conditions for use, reproduction,
10
+      and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+      "Licensor" shall mean the copyright owner or entity authorized by
13
+      the copyright owner that is granting the License.
14
+
15
+      "Legal Entity" shall mean the union of the acting entity and all
16
+      other entities that control, are controlled by, or are under common
17
+      control with that entity. For the purposes of this definition,
18
+      "control" means (i) the power, direct or indirect, to cause the
19
+      direction or management of such entity, whether by contract or
20
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+      outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+      "You" (or "Your") shall mean an individual or Legal Entity
24
+      exercising permissions granted by this License.
25
+
26
+      "Source" form shall mean the preferred form for making modifications,
27
+      including but not limited to software source code, documentation
28
+      source, and configuration files.
29
+
30
+      "Object" form shall mean any form resulting from mechanical
31
+      transformation or translation of a Source form, including but
32
+      not limited to compiled object code, generated documentation,
33
+      and conversions to other media types.
34
+
35
+      "Work" shall mean the work of authorship, whether in Source or
36
+      Object form, made available under the License, as indicated by a
37
+      copyright notice that is included in or attached to the work
38
+      (an example is provided in the Appendix below).
39
+
40
+      "Derivative Works" shall mean any work, whether in Source or Object
41
+      form, that is based on (or derived from) the Work and for which the
42
+      editorial revisions, annotations, elaborations, or other modifications
43
+      represent, as a whole, an original work of authorship. For the purposes
44
+      of this License, Derivative Works shall not include works that remain
45
+      separable from, or merely link (or bind by name) to the interfaces of,
46
+      the Work and Derivative Works thereof.
47
+
48
+      "Contribution" shall mean any work of authorship, including
49
+      the original version of the Work and any modifications or additions
50
+      to that Work or Derivative Works thereof, that is intentionally
51
+      submitted to Licensor for inclusion in the Work by the copyright owner
52
+      or by an individual or Legal Entity authorized to submit on behalf of
53
+      the copyright owner. For the purposes of this definition, "submitted"
54
+      means any form of electronic, verbal, or written communication sent
55
+      to the Licensor or its representatives, including but not limited to
56
+      communication on electronic mailing lists, source code control systems,
57
+      and issue tracking systems that are managed by, or on behalf of, the
58
+      Licensor for the purpose of discussing and improving the Work, but
59
+      excluding communication that is conspicuously marked or otherwise
60
+      designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+      "Contributor" shall mean Licensor and any individual or Legal Entity
63
+      on behalf of whom a Contribution has been received by Licensor and
64
+      subsequently incorporated within the Work.
65
+
66
+   2. Grant of Copyright License. Subject to the terms and conditions of
67
+      this License, each Contributor hereby grants to You a perpetual,
68
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+      copyright license to reproduce, prepare Derivative Works of,
70
+      publicly display, publicly perform, sublicense, and distribute the
71
+      Work and such Derivative Works in Source or Object form.
72
+
73
+   3. Grant of Patent License. Subject to the terms and conditions of
74
+      this License, each Contributor hereby grants to You a perpetual,
75
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+      (except as stated in this section) patent license to make, have made,
77
+      use, offer to sell, sell, import, and otherwise transfer the Work,
78
+      where such license applies only to those patent claims licensable
79
+      by such Contributor that are necessarily infringed by their
80
+      Contribution(s) alone or by combination of their Contribution(s)
81
+      with the Work to which such Contribution(s) was submitted. If You
82
+      institute patent litigation against any entity (including a
83
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+      or a Contribution incorporated within the Work constitutes direct
85
+      or contributory patent infringement, then any patent licenses
86
+      granted to You under this License for that Work shall terminate
87
+      as of the date such litigation is filed.
88
+
89
+   4. Redistribution. You may reproduce and distribute copies of the
90
+      Work or Derivative Works thereof in any medium, with or without
91
+      modifications, and in Source or Object form, provided that You
92
+      meet the following conditions:
93
+
94
+      (a) You must give any other recipients of the Work or
95
+          Derivative Works a copy of this License; and
96
+
97
+      (b) You must cause any modified files to carry prominent notices
98
+          stating that You changed the files; and
99
+
100
+      (c) You must retain, in the Source form of any Derivative Works
101
+          that You distribute, all copyright, patent, trademark, and
102
+          attribution notices from the Source form of the Work,
103
+          excluding those notices that do not pertain to any part of
104
+          the Derivative Works; and
105
+
106
+      (d) If the Work includes a "NOTICE" text file as part of its
107
+          distribution, then any Derivative Works that You distribute must
108
+          include a readable copy of the attribution notices contained
109
+          within such NOTICE file, excluding those notices that do not
110
+          pertain to any part of the Derivative Works, in at least one
111
+          of the following places: within a NOTICE text file distributed
112
+          as part of the Derivative Works; within the Source form or
113
+          documentation, if provided along with the Derivative Works; or,
114
+          within a display generated by the Derivative Works, if and
115
+          wherever such third-party notices normally appear. The contents
116
+          of the NOTICE file are for informational purposes only and
117
+          do not modify the License. You may add Your own attribution
118
+          notices within Derivative Works that You distribute, alongside
119
+          or as an addendum to the NOTICE text from the Work, provided
120
+          that such additional attribution notices cannot be construed
121
+          as modifying the License.
122
+
123
+      You may add Your own copyright statement to Your modifications and
124
+      may provide additional or different license terms and conditions
125
+      for use, reproduction, or distribution of Your modifications, or
126
+      for any such Derivative Works as a whole, provided Your use,
127
+      reproduction, and distribution of the Work otherwise complies with
128
+      the conditions stated in this License.
129
+
130
+   5. Submission of Contributions. Unless You explicitly state otherwise,
131
+      any Contribution intentionally submitted for inclusion in the Work
132
+      by You to the Licensor shall be under the terms and conditions of
133
+      this License, without any additional terms or conditions.
134
+      Notwithstanding the above, nothing herein shall supersede or modify
135
+      the terms of any separate license agreement you may have executed
136
+      with Licensor regarding such Contributions.
137
+
138
+   6. Trademarks. This License does not grant permission to use the trade
139
+      names, trademarks, service marks, or product names of the Licensor,
140
+      except as required for reasonable and customary use in describing the
141
+      origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+   7. Disclaimer of Warranty. Unless required by applicable law or
144
+      agreed to in writing, Licensor provides the Work (and each
145
+      Contributor provides its Contributions) on an "AS IS" BASIS,
146
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+      implied, including, without limitation, any warranties or conditions
148
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+      PARTICULAR PURPOSE. You are solely responsible for determining the
150
+      appropriateness of using or redistributing the Work and assume any
151
+      risks associated with Your exercise of permissions under this License.
152
+
153
+   8. Limitation of Liability. In no event and under no legal theory,
154
+      whether in tort (including negligence), contract, or otherwise,
155
+      unless required by applicable law (such as deliberate and grossly
156
+      negligent acts) or agreed to in writing, shall any Contributor be
157
+      liable to You for damages, including any direct, indirect, special,
158
+      incidental, or consequential damages of any character arising as a
159
+      result of this License or out of the use or inability to use the
160
+      Work (including but not limited to damages for loss of goodwill,
161
+      work stoppage, computer failure or malfunction, or any and all
162
+      other commercial damages or losses), even if such Contributor
163
+      has been advised of the possibility of such damages.
164
+
165
+   9. Accepting Warranty or Additional Liability. While redistributing
166
+      the Work or Derivative Works thereof, You may choose to offer,
167
+      and charge a fee for, acceptance of support, warranty, indemnity,
168
+      or other liability obligations and/or rights consistent with this
169
+      License. However, in accepting such obligations, You may act only
170
+      on Your own behalf and on Your sole responsibility, not on behalf
171
+      of any other Contributor, and only if You agree to indemnify,
172
+      defend, and hold each Contributor harmless for any liability
173
+      incurred by, or claims asserted against, such Contributor by reason
174
+      of your accepting any such warranty or additional liability.
175
+
176
+   END OF TERMS AND CONDITIONS
177
+
178
+   Copyright 2015 - 2020 Amish Shah
179
+
180
+   Licensed under the Apache License, Version 2.0 (the "License");
181
+   you may not use this file except in compliance with the License.
182
+   You may obtain a copy of the License at
183
+
184
+       http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+   Unless required by applicable law or agreed to in writing, software
187
+   distributed under the License is distributed on an "AS IS" BASIS,
188
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+   See the License for the specific language governing permissions and
190
+   limitations under the License.

+ 3
- 0
node_modules/@discordjs/collection/README.md View File

@@ -0,0 +1,3 @@
1
+# Collection
2
+
3
+Utility data structure used in Discord.js.

+ 319
- 0
node_modules/@discordjs/collection/dist/index.d.ts View File

@@ -0,0 +1,319 @@
1
+export interface CollectionConstructor {
2
+    new (): Collection<unknown, unknown>;
3
+    new <K, V>(entries?: ReadonlyArray<readonly [K, V]> | null): Collection<K, V>;
4
+    new <K, V>(iterable: Iterable<readonly [K, V]>): Collection<K, V>;
5
+    readonly prototype: Collection<unknown, unknown>;
6
+    readonly [Symbol.species]: CollectionConstructor;
7
+}
8
+/**
9
+ * A Map with additional utility methods. This is used throughout discord.js rather than Arrays for anything that has
10
+ * an ID, for significantly improved performance and ease-of-use.
11
+ * @extends {Map}
12
+ * @property {number} size - The amount of elements in this collection.
13
+ */
14
+declare class Collection<K, V> extends Map<K, V> {
15
+    private _array;
16
+    private _keyArray;
17
+    static readonly default: typeof Collection;
18
+    ['constructor']: typeof Collection;
19
+    constructor(entries?: ReadonlyArray<readonly [K, V]> | null);
20
+    /**
21
+     * Identical to [Map.get()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get).
22
+     * Gets an element with the specified key, and returns its value, or `undefined` if the element does not exist.
23
+     * @param {*} key - The key to get from this collection
24
+     * @returns {* | undefined}
25
+     */
26
+    get(key: K): V | undefined;
27
+    /**
28
+     * Identical to [Map.set()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/set).
29
+     * Sets a new element in the collection with the specified key and value.
30
+     * @param {*} key - The key of the element to add
31
+     * @param {*} value - The value of the element to add
32
+     * @returns {Collection}
33
+     */
34
+    set(key: K, value: V): this;
35
+    /**
36
+     * Identical to [Map.has()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has).
37
+     * Checks if an element exists in the collection.
38
+     * @param {*} key - The key of the element to check for
39
+     * @returns {boolean} `true` if the element exists, `false` if it does not exist.
40
+     */
41
+    has(key: K): boolean;
42
+    /**
43
+     * Identical to [Map.delete()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete).
44
+     * Deletes an element from the collection.
45
+     * @param {*} key - The key to delete from the collection
46
+     * @returns {boolean} `true` if the element was removed, `false` if the element does not exist.
47
+     */
48
+    delete(key: K): boolean;
49
+    /**
50
+     * Identical to [Map.clear()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/clear).
51
+     * Removes all elements from the collection.
52
+     * @returns {undefined}
53
+     */
54
+    clear(): void;
55
+    /**
56
+     * Creates an ordered array of the values of this collection, and caches it internally. The array will only be
57
+     * reconstructed if an item is added to or removed from the collection, or if you change the length of the array
58
+     * itself. If you don't want this caching behavior, use `[...collection.values()]` or
59
+     * `Array.from(collection.values())` instead.
60
+     * @returns {Array}
61
+     */
62
+    array(): V[];
63
+    /**
64
+     * Creates an ordered array of the keys of this collection, and caches it internally. The array will only be
65
+     * reconstructed if an item is added to or removed from the collection, or if you change the length of the array
66
+     * itself. If you don't want this caching behavior, use `[...collection.keys()]` or
67
+     * `Array.from(collection.keys())` instead.
68
+     * @returns {Array}
69
+     */
70
+    keyArray(): K[];
71
+    /**
72
+     * Obtains the first value(s) in this collection.
73
+     * @param {number} [amount] Amount of values to obtain from the beginning
74
+     * @returns {*|Array<*>} A single value if no amount is provided or an array of values, starting from the end if
75
+     * amount is negative
76
+     */
77
+    first(): V | undefined;
78
+    first(amount: number): V[];
79
+    /**
80
+     * Obtains the first key(s) in this collection.
81
+     * @param {number} [amount] Amount of keys to obtain from the beginning
82
+     * @returns {*|Array<*>} A single key if no amount is provided or an array of keys, starting from the end if
83
+     * amount is negative
84
+     */
85
+    firstKey(): K | undefined;
86
+    firstKey(amount: number): K[];
87
+    /**
88
+     * Obtains the last value(s) in this collection. This relies on {@link Collection#array}, and thus the caching
89
+     * mechanism applies here as well.
90
+     * @param {number} [amount] Amount of values to obtain from the end
91
+     * @returns {*|Array<*>} A single value if no amount is provided or an array of values, starting from the start if
92
+     * amount is negative
93
+     */
94
+    last(): V | undefined;
95
+    last(amount: number): V[];
96
+    /**
97
+     * Obtains the last key(s) in this collection. This relies on {@link Collection#keyArray}, and thus the caching
98
+     * mechanism applies here as well.
99
+     * @param {number} [amount] Amount of keys to obtain from the end
100
+     * @returns {*|Array<*>} A single key if no amount is provided or an array of keys, starting from the start if
101
+     * amount is negative
102
+     */
103
+    lastKey(): K | undefined;
104
+    lastKey(amount: number): K[];
105
+    /**
106
+     * Obtains unique random value(s) from this collection. This relies on {@link Collection#array}, and thus the caching
107
+     * mechanism applies here as well.
108
+     * @param {number} [amount] Amount of values to obtain randomly
109
+     * @returns {*|Array<*>} A single value if no amount is provided or an array of values
110
+     */
111
+    random(): V;
112
+    random(amount: number): V[];
113
+    /**
114
+     * Obtains unique random key(s) from this collection. This relies on {@link Collection#keyArray}, and thus the caching
115
+     * mechanism applies here as well.
116
+     * @param {number} [amount] Amount of keys to obtain randomly
117
+     * @returns {*|Array<*>} A single key if no amount is provided or an array
118
+     */
119
+    randomKey(): K;
120
+    randomKey(amount: number): K[];
121
+    /**
122
+     * Searches for a single item where the given function returns a truthy value. This behaves like
123
+     * [Array.find()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find).
124
+     * <warn>All collections used in Discord.js are mapped using their `id` property, and if you want to find by id you
125
+     * should use the `get` method. See
126
+     * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get) for details.</warn>
127
+     * @param {Function} fn The function to test with (should return boolean)
128
+     * @param {*} [thisArg] Value to use as `this` when executing function
129
+     * @returns {*}
130
+     * @example collection.find(user => user.username === 'Bob');
131
+     */
132
+    find(fn: (value: V, key: K, collection: this) => boolean): V | undefined;
133
+    find<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): V | undefined;
134
+    /**
135
+     * Searches for the key of a single item where the given function returns a truthy value. This behaves like
136
+     * [Array.findIndex()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex),
137
+     * but returns the key rather than the positional index.
138
+     * @param {Function} fn The function to test with (should return boolean)
139
+     * @param {*} [thisArg] Value to use as `this` when executing function
140
+     * @returns {*}
141
+     * @example collection.findKey(user => user.username === 'Bob');
142
+     */
143
+    findKey(fn: (value: V, key: K, collection: this) => boolean): K | undefined;
144
+    findKey<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): K | undefined;
145
+    /**
146
+     * Removes items that satisfy the provided filter function.
147
+     * @param {Function} fn Function used to test (should return a boolean)
148
+     * @param {*} [thisArg] Value to use as `this` when executing function
149
+     * @returns {number} The number of removed entries
150
+     */
151
+    sweep(fn: (value: V, key: K, collection: this) => boolean): number;
152
+    sweep<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): number;
153
+    /**
154
+     * Identical to
155
+     * [Array.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter),
156
+     * but returns a Collection instead of an Array.
157
+     * @param {Function} fn The function to test with (should return boolean)
158
+     * @param {*} [thisArg] Value to use as `this` when executing function
159
+     * @returns {Collection}
160
+     * @example collection.filter(user => user.username === 'Bob');
161
+     */
162
+    filter(fn: (value: V, key: K, collection: this) => boolean): this;
163
+    filter<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): this;
164
+    /**
165
+     * Partitions the collection into two collections where the first collection
166
+     * contains the items that passed and the second contains the items that failed.
167
+     * @param {Function} fn Function used to test (should return a boolean)
168
+     * @param {*} [thisArg] Value to use as `this` when executing function
169
+     * @returns {Collection[]}
170
+     * @example const [big, small] = collection.partition(guild => guild.memberCount > 250);
171
+     */
172
+    partition(fn: (value: V, key: K, collection: this) => boolean): [this, this];
173
+    partition<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): [this, this];
174
+    /**
175
+     * Maps each item into a Collection, then joins the results into a single Collection. Identical in behavior to
176
+     * [Array.flatMap()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap).
177
+     * @param {Function} fn Function that produces a new Collection
178
+     * @param {*} [thisArg] Value to use as `this` when executing function
179
+     * @returns {Collection}
180
+     * @example collection.flatMap(guild => guild.members.cache);
181
+     */
182
+    flatMap<T>(fn: (value: V, key: K, collection: this) => Collection<K, T>): Collection<K, T>;
183
+    flatMap<T, This>(fn: (this: This, value: V, key: K, collection: this) => Collection<K, T>, thisArg: This): Collection<K, T>;
184
+    /**
185
+     * Maps each item to another value into an array. Identical in behavior to
186
+     * [Array.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).
187
+     * @param {Function} fn Function that produces an element of the new array, taking three arguments
188
+     * @param {*} [thisArg] Value to use as `this` when executing function
189
+     * @returns {Array}
190
+     * @example collection.map(user => user.tag);
191
+     */
192
+    map<T>(fn: (value: V, key: K, collection: this) => T): T[];
193
+    map<This, T>(fn: (this: This, value: V, key: K, collection: this) => T, thisArg: This): T[];
194
+    /**
195
+     * Maps each item to another value into a collection. Identical in behavior to
196
+     * [Array.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).
197
+     * @param {Function} fn Function that produces an element of the new collection, taking three arguments
198
+     * @param {*} [thisArg] Value to use as `this` when executing function
199
+     * @returns {Collection}
200
+     * @example collection.mapValues(user => user.tag);
201
+     */
202
+    mapValues<T>(fn: (value: V, key: K, collection: this) => T): Collection<K, T>;
203
+    mapValues<This, T>(fn: (this: This, value: V, key: K, collection: this) => T, thisArg: This): Collection<K, T>;
204
+    /**
205
+     * Checks if there exists an item that passes a test. Identical in behavior to
206
+     * [Array.some()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some).
207
+     * @param {Function} fn Function used to test (should return a boolean)
208
+     * @param {*} [thisArg] Value to use as `this` when executing function
209
+     * @returns {boolean}
210
+     * @example collection.some(user => user.discriminator === '0000');
211
+     */
212
+    some(fn: (value: V, key: K, collection: this) => boolean): boolean;
213
+    some<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): boolean;
214
+    /**
215
+     * Checks if all items passes a test. Identical in behavior to
216
+     * [Array.every()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every).
217
+     * @param {Function} fn Function used to test (should return a boolean)
218
+     * @param {*} [thisArg] Value to use as `this` when executing function
219
+     * @returns {boolean}
220
+     * @example collection.every(user => !user.bot);
221
+     */
222
+    every(fn: (value: V, key: K, collection: this) => boolean): boolean;
223
+    every<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): boolean;
224
+    /**
225
+     * Applies a function to produce a single value. Identical in behavior to
226
+     * [Array.reduce()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce).
227
+     * @param {Function} fn Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,
228
+     * and `collection`
229
+     * @param {*} [initialValue] Starting value for the accumulator
230
+     * @returns {*}
231
+     * @example collection.reduce((acc, guild) => acc + guild.memberCount, 0);
232
+     */
233
+    reduce<T>(fn: (accumulator: T, value: V, key: K, collection: this) => T, initialValue?: T): T;
234
+    /**
235
+     * Identical to
236
+     * [Map.forEach()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach),
237
+     * but returns the collection instead of undefined.
238
+     * @param {Function} fn Function to execute for each element
239
+     * @param {*} [thisArg] Value to use as `this` when executing function
240
+     * @returns {Collection}
241
+     * @example
242
+     * collection
243
+     *  .each(user => console.log(user.username))
244
+     *  .filter(user => user.bot)
245
+     *  .each(user => console.log(user.username));
246
+     */
247
+    each(fn: (value: V, key: K, collection: this) => void): this;
248
+    each<T>(fn: (this: T, value: V, key: K, collection: this) => void, thisArg: T): this;
249
+    /**
250
+     * Runs a function on the collection and returns the collection.
251
+     * @param {Function} fn Function to execute
252
+     * @param {*} [thisArg] Value to use as `this` when executing function
253
+     * @returns {Collection}
254
+     * @example
255
+     * collection
256
+     *  .tap(coll => console.log(coll.size))
257
+     *  .filter(user => user.bot)
258
+     *  .tap(coll => console.log(coll.size))
259
+     */
260
+    tap(fn: (collection: this) => void): this;
261
+    tap<T>(fn: (this: T, collection: this) => void, thisArg: T): this;
262
+    /**
263
+     * Creates an identical shallow copy of this collection.
264
+     * @returns {Collection}
265
+     * @example const newColl = someColl.clone();
266
+     */
267
+    clone(): this;
268
+    /**
269
+     * Combines this collection with others into a new collection. None of the source collections are modified.
270
+     * @param {...Collection} collections Collections to merge
271
+     * @returns {Collection}
272
+     * @example const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);
273
+     */
274
+    concat(...collections: Collection<K, V>[]): this;
275
+    /**
276
+     * Checks if this collection shares identical items with another.
277
+     * This is different to checking for equality using equal-signs, because
278
+     * the collections may be different objects, but contain the same data.
279
+     * @param {Collection} collection Collection to compare with
280
+     * @returns {boolean} Whether the collections have identical contents
281
+     */
282
+    equals(collection: Collection<K, V>): boolean;
283
+    /**
284
+     * The sort method sorts the items of a collection in place and returns it.
285
+     * The sort is not necessarily stable in Node 10 or older.
286
+     * The default sort order is according to string Unicode code points.
287
+     * @param {Function} [compareFunction] Specifies a function that defines the sort order.
288
+     * If omitted, the collection is sorted according to each character's Unicode code point value,
289
+     * according to the string conversion of each element.
290
+     * @returns {Collection}
291
+     * @example collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
292
+     */
293
+    sort(compareFunction?: (firstValue: V, secondValue: V, firstKey: K, secondKey: K) => number): this;
294
+    /**
295
+     * The intersect method returns a new structure containing items where the keys are present in both original structures.
296
+     * @param {Collection} other The other Collection to filter against
297
+     * @returns {Collection}
298
+     */
299
+    intersect(other: Collection<K, V>): Collection<K, V>;
300
+    /**
301
+     * The difference method returns a new structure containing items where the key is present in one of the original structures but not the other.
302
+     * @param {Collection} other The other Collection to filter against
303
+     * @returns {Collection}
304
+     */
305
+    difference(other: Collection<K, V>): Collection<K, V>;
306
+    /**
307
+     * The sorted method sorts the items of a collection and returns it.
308
+     * The sort is not necessarily stable in Node 10 or older.
309
+     * The default sort order is according to string Unicode code points.
310
+     * @param {Function} [compareFunction] Specifies a function that defines the sort order.
311
+     * If omitted, the collection is sorted according to each character's Unicode code point value,
312
+     * according to the string conversion of each element.
313
+     * @returns {Collection}
314
+     * @example collection.sorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
315
+     */
316
+    sorted(compareFunction?: (firstValue: V, secondValue: V, firstKey: K, secondKey: K) => number): this;
317
+}
318
+export { Collection };
319
+export default Collection;

+ 392
- 0
node_modules/@discordjs/collection/dist/index.js
File diff suppressed because it is too large
View File


+ 53
- 0
node_modules/@discordjs/collection/package.json View File

@@ -0,0 +1,53 @@
1
+{
2
+  "name": "@discordjs/collection",
3
+  "version": "0.1.6",
4
+  "description": "Utility data structure used in Discord.js",
5
+  "main": "dist/index.js",
6
+  "types": "dist/index.d.ts",
7
+  "scripts": {
8
+    "lint": "eslint src --ext .ts",
9
+    "prebuild": "npm run lint",
10
+    "build": "rimraf dist/ && tsc",
11
+    "pretest": "npm run build",
12
+    "test": "node test/index.js",
13
+    "docs": "docgen --jsdoc jsdoc.json --source src/*.ts src/**/*.ts --custom docs/index.yml --output docs/docs.json",
14
+    "docs:test": "docgen --jsdoc jsdoc.json --source src/*.ts src/**/*.ts --custom docs/index.yml"
15
+  },
16
+  "repository": {
17
+    "type": "git",
18
+    "url": "git+https://github.com/discordjs/collection.git"
19
+  },
20
+  "keywords": [
21
+    "map",
22
+    "collection",
23
+    "utility"
24
+  ],
25
+  "author": "Amish Shah <amishshah.2k@gmail.com>",
26
+  "license": "Apache-2.0",
27
+  "bugs": {
28
+    "url": "https://github.com/discordjs/collection/issues"
29
+  },
30
+  "homepage": "https://github.com/discordjs/collection#readme",
31
+  "devDependencies": {
32
+    "@babel/cli": "^7.8.4",
33
+    "@babel/core": "^7.8.4",
34
+    "@babel/preset-env": "^7.8.4",
35
+    "@babel/preset-typescript": "^7.8.3",
36
+    "@types/node": "^13.7.4",
37
+    "@typescript-eslint/eslint-plugin": "^2.21.0",
38
+    "@typescript-eslint/parser": "^2.21.0",
39
+    "discord.js-docgen": "discordjs/docgen#ts-patch",
40
+    "eslint": "^6.8.0",
41
+    "eslint-config-marine": "^6.0.0",
42
+    "jsdoc-babel": "^0.5.0",
43
+    "rimraf": "^3.0.2",
44
+    "typescript": "^3.8.2"
45
+  },
46
+  "eslintConfig": {
47
+    "extends": "marine/node"
48
+  }
49
+
50
+,"_resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.6.tgz"
51
+,"_integrity": "sha512-utRNxnd9kSS2qhyivo9lMlt5qgAUasH2gb7BEOn6p0efFh24gjGomHzWKMAPn2hEReOPQZCJaRKoURwRotKucQ=="
52
+,"_from": "@discordjs/collection@0.1.6"
53
+}

+ 19
- 0
node_modules/@discordjs/form-data/License View File

@@ -0,0 +1,19 @@
1
+Copyright (c) 2012 Felix Geisendörfer (felix@debuggable.com) and contributors
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.

+ 353
- 0
node_modules/@discordjs/form-data/Readme.md View File

@@ -0,0 +1,353 @@
1
+# Form-Data [![NPM Module](https://img.shields.io/npm/v/form-data.svg)](https://www.npmjs.com/package/form-data) [![Join the chat at https://gitter.im/form-data/form-data](http://form-data.github.io/images/gitterbadge.svg)](https://gitter.im/form-data/form-data)
2
+
3
+A library to create readable ```"multipart/form-data"``` streams. Can be used to submit forms and file uploads to other web applications.
4
+
5
+The API of this library is inspired by the [XMLHttpRequest-2 FormData Interface][xhr2-fd].
6
+
7
+[xhr2-fd]: http://dev.w3.org/2006/webapi/XMLHttpRequest-2/Overview.html#the-formdata-interface
8
+
9
+[![Linux Build](https://img.shields.io/travis/form-data/form-data/master.svg?label=linux:6.x-12.x)](https://travis-ci.org/form-data/form-data)
10
+[![MacOS Build](https://img.shields.io/travis/form-data/form-data/master.svg?label=macos:6.x-12.x)](https://travis-ci.org/form-data/form-data)
11
+[![Windows Build](https://img.shields.io/travis/form-data/form-data/master.svg?label=windows:6.x-12.x)](https://travis-ci.org/form-data/form-data)
12
+
13
+[![Coverage Status](https://img.shields.io/coveralls/form-data/form-data/master.svg?label=code+coverage)](https://coveralls.io/github/form-data/form-data?branch=master)
14
+[![Dependency Status](https://img.shields.io/david/form-data/form-data.svg)](https://david-dm.org/form-data/form-data)
15
+
16
+## Install
17
+
18
+```
19
+npm install --save form-data
20
+```
21
+
22
+## Usage
23
+
24
+In this example we are constructing a form with 3 fields that contain a string,
25
+a buffer and a file stream.
26
+
27
+``` javascript
28
+var FormData = require('form-data');
29
+var fs = require('fs');
30
+
31
+var form = new FormData();
32
+form.append('my_field', 'my value');
33
+form.append('my_buffer', new Buffer(10));
34
+form.append('my_file', fs.createReadStream('/foo/bar.jpg'));
35
+```
36
+
37
+Also you can use http-response stream:
38
+
39
+``` javascript
40
+var FormData = require('form-data');
41
+var http = require('http');
42
+
43
+var form = new FormData();
44
+
45
+http.request('http://nodejs.org/images/logo.png', function(response) {
46
+  form.append('my_field', 'my value');
47
+  form.append('my_buffer', new Buffer(10));
48
+  form.append('my_logo', response);
49
+});
50
+```
51
+
52
+Or @mikeal's [request](https://github.com/request/request) stream:
53
+
54
+``` javascript
55
+var FormData = require('form-data');
56
+var request = require('request');
57
+
58
+var form = new FormData();
59
+
60
+form.append('my_field', 'my value');
61
+form.append('my_buffer', new Buffer(10));
62
+form.append('my_logo', request('http://nodejs.org/images/logo.png'));
63
+```
64
+
65
+In order to submit this form to a web application, call ```submit(url, [callback])``` method:
66
+
67
+``` javascript
68
+form.submit('http://example.org/', function(err, res) {
69
+  // res – response object (http.IncomingMessage)  //
70
+  res.resume();
71
+});
72
+
73
+```
74
+
75
+For more advanced request manipulations ```submit()``` method returns ```http.ClientRequest``` object, or you can choose from one of the alternative submission methods.
76
+
77
+### Custom options
78
+
79
+You can provide custom options, such as `maxDataSize`:
80
+
81
+``` javascript
82
+var FormData = require('form-data');
83
+
84
+var form = new FormData({ maxDataSize: 20971520 });
85
+form.append('my_field', 'my value');
86
+form.append('my_buffer', /* something big */);
87
+```
88
+
89
+List of available options could be found in [combined-stream](https://github.com/felixge/node-combined-stream/blob/master/lib/combined_stream.js#L7-L15)
90
+
91
+### Alternative submission methods
92
+
93
+You can use node's http client interface:
94
+
95
+``` javascript
96
+var http = require('http');
97
+
98
+var request = http.request({
99
+  method: 'post',
100
+  host: 'example.org',
101
+  path: '/upload',
102
+  headers: form.getHeaders()
103
+});
104
+
105
+form.pipe(request);
106
+
107
+request.on('response', function(res) {
108
+  console.log(res.statusCode);
109
+});
110
+```
111
+
112
+Or if you would prefer the `'Content-Length'` header to be set for you:
113
+
114
+``` javascript
115
+form.submit('example.org/upload', function(err, res) {
116
+  console.log(res.statusCode);
117
+});
118
+```
119
+
120
+To use custom headers and pre-known length in parts:
121
+
122
+``` javascript
123
+var CRLF = '\r\n';
124
+var form = new FormData();
125
+
126
+var options = {
127
+  header: CRLF + '--' + form.getBoundary() + CRLF + 'X-Custom-Header: 123' + CRLF + CRLF,
128
+  knownLength: 1
129
+};
130
+
131
+form.append('my_buffer', buffer, options);
132
+
133
+form.submit('http://example.com/', function(err, res) {
134
+  if (err) throw err;
135
+  console.log('Done');
136
+});
137
+```
138
+
139
+Form-Data can recognize and fetch all the required information from common types of streams (```fs.readStream```, ```http.response``` and ```mikeal's request```), for some other types of streams you'd need to provide "file"-related information manually:
140
+
141
+``` javascript
142
+someModule.stream(function(err, stdout, stderr) {
143
+  if (err) throw err;
144
+
145
+  var form = new FormData();
146
+
147
+  form.append('file', stdout, {
148
+    filename: 'unicycle.jpg', // ... or:
149
+    filepath: 'photos/toys/unicycle.jpg',
150
+    contentType: 'image/jpeg',
151
+    knownLength: 19806
152
+  });
153
+
154
+  form.submit('http://example.com/', function(err, res) {
155
+    if (err) throw err;
156
+    console.log('Done');
157
+  });
158
+});
159
+```
160
+
161
+The `filepath` property overrides `filename` and may contain a relative path. This is typically used when uploading [multiple files from a directory](https://wicg.github.io/entries-api/#dom-htmlinputelement-webkitdirectory).
162
+
163
+For edge cases, like POST request to URL with query string or to pass HTTP auth credentials, object can be passed to `form.submit()` as first parameter:
164
+
165
+``` javascript
166
+form.submit({
167
+  host: 'example.com',
168
+  path: '/probably.php?extra=params',
169
+  auth: 'username:password'
170
+}, function(err, res) {
171
+  console.log(res.statusCode);
172
+});
173
+```
174
+
175
+In case you need to also send custom HTTP headers with the POST request, you can use the `headers` key in first parameter of `form.submit()`:
176
+
177
+``` javascript
178
+form.submit({
179
+  host: 'example.com',
180
+  path: '/surelynot.php',
181
+  headers: {'x-test-header': 'test-header-value'}
182
+}, function(err, res) {
183
+  console.log(res.statusCode);
184
+});
185
+```
186
+
187
+### Methods
188
+
189
+- [_Void_ append( **String** _field_, **Mixed** _value_ [, **Mixed** _options_] )](https://github.com/form-data/form-data#void-append-string-field-mixed-value--mixed-options-).
190
+- [_Headers_ getHeaders( [**Headers** _userHeaders_] )](https://github.com/form-data/form-data#array-getheaders-array-userheaders-)
191
+- [_String_ getBoundary()](https://github.com/form-data/form-data#string-getboundary)
192
+- [_Buffer_ getBuffer()](https://github.com/form-data/form-data#buffer-getbuffer)
193
+- [_Integer_ getLengthSync()](https://github.com/form-data/form-data#integer-getlengthsync)
194
+- [_Integer_ getLength( **function** _callback_ )](https://github.com/form-data/form-data#integer-getlength-function-callback-)
195
+- [_Boolean_ hasKnownLength()](https://github.com/form-data/form-data#boolean-hasknownlength)
196
+- [_Request_ submit( _params_, **function** _callback_ )](https://github.com/form-data/form-data#request-submit-params-function-callback-)
197
+- [_String_ toString()](https://github.com/form-data/form-data#string-tostring)
198
+
199
+#### _Void_ append( **String** _field_, **Mixed** _value_ [, **Mixed** _options_] )
200
+Append data to the form. You can submit about any format (string, integer, boolean, buffer, etc.). However, Arrays are not supported and need to be turned into strings by the user.
201
+```javascript
202
+var form = new FormData();
203
+form.append( 'my_string', 'my value' );
204
+form.append( 'my_integer', 1 );
205
+form.append( 'my_boolean', true );
206
+form.append( 'my_buffer', new Buffer(10) );
207
+form.append( 'my_array_as_json', JSON.stringify( ['bird','cute'] ) )
208
+```
209
+
210
+You may provide a string for options, or an object.
211
+```javascript
212
+// Set filename by providing a string for options
213
+form.append( 'my_file', fs.createReadStream('/foo/bar.jpg'), 'bar.jpg' );
214
+
215
+// provide an object.
216
+form.append( 'my_file', fs.createReadStream('/foo/bar.jpg'), {filename: 'bar.jpg', contentType: 'image/jpeg', knownLength: 19806} );
217
+```
218
+
219
+#### _Headers_ getHeaders( [**Headers** _userHeaders_] )
220
+This method adds the correct `content-type` header to the provided array of `userHeaders`.  
221
+
222
+#### _String_ getBoundary()
223
+Return the boundary of the formData. A boundary consists of 26 `-` followed by 24 numbers
224
+for example:
225
+```javascript
226
+--------------------------515890814546601021194782
227
+```
228
+_Note: The boundary must be unique and may not appear in the data._
229
+
230
+#### _Buffer_ getBuffer()
231
+Return the full formdata request package, as a Buffer. You can insert this Buffer in e.g. Axios to send multipart data.
232
+```javascript
233
+var form = new FormData();
234
+form.append( 'my_buffer', Buffer.from([0x4a,0x42,0x20,0x52,0x6f,0x63,0x6b,0x73]) );
235
+form.append( 'my_file', fs.readFileSync('/foo/bar.jpg') );
236
+
237
+axios.post( 'https://example.com/path/to/api',
238
+            form.getBuffer(),
239
+            form.getHeaders()
240
+          )
241
+```
242
+**Note:** Because the output is of type Buffer, you can only append types that are accepted by Buffer: *string, Buffer, ArrayBuffer, Array, or Array-like Object*. A ReadStream for example will result in an error.
243
+
244
+#### _Integer_ getLengthSync()
245
+Same as `getLength` but synchronous.
246
+
247
+_Note: getLengthSync __doesn't__ calculate streams length._
248
+
249
+#### _Integer_ getLength( **function** _callback_ )
250
+Returns the `Content-Length` async. The callback is used to handle errors and continue once the length has been calculated
251
+```javascript
252
+this.getLength(function(err, length) {
253
+  if (err) {
254
+    this._error(err);
255
+    return;
256
+  }
257
+
258
+  // add content length
259
+  request.setHeader('Content-Length', length);
260
+
261
+  ...
262
+}.bind(this));
263
+```
264
+
265
+#### _Boolean_ hasKnownLength()
266
+Checks if the length of added values is known.
267
+
268
+#### _Request_ submit( _params_, **function** _callback_ )
269
+Submit the form to a web application.
270
+```javascript
271
+var form = new FormData();
272
+form.append( 'my_string', 'Hello World' );
273
+
274
+form.submit( 'http://example.com/', function(err, res) {
275
+  // res – response object (http.IncomingMessage)  //
276
+  res.resume();
277
+} );
278
+```
279
+
280
+#### _String_ toString()
281
+Returns the form data as a string. Don't use this if you are sending files or buffers, use `getBuffer()` instead.
282
+
283
+### Integration with other libraries
284
+
285
+#### Request
286
+
287
+Form submission using  [request](https://github.com/request/request):
288
+
289
+```javascript
290
+var formData = {
291
+  my_field: 'my_value',
292
+  my_file: fs.createReadStream(__dirname + '/unicycle.jpg'),
293
+};
294
+
295
+request.post({url:'http://service.com/upload', formData: formData}, function(err, httpResponse, body) {
296
+  if (err) {
297
+    return console.error('upload failed:', err);
298
+  }
299
+  console.log('Upload successful!  Server responded with:', body);
300
+});
301
+```
302
+
303
+For more details see [request readme](https://github.com/request/request#multipartform-data-multipart-form-uploads).
304
+
305
+#### node-fetch
306
+
307
+You can also submit a form using [node-fetch](https://github.com/bitinn/node-fetch):
308
+
309
+```javascript
310
+var form = new FormData();
311
+
312
+form.append('a', 1);
313
+
314
+fetch('http://example.com', { method: 'POST', body: form })
315
+    .then(function(res) {
316
+        return res.json();
317
+    }).then(function(json) {
318
+        console.log(json);
319
+    });
320
+```
321
+
322
+#### axios
323
+
324
+In Node.js you can post a file using [axios](https://github.com/axios/axios):
325
+```javascript
326
+const form = new FormData();
327
+const stream = fs.createReadStream(PATH_TO_FILE);
328
+
329
+form.append('image', stream);
330
+
331
+// In Node.js environment you need to set boundary in the header field 'Content-Type' by calling method `getHeaders`
332
+const formHeaders = form.getHeaders();
333
+
334
+axios.post('http://example.com', form, {
335
+  headers: {
336
+    ...formHeaders,
337
+  },
338
+})
339
+.then(response => response)
340
+.catch(error => error)
341
+```
342
+
343
+## Notes
344
+
345
+- ```getLengthSync()``` method DOESN'T calculate length for streams, use ```knownLength``` options as workaround.
346
+- ```getLength(cb)``` will send an error as first parameter of callback if stream length cannot be calculated (e.g. send in custom streams w/o using ```knownLength```).
347
+- ```sbumit``` will not add `content-length` if form length is unknown or not calculable.
348
+- Starting version `2.x` FormData has dropped support for `node@0.10.x`.
349
+- Starting version `3.x` FormData has dropped support for `node@4.x`.
350
+
351
+## License
352
+
353
+Form-Data is released under the [MIT](License) license.

+ 61
- 0
node_modules/@discordjs/form-data/index.d.ts View File

@@ -0,0 +1,61 @@
1
+// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>
2
+//                 Leon Yu <https://github.com/leonyu>
3
+//                 BendingBender <https://github.com/BendingBender>
4
+//                 Maple Miao <https://github.com/mapleeit>
5
+
6
+/// <reference types="node" />
7
+import * as stream from 'stream';
8
+import * as http from 'http';
9
+
10
+export = FormData;
11
+
12
+// Extracted because @types/node doesn't export interfaces.
13
+interface ReadableOptions {
14
+  highWaterMark?: number;
15
+  encoding?: string;
16
+  objectMode?: boolean;
17
+  read?(this: stream.Readable, size: number): void;
18
+  destroy?(this: stream.Readable, error: Error | null, callback: (error: Error | null) => void): void;
19
+  autoDestroy?: boolean;
20
+}
21
+
22
+interface Options extends ReadableOptions {
23
+  writable?: boolean;
24
+  readable?: boolean;
25
+  dataSize?: number;
26
+  maxDataSize?: number;
27
+  pauseStreams?: boolean;
28
+}
29
+
30
+declare class FormData extends stream.Readable {
31
+  constructor(options?: Options);
32
+  append(key: string, value: any, options?: FormData.AppendOptions | string): void;
33
+  getHeaders(userHeaders?: FormData.Headers): FormData.Headers;
34
+  submit(
35
+    params: string | FormData.SubmitOptions,
36
+    callback?: (error: Error | null, response: http.IncomingMessage) => void
37
+  ): http.ClientRequest;
38
+  getBuffer(): Buffer;
39
+  getBoundary(): string;
40
+  getLength(callback: (err: Error | null, length: number) => void): void;
41
+  getLengthSync(): number;
42
+  hasKnownLength(): boolean;
43
+}
44
+
45
+declare namespace FormData {
46
+  interface Headers {
47
+    [key: string]: any;
48
+  }
49
+
50
+  interface AppendOptions {
51
+    header?: string | Headers;
52
+    knownLength?: number;
53
+    filename?: string;
54
+    filepath?: string;
55
+    contentType?: string;
56
+  }
57
+
58
+  interface SubmitOptions extends http.RequestOptions {
59
+    protocol?: 'https:' | 'http:';
60
+  }
61
+}

+ 2
- 0
node_modules/@discordjs/form-data/lib/browser.js View File

@@ -0,0 +1,2 @@
1
+/* eslint-env browser */
2
+module.exports = typeof self == 'object' ? self.FormData : window.FormData;

+ 497
- 0
node_modules/@discordjs/form-data/lib/form_data.js View File

@@ -0,0 +1,497 @@
1
+var CombinedStream = require('combined-stream');
2
+var util = require('util');
3
+var path = require('path');
4
+var http = require('http');
5
+var https = require('https');
6
+var parseUrl = require('url').parse;
7
+var fs = require('fs');
8
+var Stream = require('stream').Stream;
9
+var mime = require('mime-types');
10
+var asynckit = require('asynckit');
11
+var populate = require('./populate.js');
12
+
13
+// Public API
14
+module.exports = FormData;
15
+
16
+// make it a Stream
17
+util.inherits(FormData, CombinedStream);
18
+
19
+/**
20
+ * Create readable "multipart/form-data" streams.
21
+ * Can be used to submit forms
22
+ * and file uploads to other web applications.
23
+ *
24
+ * @constructor
25
+ * @param {Object} options - Properties to be added/overriden for FormData and CombinedStream
26
+ */
27
+function FormData(options) {
28
+  if (!(this instanceof FormData)) {
29
+    return new FormData(options);
30
+  }
31
+
32
+  this._overheadLength = 0;
33
+  this._valueLength = 0;
34
+  this._valuesToMeasure = [];
35
+
36
+  CombinedStream.call(this);
37
+
38
+  options = options || {};
39
+  for (var option in options) {
40
+    this[option] = options[option];
41
+  }
42
+}
43
+
44
+FormData.LINE_BREAK = '\r\n';
45
+FormData.DEFAULT_CONTENT_TYPE = 'application/octet-stream';
46
+
47
+FormData.prototype.append = function(field, value, options) {
48
+
49
+  options = options || {};
50
+
51
+  // allow filename as single option
52
+  if (typeof options == 'string') {
53
+    options = {filename: options};
54
+  }
55
+
56
+  var append = CombinedStream.prototype.append.bind(this);
57
+
58
+  // all that streamy business can't handle numbers
59
+  if (typeof value == 'number') {
60
+    value = '' + value;
61
+  }
62
+
63
+  // https://github.com/felixge/node-form-data/issues/38
64
+  if (util.isArray(value)) {
65
+    // Please convert your array into string
66
+    // the way web server expects it
67
+    this._error(new Error('Arrays are not supported.'));
68
+    return;
69
+  }
70
+
71
+  var header = this._multiPartHeader(field, value, options);
72
+  var footer = this._multiPartFooter();
73
+
74
+  append(header);
75
+  append(value);
76
+  append(footer);
77
+
78
+  // pass along options.knownLength
79
+  this._trackLength(header, value, options);
80
+};
81
+
82
+FormData.prototype._trackLength = function(header, value, options) {
83
+  var valueLength = 0;
84
+
85
+  // used w/ getLengthSync(), when length is known.
86
+  // e.g. for streaming directly from a remote server,
87
+  // w/ a known file a size, and not wanting to wait for
88
+  // incoming file to finish to get its size.
89
+  if (options.knownLength != null) {
90
+    valueLength += +options.knownLength;
91
+  } else if (Buffer.isBuffer(value)) {
92
+    valueLength = value.length;
93
+  } else if (typeof value === 'string') {
94
+    valueLength = Buffer.byteLength(value);
95
+  }
96
+
97
+  this._valueLength += valueLength;
98
+
99
+  // @check why add CRLF? does this account for custom/multiple CRLFs?
100
+  this._overheadLength +=
101
+    Buffer.byteLength(header) +
102
+    FormData.LINE_BREAK.length;
103
+
104
+  // empty or either doesn't have path or not an http response or not a stream
105
+  if (!value || ( !value.path && !(value.readable && value.hasOwnProperty('httpVersion')) && !(value instanceof Stream))) {
106
+    return;
107
+  }
108
+
109
+  // no need to bother with the length
110
+  if (!options.knownLength) {
111
+    this._valuesToMeasure.push(value);
112
+  }
113
+};
114
+
115
+FormData.prototype._lengthRetriever = function(value, callback) {
116
+
117
+  if (value.hasOwnProperty('fd')) {
118
+
119
+    // take read range into a account
120
+    // `end` = Infinity –> read file till the end
121
+    //
122
+    // TODO: Looks like there is bug in Node fs.createReadStream
123
+    // it doesn't respect `end` options without `start` options
124
+    // Fix it when node fixes it.
125
+    // https://github.com/joyent/node/issues/7819
126
+    if (value.end != undefined && value.end != Infinity && value.start != undefined) {
127
+
128
+      // when end specified
129
+      // no need to calculate range
130
+      // inclusive, starts with 0
131
+      callback(null, value.end + 1 - (value.start ? value.start : 0));
132
+
133
+    // not that fast snoopy
134
+    } else {
135
+      // still need to fetch file size from fs
136
+      fs.stat(value.path, function(err, stat) {
137
+
138
+        var fileSize;
139
+
140
+        if (err) {
141
+          callback(err);
142
+          return;
143
+        }
144
+
145
+        // update final size based on the range options
146
+        fileSize = stat.size - (value.start ? value.start : 0);
147
+        callback(null, fileSize);
148
+      });
149
+    }
150
+
151
+  // or http response
152
+  } else if (value.hasOwnProperty('httpVersion')) {
153
+    callback(null, +value.headers['content-length']);
154
+
155
+  // or request stream http://github.com/mikeal/request
156
+  } else if (value.hasOwnProperty('httpModule')) {
157
+    // wait till response come back
158
+    value.on('response', function(response) {
159
+      value.pause();
160
+      callback(null, +response.headers['content-length']);
161
+    });
162
+    value.resume();
163
+
164
+  // something else
165
+  } else {
166
+    callback('Unknown stream');
167
+  }
168
+};
169
+
170
+FormData.prototype._multiPartHeader = function(field, value, options) {
171
+  // custom header specified (as string)?
172
+  // it becomes responsible for boundary
173
+  // (e.g. to handle extra CRLFs on .NET servers)
174
+  if (typeof options.header == 'string') {
175
+    return options.header;
176
+  }
177
+
178
+  var contentDisposition = this._getContentDisposition(value, options);
179
+  var contentType = this._getContentType(value, options);
180
+
181
+  var contents = '';
182
+  var headers  = {
183
+    // add custom disposition as third element or keep it two elements if not
184
+    'Content-Disposition': ['form-data', 'name="' + field + '"'].concat(contentDisposition || []),
185
+    // if no content type. allow it to be empty array
186
+    'Content-Type': [].concat(contentType || [])
187
+  };
188
+
189
+  // allow custom headers.
190
+  if (typeof options.header == 'object') {
191
+    populate(headers, options.header);
192
+  }
193
+
194
+  var header;
195
+  for (var prop in headers) {
196
+    if (!headers.hasOwnProperty(prop)) continue;
197
+    header = headers[prop];
198
+
199
+    // skip nullish headers.
200
+    if (header == null) {
201
+      continue;
202
+    }
203
+
204
+    // convert all headers to arrays.
205
+    if (!Array.isArray(header)) {
206
+      header = [header];
207
+    }
208
+
209
+    // add non-empty headers.
210
+    if (header.length) {
211
+      contents += prop + ': ' + header.join('; ') + FormData.LINE_BREAK;
212
+    }
213
+  }
214
+
215
+  return '--' + this.getBoundary() + FormData.LINE_BREAK + contents + FormData.LINE_BREAK;
216
+};
217
+
218
+FormData.prototype._getContentDisposition = function(value, options) {
219
+
220
+  var filename
221
+    , contentDisposition
222
+    ;
223
+
224
+  if (typeof options.filepath === 'string') {
225
+    // custom filepath for relative paths
226
+    filename = path.normalize(options.filepath).replace(/\\/g, '/');
227
+  } else if (options.filename || value.name || value.path) {
228
+    // custom filename take precedence
229
+    // formidable and the browser add a name property
230
+    // fs- and request- streams have path property
231
+    filename = path.basename(options.filename || value.name || value.path);
232
+  } else if (value.readable && value.hasOwnProperty('httpVersion')) {
233
+    // or try http response
234
+    filename = path.basename(value.client._httpMessage.path || '');
235
+  }
236
+
237
+  if (filename) {
238
+    contentDisposition = 'filename="' + filename + '"';
239
+  }
240
+
241
+  return contentDisposition;
242
+};
243
+
244
+FormData.prototype._getContentType = function(value, options) {
245
+
246
+  // use custom content-type above all
247
+  var contentType = options.contentType;
248
+
249
+  // or try `name` from formidable, browser