Browse Source

first commit

ALC-ProduXion 2 years 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

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

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

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

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

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

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

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

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

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

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

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

+ 22
- 0
functions/logger.js View File

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

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

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

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

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

1
+../color-support/bin.js

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

1
+../detect-libc/bin/detect-libc.js

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

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

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

1
+../mkdirp/bin/cmd.js

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

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

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

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

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

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

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

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

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

1
+../nopt/bin/nopt.js

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

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

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

1
+../npm/bin/npm-cli.js

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

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

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

1
+../npm/bin/npx-cli.js

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

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

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

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

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

1
+../rimraf/bin.js

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

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

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

1
+../semver/bin/semver.js

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

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

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

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

1
+# Collection
2
+
3
+Utility data structure used in Discord.js.

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

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

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

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

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

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

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

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
250
+  if (!contentType && value.name) {
251
+    contentType = mime.lookup(value.name);
252
+  }
253
+
254
+  // or try `path` from fs-, request- streams
255
+  if (!contentType && value.path) {
256
+    contentType = mime.lookup(value.path);
257
+  }
258
+
259
+  // or if it's http-reponse
260
+  if (!contentType && value.readable && value.hasOwnProperty('httpVersion')) {
261
+    contentType = value.headers['content-type'];
262
+  }
263
+
264
+  // or guess it from the filepath or filename
265
+  if (!contentType && (options.filepath || options.filename)) {
266
+    contentType = mime.lookup(options.filepath || options.filename);
267
+  }
268
+
269
+  // fallback to the default content type if `value` is not simple value
270
+  if (!contentType && typeof value == 'object') {
271
+    contentType = FormData.DEFAULT_CONTENT_TYPE;
272
+  }
273
+
274
+  return contentType;
275
+};
276
+
277
+FormData.prototype._multiPartFooter = function() {
278
+  return function(next) {
279
+    var footer = FormData.LINE_BREAK;
280
+
281
+    var lastPart = (this._streams.length === 0);
282
+    if (lastPart) {
283
+      footer += this._lastBoundary();
284
+    }
285
+
286
+    next(footer);
287
+  }.bind(this);
288
+};
289
+
290
+FormData.prototype._lastBoundary = function() {
291
+  return '--' + this.getBoundary() + '--' + FormData.LINE_BREAK;
292
+};
293
+
294
+FormData.prototype.getHeaders = function(userHeaders) {
295
+  var header;
296
+  var formHeaders = {
297
+    'content-type': 'multipart/form-data; boundary=' + this.getBoundary()
298
+  };
299
+
300
+  for (header in userHeaders) {
301
+    if (userHeaders.hasOwnProperty(header)) {
302
+      formHeaders[header.toLowerCase()] = userHeaders[header];
303
+    }
304
+  }
305
+
306
+  return formHeaders;
307
+};
308
+
309
+FormData.prototype.getBoundary = function() {
310
+  if (!this._boundary) {
311
+    this._generateBoundary();
312
+  }
313
+
314
+  return this._boundary;
315
+};
316
+
317
+FormData.prototype.getBuffer = function() {
318
+  var dataBuffer = new Buffer.alloc( 0 );
319
+  var boundary = this.getBoundary();
320
+
321
+  // Create the form content. Add Line breaks to the end of data.
322
+  for (var i = 0, len = this._streams.length; i < len; i++) {
323
+    if (typeof this._streams[i] !== 'function') {
324
+
325
+      // Add content to the buffer.
326
+      if(Buffer.isBuffer(this._streams[i])) {
327
+        dataBuffer = Buffer.concat( [dataBuffer, this._streams[i]]);
328
+      }else {
329
+        dataBuffer = Buffer.concat( [dataBuffer, Buffer.from(this._streams[i])]);
330
+      }
331
+
332
+      // Add break after content.
333
+      if (typeof this._streams[i] !== 'string' || this._streams[i].substring( 2, boundary.length + 2 ) !== boundary) {
334
+        dataBuffer = Buffer.concat( [dataBuffer, Buffer.from(FormData.LINE_BREAK)] );
335
+      }
336
+    }
337
+  }
338
+
339
+  // Add the footer and return the Buffer object.
340
+  return Buffer.concat( [dataBuffer, Buffer.from(this._lastBoundary())] );
341
+};
342
+
343
+FormData.prototype._generateBoundary = function() {
344
+  // This generates a 50 character boundary similar to those used by Firefox.
345
+  // They are optimized for boyer-moore parsing.
346
+  var boundary = '--------------------------';
347
+  for (var i = 0; i < 24; i++) {
348
+    boundary += Math.floor(Math.random() * 10).toString(16);
349
+  }
350
+
351
+  this._boundary = boundary;
352
+};
353
+
354
+// Note: getLengthSync DOESN'T calculate streams length
355
+// As workaround one can calculate file size manually
356
+// and add it as knownLength option
357
+FormData.prototype.getLengthSync = function() {
358
+  var knownLength = this._overheadLength + this._valueLength;
359
+
360
+  // Don't get confused, there are 3 "internal" streams for each keyval pair
361
+  // so it basically checks if there is any value added to the form
362
+  if (this._streams.length) {
363
+    knownLength += this._lastBoundary().length;
364
+  }
365
+
366
+  // https://github.com/form-data/form-data/issues/40
367
+  if (!this.hasKnownLength()) {
368
+    // Some async length retrievers are present
369
+    // therefore synchronous length calculation is false.
370
+    // Please use getLength(callback) to get proper length
371
+    this._error(new Error('Cannot calculate proper length in synchronous way.'));
372
+  }
373
+
374
+  return knownLength;
375
+};
376
+
377
+// Public API to check if length of added values is known
378
+// https://github.com/form-data/form-data/issues/196
379
+// https://github.com/form-data/form-data/issues/262
380
+FormData.prototype.hasKnownLength = function() {
381
+  var hasKnownLength = true;
382
+
383
+  if (this._valuesToMeasure.length) {
384
+    hasKnownLength = false;
385
+  }
386
+
387
+  return hasKnownLength;
388
+};
389
+
390
+FormData.prototype.getLength = function(cb) {
391
+  var knownLength = this._overheadLength + this._valueLength;
392
+
393
+  if (this._streams.length) {
394
+    knownLength += this._lastBoundary().length;
395
+  }
396
+
397
+  if (!this._valuesToMeasure.length) {
398
+    process.nextTick(cb.bind(this, null, knownLength));
399
+    return;
400
+  }
401
+
402
+  asynckit.parallel(this._valuesToMeasure, this._lengthRetriever, function(err, values) {
403
+    if (err) {
404
+      cb(err);
405
+      return;
406
+    }
407
+
408
+    values.forEach(function(length) {
409
+      knownLength += length;
410
+    });
411
+
412
+    cb(null, knownLength);
413
+  });
414
+};
415
+
416
+FormData.prototype.submit = function(params, cb) {
417
+  var request
418
+    , options
419
+    , defaults = {method: 'post'}
420
+    ;
421
+
422
+  // parse provided url if it's string
423
+  // or treat it as options object
424
+  if (typeof params == 'string') {
425
+
426
+    params = parseUrl(params);
427
+    options = populate({
428
+      port: params.port,
429
+      path: params.pathname,
430
+      host: params.hostname,
431
+      protocol: params.protocol
432
+    }, defaults);
433
+
434
+  // use custom params
435
+  } else {
436
+
437
+    options = populate(params, defaults);
438
+    // if no port provided use default one
439
+    if (!options.port) {
440
+      options.port = options.protocol == 'https:' ? 443 : 80;
441
+    }
442
+  }
443
+
444
+  // put that good code in getHeaders to some use
445
+  options.headers = this.getHeaders(params.headers);
446
+
447
+  // https if specified, fallback to http in any other case
448
+  if (options.protocol == 'https:') {
449
+    request = https.request(options);
450
+  } else {
451
+    request = http.request(options);
452
+  }
453
+
454
+  // get content length and fire away
455
+  this.getLength(function(err, length) {
456
+    if (err && err !== 'Unknown stream') {
457
+      this._error(err);
458
+      return;
459
+    }
460
+
461
+    // add content length
462
+    if (length) {
463
+      request.setHeader('Content-Length', length);
464
+    }
465
+
466
+    this.pipe(request);
467
+    if (cb) {
468
+      var onResponse;
469
+
470
+      var callback = function (error, responce) {
471
+        request.removeListener('error', callback);
472
+        request.removeListener('response', onResponse);
473
+
474
+        return cb.call(this, error, responce);
475
+      };
476
+
477
+      onResponse = callback.bind(this, null);
478
+
479
+      request.on('error', callback);
480
+      request.on('response', onResponse);
481
+    }
482
+  }.bind(this));
483
+
484
+  return request;
485
+};
486
+
487
+FormData.prototype._error = function(err) {
488
+  if (!this.error) {
489
+    this.error = err;
490
+    this.pause();
491
+    this.emit('error', err);
492
+  }
493
+};
494
+
495
+FormData.prototype.toString = function () {
496
+  return '[object FormData]';
497
+};

+ 10
- 0
node_modules/@discordjs/form-data/lib/populate.js View File

1
+// populates missing values
2
+module.exports = function(dst, src) {
3
+
4
+  Object.keys(src).forEach(function(prop)
5
+  {
6
+    dst[prop] = dst[prop] || src[prop];
7
+  });
8
+
9
+  return dst;
10
+};

+ 68
- 0
node_modules/@discordjs/form-data/package.json View File

1
+{
2
+  "author": "Felix Geisendörfer <felix@debuggable.com> (http://debuggable.com/)",
3
+  "name": "@discordjs/form-data",
4
+  "description": "A library to create readable \"multipart/form-data\" streams. Can be used to submit forms and file uploads to other web applications.",
5
+  "version": "3.0.1",
6
+  "repository": {
7
+    "type": "git",
8
+    "url": "git://github.com/form-data/form-data.git"
9
+  },
10
+  "main": "./lib/form_data",
11
+  "browser": "./lib/browser",
12
+  "typings": "./index.d.ts",
13
+  "scripts": {
14
+    "pretest": "rimraf coverage test/tmp",
15
+    "test": "istanbul cover test/run.js",
16
+    "posttest": "istanbul report lcov text",
17
+    "lint": "eslint lib/*.js test/*.js test/integration/*.js",
18
+    "report": "istanbul report lcov text",
19
+    "ci-lint": "is-node-modern 8 && npm run lint || is-node-not-modern 8",
20
+    "ci-test": "npm run test && npm run browser && npm run report",
21
+    "predebug": "rimraf coverage test/tmp",
22
+    "debug": "verbose=1 ./test/run.js",
23
+    "browser": "browserify -t browserify-istanbul test/run-browser.js | obake --coverage",
24
+    "check": "istanbul check-coverage coverage/coverage*.json",
25
+    "files": "pkgfiles --sort=name",
26
+    "get-version": "node -e \"console.log(require('./package.json').version)\""
27
+  },
28
+  "pre-commit": [
29
+    "lint",
30
+    "ci-test",
31
+    "check"
32
+  ],
33
+  "engines": {
34
+    "node": ">= 6"
35
+  },
36
+  "dependencies": {
37
+    "asynckit": "^0.4.0",
38
+    "combined-stream": "^1.0.8",
39
+    "mime-types": "^2.1.12"
40
+  },
41
+  "devDependencies": {
42
+    "@types/node": "^12.0.10",
43
+    "browserify": "^13.1.1",
44
+    "browserify-istanbul": "^2.0.0",
45
+    "coveralls": "^3.0.4",
46
+    "cross-spawn": "^6.0.5",
47
+    "eslint": "^6.0.1",
48
+    "fake": "^0.2.2",
49
+    "far": "^0.0.7",
50
+    "formidable": "^1.0.17",
51
+    "in-publish": "^2.0.0",
52
+    "is-node-modern": "^1.0.0",
53
+    "istanbul": "^0.4.5",
54
+    "obake": "^0.1.2",
55
+    "puppeteer": "^1.19.0",
56
+    "pkgfiles": "^2.3.0",
57
+    "pre-commit": "^1.1.3",
58
+    "request": "^2.88.0",
59
+    "rimraf": "^2.7.1",
60
+    "tape": "^4.6.2",
61
+    "typescript": "^3.5.2"
62
+  },
63
+  "license": "MIT"
64
+
65
+,"_resolved": "https://registry.npmjs.org/@discordjs/form-data/-/form-data-3.0.1.tgz"
66
+,"_integrity": "sha512-ZfFsbgEXW71Rw/6EtBdrP5VxBJy4dthyC0tpQKGKmYFImlmmrykO14Za+BiIVduwjte0jXEBlhSKf0MWbFp9Eg=="
67
+,"_from": "@discordjs/form-data@3.0.1"
68
+}

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

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 - 2021 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/rest/README.md View File

1
+# `@discordjs/rest`
2
+
3
+> The REST API module for Discord.js

+ 7
- 0
node_modules/@discordjs/rest/dist/index.d.ts View File

1
+export * from './lib/CDN';
2
+export * from './lib/errors/DiscordAPIError';
3
+export * from './lib/errors/HTTPError';
4
+export * from './lib/RequestManager';
5
+export * from './lib/REST';
6
+export * from './lib/utils/constants';
7
+//# sourceMappingURL=index.d.ts.map

+ 1
- 0
node_modules/@discordjs/rest/dist/index.d.ts.map View File

1
+{"version":3,"file":"index.d.ts","sourceRoot":"./","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC"}

+ 10
- 0
node_modules/@discordjs/rest/dist/index.js View File

1
+"use strict";
2
+Object.defineProperty(exports, "__esModule", { value: true });
3
+const tslib_1 = require("tslib");
4
+tslib_1.__exportStar(require("./lib/CDN"), exports);
5
+tslib_1.__exportStar(require("./lib/errors/DiscordAPIError"), exports);
6
+tslib_1.__exportStar(require("./lib/errors/HTTPError"), exports);
7
+tslib_1.__exportStar(require("./lib/RequestManager"), exports);
8
+tslib_1.__exportStar(require("./lib/REST"), exports);
9
+tslib_1.__exportStar(require("./lib/utils/constants"), exports);
10
+//# sourceMappingURL=index.js.map

+ 1
- 0
node_modules/@discordjs/rest/dist/index.js.map View File

1
+{"version":3,"file":"index.js","sourceRoot":"./","sources":["index.ts"],"names":[],"mappings":";;;AAAA,oDAA0B;AAC1B,uEAA6C;AAC7C,iEAAuC;AACvC,+DAAqC;AACrC,qDAA2B;AAC3B,gEAAsC"}

+ 94
- 0
node_modules/@discordjs/rest/dist/lib/CDN.d.ts View File

1
+import { ImageExtension, ImageSize } from './utils/constants';
2
+export interface ImageURLOptions {
3
+    extension?: ImageExtension;
4
+    size?: ImageSize;
5
+    dynamic?: boolean;
6
+}
7
+/**
8
+ * The CDN link builder
9
+ */
10
+export declare class CDN {
11
+    private readonly base;
12
+    constructor(base?: string);
13
+    /**
14
+     * Generates an app asset URL for a client's asset.
15
+     * @param clientID The client ID that has the asset
16
+     * @param assetHash The hash provided by Discord for this asset
17
+     * @param options Optional options for the asset
18
+     */
19
+    appAsset(clientID: string, assetHash: string, options?: ImageURLOptions): string;
20
+    /**
21
+     * Generates an app icon URL for a client's icon.
22
+     * @param clientID The client ID that has the icon
23
+     * @param iconHash The hash provided by Discord for this icon
24
+     * @param options Optional options for the icon
25
+     */
26
+    appIcon(clientID: string, iconHash: string, options?: ImageURLOptions): string;
27
+    /**
28
+     * Generates the default avatar URL for a discriminator.
29
+     * @param discriminator The discriminator modulo 5
30
+     */
31
+    defaultAvatar(discriminator: number): string;
32
+    /**
33
+     * Generates a discovery splash URL for a guild's discovery splash.
34
+     * @param guildID The guild ID that has the discovery splash
35
+     * @param splashHash The hash provided by Discord for this splash
36
+     * @param options Optional options for the splash
37
+     */
38
+    discoverySplash(guildID: string, splashHash: string, options?: ImageURLOptions): string;
39
+    /**
40
+     * Generates an emoji's URL for an emoji.
41
+     * @param emojiID The emoji ID
42
+     * @param extension The extension of the emoji
43
+     */
44
+    emoji(emojiID: string, extension?: ImageExtension): string;
45
+    /**
46
+     * Generates a group DM icon URL for a group DM.
47
+     * @param channelID The group channel ID that has the icon
48
+     * @param iconHash The hash provided by Discord for this group DM channel
49
+     * @param options Optional options for the icon
50
+     */
51
+    groupDMIcon(channelID: string, iconHash: string, options?: ImageURLOptions): string;
52
+    /**
53
+     * Generates a banner URL for a guild's banner.
54
+     * @param guildID The guild ID that has the banner splash
55
+     * @param bannerHash The hash provided by Discord for this banner
56
+     * @param options Optional options for the banner
57
+     */
58
+    guildBanner(guildID: string, bannerHash: string, options?: ImageURLOptions): string;
59
+    /**
60
+     * Generates an icon URL for a guild's icon.
61
+     * @param guildID The guild ID that has the icon splash
62
+     * @param iconHash The hash provided by Discord for this icon
63
+     * @param options Optional options for the icon
64
+     */
65
+    guildIcon(guildID: string, iconHash: string, options?: ImageURLOptions): string;
66
+    /**
67
+     * Generates a guild invite splash URL for a guild's invite splash.
68
+     * @param guildID The guild ID that has the invite splash
69
+     * @param splashHash The hash provided by Discord for this splash
70
+     * @param options Optional options for the splash
71
+     */
72
+    splash(guildID: string, splashHash: string, options?: ImageURLOptions): string;
73
+    /**
74
+     * Generates a team icon URL for a team's icon.
75
+     * @param teamID The team ID that has the icon
76
+     * @param iconHash The hash provided by Discord for this icon
77
+     * @param options Optional options for the icon
78
+     */
79
+    teamIcon(teamID: string, iconHash: string, options?: ImageURLOptions): string;
80
+    /**
81
+     * Generates a user avatar URL for a user's avatar.
82
+     * @param userID The user ID that has the icon
83
+     * @param avatarHash The hash provided by Discord for this avatar
84
+     * @param options Optional options for the avatar
85
+     */
86
+    userAvatar(userID: string, avatarHash: string, { dynamic, ...options }?: ImageURLOptions): string;
87
+    /**
88
+     * Constructs the URL for the resource
89
+     * @param base The base cdn route
90
+     * @param options The extension/size options for the link
91
+     */
92
+    private makeURL;
93
+}
94
+//# sourceMappingURL=CDN.d.ts.map

+ 1
- 0
node_modules/@discordjs/rest/dist/lib/CDN.d.ts.map View File

1
+{"version":3,"file":"CDN.d.ts","sourceRoot":"./","sources":["lib/CDN.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyD,cAAc,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAErH,MAAM,WAAW,eAAe;IAC/B,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,qBAAa,GAAG;IACI,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,GAAE,MAA+B;IAEzE;;;;;OAKG;IACI,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,MAAM;IAIvF;;;;;OAKG;IACI,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,MAAM;IAIrF;;;OAGG;IACI,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM;IAInD;;;;;OAKG;IACI,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,MAAM;IAI9F;;;;OAIG;IACI,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,cAAc,GAAG,MAAM;IAIjE;;;;;OAKG;IACI,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,MAAM;IAI1F;;;;;OAKG;IACI,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,MAAM;IAI1F;;;;;OAKG;IACI,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,MAAM;IAItF;;;;;OAKG;IACI,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,MAAM;IAIrF;;;;;OAKG;IACI,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,MAAM;IAIpF;;;;;OAKG;IACI,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,OAAe,EAAE,GAAG,OAAO,EAAE,GAAE,eAAoB,GAAG,MAAM;IAQpH;;;;OAIG;IACH,OAAO,CAAC,OAAO;CAqBf"}

+ 132
- 0
node_modules/@discordjs/rest/dist/lib/CDN.js View File

1
+"use strict";
2
+Object.defineProperty(exports, "__esModule", { value: true });
3
+exports.CDN = void 0;
4
+const constants_1 = require("./utils/constants");
5
+/**
6
+ * The CDN link builder
7
+ */
8
+class CDN {
9
+    constructor(base = constants_1.DefaultRestOptions.cdn) {
10
+        this.base = base;
11
+    }
12
+    /**
13
+     * Generates an app asset URL for a client's asset.
14
+     * @param clientID The client ID that has the asset
15
+     * @param assetHash The hash provided by Discord for this asset
16
+     * @param options Optional options for the asset
17
+     */
18
+    appAsset(clientID, assetHash, options) {
19
+        return this.makeURL(`/app-assets/${clientID}/${assetHash}`, options);
20
+    }
21
+    /**
22
+     * Generates an app icon URL for a client's icon.
23
+     * @param clientID The client ID that has the icon
24
+     * @param iconHash The hash provided by Discord for this icon
25
+     * @param options Optional options for the icon
26
+     */
27
+    appIcon(clientID, iconHash, options) {
28
+        return this.makeURL(`/app-icons/${clientID}/${iconHash}`, options);
29
+    }
30
+    /**
31
+     * Generates the default avatar URL for a discriminator.
32
+     * @param discriminator The discriminator modulo 5
33
+     */
34
+    defaultAvatar(discriminator) {
35
+        return this.makeURL(`/embed/avatars/${discriminator}`);
36
+    }
37
+    /**
38
+     * Generates a discovery splash URL for a guild's discovery splash.
39
+     * @param guildID The guild ID that has the discovery splash
40
+     * @param splashHash The hash provided by Discord for this splash
41
+     * @param options Optional options for the splash
42
+     */
43
+    discoverySplash(guildID, splashHash, options) {
44
+        return this.makeURL(`/discovery-splashes/${guildID}/${splashHash}`, options);
45
+    }
46
+    /**
47
+     * Generates an emoji's URL for an emoji.
48
+     * @param emojiID The emoji ID
49
+     * @param extension The extension of the emoji
50
+     */
51
+    emoji(emojiID, extension) {
52
+        return this.makeURL(`/emojis/${emojiID}`, { extension });
53
+    }
54
+    /**
55
+     * Generates a group DM icon URL for a group DM.
56
+     * @param channelID The group channel ID that has the icon
57
+     * @param iconHash The hash provided by Discord for this group DM channel
58
+     * @param options Optional options for the icon
59
+     */
60
+    groupDMIcon(channelID, iconHash, options) {
61
+        return this.makeURL(`/channel-icons/${channelID}/${iconHash}`, options);
62
+    }
63
+    /**
64
+     * Generates a banner URL for a guild's banner.
65
+     * @param guildID The guild ID that has the banner splash
66
+     * @param bannerHash The hash provided by Discord for this banner
67
+     * @param options Optional options for the banner
68
+     */
69
+    guildBanner(guildID, bannerHash, options) {
70
+        return this.makeURL(`/banners/${guildID}/${bannerHash}`, options);
71
+    }
72
+    /**
73
+     * Generates an icon URL for a guild's icon.
74
+     * @param guildID The guild ID that has the icon splash
75
+     * @param iconHash The hash provided by Discord for this icon
76
+     * @param options Optional options for the icon
77
+     */
78
+    guildIcon(guildID, iconHash, options) {
79
+        return this.makeURL(`/icons/${guildID}/${iconHash}`, options);
80
+    }
81
+    /**
82
+     * Generates a guild invite splash URL for a guild's invite splash.
83
+     * @param guildID The guild ID that has the invite splash
84
+     * @param splashHash The hash provided by Discord for this splash
85
+     * @param options Optional options for the splash
86
+     */
87
+    splash(guildID, splashHash, options) {
88
+        return this.makeURL(`/splashes/${guildID}/${splashHash}`, options);
89
+    }
90
+    /**
91
+     * Generates a team icon URL for a team's icon.
92
+     * @param teamID The team ID that has the icon
93
+     * @param iconHash The hash provided by Discord for this icon
94
+     * @param options Optional options for the icon
95
+     */
96
+    teamIcon(teamID, iconHash, options) {
97
+        return this.makeURL(`/team-icons/${teamID}/${iconHash}`, options);
98
+    }
99
+    /**
100
+     * Generates a user avatar URL for a user's avatar.
101
+     * @param userID The user ID that has the icon
102
+     * @param avatarHash The hash provided by Discord for this avatar
103
+     * @param options Optional options for the avatar
104
+     */
105
+    userAvatar(userID, avatarHash, { dynamic = false, ...options } = {}) {
106
+        if (dynamic && avatarHash.startsWith('a_')) {
107
+            options.extension = 'gif';
108
+        }
109
+        return this.makeURL(`/avatars/${userID}/${avatarHash}`, options);
110
+    }
111
+    /**
112
+     * Constructs the URL for the resource
113
+     * @param base The base cdn route
114
+     * @param options The extension/size options for the link
115
+     */
116
+    makeURL(base, { extension = 'png', size } = {}) {
117
+        extension = String(extension).toLowerCase();
118
+        if (!constants_1.ALLOWED_EXTENSIONS.includes(extension)) {
119
+            throw new RangeError(`Invalid extension provided: ${extension}\nMust be one of: ${constants_1.ALLOWED_EXTENSIONS.join(', ')}`);
120
+        }
121
+        if (size && !constants_1.ALLOWED_SIZES.includes(size)) {
122
+            throw new RangeError(`Invalid size provided: ${size}\nMust be one of: ${constants_1.ALLOWED_SIZES.join(', ')}`);
123
+        }
124
+        const url = new URL(`${this.base}${base}.${extension}`);
125
+        if (size) {
126
+            url.searchParams.set('size', String(size));
127
+        }
128
+        return url.toString();
129
+    }
130
+}
131
+exports.CDN = CDN;
132
+//# sourceMappingURL=CDN.js.map

+ 1
- 0
node_modules/@discordjs/rest/dist/lib/CDN.js.map View File

1
+{"version":3,"file":"CDN.js","sourceRoot":"./","sources":["lib/CDN.ts"],"names":[],"mappings":";;;AAAA,iDAAqH;AAQrH;;GAEG;AACH,MAAa,GAAG;IACf,YAAoC,OAAe,8BAAkB,CAAC,G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AC,0BAA0B,IAAI,qBAAqB,yBAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SACpG;QAED,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,SAAS,EAAE,CAAC,CAAC;QAExD,IAAI,IAAI,EAAE;YACT,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;SAC3C;QAED,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;IACvB,CAAC;CACD;AA5ID,kBA4IC"}

+ 140
- 0
node_modules/@discordjs/rest/dist/lib/REST.d.ts View File

1
+/// <reference types="node" />
2
+import { EventEmitter } from 'events';
3
+import { CDN } from './CDN';
4
+import { InternalRequest, RequestData, RequestManager, RouteLike } from './RequestManager';
5
+/**
6
+ * Options to be passed when creating the REST instance
7
+ */
8
+export interface RESTOptions {
9
+    /**
10
+     * The base api path, without version
11
+     * @default 'https://discord.com/api'
12
+     */
13
+    api: string;
14
+    /**
15
+     * The cdn path
16
+     * @default 'https://cdn.discordapp.com'
17
+     */
18
+    cdn: string;
19
+    /**
20
+     * The extra offset to add to rate limits in milliseconds
21
+     * @default 50
22
+     */
23
+    offset: number;
24
+    /**
25
+     * The number of retries for errors with the 500 code, or errors
26
+     * that timeout
27
+     * @default 3
28
+     */
29
+    retries: number;
30
+    /**
31
+     * The time to wait in milliseconds before a request is aborted
32
+     * @default 15_000
33
+     */
34
+    timeout: number;
35
+    /**
36
+     * Extra information to add to the user agent
37
+     * @default `Node.js ${process.version}`
38
+     */
39
+    userAgentAppendix: string;
40
+    /**
41
+     * The version of the API to use
42
+     * @default '8'
43
+     */
44
+    version: string;
45
+}
46
+/**
47
+ * Data emitted on `RESTEvents.Debug`
48
+ */
49
+export interface RatelimitData {
50
+    /**
51
+     * The time, in milliseconds, until the request-lock is reset
52
+     */
53
+    timeToReset: number;
54
+    /**
55
+     * The amount of requests we can perform before locking requests
56
+     */
57
+    limit: number;
58
+    /**
59
+     * The HTTP method being performed
60
+     */
61
+    method: string;
62
+    /**
63
+     * The bucket hash for this request
64
+     */
65
+    hash: string;
66
+    /**
67
+     * The route being hit in this request
68
+     */
69
+    route: string;
70
+    /**
71
+     * The major parameter of the route
72
+     *
73
+     * For example, in `/channels/x`, this will be `x`.
74
+     * If there is no major parameter (e.g: `/bot/gateway`) this will be `global`.
75
+     */
76
+    majorParameter: string;
77
+}
78
+interface RestEvents {
79
+    restDebug: [info: string];
80
+    rateLimited: [rateLimitInfo: RatelimitData];
81
+}
82
+export interface REST {
83
+    on<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void): this;
84
+    on<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void): this;
85
+    once<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void): this;
86
+    once<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void): this;
87
+    emit<K extends keyof RestEvents>(event: K, ...args: RestEvents[K]): boolean;
88
+    emit<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, ...args: any[]): boolean;
89
+    off<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void): this;
90
+    off<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void): this;
91
+    removeAllListeners<K extends keyof RestEvents>(event?: K): this;
92
+    removeAllListeners<S extends string | symbol>(event?: Exclude<S, keyof RestEvents>): this;
93
+}
94
+export declare class REST extends EventEmitter {
95
+    readonly cdn: CDN;
96
+    readonly requestManager: RequestManager;
97
+    constructor(options?: Partial<RESTOptions>);
98
+    /**
99
+     * Sets the authorization token that should be used for requests
100
+     * @param token The authorization token to use
101
+     */
102
+    setToken(token: string): this;
103
+    /**
104
+     * Runs a get request from the api
105
+     * @param fullRoute The full route to query
106
+     * @param options Optional request options
107
+     */
108
+    get(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
109
+    /**
110
+     * Runs a delete request from the api
111
+     * @param fullRoute The full route to query
112
+     * @param options Optional request options
113
+     */
114
+    delete(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
115
+    /**
116
+     * Runs a post request from the api
117
+     * @param fullRoute The full route to query
118
+     * @param options Optional request options
119
+     */
120
+    post(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
121
+    /**
122
+     * Runs a put request from the api
123
+     * @param fullRoute The full route to query
124
+     * @param options Optional request options
125
+     */
126
+    put(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
127
+    /**
128
+     * Runs a patch request from the api
129
+     * @param fullRoute The full route to query
130
+     * @param options Optional request options
131
+     */
132
+    patch(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
133
+    /**
134
+     * Runs a request from the api
135
+     * @param options Request options
136
+     */
137
+    request(options: InternalRequest): Promise<unknown>;
138
+}
139
+export {};
140
+//# sourceMappingURL=REST.d.ts.map

+ 1
- 0
node_modules/@discordjs/rest/dist/lib/REST.d.ts.map View File

1
+{"version":3,"file":"REST.d.ts","sourceRoot":"./","sources":["lib/REST.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,cAAc,EAAiB,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG1G;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,OAAO,EAAE,MAA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,SAAS,EAAE,SAAS,EAAE,OAAO,GAAE,WAAgB;IAI3D;;;;OAIG;IACI,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,GAAE,WAAgB;IAI1D;;;;OAIG;IACI,KAAK,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,GAAE,WAAgB;IAI5D;;;OAGG;IACI,OAAO,CAAC,OAAO,EAAE,eAAe;CAGvC"}

+ 73
- 0
node_modules/@discordjs/rest/dist/lib/REST.js View File

1
+"use strict";
2
+Object.defineProperty(exports, "__esModule", { value: true });
3
+exports.REST = void 0;
4
+const events_1 = require("events");
5
+const CDN_1 = require("./CDN");
6
+const RequestManager_1 = require("./RequestManager");
7
+const constants_1 = require("./utils/constants");
8
+class REST extends events_1.EventEmitter {
9
+    constructor(options = {}) {
10
+        super();
11
+        this.cdn = new CDN_1.CDN(options.cdn ?? constants_1.DefaultRestOptions.cdn);
12
+        this.requestManager = new RequestManager_1.RequestManager(options)
13
+            .on("restDebug" /* Debug */, this.emit.bind(this, "restDebug" /* Debug */))
14
+            .on("rateLimited" /* RateLimited */, this.emit.bind(this, "rateLimited" /* RateLimited */));
15
+    }
16
+    /**
17
+     * Sets the authorization token that should be used for requests
18
+     * @param token The authorization token to use
19
+     */
20
+    setToken(token) {
21
+        this.requestManager.setToken(token);
22
+        return this;
23
+    }
24
+    /**
25
+     * Runs a get request from the api
26
+     * @param fullRoute The full route to query
27
+     * @param options Optional request options
28
+     */
29
+    get(fullRoute, options = {}) {
30
+        return this.request({ ...options, fullRoute, method: "get" /* Get */ });
31
+    }
32
+    /**
33
+     * Runs a delete request from the api
34
+     * @param fullRoute The full route to query
35
+     * @param options Optional request options
36
+     */
37
+    delete(fullRoute, options = {}) {
38
+        return this.request({ ...options, fullRoute, method: "delete" /* Delete */ });
39
+    }
40
+    /**
41
+     * Runs a post request from the api
42
+     * @param fullRoute The full route to query
43
+     * @param options Optional request options
44
+     */
45
+    post(fullRoute, options = {}) {
46
+        return this.request({ ...options, fullRoute, method: "post" /* Post */ });
47
+    }
48
+    /**
49
+     * Runs a put request from the api
50
+     * @param fullRoute The full route to query
51
+     * @param options Optional request options
52
+     */
53
+    put(fullRoute, options = {}) {
54
+        return this.request({ ...options, fullRoute, method: "put" /* Put */ });
55
+    }
56
+    /**
57
+     * Runs a patch request from the api
58
+     * @param fullRoute The full route to query
59
+     * @param options Optional request options
60
+     */
61
+    patch(fullRoute, options = {}) {
62
+        return this.request({ ...options, fullRoute, method: "patch" /* Patch */ });
63
+    }
64
+    /**
65
+     * Runs a request from the api
66
+     * @param options Request options
67
+     */
68
+    request(options) {
69
+        return this.requestManager.queueRequest(options);
70
+    }
71
+}
72
+exports.REST = REST;
73
+//# sourceMappingURL=REST.js.map

+ 1
- 0
node_modules/@discordjs/rest/dist/lib/REST.js.map View File

1
+{"version":3,"file":"REST.js","sourceRoot":"./","sources":["lib/REST.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AACtC,+BAA4B;AAC5B,qDAA0G;AAC1G,iDAAmE;AAmGnE,MAAa,IAAK,SAAQ,qBAAY;IAIrC,YAAmB,UAAgC,EAAE;QACpD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,GAAG,GAAG,IAAI,SAAG,CAAC,OAAO,CAAC,GAAG,IAAI,8BAAkB,CAAC,GAAG,CAAC,CAAC;QAC1D,IAAI,CAAC,cAAc,GAAG,IAAI,+BAAc,CAAC,OAAO,CAAC;aAC/C,EAAE,0BAAmB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,0BAAmB,CAAC;aAC5D,EAAE,kCAAyB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,kCAAyB,CAAC,CAAC;IAC5E,CAAC;IAED;;;OAGG;IACI,QAAQ,CAAC,KAAa;QAC5B,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACpC,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;;OAIG;IACI,GAAG,CAAC,SAAoB,EAAE,UAAuB,EAAE;QACzD,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAmB,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,SAAoB,EAAE,UAAuB,EAAE;QAC5D,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAsB,EAAE,CAAC,CAAC;IAC9E,CAAC;IAED;;;;OAIG;IACI,IAAI,CAAC,SAAoB,EAAE,UAAuB,EAAE;QAC1D,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAoB,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED;;;;OAIG;IACI,GAAG,CAAC,SAAoB,EAAE,UAAuB,EAAE;QACzD,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAmB,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,SAAoB,EAAE,UAAuB,EAAE;QAC3D,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED;;;OAGG;IACI,OAAO,CAAC,OAAwB;QACtC,OAAO,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;CACD;AAzED,oBAyEC"}

+ 142
- 0
node_modules/@discordjs/rest/dist/lib/RequestManager.d.ts View File

1
+/// <reference types="node" />
2
+import Collection from '@discordjs/collection';
3
+import { EventEmitter } from 'events';
4
+import type { IHandler } from './handlers/IHandler';
5
+import type { RESTOptions } from './REST';
6
+/**
7
+ * Represents an attachment to be added to the request
8
+ */
9
+export interface RawAttachment {
10
+    fileName: string;
11
+    rawBuffer: Buffer;
12
+}
13
+/**
14
+ * Represents possible data to be given to an endpoint
15
+ */
16
+export interface RequestData {
17
+    /**
18
+     * Files to be attached to this request
19
+     */
20
+    attachments?: RawAttachment[];
21
+    /**
22
+     * If this request needs the `Authorization` header
23
+     * @default true
24
+     */
25
+    auth?: boolean;
26
+    /**
27
+     * The authorization prefix to use for this request, useful if you use this with bearer tokens
28
+     * @default 'Bot'
29
+     */
30
+    authPrefix?: 'Bot' | 'Bearer';
31
+    /**
32
+     * The body to send to this request
33
+     */
34
+    body?: unknown;
35
+    /**
36
+     * Additional headers to add to this request
37
+     */
38
+    headers?: Record<string, string>;
39
+    /**
40
+     * Query string parameters to append to the called endpoint
41
+     */
42
+    query?: URLSearchParams;
43
+    /**
44
+     * Reason to show in the audit logs
45
+     */
46
+    reason?: string;
47
+    /**
48
+     * If this request should be versioned
49
+     * @default true
50
+     */
51
+    versioned?: boolean;
52
+}
53
+/**
54
+ * Possible headers for an API call
55
+ */
56
+export interface RequestHeaders {
57
+    Authorization?: string;
58
+    'User-Agent': string;
59
+    'X-Audit-Log-Reason'?: string;
60
+}
61
+/**
62
+ * Possible API methods to be used when doing requests
63
+ */
64
+export declare const enum RequestMethod {
65
+    Delete = "delete",
66
+    Get = "get",
67
+    Patch = "patch",
68
+    Post = "post",
69
+    Put = "put"
70
+}
71
+export declare type RouteLike = `/${string}`;
72
+/**
73
+ * Internal request options
74
+ *
75
+ * @internal
76
+ */
77
+export interface InternalRequest extends RequestData {
78
+    method: RequestMethod;
79
+    fullRoute: RouteLike;
80
+}
81
+/**
82
+ * Parsed route data for an endpoint
83
+ *
84
+ * @internal
85
+ */
86
+export interface RouteData {
87
+    majorParameter: string;
88
+    bucketRoute: string;
89
+    original: string;
90
+}
91
+/**
92
+ * Represents the class that manages handlers for endpoints
93
+ */
94
+export declare class RequestManager extends EventEmitter {
95
+    #private;
96
+    /**
97
+     * A timeout promise that is set when we hit the global rate limit
98
+     * @default null
99
+     */
100
+    globalTimeout: Promise<void> | null;
101
+    /**
102
+     * API bucket hashes that are cached from provided routes
103
+     */
104
+    readonly hashes: Collection<string, string>;
105
+    /**
106
+     * Request handlers created from the bucket hash and the major parameters
107
+     */
108
+    readonly handlers: Collection<string, IHandler>;
109
+    readonly options: RESTOptions;
110
+    constructor(options: Partial<RESTOptions>);
111
+    /**
112
+     * Sets the authorization token that should be used for requests
113
+     * @param token The authorization token to use
114
+     */
115
+    setToken(token: string): this;
116
+    /**
117
+     * Queues a request to be sent
118
+     * @param request All the information needed to make a request
119
+     * @returns The response from the api request
120
+     */
121
+    queueRequest(request: InternalRequest): Promise<unknown>;
122
+    /**
123
+     * Creates a new rate limit handler from a hash, based on the hash and the major parameter
124
+     * @param hash The hash for the route
125
+     * @param majorParameter The major parameter for this handler
126
+     * @private
127
+     */
128
+    private createHandler;
129
+    /**
130
+     * Formats the request data to a usable format for fetch
131
+     * @param request The request data
132
+     */
133
+    private resolveRequest;
134
+    /**
135
+     * Generates route data for an endpoint:method
136
+     * @param endpoint The raw endpoint to generalize
137
+     * @param method The HTTP method this endpoint is called without
138
+     * @private
139
+     */
140
+    private static generateRouteData;
141
+}
142
+//# sourceMappingURL=RequestManager.d.ts.map

+ 1
- 0
node_modules/@discordjs/rest/dist/lib/RequestManager.d.ts.map View File

1
+{"version":3,"file":"RequestManager.d.ts","sourceRoot":"./","sources":["lib/RequestManager.ts"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAG/C,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAK1C;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B;;OAEG;IACH,WAAW,CAAC,EAAE,a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AAO,EAAE,OAAO,CAAC,WAAW,CAAC;IAMhD;;;OAGG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM;IAK7B;;;;OAIG;IACU,YAAY,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC;IAkBrE;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IASrB;;;OAGG;IACH,OAAO,CAAC,cAAc;IA4EtB;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;CA8BhC"}

+ 184
- 0
node_modules/@discordjs/rest/dist/lib/RequestManager.js View File

1
+"use strict";
2
+var _RequestManager_token;
3
+Object.defineProperty(exports, "__esModule", { value: true });
4
+exports.RequestManager = exports.RequestMethod = void 0;
5
+const tslib_1 = require("tslib");
6
+const collection_1 = tslib_1.__importDefault(require("@discordjs/collection"));
7
+const form_data_1 = tslib_1.__importDefault(require("form-data"));
8
+const snowflake_1 = require("@sapphire/snowflake");
9
+const events_1 = require("events");
10
+const https_1 = require("https");
11
+const SequentialHandler_1 = require("./handlers/SequentialHandler");
12
+const constants_1 = require("./utils/constants");
13
+const agent = new https_1.Agent({ keepAlive: true });
14
+/**
15
+ * Possible API methods to be used when doing requests
16
+ */
17
+var RequestMethod;
18
+(function (RequestMethod) {
19
+    RequestMethod["Delete"] = "delete";
20
+    RequestMethod["Get"] = "get";
21
+    RequestMethod["Patch"] = "patch";
22
+    RequestMethod["Post"] = "post";
23
+    RequestMethod["Put"] = "put";
24
+})(RequestMethod = exports.RequestMethod || (exports.RequestMethod = {}));
25
+/**
26
+ * Represents the class that manages handlers for endpoints
27
+ */
28
+class RequestManager extends events_1.EventEmitter {
29
+    constructor(options) {
30
+        super();
31
+        /**
32
+         * A timeout promise that is set when we hit the global rate limit
33
+         * @default null
34
+         */
35
+        this.globalTimeout = null;
36
+        /**
37
+         * API bucket hashes that are cached from provided routes
38
+         */
39
+        this.hashes = new collection_1.default();
40
+        /**
41
+         * Request handlers created from the bucket hash and the major parameters
42
+         */
43
+        this.handlers = new collection_1.default();
44
+        // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
45
+        _RequestManager_token.set(this, null);
46
+        this.options = { ...constants_1.DefaultRestOptions, ...options };
47
+        this.options.offset = Math.max(0, this.options.offset);
48
+    }
49
+    /**
50
+     * Sets the authorization token that should be used for requests
51
+     * @param token The authorization token to use
52
+     */
53
+    setToken(token) {
54
+        tslib_1.__classPrivateFieldSet(this, _RequestManager_token, token, "f");
55
+        return this;
56
+    }
57
+    /**
58
+     * Queues a request to be sent
59
+     * @param request All the information needed to make a request
60
+     * @returns The response from the api request
61
+     */
62
+    async queueRequest(request) {
63
+        // Generalize the endpoint to its route data
64
+        const routeID = RequestManager.generateRouteData(request.fullRoute, request.method);
65
+        // Get the bucket hash for the generic route, or point to a global route otherwise
66
+        const hash = this.hashes.get(`${request.method}:${routeID.bucketRoute}`) ?? `Global(${request.method}:${routeID.bucketRoute})`;
67
+        // Get the request handler for the obtained hash, with its major parameter
68
+        const handler = this.handlers.get(`${hash}:${routeID.majorParameter}`) ?? this.createHandler(hash, routeID.majorParameter);
69
+        // Resolve the request into usable fetch/node-fetch options
70
+        const { url, fetchOptions } = this.resolveRequest(request);
71
+        // Queue the request
72
+        return handler.queueRequest(routeID, url, fetchOptions);
73
+    }
74
+    /**
75
+     * Creates a new rate limit handler from a hash, based on the hash and the major parameter
76
+     * @param hash The hash for the route
77
+     * @param majorParameter The major parameter for this handler
78
+     * @private
79
+     */
80
+    createHandler(hash, majorParameter) {
81
+        // Create the async request queue to handle requests
82
+        const queue = new SequentialHandler_1.SequentialHandler(this, hash, majorParameter);
83
+        // Save the queue based on its ID
84
+        this.handlers.set(queue.id, queue);
85
+        return queue;
86
+    }
87
+    /**
88
+     * Formats the request data to a usable format for fetch
89
+     * @param request The request data
90
+     */
91
+    resolveRequest(request) {
92
+        const { options } = this;
93
+        let query = '';
94
+        // If a query option is passed, use it
95
+        if (request.query) {
96
+            query = `?${request.query.toString()}`;
97
+        }
98
+        // Create the required headers
99
+        const headers = {
100
+            'User-Agent': `${constants_1.DefaultUserAgent} ${options.userAgentAppendix}`.trim(),
101
+        };
102
+        // If this request requires authorization (allowing non-"authorized" requests for webhooks)
103
+        if (request.auth !== false) {
104
+            // If we haven't received a token, throw an error
105
+            if (!tslib_1.__classPrivateFieldGet(this, _RequestManager_token, "f")) {
106
+                throw new Error('Expected token to be set for this request, but none was present');
107
+            }
108
+            headers.Authorization = `${request.authPrefix ?? 'Bot'} ${tslib_1.__classPrivateFieldGet(this, _RequestManager_token, "f")}`;
109
+        }
110
+        // If a reason was set, set it's appropriate header
111
+        if (request.reason?.length) {
112
+            headers['X-Audit-Log-Reason'] = encodeURIComponent(request.reason);
113
+        }
114
+        // Format the full request URL (api base, optional version, endpoint, optional querystring)
115
+        const url = `${options.api}${request.versioned === false ? '' : `/v${options.version}`}${request.fullRoute}${query}`;
116
+        let finalBody;
117
+        let additionalHeaders = {};
118
+        if (request.attachments?.length) {
119
+            const formData = new form_data_1.default();
120
+            // Attach all files to the request
121
+            for (const attachment of request.attachments) {
122
+                formData.append(attachment.fileName, attachment.rawBuffer, attachment.fileName);
123
+            }
124
+            // If a JSON body was added as well, attach it to the form data
125
+            // eslint-disable-next-line no-eq-null
126
+            if (request.body != null) {
127
+                formData.append('payload_json', JSON.stringify(request.body));
128
+            }
129
+            // Set the final body to the form data
130
+            finalBody = formData;
131
+            // Set the additional headers to the form data ones
132
+            additionalHeaders = formData.getHeaders();
133
+            // eslint-disable-next-line no-eq-null
134
+        }
135
+        else if (request.body != null) {
136
+            // Stringify the JSON data
137
+            finalBody = JSON.stringify(request.body);
138
+            // Set the additional headers to specify the content-type
139
+            additionalHeaders = { 'Content-Type': 'application/json' };
140
+        }
141
+        const fetchOptions = {
142
+            agent,
143
+            body: finalBody,
144
+            // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
145
+            headers: { ...(request.headers ?? {}), ...additionalHeaders, ...headers },
146
+            method: request.method,
147
+        };
148
+        return { url, fetchOptions };
149
+    }
150
+    /**
151
+     * Generates route data for an endpoint:method
152
+     * @param endpoint The raw endpoint to generalize
153
+     * @param method The HTTP method this endpoint is called without
154
+     * @private
155
+     */
156
+    static generateRouteData(endpoint, method) {
157
+        const majorIDMatch = /^\/(?:channels|guilds|webhooks)\/(\d{16,19})/.exec(endpoint);
158
+        // Get the major ID for this route - global otherwise
159
+        const majorID = majorIDMatch?.[1] ?? 'global';
160
+        const baseRoute = endpoint
161
+            // Strip out all IDs
162
+            .replace(/\d{16,19}/g, ':id')
163
+            // Strip out reaction as they fall under the same bucket
164
+            .replace(/\/reactions\/(.*)/, '/reactions/:reaction');
165
+        let exceptions = '';
166
+        // Hard-Code Old Message Deletion Exception (2 week+ old messages are a different bucket)
167
+        // https://github.com/discord/discord-api-docs/issues/1295
168
+        if (method === "delete" /* Delete */ && baseRoute === '/channels/:id/messages/:id') {
169
+            const id = /\d{16,19}$/.exec(endpoint)[0];
170
+            const snowflake = snowflake_1.DiscordSnowflake.deconstruct(id);
171
+            if (Date.now() - Number(snowflake.timestamp) > 1000 * 60 * 60 * 24 * 14) {
172
+                exceptions += '/Delete Old Message';
173
+            }
174
+        }
175
+        return {
176
+            majorParameter: majorID,
177
+            bucketRoute: baseRoute + exceptions,
178
+            original: endpoint,
179
+        };
180
+    }
181
+}
182
+exports.RequestManager = RequestManager;
183
+_RequestManager_token = new WeakMap();
184
+//# sourceMappingURL=RequestManager.js.map

+ 1
- 0
node_modules/@discordjs/rest/dist/lib/RequestManager.js.map View File

1
+{"version":3,"file":"RequestManager.js","sourceRoot":"./","sources":["lib/RequestManager.ts"],"names":[],"mappings":";;;;;AAAA,+EAA+C;AAC/C,kEAAiC;AACjC,mDAAuD;AACvD,mCAAsC;AACtC,iCAA8B;AAG9B,oEAAiE;AAEjE,iDAAyE;AAEzE,MAAM,KAAK,GAAG,IAAI,aAAK,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AA4D7C;;GAEG;AACH,IAAkB,aAMjB;A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ACxE,UAAU,IAAI,qBAAqB,CAAC;aACpC;SACD;QAED,OAAO;YACN,cAAc,EAAE,OAAO;YACvB,WAAW,EAAE,SAAS,GAAG,UAAU;YACnC,QAAQ,EAAE,QAAQ;SAClB,CAAC;IACH,CAAC;CACD;AA/LD,wCA+LC"}

+ 42
- 0
node_modules/@discordjs/rest/dist/lib/errors/DiscordAPIError.d.ts View File

1
+interface DiscordErrorFieldInformation {
2
+    code: string;
3
+    message: string;
4
+}
5
+interface DiscordErrorGroupWrapper {
6
+    _errors: DiscordError[];
7
+}
8
+declare type DiscordError = DiscordErrorGroupWrapper | DiscordErrorFieldInformation | {
9
+    [k: string]: DiscordError;
10
+} | string;
11
+export interface DiscordErrorData {
12
+    code: number;
13
+    message: string;
14
+    errors?: DiscordError;
15
+}
16
+/**
17
+ * Represents an API error returned by Discord
18
+ * @extends Error
19
+ */
20
+export declare class DiscordAPIError extends Error {
21
+    rawError: DiscordErrorData;
22
+    code: number;
23
+    status: number;
24
+    method: string;
25
+    url: string;
26
+    /**
27
+     * @param rawError The error reported by Discord
28
+     * @param code The error code reported by Discord
29
+     * @param status The status code of the response
30
+     * @param method The method of the request that erred
31
+     * @param url The url of the request that erred
32
+     */
33
+    constructor(rawError: DiscordErrorData, code: number, status: number, method: string, url: string);
34
+    /**
35
+     * The name of the error
36
+     */
37
+    get name(): string;
38
+    private static getMessage;
39
+    private static flattenDiscordError;
40
+}
41
+export {};
42
+//# sourceMappingURL=DiscordAPIError.d.ts.map

+ 1
- 0
node_modules/@discordjs/rest/dist/lib/errors/DiscordAPIError.d.ts.map View File

1
+{"version":3,"file":"DiscordAPIError.d.ts","sourceRoot":"./","sources":["lib/errors/DiscordAPIError.ts"],"names":[],"mappings":"AAAA,UAAU,4BAA4B;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,wBAAwB;IACjC,OAAO,EAAE,YAAY,EAAE,CAAC;CACxB;AAED,aAAK,YAAY,GAAG,wBAAwB,GAAG,4BAA4B,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,YAAY,CAAA;CAAE,GAAG,MAAM,CAAC;AAErH,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,YAAY,CAAC;CACtB;AAUD;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IASjC,QAAQ,EAAE,gBAAgB;IAC1B,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,MAAM;IACd,GAAG,EAAE,MAAM;IAZnB;;;;;;OAMG;gBAEK,QAAQ,EAAE,gBAAgB,EAC1B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM;IAKnB;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,OAAO,CAAC,MAAM,CAAC,UAAU;IAUzB,OAAO,CAAC,MAAM,CAAE,mBAAmB;CAmBnC"}

+ 66
- 0
node_modules/@discordjs/rest/dist/lib/errors/DiscordAPIError.js View File

1
+"use strict";
2
+Object.defineProperty(exports, "__esModule", { value: true });
3
+exports.DiscordAPIError = void 0;
4
+function isErrorGroupWrapper(error) {
5
+    return Reflect.has(error, '_errors');
6
+}
7
+function isErrorResponse(error) {
8
+    return typeof Reflect.get(error, 'message') === 'string';
9
+}
10
+/**
11
+ * Represents an API error returned by Discord
12
+ * @extends Error
13
+ */
14
+class DiscordAPIError extends Error {
15
+    /**
16
+     * @param rawError The error reported by Discord
17
+     * @param code The error code reported by Discord
18
+     * @param status The status code of the response
19
+     * @param method The method of the request that erred
20
+     * @param url The url of the request that erred
21
+     */
22
+    constructor(rawError, code, status, method, url) {
23
+        super(DiscordAPIError.getMessage(rawError));
24
+        this.rawError = rawError;
25
+        this.code = code;
26
+        this.status = status;
27
+        this.method = method;
28
+        this.url = url;
29
+    }
30
+    /**
31
+     * The name of the error
32
+     */
33
+    get name() {
34
+        return `${DiscordAPIError.name}[${this.code}]`;
35
+    }
36
+    static getMessage(error) {
37
+        let flattened = '';
38
+        if (error.errors) {
39
+            flattened = [...this.flattenDiscordError(error.errors)].join('\n');
40
+        }
41
+        return error.message && flattened
42
+            ? `${error.message}\n${flattened}`
43
+            : error.message || flattened || 'Unknown Error';
44
+    }
45
+    static *flattenDiscordError(obj, key = '') {
46
+        if (isErrorResponse(obj)) {
47
+            return yield `${key.length ? `${key}[${obj.code}]` : `${obj.code}`}: ${obj.message}`.trim();
48
+        }
49
+        for (const [k, v] of Object.entries(obj)) {
50
+            const nextKey = k.startsWith('_') ? key : key ? (Number.isNaN(Number(k)) ? `${key}.${k}` : `${key}[${k}]`) : k;
51
+            if (typeof v === 'string') {
52
+                yield v;
53
+            }
54
+            else if (isErrorGroupWrapper(v)) {
55
+                for (const error of v._errors) {
56
+                    yield* this.flattenDiscordError(error, nextKey);
57
+                }
58
+            }
59
+            else {
60
+                yield* this.flattenDiscordError(v, nextKey);
61
+            }
62
+        }
63
+    }
64
+}
65
+exports.DiscordAPIError = DiscordAPIError;
66
+//# sourceMappingURL=DiscordAPIError.js.map

+ 1
- 0
node_modules/@discordjs/rest/dist/lib/errors/DiscordAPIError.js.map View File

1
+{"version":3,"file":"DiscordAPIError.js","sourceRoot":"./","sources":["lib/errors/DiscordAPIError.ts"],"names":[],"mappings":";;;AAiBA,SAAS,mBAAmB,CAAC,KAAU;IACtC,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AACtC,CAAC;AAED,SAAS,eAAe,CAAC,KAAU;IAClC,OAAO,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,QAAQ,CAAC;AAC1D,CAAC;AAED;;;GAGG;AACH,MAAa,eAAgB,SAAQ,KAAK;IACzC;;;;;;OAMG;IACH,YACQ,QAA0B,EAC1B,IAAY,EACZ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AAO,GAAG,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAE/G,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE;gBAC1B,MAAM,CAAC,CAAC;aACR;iBAAM,IAAI,mBAAmB,CAAC,CAAC,CAAC,EAAE;gBAClC,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,OAAO,EAAE;oBAC9B,KAAK,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;iBAChD;aACD;iBAAM;gBACN,KAAK,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;aAC5C;SACD;IACF,CAAC;CACD;AAtDD,0CAsDC"}

+ 18
- 0
node_modules/@discordjs/rest/dist/lib/errors/HTTPError.d.ts View File

1
+/**
2
+ * Represents a HTTP error
3
+ */
4
+export declare class HTTPError extends Error {
5
+    name: string;
6
+    status: number;
7
+    method: string;
8
+    url: string;
9
+    /**
10
+     * @param message The error message
11
+     * @param name The name of the error
12
+     * @param status The status code of the response
13
+     * @param method The method of the request that erred
14
+     * @param url The url of the request that erred
15
+     */
16
+    constructor(message: string, name: string, status: number, method: string, url: string);
17
+}
18
+//# sourceMappingURL=HTTPError.d.ts.map

+ 1
- 0
node_modules/@discordjs/rest/dist/lib/errors/HTTPError.d.ts.map View File

1
+{"version":3,"file":"HTTPError.d.ts","sourceRoot":"./","sources":["lib/errors/HTTPError.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAU3B,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,MAAM;IACd,GAAG,EAAE,MAAM;IAZnB;;;;;;OAMG;gBAEF,OAAO,EAAE,MAAM,EACR,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM;CAInB"}

+ 24
- 0
node_modules/@discordjs/rest/dist/lib/errors/HTTPError.js View File

1
+"use strict";
2
+Object.defineProperty(exports, "__esModule", { value: true });
3
+exports.HTTPError = void 0;
4
+/**
5
+ * Represents a HTTP error
6
+ */
7
+class HTTPError extends Error {
8
+    /**
9
+     * @param message The error message
10
+     * @param name The name of the error
11
+     * @param status The status code of the response
12
+     * @param method The method of the request that erred
13
+     * @param url The url of the request that erred
14
+     */
15
+    constructor(message, name, status, method, url) {
16
+        super(message);
17
+        this.name = name;
18
+        this.status = status;
19
+        this.method = method;
20
+        this.url = url;
21
+    }
22
+}
23
+exports.HTTPError = HTTPError;
24
+//# sourceMappingURL=HTTPError.js.map

+ 1
- 0
node_modules/@discordjs/rest/dist/lib/errors/HTTPError.js.map View File

1
+{"version":3,"file":"HTTPError.js","sourceRoot":"./","sources":["lib/errors/HTTPError.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,SAAU,SAAQ,KAAK;IACnC;;;;;;OAMG;IACH,YACC,OAAe,EACR,IAAY,EACZ,MAAc,EACd,MAAc,EACd,GAAW;QAElB,KAAK,CAAC,OAAO,CAAC,CAAC;QALR,SAAI,GAAJ,IAAI,CAAQ;QACZ,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAAQ;QACd,QAAG,GAAH,GAAG,CAAQ;IAGnB,CAAC;CACD;AAjBD,8BAiBC"}

+ 6
- 0
node_modules/@discordjs/rest/dist/lib/handlers/IHandler.d.ts View File

1
+import type { RequestInit } from 'node-fetch';
2
+import type { RouteData } from '../RequestManager';
3
+export interface IHandler {
4
+    queueRequest(routeID: RouteData, url: string, options: RequestInit): Promise<unknown>;
5
+}
6
+//# sourceMappingURL=IHandler.d.ts.map

+ 1
- 0
node_modules/@discordjs/rest/dist/lib/handlers/IHandler.d.ts.map View File

1
+{"version":3,"file":"IHandler.d.ts","sourceRoot":"./","sources":["lib/handlers/IHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,WAAW,QAAQ;IACxB,YAAY,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACtF"}

+ 3
- 0
node_modules/@discordjs/rest/dist/lib/handlers/IHandler.js View File

1
+"use strict";
2
+Object.defineProperty(exports, "__esModule", { value: true });
3
+//# sourceMappingURL=IHandler.js.map

+ 1
- 0
node_modules/@discordjs/rest/dist/lib/handlers/IHandler.js.map View File

1
+{"version":3,"file":"IHandler.js","sourceRoot":"./","sources":["lib/handlers/IHandler.ts"],"names":[],"mappings":""}

+ 66
- 0
node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.d.ts View File

1
+import { RequestInit } from 'node-fetch';
2
+import type { RequestManager, RouteData } from '../RequestManager';
3
+/**
4
+ * The structure used to handle requests for a given bucket
5
+ */
6
+export declare class SequentialHandler {
7
+    #private;
8
+    private readonly manager;
9
+    private readonly hash;
10
+    private readonly majorParameter;
11
+    /**
12
+     * The unique ID of the handler
13
+     */
14
+    readonly id: string;
15
+    /**
16
+     * The time this rate limit bucket will reset
17
+     */
18
+    private reset;
19
+    /**
20
+     * The remaining requests that can be made before we are rate limited
21
+     */
22
+    private remaining;
23
+    /**
24
+     * The total number of requests that can be made before we are rate limited
25
+     */
26
+    private limit;
27
+    /**
28
+     * @param manager The request manager
29
+     * @param hash The hash that this RequestHandler handles
30
+     * @param majorParameter The major parameter for this handler
31
+     */
32
+    constructor(manager: RequestManager, hash: string, majorParameter: string);
33
+    /**
34
+     * If the bucket is currently inactive (no pending requests)
35
+     */
36
+    get inactive(): boolean;
37
+    /**
38
+     * If the rate limit bucket is currently limited
39
+     */
40
+    private get limited();
41
+    /**
42
+     * The time until queued requests can continue
43
+     */
44
+    private get timeToReset();
45
+    /**
46
+     * Emits a debug message
47
+     * @param message The message to debug
48
+     */
49
+    private debug;
50
+    /**
51
+     * Queues a request to be sent
52
+     * @param routeID The generalized api route with literal ids for major parameters
53
+     * @param url The url to do the request on
54
+     * @param options All the information needed to make a request
55
+     */
56
+    queueRequest(routeID: RouteData, url: string, options: RequestInit): Promise<unknown>;
57
+    /**
58
+     * The method that actually makes the request to the api, and updates info about the bucket accordingly
59
+     * @param routeID The generalized api route with literal ids for major parameters
60
+     * @param url The fully resolved url to make the request to
61
+     * @param options The node-fetch options needed to make the request
62
+     * @param retries The number of retries this request has already attempted (recursion)
63
+     */
64
+    private runRequest;
65
+}
66
+//# sourceMappingURL=SequentialHandler.d.ts.map

+ 1
- 0
node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.d.ts.map View File

1
+{"version":3,"file":"SequentialHandler.d.ts","sourceRoot":"./","sources":["lib/handlers/SequentialHandler.ts"],"names":[],"mappings":"AAGA,OAAc,EAAE,WAAW,EAAY,MAAM,YAAY,CAAC;AAG1D,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAInE;;GAEG;AACH,qBAAa,iBAAiB;;IAiC5B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAlChC;;OAEG;IACH,SAAgB,EAAE,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,OAAO,CAAC,KAAK,CAAM;IAEnB;;OAEG;IACH,OAAO,CAAC,SAAS,CAAK;IAEtB;;OAEG;IACH,OAAO,CAAC,KAAK,CAAY;IAQzB;;;;OAIG;gBAEe,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,MAAM;IAKxC;;OAEG;IACH,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAED;;OAEG;IACH,OAAO,KAAK,OAAO,GAElB;IAED;;OAEG;IACH,OAAO,KAAK,WAAW,GAEtB;IAED;;;OAGG;IACH,OAAO,CAAC,KAAK;IAIb;;;;;OAKG;IACU,YAAY,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IA6BlG;;;;;;OAMG;YACW,UAAU;CA+FxB"}

+ 206
- 0
node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.js View File

1
+"use strict";
2
+var _SequentialHandler_asyncQueue;
3
+Object.defineProperty(exports, "__esModule", { value: true });
4
+exports.SequentialHandler = void 0;
5
+const tslib_1 = require("tslib");
6
+const promises_1 = require("timers/promises");
7
+const async_queue_1 = require("@sapphire/async-queue");
8
+const abort_controller_1 = tslib_1.__importDefault(require("abort-controller"));
9
+const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
10
+const DiscordAPIError_1 = require("../errors/DiscordAPIError");
11
+const HTTPError_1 = require("../errors/HTTPError");
12
+require("../utils/constants");
13
+const utils_1 = require("../utils/utils");
14
+/**
15
+ * The structure used to handle requests for a given bucket
16
+ */
17
+class SequentialHandler {
18
+    /**
19
+     * @param manager The request manager
20
+     * @param hash The hash that this RequestHandler handles
21
+     * @param majorParameter The major parameter for this handler
22
+     */
23
+    constructor(manager, hash, majorParameter) {
24
+        this.manager = manager;
25
+        this.hash = hash;
26
+        this.majorParameter = majorParameter;
27
+        /**
28
+         * The time this rate limit bucket will reset
29
+         */
30
+        this.reset = -1;
31
+        /**
32
+         * The remaining requests that can be made before we are rate limited
33
+         */
34
+        this.remaining = 1;
35
+        /**
36
+         * The total number of requests that can be made before we are rate limited
37
+         */
38
+        this.limit = Infinity;
39
+        /**
40
+         * The interface used to sequence async requests sequentially
41
+         */
42
+        // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
43
+        _SequentialHandler_asyncQueue.set(this, new async_queue_1.AsyncQueue());
44
+        this.id = `${hash}:${majorParameter}`;
45
+    }
46
+    /**
47
+     * If the bucket is currently inactive (no pending requests)
48
+     */
49
+    get inactive() {
50
+        return tslib_1.__classPrivateFieldGet(this, _SequentialHandler_asyncQueue, "f").remaining === 0 && !this.limited;
51
+    }
52
+    /**
53
+     * If the rate limit bucket is currently limited
54
+     */
55
+    get limited() {
56
+        return this.remaining <= 0 && Date.now() < this.reset;
57
+    }
58
+    /**
59
+     * The time until queued requests can continue
60
+     */
61
+    get timeToReset() {
62
+        return this.reset - Date.now();
63
+    }
64
+    /**
65
+     * Emits a debug message
66
+     * @param message The message to debug
67
+     */
68
+    debug(message) {
69
+        this.manager.emit("restDebug" /* Debug */, `[REST ${this.id}] ${message}`);
70
+    }
71
+    /**
72
+     * Queues a request to be sent
73
+     * @param routeID The generalized api route with literal ids for major parameters
74
+     * @param url The url to do the request on
75
+     * @param options All the information needed to make a request
76
+     */
77
+    async queueRequest(routeID, url, options) {
78
+        // Wait for any previous requests to be completed before this one is run
79
+        await tslib_1.__classPrivateFieldGet(this, _SequentialHandler_asyncQueue, "f").wait();
80
+        try {
81
+            // Wait for any global rate limits to pass before continuing to process requests
82
+            await this.manager.globalTimeout;
83
+            // Check if this request handler is currently rate limited
84
+            if (this.limited) {
85
+                // Let library users know they have hit a rate limit
86
+                this.manager.emit("rateLimited" /* RateLimited */, {
87
+                    timeToReset: this.timeToReset,
88
+                    limit: this.limit,
89
+                    method: options.method,
90
+                    hash: this.hash,
91
+                    route: routeID.bucketRoute,
92
+                    majorParameter: this.majorParameter,
93
+                });
94
+                this.debug(`Waiting ${this.timeToReset}ms for rate limit to pass`);
95
+                // Wait the remaining time left before the rate limit resets
96
+                await promises_1.setTimeout(this.timeToReset);
97
+            }
98
+            // Make the request, and return the results
99
+            return await this.runRequest(routeID, url, options);
100
+        }
101
+        finally {
102
+            // Allow the next request to fire
103
+            tslib_1.__classPrivateFieldGet(this, _SequentialHandler_asyncQueue, "f").shift();
104
+        }
105
+    }
106
+    /**
107
+     * The method that actually makes the request to the api, and updates info about the bucket accordingly
108
+     * @param routeID The generalized api route with literal ids for major parameters
109
+     * @param url The fully resolved url to make the request to
110
+     * @param options The node-fetch options needed to make the request
111
+     * @param retries The number of retries this request has already attempted (recursion)
112
+     */
113
+    async runRequest(routeID, url, options, retries = 0) {
114
+        const controller = new abort_controller_1.default();
115
+        const timeout = setTimeout(() => controller.abort(), this.manager.options.timeout);
116
+        let res;
117
+        try {
118
+            res = await node_fetch_1.default(url, { ...options, signal: controller.signal });
119
+        }
120
+        catch (error) {
121
+            const err = error;
122
+            // Retry the specified number of times for possible timed out requests
123
+            if (err.name === 'AbortError' && retries !== this.manager.options.retries) {
124
+                return this.runRequest(routeID, url, options, ++retries);
125
+            }
126
+            throw err;
127
+        }
128
+        finally {
129
+            clearTimeout(timeout);
130
+        }
131
+        let retryAfter = 0;
132
+        const method = options.method ?? 'get';
133
+        const limit = res.headers.get('X-RateLimit-Limit');
134
+        const remaining = res.headers.get('X-RateLimit-Remaining');
135
+        const reset = res.headers.get('X-RateLimit-Reset-After');
136
+        const hash = res.headers.get('X-RateLimit-Bucket');
137
+        const retry = res.headers.get('Retry-After');
138
+        // Update the total number of requests that can be made before the rate limit resets
139
+        this.limit = limit ? Number(limit) : Infinity;
140
+        // Update the number of remaining requests that can be made before the rate limit resets
141
+        this.remaining = remaining ? Number(remaining) : 1;
142
+        // Update the time when this rate limit resets (reset-after is in seconds)
143
+        this.reset = reset ? Number(reset) * 1000 + Date.now() + this.manager.options.offset : Date.now();
144
+        // Amount of time in milliseconds until we should retry if rate limited (globally or otherwise)
145
+        if (retry)
146
+            retryAfter = Number(retry) * 1000 + this.manager.options.offset;
147
+        // Handle buckets via the hash header retroactively
148
+        if (hash && hash !== this.hash) {
149
+            // Let library users know when rate limit buckets have been updated
150
+            this.debug(['Received bucket hash update', `  Old Hash  : ${this.hash}`, `  New Hash  : ${hash}`].join('\n'));
151
+            // This queue will eventually be eliminated via attrition
152
+            this.manager.hashes.set(`${method}:${routeID.bucketRoute}`, hash);
153
+        }
154
+        // Handle global rate limit
155
+        if (res.headers.get('X-RateLimit-Global')) {
156
+            this.debug(`We are globally rate limited, blocking all requests for ${retryAfter}ms`);
157
+            // Set the manager's global timeout as the promise for other requests to "wait"
158
+            this.manager.globalTimeout = promises_1.setTimeout(retryAfter).then(() => {
159
+                // After the timer is up, clear the promise
160
+                this.manager.globalTimeout = null;
161
+            });
162
+        }
163
+        if (res.ok) {
164
+            return utils_1.parseResponse(res);
165
+        }
166
+        else if (res.status === 429) {
167
+            // A rate limit was hit - this may happen if the route isn't associated with an official bucket hash yet, or when first globally rate limited
168
+            this.debug([
169
+                'Encountered unexpected 429 rate limit',
170
+                `  Bucket         : ${routeID.bucketRoute}`,
171
+                `  Major parameter: ${routeID.majorParameter}`,
172
+                `  Hash           : ${this.hash}`,
173
+                `  Retry After    : ${retryAfter}ms`,
174
+            ].join('\n'));
175
+            // Wait the retryAfter amount of time before retrying the request
176
+            await promises_1.setTimeout(retryAfter);
177
+            // Since this is not a server side issue, the next request should pass, so we don't bump the retries counter
178
+            return this.runRequest(routeID, url, options, retries);
179
+        }
180
+        else if (res.status >= 500 && res.status < 600) {
181
+            // Retry the specified number of times for possible server side issues
182
+            if (retries !== this.manager.options.retries) {
183
+                return this.runRequest(routeID, url, options, ++retries);
184
+            }
185
+            // We are out of retries, throw an error
186
+            throw new HTTPError_1.HTTPError(res.statusText, res.constructor.name, res.status, method, url);
187
+        }
188
+        else {
189
+            // Handle possible malformed requests
190
+            if (res.status >= 400 && res.status < 500) {
191
+                // If we receive this status code, it means the token we had is no longer valid.
192
+                if (res.status === 401) {
193
+                    this.manager.setToken(null);
194
+                }
195
+                // The request will not succeed for some reason, parse the error returned from the api
196
+                const data = (await utils_1.parseResponse(res));
197
+                // throw the API error
198
+                throw new DiscordAPIError_1.DiscordAPIError(data, data.code, res.status, method, url);
199
+            }
200
+            return null;
201
+        }
202
+    }
203
+}
204
+exports.SequentialHandler = SequentialHandler;
205
+_SequentialHandler_asyncQueue = new WeakMap();
206
+//# sourceMappingURL=SequentialHandler.js.map

+ 1
- 0
node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.js.map
File diff suppressed because it is too large
View File


+ 15
- 0
node_modules/@discordjs/rest/dist/lib/utils/constants.d.ts View File

1
+import type { RESTOptions } from '../REST';
2
+export declare const DefaultUserAgent: string;
3
+export declare const DefaultRestOptions: Required<RESTOptions>;
4
+/**
5
+ * The events that the REST manager emits
6
+ */
7
+export declare const enum RESTEvents {
8
+    Debug = "restDebug",
9
+    RateLimited = "rateLimited"
10
+}
11
+export declare const ALLOWED_EXTENSIONS: readonly ["webp", "png", "jpg", "jpeg", "gif"];
12
+export declare const ALLOWED_SIZES: readonly [16, 32, 64, 128, 256, 512, 1024, 2048, 4096];
13
+export declare type ImageExtension = typeof ALLOWED_EXTENSIONS[number];
14
+export declare type ImageSize = typeof ALLOWED_SIZES[number];
15
+//# sourceMappingURL=constants.d.ts.map

+ 1
- 0
node_modules/@discordjs/rest/dist/lib/utils/constants.d.ts.map View File

1
+{"version":3,"file":"constants.d.ts","sourceRoot":"./","sources":["lib/utils/constants.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAK3C,eAAO,MAAM,gBAAgB,QAAyD,CAAC;AAEvF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAQpD,CAAC;AAEF;;GAEG;AACH,0BAAkB,UAAU;IAC3B,KAAK,cAAc;IACnB,WAAW,gBAAgB;CAC3B;AAED,eAAO,MAAM,kBAAkB,gDAAiD,CAAC;AACjF,eAAO,MAAM,aAAa,wDAAyD,CAAC;AAEpF,oBAAY,cAAc,GAAG,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAC/D,oBAAY,SAAS,GAAG,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC"}

+ 28
- 0
node_modules/@discordjs/rest/dist/lib/utils/constants.js View File

1
+"use strict";
2
+Object.defineProperty(exports, "__esModule", { value: true });
3
+exports.ALLOWED_SIZES = exports.ALLOWED_EXTENSIONS = exports.RESTEvents = exports.DefaultRestOptions = exports.DefaultUserAgent = void 0;
4
+const v8_1 = require("discord-api-types/v8");
5
+// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
6
+const Package = require('../../../package.json');
7
+// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
8
+exports.DefaultUserAgent = `DiscordBot (${Package.homepage}, ${Package.version})`;
9
+exports.DefaultRestOptions = {
10
+    api: 'https://discord.com/api',
11
+    cdn: 'https://cdn.discordapp.com',
12
+    offset: 50,
13
+    retries: 3,
14
+    timeout: 15000,
15
+    userAgentAppendix: `Node.js ${process.version}`,
16
+    version: v8_1.APIVersion,
17
+};
18
+/**
19
+ * The events that the REST manager emits
20
+ */
21
+var RESTEvents;
22
+(function (RESTEvents) {
23
+    RESTEvents["Debug"] = "restDebug";
24
+    RESTEvents["RateLimited"] = "rateLimited";
25
+})(RESTEvents = exports.RESTEvents || (exports.RESTEvents = {}));
26
+exports.ALLOWED_EXTENSIONS = ['webp', 'png', 'jpg', 'jpeg', 'gif'];
27
+exports.ALLOWED_SIZES = [16, 32, 64, 128, 256, 512, 1024, 2048, 4096];
28
+//# sourceMappingURL=constants.js.map

+ 1
- 0
node_modules/@discordjs/rest/dist/lib/utils/constants.js.map View File

1
+{"version":3,"file":"constants.js","sourceRoot":"./","sources":["lib/utils/constants.ts"],"names":[],"mappings":";;;AAAA,6CAAkD;AAElD,qGAAqG;AACrG,MAAM,OAAO,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAEjD,4EAA4E;AAC/D,QAAA,gBAAgB,GAAG,eAAe,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,OAAO,GAAG,CAAC;AAE1E,QAAA,kBAAkB,GAA0B;IACxD,GAAG,EAAE,yBAAyB;IAC9B,GAAG,EAAE,4BAA4B;IACjC,MAAM,EAAE,EAAE;IACV,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,KAAM;IACf,iBAAiB,EAAE,WAAW,OAAO,CAAC,OAAO,EAAE;IAC/C,OAAO,EAAE,eAAU;CACnB,CAAC;AAEF;;GAEG;AACH,IAAkB,UAGjB;AAHD,WAAkB,UAAU;IAC3B,iCAAmB,CAAA;IACnB,yCAA2B,CAAA;AAC5B,CAAC,EAHiB,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAG3B;AAEY,QAAA,kBAAkB,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAU,CAAC;AACpE,QAAA,aAAa,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAU,CAAC"}

+ 7
- 0
node_modules/@discordjs/rest/dist/lib/utils/utils.d.ts View File

1
+import type { Response } from 'node-fetch';
2
+/**
3
+ * Converts the response to usable data
4
+ * @param res The node-fetch response
5
+ */
6
+export declare function parseResponse(res: Response): Promise<unknown>;
7
+//# sourceMappingURL=utils.d.ts.map

+ 1
- 0
node_modules/@discordjs/rest/dist/lib/utils/utils.d.ts.map View File

1
+{"version":3,"file":"utils.d.ts","sourceRoot":"./","sources":["lib/utils/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAM7D"}

+ 15
- 0
node_modules/@discordjs/rest/dist/lib/utils/utils.js View File

1
+"use strict";
2
+Object.defineProperty(exports, "__esModule", { value: true });
3
+exports.parseResponse = void 0;
4
+/**
5
+ * Converts the response to usable data
6
+ * @param res The node-fetch response
7
+ */
8
+function parseResponse(res) {
9
+    if (res.headers.get('Content-Type')?.startsWith('application/json')) {
10
+        return res.json();
11
+    }
12
+    return res.buffer();
13
+}
14
+exports.parseResponse = parseResponse;
15
+//# sourceMappingURL=utils.js.map

+ 1
- 0
node_modules/@discordjs/rest/dist/lib/utils/utils.js.map View File

1
+{"version":3,"file":"utils.js","sourceRoot":"./","sources":["lib/utils/utils.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACH,SAAgB,aAAa,CAAC,GAAa;IAC1C,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC,kBAAkB,CAAC,EAAE;QACpE,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC;KAClB;IAED,OAAO,GAAG,CAAC,MAAM,EAAE,CAAC;AACrB,CAAC;AAND,sCAMC"}

+ 61
- 0
node_modules/@discordjs/rest/package.json View File

1
+{
2
+	"$schema": "http://json.schemastore.org/package",
3
+	"name": "@discordjs/rest",
4
+	"version": "0.1.0-canary.0",
5
+	"description": "The REST API for Discord.js",
6
+	"contributors": [
7
+		"Amish Shah <amishshah.2k@gmail.com>",
8
+		"Crawl <icrawltogo@gmail.com>",
9
+		"SpaceEEC <spaceeec@yahoo.com>",
10
+		"Vlad Frangu <kingdgrizzle@gmail.com>",
11
+		"Antonio Roman <kyradiscord@gmail.com>"
12
+	],
13
+	"license": "Apache-2.0",
14
+	"scripts": {
15
+		"test": "echo \"Error: run tests from root\" && exit 1",
16
+		"build": "tsc --build --force"
17
+	},
18
+	"repository": {
19
+		"type": "git",
20
+		"url": "git+https://github.com/discordjs/discord.js-next.git"
21
+	},
22
+	"bugs": {
23
+		"url": "https://github.com/discordjs/discord.js-next/issues"
24
+	},
25
+	"homepage": "https://github.com/discordjs/discord.js-next/tree/master/packages/rest",
26
+	"keywords": [
27
+		"discord",
28
+		"api",
29
+		"rest",
30
+		"discordapp",
31
+		"discordjs"
32
+	],
33
+	"main": "dist/index.js",
34
+	"directories": {
35
+		"lib": "src",
36
+		"test": "__tests__"
37
+	},
38
+	"files": [
39
+		"dist"
40
+	],
41
+	"dependencies": {
42
+		"@discordjs/collection": "^0.1.6",
43
+		"@sapphire/async-queue": "^1.1.4",
44
+		"@sapphire/snowflake": "^1.3.5",
45
+		"abort-controller": "^3.0.0",
46
+		"discord-api-types": "^0.18.1",
47
+		"form-data": "^4.0.0",
48
+		"node-fetch": "^2.6.1",
49
+		"tslib": "^2.3.0"
50
+	},
51
+	"devDependencies": {
52
+		"@types/node-fetch": "^2.5.10"
53
+	},
54
+	"engines": {
55
+		"node": ">=16.0.0"
56
+	},
57
+	"publishConfig": {
58
+		"access": "public"
59
+	},
60
+	"gitHead": "2e640a9ffeaecc562f4845ffeebccdb803607ef3"
61
+}

+ 0
- 0
node_modules/@mapbox/node-pre-gyp/CHANGELOG.md View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save