first commit
This commit is contained in:
parent
f34b9f78a6
commit
68718fc865
4121 changed files with 555248 additions and 0 deletions
19
commands/del.js
Normal file
19
commands/del.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
module.exports = {
|
||||
name: 'del',
|
||||
description: 'Delete message',
|
||||
execute(message, args) {
|
||||
if (args[0]) {
|
||||
const amount = parseInt(args[0]) + 1;
|
||||
if (isNaN(amount)) {
|
||||
return message.reply('Ce n\'est pas un nombre valide !');
|
||||
}
|
||||
else if (amount <= 1 || amount > 100) {
|
||||
return message.reply('Ce n\'est pas un nombre valide ! (entre 1 et 99)');
|
||||
}
|
||||
message.channel.bulkDelete(amount)
|
||||
.then(messages => {
|
||||
console.log(`${messages.size - 1} messages supprimés par ${message.author.username} sur ${message.guild.name} dans ${message.channel.name}`);
|
||||
});
|
||||
} else { message.reply("Merci d'indiquer le nombre de messages à supprimer"); }
|
||||
}
|
||||
}
|
11
commands/help.js
Normal file
11
commands/help.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
module.exports = {
|
||||
name: 'help',
|
||||
description: 'Obtenir la liste des commandes disponibles',
|
||||
execute(message) {
|
||||
if (message.member.hasPermission("BAN_MEMBERS")) {
|
||||
message.channel.send(`Voici les commandes disponibles en tant qu'administrateur :
|
||||
> \`.message\` - permet de gérer les messages classiques envoyés par le bot
|
||||
> \`.del n\` - permet de supprimer les n derniers messages envoyés`)
|
||||
}
|
||||
}
|
||||
}
|
219
commands/message.js
Normal file
219
commands/message.js
Normal file
|
@ -0,0 +1,219 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { client, logch } = require("../index.js");
|
||||
|
||||
module.exports = {
|
||||
name: 'message',
|
||||
description: "Permet d'envoyer des messages avec le bot",
|
||||
execute(message, args) {
|
||||
|
||||
// Prompt help
|
||||
if (!args[0] || args[0] == "help" || args[0] == "h") {
|
||||
message.channel.send(`
|
||||
Aide à propos de \`.message\` :
|
||||
Pour utiliser la commande il vous suffit d'utiliser un des arguments suivants :
|
||||
> list *liste l'ensemble des messages envoyés par le bot en indiquant l'ID du message*
|
||||
> send ChannelID/nomDuChannel le message que vous souhaitez envoyer
|
||||
> edit MessageID (trouvable grâce à l'argument list) nouveau contenu du message
|
||||
> add MessageID 🙂 @Role *ajoute la réaction 🙂 en dessous du message et donne le @Role à ceux qui cliquent dessus*
|
||||
> rem MessageID 🙂 *supprime la réaction 🙂 en dessous du message*
|
||||
> delete MessageID *supprime le message choisi (IRREVERSIBLE)*`);
|
||||
}
|
||||
|
||||
// list messages
|
||||
else if (args[0] == "list") {
|
||||
const listMsg = fs.readdirSync(`./data/messages/`).filter(file => file.endsWith('.json'));
|
||||
console.log(listMsg);
|
||||
if (listMsg.length == 0) {
|
||||
console.log("pas de messages envoyés");
|
||||
return message.channel.send("Aucun message n'a été envoyé via le bot");
|
||||
}
|
||||
nbMessages = 0;
|
||||
messagetosend = "Liste des messages envoyés via le bot :\n";
|
||||
for (const msg of listMsg) {
|
||||
if (messagetosend.length >= 1400) {
|
||||
message.channel.send(messagetosend);
|
||||
messagetosend = "";
|
||||
}
|
||||
msgFileContent = JSON.parse(fs.readFileSync(path.resolve(`./data/messages/${msg}`)));
|
||||
if (!msgFileContent.deleted) {
|
||||
nbMessages += 1;
|
||||
messagetosend += ` - ${msgFileContent.id} dans <#${msgFileContent.channelid}> : *"${msgFileContent.content.slice(0, 30)}..."*\n`
|
||||
}
|
||||
}
|
||||
messagetosend += `${nbMessages} message(s) ont été envoyés via le bot`
|
||||
message.channel.send(messagetosend)
|
||||
}
|
||||
|
||||
// send message
|
||||
else if (args[0] == "send") {
|
||||
if (!args[2]) return message.channel.send("Merci de vérifier d'entrer un channel et un message à envoyer (.message help)")
|
||||
|
||||
// Check if this channel exists
|
||||
channeltosendname = message.guild.channels.cache.find(channel => channel.name.toLowerCase() == args[1])
|
||||
channeltosendid = client.channels.cache.get(args[1]);
|
||||
if (channeltosendname) {
|
||||
channeltosend = channeltosendname;
|
||||
}
|
||||
else if (channeltosendid) {
|
||||
channeltosend = channeltosendid;
|
||||
}
|
||||
else return message.channel.send("Merci de vérifier d'avoir entré un nom de channel (ou ID) valide")
|
||||
|
||||
actualtimestamp = + new Date();
|
||||
args.splice(0, 2);
|
||||
messagecontent = args.join(" ");
|
||||
channeltosend.send(messagecontent).then(sent => {
|
||||
messageinfo = {
|
||||
id: `${sent.channel.id}o${sent.id}`,
|
||||
deleted: false,
|
||||
channelid: sent.channel.id,
|
||||
content: messagecontent,
|
||||
created: actualtimestamp,
|
||||
lastChange: actualtimestamp,
|
||||
reactnumber: 0
|
||||
}
|
||||
const jsonStringmsg = JSON.stringify(messageinfo);
|
||||
fs.writeFile(`./data/messages/${sent.channel.id}o${sent.id}.json`, jsonStringmsg, err => {
|
||||
if (err) {
|
||||
console.log(`Error writing message`, err)
|
||||
} else {
|
||||
console.log(`Successfully wrote message`)
|
||||
}
|
||||
});
|
||||
message.react("✅");
|
||||
message.channel.send("Message envoyé.")
|
||||
});
|
||||
}
|
||||
|
||||
// edit message
|
||||
else if (args[0] == "edit") {
|
||||
if (!args[2]) return message.channel.send("Merci de vérifier d'entrer un id de message correct et un nouveau message(.message help)");
|
||||
try {
|
||||
idChMsg = args[1].split(/\o+/);
|
||||
argsmessage = args.slice(0);
|
||||
argsmessage.splice(0, 2);
|
||||
newcontent = argsmessage.join(" ");
|
||||
client.channels.cache.get(idChMsg[0]).messages.fetch(idChMsg[1]).then(msg => msg.edit(newcontent));
|
||||
// update message file
|
||||
updatemsg = JSON.parse(fs.readFileSync(path.resolve(`./data/messages/${args[1]}.json`)));
|
||||
actualtimestamp = + new Date();
|
||||
updatemsg.content = newcontent;
|
||||
updatemsg.lastChange = actualtimestamp;
|
||||
const jsonStringmsg = JSON.stringify(updatemsg);
|
||||
fs.writeFile(`./data/messages/${args[1]}.json`, jsonStringmsg, err => {
|
||||
if (err) {
|
||||
console.log(`Error writing message`, err)
|
||||
} else {
|
||||
console.log(`Successfully wrote message`)
|
||||
}
|
||||
})
|
||||
message.react("✅");
|
||||
message.channel.send("Message modifié.")
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return message.channel.send("Merci de vérifier d'entrer un id de message correct (.message list)");
|
||||
}
|
||||
}
|
||||
|
||||
// delete message
|
||||
else if (args[0] == "delete" || args[0] == "del") {
|
||||
if (!args[1]) return message.channel.send("Merci de vérifier d'entrer un id de message correct (.message help)");
|
||||
try {
|
||||
idChMsg = args[1].split(/\o+/);
|
||||
client.channels.cache.get(idChMsg[0]).messages.fetch(idChMsg[1]).then(msg => msg.delete());
|
||||
// update message file
|
||||
updatemsg = JSON.parse(fs.readFileSync(path.resolve(`./data/messages/${args[1]}.json`)));
|
||||
updatemsg.deleted = true;
|
||||
actualtimestamp = + new Date();
|
||||
updatemsg.lastChange = actualtimestamp;
|
||||
const jsonStringmsg = JSON.stringify(updatemsg);
|
||||
fs.writeFile(`./data/messages/${args[1]}.json`, jsonStringmsg, err => {
|
||||
if (err) {
|
||||
console.log(`Error writing message`, err)
|
||||
} else {
|
||||
console.log(`Successfully wrote message`)
|
||||
}
|
||||
})
|
||||
message.react("✅");
|
||||
message.channel.send("Message supprimé.")
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return message.channel.send("Merci de vérifier d'entrer un id de message correct (.message list)");
|
||||
}
|
||||
}
|
||||
|
||||
// add reaction
|
||||
else if (args[0] == "add") {
|
||||
if (!args[2]) return message.channel.send("Merci de mettre une emote valide");
|
||||
try {
|
||||
idChMsg = args[1].split(/\o+/);
|
||||
client.channels.cache.get(idChMsg[0]).messages.fetch(idChMsg[1]).then(msg => msg.react(args[2]));
|
||||
// update message file
|
||||
updatemsg = JSON.parse(fs.readFileSync(path.resolve(`./data/messages/${args[1]}.json`)));
|
||||
updatemsg.reactnumber += 1;
|
||||
eval(`updatemsg.emoj${updatemsg.reactnumber} = args[2];`);
|
||||
if (args[3] && args[3].length > 0) {
|
||||
roleID = args[3].replace('<@&', '').replace('>', '');
|
||||
rolefound = message.guild.roles.cache.find(r => r.id == roleID);
|
||||
if (rolefound) {
|
||||
eval(`updatemsg.action${updatemsg.reactnumber} = roleID;`);
|
||||
}
|
||||
else {
|
||||
message.channel.send("Ceci n'est pas un rôle, l'emoj n'a donc été associé à aucun rôle");
|
||||
eval(`updatemsg.action${updatemsg.reactnumber} = "none";`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
message.channel.send("Vous n'avez pas précisé de rôle, l'emoj n'a donc été associé à aucun rôle");
|
||||
eval(`updatemsg.action${updatemsg.reactnumber} = "none";`);
|
||||
}
|
||||
actualtimestamp = + new Date();
|
||||
updatemsg.lastChange = actualtimestamp;
|
||||
const jsonStringmsg = JSON.stringify(updatemsg);
|
||||
fs.writeFile(`./data/messages/${args[1]}.json`, jsonStringmsg, err => {
|
||||
if (err) {
|
||||
console.log(`Error writing message`, err)
|
||||
} else {
|
||||
console.log(`Successfully wrote message`)
|
||||
}
|
||||
})
|
||||
message.react("✅");
|
||||
message.channel.send("Réaction ajoutée.")
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return message.channel.send("Merci de vérifier d'entrer un id de message correct (.message list) et/ou une emote valide");
|
||||
}
|
||||
}
|
||||
|
||||
// remove reaction
|
||||
else if (args[0] == "rem") {
|
||||
if (!args[2]) return message.channel.send("Merci de mettre une emote valide");
|
||||
try {
|
||||
idChMsg = args[1].split(/\o+/);
|
||||
client.channels.cache.get(idChMsg[0]).messages.fetch(idChMsg[1]).then(msg => msg.reactions.cache.find(reaction => reaction.emoji.name == args[2]).remove());
|
||||
// update message file
|
||||
updatemsg = JSON.parse(fs.readFileSync(path.resolve(`./data/messages/${args[1]}.json`)));
|
||||
for (let index = 1; index < updatemsg.reactnumber + 1; index++) {
|
||||
eval(`if (updatemsg.emoj${index} == args[2]) updatemsg.emoj${index} = "Deleted"`);
|
||||
}
|
||||
|
||||
actualtimestamp = + new Date();
|
||||
updatemsg.lastChange = actualtimestamp;
|
||||
const jsonStringmsg = JSON.stringify(updatemsg);
|
||||
fs.writeFile(`./data/messages/${args[1]}.json`, jsonStringmsg, err => {
|
||||
if (err) {
|
||||
console.log(`Error writing message`, err)
|
||||
} else {
|
||||
console.log(`Successfully wrote message`)
|
||||
}
|
||||
})
|
||||
message.react("✅");
|
||||
message.channel.send("Réaction supprimée.")
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return message.channel.send("Merci de vérifier d'entrer un id de message correct (.message list) et/ou une emote valide");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
13
config/badwords.json
Normal file
13
config/badwords.json
Normal file
|
@ -0,0 +1,13 @@
|
|||
[
|
||||
"pute",
|
||||
"pétasse",
|
||||
"connard",
|
||||
"couillon",
|
||||
"fuck",
|
||||
"fdp",
|
||||
"free nitro",
|
||||
"gift",
|
||||
"enculé",
|
||||
"fils de pute",
|
||||
"teubé"
|
||||
]
|
7
config/botinfo.json
Normal file
7
config/botinfo.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"activity": "Agir ensemble",
|
||||
"logChannelID": "963136429779734578",
|
||||
"mpChannelID": "963136429779734578",
|
||||
"presentationChannelID": "962010843451629618",
|
||||
"memberRoleID": "964536803510059048"
|
||||
}
|
6
config/credentials.json
Normal file
6
config/credentials.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"appID": "962013583074533496",
|
||||
"publicKey": "f3b1f4961bb002f64e7cade37aa3a3e3ef453e43f32f84779dd4e0872cd97984",
|
||||
"prefix": ".",
|
||||
"token": "LoL t'as cru que je laisserais le token ?"
|
||||
}
|
1
data/users/348848036031758337.json
Normal file
1
data/users/348848036031758337.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"id":"348848036031758337","hasleft":false,"join":1650044362737,"left":0}
|
1
data/users/444579657279602699.json
Normal file
1
data/users/444579657279602699.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"id":"444579657279602699","hasleft":false,"join":1650041746012,"firstMsgDate":1650041746012,"left":0}
|
1
data/users/931995381590548501.json
Normal file
1
data/users/931995381590548501.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"id":"931995381590548501","hasleft":false,"join":1650043735089,"left":0}
|
22
functions/logger.js
Normal file
22
functions/logger.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
const { client, logch } = require("../index.js")
|
||||
|
||||
module.exports = {
|
||||
// log in discord channel & console
|
||||
all: function (ttolog) {
|
||||
console.log(ttolog);
|
||||
try {
|
||||
client.channels.cache.get(logch).send(ttolog);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
},
|
||||
|
||||
// log only in discord channel
|
||||
channel: function (ttolog) {
|
||||
try {
|
||||
client.channels.cache.get(logch).send(ttolog);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
},
|
||||
};
|
125
functions/messageCheck.js
Normal file
125
functions/messageCheck.js
Normal file
|
@ -0,0 +1,125 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { client, logch } = require("../index.js");
|
||||
const logger = require("./logger.js");
|
||||
|
||||
const botconfig = JSON.parse(fs.readFileSync(path.resolve(`./config/botinfo.json`)));
|
||||
let memberRoleID = botconfig.memberRoleID
|
||||
const badwords = JSON.parse(fs.readFileSync(path.resolve(`./config/badwords.json`)));
|
||||
|
||||
|
||||
function checkBadwords(msg) {
|
||||
badwordlist = badwords.filter(word => msg.content.includes(word));
|
||||
return badwordlist;
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
// Check general properties of message
|
||||
general: function (message) {
|
||||
fs.stat(`./data/users/${message.author.id}.json`, function (err, stat) {
|
||||
if (err == null) {
|
||||
// Check if the message is safe for community
|
||||
suspiciousWords = checkBadwords(message);
|
||||
if (suspiciousWords.length > 0) {
|
||||
logger.all(`${message.author.tag} a dit ${suspiciousWords.toString()} dans ${message.channel.name}`);
|
||||
}
|
||||
|
||||
|
||||
} else if (err.code === 'ENOENT') {
|
||||
// If it is the first message of the member we give him member role except if his messages contains suspicious words
|
||||
suspiciousWords = checkBadwords(message);
|
||||
if (suspiciousWords.length > 0) {
|
||||
return logger.all(`${message.author.tag} a dit ${suspiciousWords.toString()} dans ${message.channel.name}`);
|
||||
}
|
||||
actualtimestamp = + new Date();
|
||||
usrinfo = {
|
||||
id: message.author.id,
|
||||
hasleft: false,
|
||||
join: actualtimestamp,
|
||||
left: 0
|
||||
}
|
||||
const jsonStringusr = JSON.stringify(usrinfo);
|
||||
fs.writeFile(`./data/users/${message.author.id}.json`, jsonStringusr, err => {
|
||||
if (err) {
|
||||
console.log(`Error writing user profile`, err)
|
||||
} else {
|
||||
console.log(`Successfully wrote user profile`)
|
||||
}
|
||||
});
|
||||
|
||||
memberRole = message.guild.roles.cache.find(role => role.id == memberRoleID);
|
||||
message.member.roles.add(memberRole);
|
||||
|
||||
|
||||
} else {
|
||||
console.log('Error: ', err.code);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
// Update profile
|
||||
memberUpdate: function (member, event) {
|
||||
fs.stat(`./data/users/${member.user.id}.json`, function (err, stat) {
|
||||
actualtimestamp = + new Date();
|
||||
if (err == null) {
|
||||
oldusrinfo = JSON.parse(fs.readFileSync(path.resolve(`./data/users/${member.user.id}.json`)));
|
||||
if (event == "join") {
|
||||
joininfo = actualtimestamp;
|
||||
leftinfo = oldusrinfo.left;
|
||||
hasleftinfo = false;
|
||||
memberRole = member.guild.roles.cache.find(role => role.id == memberRoleID);
|
||||
member.roles.add(memberRole);
|
||||
|
||||
} else if (event == "left") {
|
||||
leftinfo = actualtimestamp;
|
||||
joininfo = oldusrinfo.join;
|
||||
hasleftinfo = true;
|
||||
}
|
||||
usrinfo = {
|
||||
id: member.user.id,
|
||||
hasleft: hasleftinfo,
|
||||
join: joininfo,
|
||||
left: leftinfo,
|
||||
}
|
||||
const jsonStringusr = JSON.stringify(usrinfo);
|
||||
fs.writeFile(`./data/users/${member.user.id}.json`, jsonStringusr, err => {
|
||||
if (err) {
|
||||
console.log(`Error writing user profile`, err)
|
||||
} else {
|
||||
console.log(`Successfully wrote user profile`)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
} else if (err.code === 'ENOENT') {
|
||||
|
||||
if (event == "join") {
|
||||
return logger.all("Il doit donc se présenter dans le channel 👋-présentation");
|
||||
} else if (event == "left") {
|
||||
leftinfo = actualtimestamp;
|
||||
joininfo = 0;
|
||||
hasleftinfo = true;
|
||||
}
|
||||
usrinfo = {
|
||||
id: member.user.id,
|
||||
hasleft: hasleftinfo,
|
||||
join: joininfo,
|
||||
left: leftinfo,
|
||||
}
|
||||
const jsonStringusr = JSON.stringify(usrinfo);
|
||||
fs.writeFile(`./data/users/${member.user.id}.json`, jsonStringusr, err => {
|
||||
if (err) {
|
||||
console.log(`Error writing user profile`, err)
|
||||
} else {
|
||||
console.log(`Successfully wrote user profile`)
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
console.log('Error: ', err.code);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
22
functions/random.js
Normal file
22
functions/random.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
const { client, logch } = require("../index.js")
|
||||
module.exports = {
|
||||
// log in discord channel & console
|
||||
string: function (myLength) {
|
||||
const chars =
|
||||
"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890";
|
||||
const randomArray = Array.from(
|
||||
{ length: myLength },
|
||||
(v, k) => chars[Math.floor(Math.random() * chars.length)]
|
||||
);
|
||||
|
||||
const randomString = randomArray.join("");
|
||||
return randomString;
|
||||
},
|
||||
|
||||
// log only in discord channel
|
||||
int: function (min, max) {
|
||||
min = Math.ceil(min);
|
||||
max = Math.floor(max);
|
||||
return Math.floor(Math.random() * (max - min)) + min;
|
||||
},
|
||||
};
|
83
functions/rolereaction.js
Normal file
83
functions/rolereaction.js
Normal file
|
@ -0,0 +1,83 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { client, logch } = require("../index.js");
|
||||
const logger = require("./logger.js");
|
||||
|
||||
module.exports = {
|
||||
// cache messages
|
||||
cache: function () {
|
||||
console.log("Caching messages...");
|
||||
const msgFiles = fs.readdirSync('./data/messages/').filter(file => file.endsWith('.json'));
|
||||
for (const file of msgFiles) {
|
||||
idChMsg = file.replace('.json', '').split(/\o+/);
|
||||
console.log(idChMsg);
|
||||
try {
|
||||
client.channels.cache.get(idChMsg[0]).messages.fetch(idChMsg[1])
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
// give a role
|
||||
give: function (reaction, user) {
|
||||
fileMessage = `${reaction.message.channel.id}o${reaction.message.id}`;
|
||||
fs.stat(`./data/messages/${fileMessage}.json`, function (err, stat) {
|
||||
if (err == null) {
|
||||
try {
|
||||
member = reaction.message.guild.members.cache.find(mem => mem.user.id == user.id);
|
||||
msginfo = JSON.parse(fs.readFileSync(path.resolve(`./data/messages/${fileMessage}.json`)));
|
||||
for (let index = 1; index < msginfo.reactnumber + 1; index++) {
|
||||
eval(`
|
||||
if (msginfo.action${index} && msginfo.emoj${index} == reaction.emoji.name && msginfo.action${index} != "none") {
|
||||
|
||||
roleactionID = msginfo.action${index};
|
||||
console.log(roleactionID);
|
||||
memberRole = reaction.message.guild.roles.cache.find(role => role.id == roleactionID);
|
||||
member.roles.add(memberRole);
|
||||
logger.all(user.tag + " a obtenu le rôle par réaction : " + memberRole.name);
|
||||
}`);
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
} else {
|
||||
null;
|
||||
//console.log('Error: ', err.code);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// give a role
|
||||
remove: function (reaction, user) {
|
||||
fileMessage = `${reaction.message.channel.id}o${reaction.message.id}`;
|
||||
fs.stat(`./data/messages/${fileMessage}.json`, function (err, stat) {
|
||||
if (err == null) {
|
||||
try {
|
||||
member = reaction.message.guild.members.cache.find(mem => mem.user.id == user.id);
|
||||
msginfo = JSON.parse(fs.readFileSync(path.resolve(`./data/messages/${fileMessage}.json`)));
|
||||
for (let index = 1; index < msginfo.reactnumber + 1; index++) {
|
||||
eval(`
|
||||
if (msginfo.action${index} && msginfo.emoj${index} == reaction.emoji.name && msginfo.action${index} != "none") {
|
||||
|
||||
roleactionID = msginfo.action${index};
|
||||
console.log(roleactionID);
|
||||
memberRole = reaction.message.guild.roles.cache.find(role => role.id == roleactionID);
|
||||
member.roles.remove(memberRole);
|
||||
logger.all(user.tag + " a enlevé son rôle par réaction : " + memberRole.name);
|
||||
}`);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
} else {
|
||||
null;
|
||||
//console.log('Error: ', err.code);
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
102
index.js
Normal file
102
index.js
Normal file
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
Bot Ingénieurs pour demain
|
||||
Developped by Valentin SERVIERES, if you have any question, you can contact me by Discord MagicTINTIN#4389
|
||||
- Discord.js version v12 (depreciated)
|
||||
*/
|
||||
console.log("Starting...");
|
||||
const { appID, publicKey, token, prefix } = require('./config/credentials.json');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const Discord = require('discord.js');
|
||||
const { Client, Intents, MessageEmbed } = require('discord.js');
|
||||
// Only mandatory for Discord.js v13
|
||||
const client = new Client({
|
||||
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],
|
||||
});
|
||||
exports.client = client;
|
||||
|
||||
|
||||
// --- INITIALIZING BOT ---
|
||||
config = JSON.parse(fs.readFileSync(path.resolve(`./config/botinfo.json`)));
|
||||
console.log("config found\ngetting log channel id");
|
||||
const logch = config.logChannelID
|
||||
exports.logch = logch;
|
||||
|
||||
// Import functions
|
||||
const random = require("./functions/random.js");
|
||||
const logger = require("./functions/logger.js");
|
||||
const msgcheck = require("./functions/messageCheck.js");
|
||||
const rolereact = require("./functions/rolereaction.js");
|
||||
|
||||
// Import commands
|
||||
client.commands = new Discord.Collection();
|
||||
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
|
||||
for (const file of commandFiles) {
|
||||
const command = require(`./commands/${file}`);
|
||||
client.commands.set(command.name, command);
|
||||
}
|
||||
|
||||
|
||||
client.once('ready', () => {
|
||||
// cache message that could be used for reactions
|
||||
rolereact.cache();
|
||||
console.log('Ready to act !')
|
||||
client.user.setActivity(config.activity, { type: 'PLAYING' });
|
||||
client.channels.cache.get(logch).send("**❕ BOT ONLINE** - ready to act");
|
||||
});
|
||||
// --- END INITIALIZATION ---
|
||||
|
||||
|
||||
client.on('message', async message => {
|
||||
if (message.author.bot) return
|
||||
if (!message.channel.guild) {
|
||||
return logger.all(message.author.tag + " a envoyé un mp : " + message.content)
|
||||
}
|
||||
// For more details see /functions/messageCheck.js
|
||||
msgcheck.general(message);
|
||||
// Command trigger
|
||||
if (!message.content.startsWith(prefix) || message.author.bot) return;
|
||||
|
||||
const args = message.content.slice(prefix.length).split(/ +/);
|
||||
const command = args.shift().toLocaleLowerCase();
|
||||
|
||||
if (!client.commands.has(command)) return;
|
||||
|
||||
try {
|
||||
client.commands.get(command).execute(message, args);
|
||||
logger.all(`🔨 ${message.author.tag} - \`${message}\``)
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
client.on('guildMemberAdd', async member => {
|
||||
try {
|
||||
logger.all(`🆕 ${member.user.tag} vient d'arriver sur le serveur`);
|
||||
// update user file
|
||||
msgcheck.memberUpdate(member, "join");
|
||||
} catch (err) { console.error(err); }
|
||||
});
|
||||
client.on('guildMemberRemove', async member => {
|
||||
try {
|
||||
logger.all(`❌ ${member.user.tag} vient de quitter le serveur`);
|
||||
// update user file
|
||||
msgcheck.memberUpdate(member, "left");
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
client.on('messageReactionAdd', (reaction, user) => {
|
||||
rolereact.give(reaction, user);
|
||||
});
|
||||
client.on('messageReactionRemove', (reaction, user) => {
|
||||
rolereact.remove(reaction, user);
|
||||
});
|
||||
|
||||
|
||||
client.login(token);
|
1
node_modules/.bin/color-support
generated
vendored
Symbolic link
1
node_modules/.bin/color-support
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../color-support/bin.js
|
1
node_modules/.bin/detect-libc
generated
vendored
Symbolic link
1
node_modules/.bin/detect-libc
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../detect-libc/bin/detect-libc.js
|
17
node_modules/.bin/detect-libc.cmd
generated
vendored
Normal file
17
node_modules/.bin/detect-libc.cmd
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\detect-libc\bin\detect-libc.js" %*
|
28
node_modules/.bin/detect-libc.ps1
generated
vendored
Normal file
28
node_modules/.bin/detect-libc.ps1
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../detect-libc/bin/detect-libc.js" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../detect-libc/bin/detect-libc.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../detect-libc/bin/detect-libc.js" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../detect-libc/bin/detect-libc.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
1
node_modules/.bin/mkdirp
generated
vendored
Symbolic link
1
node_modules/.bin/mkdirp
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../mkdirp/bin/cmd.js
|
17
node_modules/.bin/mkdirp.cmd
generated
vendored
Normal file
17
node_modules/.bin/mkdirp.cmd
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\mkdirp\bin\cmd.js" %*
|
28
node_modules/.bin/mkdirp.ps1
generated
vendored
Normal file
28
node_modules/.bin/mkdirp.ps1
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../mkdirp/bin/cmd.js" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../mkdirp/bin/cmd.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../mkdirp/bin/cmd.js" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../mkdirp/bin/cmd.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
17
node_modules/.bin/needle.cmd
generated
vendored
Normal file
17
node_modules/.bin/needle.cmd
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\needle\bin\needle" %*
|
28
node_modules/.bin/needle.ps1
generated
vendored
Normal file
28
node_modules/.bin/needle.ps1
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../needle/bin/needle" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../needle/bin/needle" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../needle/bin/needle" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../needle/bin/needle" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
1
node_modules/.bin/node-pre-gyp
generated
vendored
Symbolic link
1
node_modules/.bin/node-pre-gyp
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../@mapbox/node-pre-gyp/bin/node-pre-gyp
|
17
node_modules/.bin/node-pre-gyp.cmd
generated
vendored
Normal file
17
node_modules/.bin/node-pre-gyp.cmd
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\node-pre-gyp\bin\node-pre-gyp" %*
|
28
node_modules/.bin/node-pre-gyp.ps1
generated
vendored
Normal file
28
node_modules/.bin/node-pre-gyp.ps1
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../node-pre-gyp/bin/node-pre-gyp" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../node-pre-gyp/bin/node-pre-gyp" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../node-pre-gyp/bin/node-pre-gyp" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../node-pre-gyp/bin/node-pre-gyp" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
1
node_modules/.bin/nopt
generated
vendored
Symbolic link
1
node_modules/.bin/nopt
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../nopt/bin/nopt.js
|
17
node_modules/.bin/nopt.cmd
generated
vendored
Normal file
17
node_modules/.bin/nopt.cmd
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\nopt\bin\nopt.js" %*
|
28
node_modules/.bin/nopt.ps1
generated
vendored
Normal file
28
node_modules/.bin/nopt.ps1
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../nopt/bin/nopt.js" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../nopt/bin/nopt.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../nopt/bin/nopt.js" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../nopt/bin/nopt.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
1
node_modules/.bin/npm
generated
vendored
Symbolic link
1
node_modules/.bin/npm
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../npm/bin/npm-cli.js
|
17
node_modules/.bin/npm.cmd
generated
vendored
Normal file
17
node_modules/.bin/npm.cmd
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\npm\bin\npm-cli.js" %*
|
28
node_modules/.bin/npm.ps1
generated
vendored
Normal file
28
node_modules/.bin/npm.ps1
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../npm/bin/npm-cli.js" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../npm/bin/npm-cli.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../npm/bin/npm-cli.js" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../npm/bin/npm-cli.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
1
node_modules/.bin/npx
generated
vendored
Symbolic link
1
node_modules/.bin/npx
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../npm/bin/npx-cli.js
|
17
node_modules/.bin/npx.cmd
generated
vendored
Normal file
17
node_modules/.bin/npx.cmd
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\npm\bin\npx-cli.js" %*
|
28
node_modules/.bin/npx.ps1
generated
vendored
Normal file
28
node_modules/.bin/npx.ps1
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../npm/bin/npx-cli.js" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../npm/bin/npx-cli.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../npm/bin/npx-cli.js" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../npm/bin/npx-cli.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
17
node_modules/.bin/rc.cmd
generated
vendored
Normal file
17
node_modules/.bin/rc.cmd
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\rc\cli.js" %*
|
28
node_modules/.bin/rc.ps1
generated
vendored
Normal file
28
node_modules/.bin/rc.ps1
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../rc/cli.js" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../rc/cli.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../rc/cli.js" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../rc/cli.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
1
node_modules/.bin/rimraf
generated
vendored
Symbolic link
1
node_modules/.bin/rimraf
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../rimraf/bin.js
|
17
node_modules/.bin/rimraf.cmd
generated
vendored
Normal file
17
node_modules/.bin/rimraf.cmd
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\rimraf\bin.js" %*
|
28
node_modules/.bin/rimraf.ps1
generated
vendored
Normal file
28
node_modules/.bin/rimraf.ps1
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../rimraf/bin.js" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../rimraf/bin.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../rimraf/bin.js" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../rimraf/bin.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
1
node_modules/.bin/semver
generated
vendored
Symbolic link
1
node_modules/.bin/semver
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../semver/bin/semver.js
|
17
node_modules/.bin/semver.cmd
generated
vendored
Normal file
17
node_modules/.bin/semver.cmd
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\semver\bin\semver" %*
|
28
node_modules/.bin/semver.ps1
generated
vendored
Normal file
28
node_modules/.bin/semver.ps1
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../semver/bin/semver" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../semver/bin/semver" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../semver/bin/semver" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../semver/bin/semver" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
3334
node_modules/.package-lock.json
generated
vendored
Normal file
3334
node_modules/.package-lock.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
190
node_modules/@discordjs/collection/LICENSE
generated
vendored
Normal file
190
node_modules/@discordjs/collection/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,190 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Copyright 2015 - 2020 Amish Shah
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
3
node_modules/@discordjs/collection/README.md
generated
vendored
Normal file
3
node_modules/@discordjs/collection/README.md
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Collection
|
||||
|
||||
Utility data structure used in Discord.js.
|
319
node_modules/@discordjs/collection/dist/index.d.ts
generated
vendored
Normal file
319
node_modules/@discordjs/collection/dist/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,319 @@
|
|||
export interface CollectionConstructor {
|
||||
new (): Collection<unknown, unknown>;
|
||||
new <K, V>(entries?: ReadonlyArray<readonly [K, V]> | null): Collection<K, V>;
|
||||
new <K, V>(iterable: Iterable<readonly [K, V]>): Collection<K, V>;
|
||||
readonly prototype: Collection<unknown, unknown>;
|
||||
readonly [Symbol.species]: CollectionConstructor;
|
||||
}
|
||||
/**
|
||||
* A Map with additional utility methods. This is used throughout discord.js rather than Arrays for anything that has
|
||||
* an ID, for significantly improved performance and ease-of-use.
|
||||
* @extends {Map}
|
||||
* @property {number} size - The amount of elements in this collection.
|
||||
*/
|
||||
declare class Collection<K, V> extends Map<K, V> {
|
||||
private _array;
|
||||
private _keyArray;
|
||||
static readonly default: typeof Collection;
|
||||
['constructor']: typeof Collection;
|
||||
constructor(entries?: ReadonlyArray<readonly [K, V]> | null);
|
||||
/**
|
||||
* Identical to [Map.get()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get).
|
||||
* Gets an element with the specified key, and returns its value, or `undefined` if the element does not exist.
|
||||
* @param {*} key - The key to get from this collection
|
||||
* @returns {* | undefined}
|
||||
*/
|
||||
get(key: K): V | undefined;
|
||||
/**
|
||||
* Identical to [Map.set()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/set).
|
||||
* Sets a new element in the collection with the specified key and value.
|
||||
* @param {*} key - The key of the element to add
|
||||
* @param {*} value - The value of the element to add
|
||||
* @returns {Collection}
|
||||
*/
|
||||
set(key: K, value: V): this;
|
||||
/**
|
||||
* Identical to [Map.has()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has).
|
||||
* Checks if an element exists in the collection.
|
||||
* @param {*} key - The key of the element to check for
|
||||
* @returns {boolean} `true` if the element exists, `false` if it does not exist.
|
||||
*/
|
||||
has(key: K): boolean;
|
||||
/**
|
||||
* Identical to [Map.delete()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete).
|
||||
* Deletes an element from the collection.
|
||||
* @param {*} key - The key to delete from the collection
|
||||
* @returns {boolean} `true` if the element was removed, `false` if the element does not exist.
|
||||
*/
|
||||
delete(key: K): boolean;
|
||||
/**
|
||||
* Identical to [Map.clear()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/clear).
|
||||
* Removes all elements from the collection.
|
||||
* @returns {undefined}
|
||||
*/
|
||||
clear(): void;
|
||||
/**
|
||||
* Creates an ordered array of the values of this collection, and caches it internally. The array will only be
|
||||
* reconstructed if an item is added to or removed from the collection, or if you change the length of the array
|
||||
* itself. If you don't want this caching behavior, use `[...collection.values()]` or
|
||||
* `Array.from(collection.values())` instead.
|
||||
* @returns {Array}
|
||||
*/
|
||||
array(): V[];
|
||||
/**
|
||||
* Creates an ordered array of the keys of this collection, and caches it internally. The array will only be
|
||||
* reconstructed if an item is added to or removed from the collection, or if you change the length of the array
|
||||
* itself. If you don't want this caching behavior, use `[...collection.keys()]` or
|
||||
* `Array.from(collection.keys())` instead.
|
||||
* @returns {Array}
|
||||
*/
|
||||
keyArray(): K[];
|
||||
/**
|
||||
* Obtains the first value(s) in this collection.
|
||||
* @param {number} [amount] Amount of values to obtain from the beginning
|
||||
* @returns {*|Array<*>} A single value if no amount is provided or an array of values, starting from the end if
|
||||
* amount is negative
|
||||
*/
|
||||
first(): V | undefined;
|
||||
first(amount: number): V[];
|
||||
/**
|
||||
* Obtains the first key(s) in this collection.
|
||||
* @param {number} [amount] Amount of keys to obtain from the beginning
|
||||
* @returns {*|Array<*>} A single key if no amount is provided or an array of keys, starting from the end if
|
||||
* amount is negative
|
||||
*/
|
||||
firstKey(): K | undefined;
|
||||
firstKey(amount: number): K[];
|
||||
/**
|
||||
* Obtains the last value(s) in this collection. This relies on {@link Collection#array}, and thus the caching
|
||||
* mechanism applies here as well.
|
||||
* @param {number} [amount] Amount of values to obtain from the end
|
||||
* @returns {*|Array<*>} A single value if no amount is provided or an array of values, starting from the start if
|
||||
* amount is negative
|
||||
*/
|
||||
last(): V | undefined;
|
||||
last(amount: number): V[];
|
||||
/**
|
||||
* Obtains the last key(s) in this collection. This relies on {@link Collection#keyArray}, and thus the caching
|
||||
* mechanism applies here as well.
|
||||
* @param {number} [amount] Amount of keys to obtain from the end
|
||||
* @returns {*|Array<*>} A single key if no amount is provided or an array of keys, starting from the start if
|
||||
* amount is negative
|
||||
*/
|
||||
lastKey(): K | undefined;
|
||||
lastKey(amount: number): K[];
|
||||
/**
|
||||
* Obtains unique random value(s) from this collection. This relies on {@link Collection#array}, and thus the caching
|
||||
* mechanism applies here as well.
|
||||
* @param {number} [amount] Amount of values to obtain randomly
|
||||
* @returns {*|Array<*>} A single value if no amount is provided or an array of values
|
||||
*/
|
||||
random(): V;
|
||||
random(amount: number): V[];
|
||||
/**
|
||||
* Obtains unique random key(s) from this collection. This relies on {@link Collection#keyArray}, and thus the caching
|
||||
* mechanism applies here as well.
|
||||
* @param {number} [amount] Amount of keys to obtain randomly
|
||||
* @returns {*|Array<*>} A single key if no amount is provided or an array
|
||||
*/
|
||||
randomKey(): K;
|
||||
randomKey(amount: number): K[];
|
||||
/**
|
||||
* Searches for a single item where the given function returns a truthy value. This behaves like
|
||||
* [Array.find()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find).
|
||||
* <warn>All collections used in Discord.js are mapped using their `id` property, and if you want to find by id you
|
||||
* should use the `get` method. See
|
||||
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get) for details.</warn>
|
||||
* @param {Function} fn The function to test with (should return boolean)
|
||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
||||
* @returns {*}
|
||||
* @example collection.find(user => user.username === 'Bob');
|
||||
*/
|
||||
find(fn: (value: V, key: K, collection: this) => boolean): V | undefined;
|
||||
find<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): V | undefined;
|
||||
/**
|
||||
* Searches for the key of a single item where the given function returns a truthy value. This behaves like
|
||||
* [Array.findIndex()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex),
|
||||
* but returns the key rather than the positional index.
|
||||
* @param {Function} fn The function to test with (should return boolean)
|
||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
||||
* @returns {*}
|
||||
* @example collection.findKey(user => user.username === 'Bob');
|
||||
*/
|
||||
findKey(fn: (value: V, key: K, collection: this) => boolean): K | undefined;
|
||||
findKey<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): K | undefined;
|
||||
/**
|
||||
* Removes items that satisfy the provided filter function.
|
||||
* @param {Function} fn Function used to test (should return a boolean)
|
||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
||||
* @returns {number} The number of removed entries
|
||||
*/
|
||||
sweep(fn: (value: V, key: K, collection: this) => boolean): number;
|
||||
sweep<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): number;
|
||||
/**
|
||||
* Identical to
|
||||
* [Array.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter),
|
||||
* but returns a Collection instead of an Array.
|
||||
* @param {Function} fn The function to test with (should return boolean)
|
||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
||||
* @returns {Collection}
|
||||
* @example collection.filter(user => user.username === 'Bob');
|
||||
*/
|
||||
filter(fn: (value: V, key: K, collection: this) => boolean): this;
|
||||
filter<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): this;
|
||||
/**
|
||||
* Partitions the collection into two collections where the first collection
|
||||
* contains the items that passed and the second contains the items that failed.
|
||||
* @param {Function} fn Function used to test (should return a boolean)
|
||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
||||
* @returns {Collection[]}
|
||||
* @example const [big, small] = collection.partition(guild => guild.memberCount > 250);
|
||||
*/
|
||||
partition(fn: (value: V, key: K, collection: this) => boolean): [this, this];
|
||||
partition<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): [this, this];
|
||||
/**
|
||||
* Maps each item into a Collection, then joins the results into a single Collection. Identical in behavior to
|
||||
* [Array.flatMap()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap).
|
||||
* @param {Function} fn Function that produces a new Collection
|
||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
||||
* @returns {Collection}
|
||||
* @example collection.flatMap(guild => guild.members.cache);
|
||||
*/
|
||||
flatMap<T>(fn: (value: V, key: K, collection: this) => Collection<K, T>): Collection<K, T>;
|
||||
flatMap<T, This>(fn: (this: This, value: V, key: K, collection: this) => Collection<K, T>, thisArg: This): Collection<K, T>;
|
||||
/**
|
||||
* Maps each item to another value into an array. Identical in behavior to
|
||||
* [Array.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).
|
||||
* @param {Function} fn Function that produces an element of the new array, taking three arguments
|
||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
||||
* @returns {Array}
|
||||
* @example collection.map(user => user.tag);
|
||||
*/
|
||||
map<T>(fn: (value: V, key: K, collection: this) => T): T[];
|
||||
map<This, T>(fn: (this: This, value: V, key: K, collection: this) => T, thisArg: This): T[];
|
||||
/**
|
||||
* Maps each item to another value into a collection. Identical in behavior to
|
||||
* [Array.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).
|
||||
* @param {Function} fn Function that produces an element of the new collection, taking three arguments
|
||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
||||
* @returns {Collection}
|
||||
* @example collection.mapValues(user => user.tag);
|
||||
*/
|
||||
mapValues<T>(fn: (value: V, key: K, collection: this) => T): Collection<K, T>;
|
||||
mapValues<This, T>(fn: (this: This, value: V, key: K, collection: this) => T, thisArg: This): Collection<K, T>;
|
||||
/**
|
||||
* Checks if there exists an item that passes a test. Identical in behavior to
|
||||
* [Array.some()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some).
|
||||
* @param {Function} fn Function used to test (should return a boolean)
|
||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
||||
* @returns {boolean}
|
||||
* @example collection.some(user => user.discriminator === '0000');
|
||||
*/
|
||||
some(fn: (value: V, key: K, collection: this) => boolean): boolean;
|
||||
some<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): boolean;
|
||||
/**
|
||||
* Checks if all items passes a test. Identical in behavior to
|
||||
* [Array.every()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every).
|
||||
* @param {Function} fn Function used to test (should return a boolean)
|
||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
||||
* @returns {boolean}
|
||||
* @example collection.every(user => !user.bot);
|
||||
*/
|
||||
every(fn: (value: V, key: K, collection: this) => boolean): boolean;
|
||||
every<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): boolean;
|
||||
/**
|
||||
* Applies a function to produce a single value. Identical in behavior to
|
||||
* [Array.reduce()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce).
|
||||
* @param {Function} fn Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,
|
||||
* and `collection`
|
||||
* @param {*} [initialValue] Starting value for the accumulator
|
||||
* @returns {*}
|
||||
* @example collection.reduce((acc, guild) => acc + guild.memberCount, 0);
|
||||
*/
|
||||
reduce<T>(fn: (accumulator: T, value: V, key: K, collection: this) => T, initialValue?: T): T;
|
||||
/**
|
||||
* Identical to
|
||||
* [Map.forEach()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach),
|
||||
* but returns the collection instead of undefined.
|
||||
* @param {Function} fn Function to execute for each element
|
||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
||||
* @returns {Collection}
|
||||
* @example
|
||||
* collection
|
||||
* .each(user => console.log(user.username))
|
||||
* .filter(user => user.bot)
|
||||
* .each(user => console.log(user.username));
|
||||
*/
|
||||
each(fn: (value: V, key: K, collection: this) => void): this;
|
||||
each<T>(fn: (this: T, value: V, key: K, collection: this) => void, thisArg: T): this;
|
||||
/**
|
||||
* Runs a function on the collection and returns the collection.
|
||||
* @param {Function} fn Function to execute
|
||||
* @param {*} [thisArg] Value to use as `this` when executing function
|
||||
* @returns {Collection}
|
||||
* @example
|
||||
* collection
|
||||
* .tap(coll => console.log(coll.size))
|
||||
* .filter(user => user.bot)
|
||||
* .tap(coll => console.log(coll.size))
|
||||
*/
|
||||
tap(fn: (collection: this) => void): this;
|
||||
tap<T>(fn: (this: T, collection: this) => void, thisArg: T): this;
|
||||
/**
|
||||
* Creates an identical shallow copy of this collection.
|
||||
* @returns {Collection}
|
||||
* @example const newColl = someColl.clone();
|
||||
*/
|
||||
clone(): this;
|
||||
/**
|
||||
* Combines this collection with others into a new collection. None of the source collections are modified.
|
||||
* @param {...Collection} collections Collections to merge
|
||||
* @returns {Collection}
|
||||
* @example const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);
|
||||
*/
|
||||
concat(...collections: Collection<K, V>[]): this;
|
||||
/**
|
||||
* Checks if this collection shares identical items with another.
|
||||
* This is different to checking for equality using equal-signs, because
|
||||
* the collections may be different objects, but contain the same data.
|
||||
* @param {Collection} collection Collection to compare with
|
||||
* @returns {boolean} Whether the collections have identical contents
|
||||
*/
|
||||
equals(collection: Collection<K, V>): boolean;
|
||||
/**
|
||||
* The sort method sorts the items of a collection in place and returns it.
|
||||
* The sort is not necessarily stable in Node 10 or older.
|
||||
* The default sort order is according to string Unicode code points.
|
||||
* @param {Function} [compareFunction] Specifies a function that defines the sort order.
|
||||
* If omitted, the collection is sorted according to each character's Unicode code point value,
|
||||
* according to the string conversion of each element.
|
||||
* @returns {Collection}
|
||||
* @example collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
||||
*/
|
||||
sort(compareFunction?: (firstValue: V, secondValue: V, firstKey: K, secondKey: K) => number): this;
|
||||
/**
|
||||
* The intersect method returns a new structure containing items where the keys are present in both original structures.
|
||||
* @param {Collection} other The other Collection to filter against
|
||||
* @returns {Collection}
|
||||
*/
|
||||
intersect(other: Collection<K, V>): Collection<K, V>;
|
||||
/**
|
||||
* The difference method returns a new structure containing items where the key is present in one of the original structures but not the other.
|
||||
* @param {Collection} other The other Collection to filter against
|
||||
* @returns {Collection}
|
||||
*/
|
||||
difference(other: Collection<K, V>): Collection<K, V>;
|
||||
/**
|
||||
* The sorted method sorts the items of a collection and returns it.
|
||||
* The sort is not necessarily stable in Node 10 or older.
|
||||
* The default sort order is according to string Unicode code points.
|
||||
* @param {Function} [compareFunction] Specifies a function that defines the sort order.
|
||||
* If omitted, the collection is sorted according to each character's Unicode code point value,
|
||||
* according to the string conversion of each element.
|
||||
* @returns {Collection}
|
||||
* @example collection.sorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
||||
*/
|
||||
sorted(compareFunction?: (firstValue: V, secondValue: V, firstKey: K, secondKey: K) => number): this;
|
||||
}
|
||||
export { Collection };
|
||||
export default Collection;
|
392
node_modules/@discordjs/collection/dist/index.js
generated
vendored
Normal file
392
node_modules/@discordjs/collection/dist/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
53
node_modules/@discordjs/collection/package.json
generated
vendored
Normal file
53
node_modules/@discordjs/collection/package.json
generated
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"name": "@discordjs/collection",
|
||||
"version": "0.1.6",
|
||||
"description": "Utility data structure used in Discord.js",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"lint": "eslint src --ext .ts",
|
||||
"prebuild": "npm run lint",
|
||||
"build": "rimraf dist/ && tsc",
|
||||
"pretest": "npm run build",
|
||||
"test": "node test/index.js",
|
||||
"docs": "docgen --jsdoc jsdoc.json --source src/*.ts src/**/*.ts --custom docs/index.yml --output docs/docs.json",
|
||||
"docs:test": "docgen --jsdoc jsdoc.json --source src/*.ts src/**/*.ts --custom docs/index.yml"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/discordjs/collection.git"
|
||||
},
|
||||
"keywords": [
|
||||
"map",
|
||||
"collection",
|
||||
"utility"
|
||||
],
|
||||
"author": "Amish Shah <amishshah.2k@gmail.com>",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/discordjs/collection/issues"
|
||||
},
|
||||
"homepage": "https://github.com/discordjs/collection#readme",
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.8.4",
|
||||
"@babel/core": "^7.8.4",
|
||||
"@babel/preset-env": "^7.8.4",
|
||||
"@babel/preset-typescript": "^7.8.3",
|
||||
"@types/node": "^13.7.4",
|
||||
"@typescript-eslint/eslint-plugin": "^2.21.0",
|
||||
"@typescript-eslint/parser": "^2.21.0",
|
||||
"discord.js-docgen": "discordjs/docgen#ts-patch",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-marine": "^6.0.0",
|
||||
"jsdoc-babel": "^0.5.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^3.8.2"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "marine/node"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.6.tgz"
|
||||
,"_integrity": "sha512-utRNxnd9kSS2qhyivo9lMlt5qgAUasH2gb7BEOn6p0efFh24gjGomHzWKMAPn2hEReOPQZCJaRKoURwRotKucQ=="
|
||||
,"_from": "@discordjs/collection@0.1.6"
|
||||
}
|
19
node_modules/@discordjs/form-data/License
generated
vendored
Normal file
19
node_modules/@discordjs/form-data/License
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2012 Felix Geisendörfer (felix@debuggable.com) and contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
353
node_modules/@discordjs/form-data/Readme.md
generated
vendored
Normal file
353
node_modules/@discordjs/form-data/Readme.md
generated
vendored
Normal file
|
@ -0,0 +1,353 @@
|
|||
# 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)
|
||||
|
||||
A library to create readable ```"multipart/form-data"``` streams. Can be used to submit forms and file uploads to other web applications.
|
||||
|
||||
The API of this library is inspired by the [XMLHttpRequest-2 FormData Interface][xhr2-fd].
|
||||
|
||||
[xhr2-fd]: http://dev.w3.org/2006/webapi/XMLHttpRequest-2/Overview.html#the-formdata-interface
|
||||
|
||||
[![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)
|
||||
[![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)
|
||||
[![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)
|
||||
|
||||
[![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)
|
||||
[![Dependency Status](https://img.shields.io/david/form-data/form-data.svg)](https://david-dm.org/form-data/form-data)
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
npm install --save form-data
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
In this example we are constructing a form with 3 fields that contain a string,
|
||||
a buffer and a file stream.
|
||||
|
||||
``` javascript
|
||||
var FormData = require('form-data');
|
||||
var fs = require('fs');
|
||||
|
||||
var form = new FormData();
|
||||
form.append('my_field', 'my value');
|
||||
form.append('my_buffer', new Buffer(10));
|
||||
form.append('my_file', fs.createReadStream('/foo/bar.jpg'));
|
||||
```
|
||||
|
||||
Also you can use http-response stream:
|
||||
|
||||
``` javascript
|
||||
var FormData = require('form-data');
|
||||
var http = require('http');
|
||||
|
||||
var form = new FormData();
|
||||
|
||||
http.request('http://nodejs.org/images/logo.png', function(response) {
|
||||
form.append('my_field', 'my value');
|
||||
form.append('my_buffer', new Buffer(10));
|
||||
form.append('my_logo', response);
|
||||
});
|
||||
```
|
||||
|
||||
Or @mikeal's [request](https://github.com/request/request) stream:
|
||||
|
||||
``` javascript
|
||||
var FormData = require('form-data');
|
||||
var request = require('request');
|
||||
|
||||
var form = new FormData();
|
||||
|
||||
form.append('my_field', 'my value');
|
||||
form.append('my_buffer', new Buffer(10));
|
||||
form.append('my_logo', request('http://nodejs.org/images/logo.png'));
|
||||
```
|
||||
|
||||
In order to submit this form to a web application, call ```submit(url, [callback])``` method:
|
||||
|
||||
``` javascript
|
||||
form.submit('http://example.org/', function(err, res) {
|
||||
// res – response object (http.IncomingMessage) //
|
||||
res.resume();
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
For more advanced request manipulations ```submit()``` method returns ```http.ClientRequest``` object, or you can choose from one of the alternative submission methods.
|
||||
|
||||
### Custom options
|
||||
|
||||
You can provide custom options, such as `maxDataSize`:
|
||||
|
||||
``` javascript
|
||||
var FormData = require('form-data');
|
||||
|
||||
var form = new FormData({ maxDataSize: 20971520 });
|
||||
form.append('my_field', 'my value');
|
||||
form.append('my_buffer', /* something big */);
|
||||
```
|
||||
|
||||
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)
|
||||
|
||||
### Alternative submission methods
|
||||
|
||||
You can use node's http client interface:
|
||||
|
||||
``` javascript
|
||||
var http = require('http');
|
||||
|
||||
var request = http.request({
|
||||
method: 'post',
|
||||
host: 'example.org',
|
||||
path: '/upload',
|
||||
headers: form.getHeaders()
|
||||
});
|
||||
|
||||
form.pipe(request);
|
||||
|
||||
request.on('response', function(res) {
|
||||
console.log(res.statusCode);
|
||||
});
|
||||
```
|
||||
|
||||
Or if you would prefer the `'Content-Length'` header to be set for you:
|
||||
|
||||
``` javascript
|
||||
form.submit('example.org/upload', function(err, res) {
|
||||
console.log(res.statusCode);
|
||||
});
|
||||
```
|
||||
|
||||
To use custom headers and pre-known length in parts:
|
||||
|
||||
``` javascript
|
||||
var CRLF = '\r\n';
|
||||
var form = new FormData();
|
||||
|
||||
var options = {
|
||||
header: CRLF + '--' + form.getBoundary() + CRLF + 'X-Custom-Header: 123' + CRLF + CRLF,
|
||||
knownLength: 1
|
||||
};
|
||||
|
||||
form.append('my_buffer', buffer, options);
|
||||
|
||||
form.submit('http://example.com/', function(err, res) {
|
||||
if (err) throw err;
|
||||
console.log('Done');
|
||||
});
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||
``` javascript
|
||||
someModule.stream(function(err, stdout, stderr) {
|
||||
if (err) throw err;
|
||||
|
||||
var form = new FormData();
|
||||
|
||||
form.append('file', stdout, {
|
||||
filename: 'unicycle.jpg', // ... or:
|
||||
filepath: 'photos/toys/unicycle.jpg',
|
||||
contentType: 'image/jpeg',
|
||||
knownLength: 19806
|
||||
});
|
||||
|
||||
form.submit('http://example.com/', function(err, res) {
|
||||
if (err) throw err;
|
||||
console.log('Done');
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
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).
|
||||
|
||||
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:
|
||||
|
||||
``` javascript
|
||||
form.submit({
|
||||
host: 'example.com',
|
||||
path: '/probably.php?extra=params',
|
||||
auth: 'username:password'
|
||||
}, function(err, res) {
|
||||
console.log(res.statusCode);
|
||||
});
|
||||
```
|
||||
|
||||
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()`:
|
||||
|
||||
``` javascript
|
||||
form.submit({
|
||||
host: 'example.com',
|
||||
path: '/surelynot.php',
|
||||
headers: {'x-test-header': 'test-header-value'}
|
||||
}, function(err, res) {
|
||||
console.log(res.statusCode);
|
||||
});
|
||||
```
|
||||
|
||||
### Methods
|
||||
|
||||
- [_Void_ append( **String** _field_, **Mixed** _value_ [, **Mixed** _options_] )](https://github.com/form-data/form-data#void-append-string-field-mixed-value--mixed-options-).
|
||||
- [_Headers_ getHeaders( [**Headers** _userHeaders_] )](https://github.com/form-data/form-data#array-getheaders-array-userheaders-)
|
||||
- [_String_ getBoundary()](https://github.com/form-data/form-data#string-getboundary)
|
||||
- [_Buffer_ getBuffer()](https://github.com/form-data/form-data#buffer-getbuffer)
|
||||
- [_Integer_ getLengthSync()](https://github.com/form-data/form-data#integer-getlengthsync)
|
||||
- [_Integer_ getLength( **function** _callback_ )](https://github.com/form-data/form-data#integer-getlength-function-callback-)
|
||||
- [_Boolean_ hasKnownLength()](https://github.com/form-data/form-data#boolean-hasknownlength)
|
||||
- [_Request_ submit( _params_, **function** _callback_ )](https://github.com/form-data/form-data#request-submit-params-function-callback-)
|
||||
- [_String_ toString()](https://github.com/form-data/form-data#string-tostring)
|
||||
|
||||
#### _Void_ append( **String** _field_, **Mixed** _value_ [, **Mixed** _options_] )
|
||||
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.
|
||||
```javascript
|
||||
var form = new FormData();
|
||||
form.append( 'my_string', 'my value' );
|
||||
form.append( 'my_integer', 1 );
|
||||
form.append( 'my_boolean', true );
|
||||
form.append( 'my_buffer', new Buffer(10) );
|
||||
form.append( 'my_array_as_json', JSON.stringify( ['bird','cute'] ) )
|
||||
```
|
||||
|
||||
You may provide a string for options, or an object.
|
||||
```javascript
|
||||
// Set filename by providing a string for options
|
||||
form.append( 'my_file', fs.createReadStream('/foo/bar.jpg'), 'bar.jpg' );
|
||||
|
||||
// provide an object.
|
||||
form.append( 'my_file', fs.createReadStream('/foo/bar.jpg'), {filename: 'bar.jpg', contentType: 'image/jpeg', knownLength: 19806} );
|
||||
```
|
||||
|
||||
#### _Headers_ getHeaders( [**Headers** _userHeaders_] )
|
||||
This method adds the correct `content-type` header to the provided array of `userHeaders`.
|
||||
|
||||
#### _String_ getBoundary()
|
||||
Return the boundary of the formData. A boundary consists of 26 `-` followed by 24 numbers
|
||||
for example:
|
||||
```javascript
|
||||
--------------------------515890814546601021194782
|
||||
```
|
||||
_Note: The boundary must be unique and may not appear in the data._
|
||||
|
||||
#### _Buffer_ getBuffer()
|
||||
Return the full formdata request package, as a Buffer. You can insert this Buffer in e.g. Axios to send multipart data.
|
||||
```javascript
|
||||
var form = new FormData();
|
||||
form.append( 'my_buffer', Buffer.from([0x4a,0x42,0x20,0x52,0x6f,0x63,0x6b,0x73]) );
|
||||
form.append( 'my_file', fs.readFileSync('/foo/bar.jpg') );
|
||||
|
||||
axios.post( 'https://example.com/path/to/api',
|
||||
form.getBuffer(),
|
||||
form.getHeaders()
|
||||
)
|
||||
```
|
||||
**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.
|
||||
|
||||
#### _Integer_ getLengthSync()
|
||||
Same as `getLength` but synchronous.
|
||||
|
||||
_Note: getLengthSync __doesn't__ calculate streams length._
|
||||
|
||||
#### _Integer_ getLength( **function** _callback_ )
|
||||
Returns the `Content-Length` async. The callback is used to handle errors and continue once the length has been calculated
|
||||
```javascript
|
||||
this.getLength(function(err, length) {
|
||||
if (err) {
|
||||
this._error(err);
|
||||
return;
|
||||
}
|
||||
|
||||
// add content length
|
||||
request.setHeader('Content-Length', length);
|
||||
|
||||
...
|
||||
}.bind(this));
|
||||
```
|
||||
|
||||
#### _Boolean_ hasKnownLength()
|
||||
Checks if the length of added values is known.
|
||||
|
||||
#### _Request_ submit( _params_, **function** _callback_ )
|
||||
Submit the form to a web application.
|
||||
```javascript
|
||||
var form = new FormData();
|
||||
form.append( 'my_string', 'Hello World' );
|
||||
|
||||
form.submit( 'http://example.com/', function(err, res) {
|
||||
// res – response object (http.IncomingMessage) //
|
||||
res.resume();
|
||||
} );
|
||||
```
|
||||
|
||||
#### _String_ toString()
|
||||
Returns the form data as a string. Don't use this if you are sending files or buffers, use `getBuffer()` instead.
|
||||
|
||||
### Integration with other libraries
|
||||
|
||||
#### Request
|
||||
|
||||
Form submission using [request](https://github.com/request/request):
|
||||
|
||||
```javascript
|
||||
var formData = {
|
||||
my_field: 'my_value',
|
||||
my_file: fs.createReadStream(__dirname + '/unicycle.jpg'),
|
||||
};
|
||||
|
||||
request.post({url:'http://service.com/upload', formData: formData}, function(err, httpResponse, body) {
|
||||
if (err) {
|
||||
return console.error('upload failed:', err);
|
||||
}
|
||||
console.log('Upload successful! Server responded with:', body);
|
||||
});
|
||||
```
|
||||
|
||||
For more details see [request readme](https://github.com/request/request#multipartform-data-multipart-form-uploads).
|
||||
|
||||
#### node-fetch
|
||||
|
||||
You can also submit a form using [node-fetch](https://github.com/bitinn/node-fetch):
|
||||
|
||||
```javascript
|
||||
var form = new FormData();
|
||||
|
||||
form.append('a', 1);
|
||||
|
||||
fetch('http://example.com', { method: 'POST', body: form })
|
||||
.then(function(res) {
|
||||
return res.json();
|
||||
}).then(function(json) {
|
||||
console.log(json);
|
||||
});
|
||||
```
|
||||
|
||||
#### axios
|
||||
|
||||
In Node.js you can post a file using [axios](https://github.com/axios/axios):
|
||||
```javascript
|
||||
const form = new FormData();
|
||||
const stream = fs.createReadStream(PATH_TO_FILE);
|
||||
|
||||
form.append('image', stream);
|
||||
|
||||
// In Node.js environment you need to set boundary in the header field 'Content-Type' by calling method `getHeaders`
|
||||
const formHeaders = form.getHeaders();
|
||||
|
||||
axios.post('http://example.com', form, {
|
||||
headers: {
|
||||
...formHeaders,
|
||||
},
|
||||
})
|
||||
.then(response => response)
|
||||
.catch(error => error)
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- ```getLengthSync()``` method DOESN'T calculate length for streams, use ```knownLength``` options as workaround.
|
||||
- ```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```).
|
||||
- ```sbumit``` will not add `content-length` if form length is unknown or not calculable.
|
||||
- Starting version `2.x` FormData has dropped support for `node@0.10.x`.
|
||||
- Starting version `3.x` FormData has dropped support for `node@4.x`.
|
||||
|
||||
## License
|
||||
|
||||
Form-Data is released under the [MIT](License) license.
|
61
node_modules/@discordjs/form-data/index.d.ts
generated
vendored
Normal file
61
node_modules/@discordjs/form-data/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>
|
||||
// Leon Yu <https://github.com/leonyu>
|
||||
// BendingBender <https://github.com/BendingBender>
|
||||
// Maple Miao <https://github.com/mapleeit>
|
||||
|
||||
/// <reference types="node" />
|
||||
import * as stream from 'stream';
|
||||
import * as http from 'http';
|
||||
|
||||
export = FormData;
|
||||
|
||||
// Extracted because @types/node doesn't export interfaces.
|
||||
interface ReadableOptions {
|
||||
highWaterMark?: number;
|
||||
encoding?: string;
|
||||
objectMode?: boolean;
|
||||
read?(this: stream.Readable, size: number): void;
|
||||
destroy?(this: stream.Readable, error: Error | null, callback: (error: Error | null) => void): void;
|
||||
autoDestroy?: boolean;
|
||||
}
|
||||
|
||||
interface Options extends ReadableOptions {
|
||||
writable?: boolean;
|
||||
readable?: boolean;
|
||||
dataSize?: number;
|
||||
maxDataSize?: number;
|
||||
pauseStreams?: boolean;
|
||||
}
|
||||
|
||||
declare class FormData extends stream.Readable {
|
||||
constructor(options?: Options);
|
||||
append(key: string, value: any, options?: FormData.AppendOptions | string): void;
|
||||
getHeaders(userHeaders?: FormData.Headers): FormData.Headers;
|
||||
submit(
|
||||
params: string | FormData.SubmitOptions,
|
||||
callback?: (error: Error | null, response: http.IncomingMessage) => void
|
||||
): http.ClientRequest;
|
||||
getBuffer(): Buffer;
|
||||
getBoundary(): string;
|
||||
getLength(callback: (err: Error | null, length: number) => void): void;
|
||||
getLengthSync(): number;
|
||||
hasKnownLength(): boolean;
|
||||
}
|
||||
|
||||
declare namespace FormData {
|
||||
interface Headers {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
interface AppendOptions {
|
||||
header?: string | Headers;
|
||||
knownLength?: number;
|
||||
filename?: string;
|
||||
filepath?: string;
|
||||
contentType?: string;
|
||||
}
|
||||
|
||||
interface SubmitOptions extends http.RequestOptions {
|
||||
protocol?: 'https:' | 'http:';
|
||||
}
|
||||
}
|
2
node_modules/@discordjs/form-data/lib/browser.js
generated
vendored
Normal file
2
node_modules/@discordjs/form-data/lib/browser.js
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
/* eslint-env browser */
|
||||
module.exports = typeof self == 'object' ? self.FormData : window.FormData;
|
497
node_modules/@discordjs/form-data/lib/form_data.js
generated
vendored
Normal file
497
node_modules/@discordjs/form-data/lib/form_data.js
generated
vendored
Normal file
|
@ -0,0 +1,497 @@
|
|||
var CombinedStream = require('combined-stream');
|
||||
var util = require('util');
|
||||
var path = require('path');
|
||||
var http = require('http');
|
||||
var https = require('https');
|
||||
var parseUrl = require('url').parse;
|
||||
var fs = require('fs');
|
||||
var Stream = require('stream').Stream;
|
||||
var mime = require('mime-types');
|
||||
var asynckit = require('asynckit');
|
||||
var populate = require('./populate.js');
|
||||
|
||||
// Public API
|
||||
module.exports = FormData;
|
||||
|
||||
// make it a Stream
|
||||
util.inherits(FormData, CombinedStream);
|
||||
|
||||
/**
|
||||
* Create readable "multipart/form-data" streams.
|
||||
* Can be used to submit forms
|
||||
* and file uploads to other web applications.
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} options - Properties to be added/overriden for FormData and CombinedStream
|
||||
*/
|
||||
function FormData(options) {
|
||||
if (!(this instanceof FormData)) {
|
||||
return new FormData(options);
|
||||
}
|
||||
|
||||
this._overheadLength = 0;
|
||||
this._valueLength = 0;
|
||||
this._valuesToMeasure = [];
|
||||
|
||||
CombinedStream.call(this);
|
||||
|
||||
options = options || {};
|
||||
for (var option in options) {
|
||||
this[option] = options[option];
|
||||
}
|
||||
}
|
||||
|
||||
FormData.LINE_BREAK = '\r\n';
|
||||
FormData.DEFAULT_CONTENT_TYPE = 'application/octet-stream';
|
||||
|
||||
FormData.prototype.append = function(field, value, options) {
|
||||
|
||||
options = options || {};
|
||||
|
||||
// allow filename as single option
|
||||
if (typeof options == 'string') {
|
||||
options = {filename: options};
|
||||
}
|
||||
|
||||
var append = CombinedStream.prototype.append.bind(this);
|
||||
|
||||
// all that streamy business can't handle numbers
|
||||
if (typeof value == 'number') {
|
||||
value = '' + value;
|
||||
}
|
||||
|
||||
// https://github.com/felixge/node-form-data/issues/38
|
||||
if (util.isArray(value)) {
|
||||
// Please convert your array into string
|
||||
// the way web server expects it
|
||||
this._error(new Error('Arrays are not supported.'));
|
||||
return;
|
||||
}
|
||||
|
||||
var header = this._multiPartHeader(field, value, options);
|
||||
var footer = this._multiPartFooter();
|
||||
|
||||
append(header);
|
||||
append(value);
|
||||
append(footer);
|
||||
|
||||
// pass along options.knownLength
|
||||
this._trackLength(header, value, options);
|
||||
};
|
||||
|
||||
FormData.prototype._trackLength = function(header, value, options) {
|
||||
var valueLength = 0;
|
||||
|
||||
// used w/ getLengthSync(), when length is known.
|
||||
// e.g. for streaming directly from a remote server,
|
||||
// w/ a known file a size, and not wanting to wait for
|
||||
// incoming file to finish to get its size.
|
||||
if (options.knownLength != null) {
|
||||
valueLength += +options.knownLength;
|
||||
} else if (Buffer.isBuffer(value)) {
|
||||
valueLength = value.length;
|
||||
} else if (typeof value === 'string') {
|
||||
valueLength = Buffer.byteLength(value);
|
||||
}
|
||||
|
||||
this._valueLength += valueLength;
|
||||
|
||||
// @check why add CRLF? does this account for custom/multiple CRLFs?
|
||||
this._overheadLength +=
|
||||
Buffer.byteLength(header) +
|
||||
FormData.LINE_BREAK.length;
|
||||
|
||||
// empty or either doesn't have path or not an http response or not a stream
|
||||
if (!value || ( !value.path && !(value.readable && value.hasOwnProperty('httpVersion')) && !(value instanceof Stream))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// no need to bother with the length
|
||||
if (!options.knownLength) {
|
||||
this._valuesToMeasure.push(value);
|
||||
}
|
||||
};
|
||||
|
||||
FormData.prototype._lengthRetriever = function(value, callback) {
|
||||
|
||||
if (value.hasOwnProperty('fd')) {
|
||||
|
||||
// take read range into a account
|
||||
// `end` = Infinity –> read file till the end
|
||||
//
|
||||
// TODO: Looks like there is bug in Node fs.createReadStream
|
||||
// it doesn't respect `end` options without `start` options
|
||||
// Fix it when node fixes it.
|
||||
// https://github.com/joyent/node/issues/7819
|
||||
if (value.end != undefined && value.end != Infinity && value.start != undefined) {
|
||||
|
||||
// when end specified
|
||||
// no need to calculate range
|
||||
// inclusive, starts with 0
|
||||
callback(null, value.end + 1 - (value.start ? value.start : 0));
|
||||
|
||||
// not that fast snoopy
|
||||
} else {
|
||||
// still need to fetch file size from fs
|
||||
fs.stat(value.path, function(err, stat) {
|
||||
|
||||
var fileSize;
|
||||
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
// update final size based on the range options
|
||||
fileSize = stat.size - (value.start ? value.start : 0);
|
||||
callback(null, fileSize);
|
||||
});
|
||||
}
|
||||
|
||||
// or http response
|
||||
} else if (value.hasOwnProperty('httpVersion')) {
|
||||
callback(null, +value.headers['content-length']);
|
||||
|
||||
// or request stream http://github.com/mikeal/request
|
||||
} else if (value.hasOwnProperty('httpModule')) {
|
||||
// wait till response come back
|
||||
value.on('response', function(response) {
|
||||
value.pause();
|
||||
callback(null, +response.headers['content-length']);
|
||||
});
|
||||
value.resume();
|
||||
|
||||
// something else
|
||||
} else {
|
||||
callback('Unknown stream');
|
||||
}
|
||||
};
|
||||
|
||||
FormData.prototype._multiPartHeader = function(field, value, options) {
|
||||
// custom header specified (as string)?
|
||||
// it becomes responsible for boundary
|
||||
// (e.g. to handle extra CRLFs on .NET servers)
|
||||
if (typeof options.header == 'string') {
|
||||
return options.header;
|
||||
}
|
||||
|
||||
var contentDisposition = this._getContentDisposition(value, options);
|
||||
var contentType = this._getContentType(value, options);
|
||||
|
||||
var contents = '';
|
||||
var headers = {
|
||||
// add custom disposition as third element or keep it two elements if not
|
||||
'Content-Disposition': ['form-data', 'name="' + field + '"'].concat(contentDisposition || []),
|
||||
// if no content type. allow it to be empty array
|
||||
'Content-Type': [].concat(contentType || [])
|
||||
};
|
||||
|
||||
// allow custom headers.
|
||||
if (typeof options.header == 'object') {
|
||||
populate(headers, options.header);
|
||||
}
|
||||
|
||||
var header;
|
||||
for (var prop in headers) {
|
||||
if (!headers.hasOwnProperty(prop)) continue;
|
||||
header = headers[prop];
|
||||
|
||||
// skip nullish headers.
|
||||
if (header == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// convert all headers to arrays.
|
||||
if (!Array.isArray(header)) {
|
||||
header = [header];
|
||||
}
|
||||
|
||||
// add non-empty headers.
|
||||
if (header.length) {
|
||||
contents += prop + ': ' + header.join('; ') + FormData.LINE_BREAK;
|
||||
}
|
||||
}
|
||||
|
||||
return '--' + this.getBoundary() + FormData.LINE_BREAK + contents + FormData.LINE_BREAK;
|
||||
};
|
||||
|
||||
FormData.prototype._getContentDisposition = function(value, options) {
|
||||
|
||||
var filename
|
||||
, contentDisposition
|
||||
;
|
||||
|
||||
if (typeof options.filepath === 'string') {
|
||||
// custom filepath for relative paths
|
||||
filename = path.normalize(options.filepath).replace(/\\/g, '/');
|
||||
} else if (options.filename || value.name || value.path) {
|
||||
// custom filename take precedence
|
||||
// formidable and the browser add a name property
|
||||
// fs- and request- streams have path property
|
||||
filename = path.basename(options.filename || value.name || value.path);
|
||||
} else if (value.readable && value.hasOwnProperty('httpVersion')) {
|
||||
// or try http response
|
||||
filename = path.basename(value.client._httpMessage.path || '');
|
||||
}
|
||||
|
||||
if (filename) {
|
||||
contentDisposition = 'filename="' + filename + '"';
|
||||
}
|
||||
|
||||
return contentDisposition;
|
||||
};
|
||||
|
||||
FormData.prototype._getContentType = function(value, options) {
|
||||
|
||||
// use custom content-type above all
|
||||
var contentType = options.contentType;
|
||||
|
||||
// or try `name` from formidable, browser
|
||||
if (!contentType && value.name) {
|
||||
contentType = mime.lookup(value.name);
|
||||
}
|
||||
|
||||
// or try `path` from fs-, request- streams
|
||||
if (!contentType && value.path) {
|
||||
contentType = mime.lookup(value.path);
|
||||
}
|
||||
|
||||
// or if it's http-reponse
|
||||
if (!contentType && value.readable && value.hasOwnProperty('httpVersion')) {
|
||||
contentType = value.headers['content-type'];
|
||||
}
|
||||
|
||||
// or guess it from the filepath or filename
|
||||
if (!contentType && (options.filepath || options.filename)) {
|
||||
contentType = mime.lookup(options.filepath || options.filename);
|
||||
}
|
||||
|
||||
// fallback to the default content type if `value` is not simple value
|
||||
if (!contentType && typeof value == 'object') {
|
||||
contentType = FormData.DEFAULT_CONTENT_TYPE;
|
||||
}
|
||||
|
||||
return contentType;
|
||||
};
|
||||
|
||||
FormData.prototype._multiPartFooter = function() {
|
||||
return function(next) {
|
||||
var footer = FormData.LINE_BREAK;
|
||||
|
||||
var lastPart = (this._streams.length === 0);
|
||||
if (lastPart) {
|
||||
footer += this._lastBoundary();
|
||||
}
|
||||
|
||||
next(footer);
|
||||
}.bind(this);
|
||||
};
|
||||
|
||||
FormData.prototype._lastBoundary = function() {
|
||||
return '--' + this.getBoundary() + '--' + FormData.LINE_BREAK;
|
||||
};
|
||||
|
||||
FormData.prototype.getHeaders = function(userHeaders) {
|
||||
var header;
|
||||
var formHeaders = {
|
||||
'content-type': 'multipart/form-data; boundary=' + this.getBoundary()
|
||||
};
|
||||
|
||||
for (header in userHeaders) {
|
||||
if (userHeaders.hasOwnProperty(header)) {
|
||||
formHeaders[header.toLowerCase()] = userHeaders[header];
|
||||
}
|
||||
}
|
||||
|
||||
return formHeaders;
|
||||
};
|
||||
|
||||
FormData.prototype.getBoundary = function() {
|
||||
if (!this._boundary) {
|
||||
this._generateBoundary();
|
||||
}
|
||||
|
||||
return this._boundary;
|
||||
};
|
||||
|
||||
FormData.prototype.getBuffer = function() {
|
||||
var dataBuffer = new Buffer.alloc( 0 );
|
||||
var boundary = this.getBoundary();
|
||||
|
||||
// Create the form content. Add Line breaks to the end of data.
|
||||
for (var i = 0, len = this._streams.length; i < len; i++) {
|
||||
if (typeof this._streams[i] !== 'function') {
|
||||
|
||||
// Add content to the buffer.
|
||||
if(Buffer.isBuffer(this._streams[i])) {
|
||||
dataBuffer = Buffer.concat( [dataBuffer, this._streams[i]]);
|
||||
}else {
|
||||
dataBuffer = Buffer.concat( [dataBuffer, Buffer.from(this._streams[i])]);
|
||||
}
|
||||
|
||||
// Add break after content.
|
||||
if (typeof this._streams[i] !== 'string' || this._streams[i].substring( 2, boundary.length + 2 ) !== boundary) {
|
||||
dataBuffer = Buffer.concat( [dataBuffer, Buffer.from(FormData.LINE_BREAK)] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add the footer and return the Buffer object.
|
||||
return Buffer.concat( [dataBuffer, Buffer.from(this._lastBoundary())] );
|
||||
};
|
||||
|
||||
FormData.prototype._generateBoundary = function() {
|
||||
// This generates a 50 character boundary similar to those used by Firefox.
|
||||
// They are optimized for boyer-moore parsing.
|
||||
var boundary = '--------------------------';
|
||||
for (var i = 0; i < 24; i++) {
|
||||
boundary += Math.floor(Math.random() * 10).toString(16);
|
||||
}
|
||||
|
||||
this._boundary = boundary;
|
||||
};
|
||||
|
||||
// Note: getLengthSync DOESN'T calculate streams length
|
||||
// As workaround one can calculate file size manually
|
||||
// and add it as knownLength option
|
||||
FormData.prototype.getLengthSync = function() {
|
||||
var knownLength = this._overheadLength + this._valueLength;
|
||||
|
||||
// Don't get confused, there are 3 "internal" streams for each keyval pair
|
||||
// so it basically checks if there is any value added to the form
|
||||
if (this._streams.length) {
|
||||
knownLength += this._lastBoundary().length;
|
||||
}
|
||||
|
||||
// https://github.com/form-data/form-data/issues/40
|
||||
if (!this.hasKnownLength()) {
|
||||
// Some async length retrievers are present
|
||||
// therefore synchronous length calculation is false.
|
||||
// Please use getLength(callback) to get proper length
|
||||
this._error(new Error('Cannot calculate proper length in synchronous way.'));
|
||||
}
|
||||
|
||||
return knownLength;
|
||||
};
|
||||
|
||||
// Public API to check if length of added values is known
|
||||
// https://github.com/form-data/form-data/issues/196
|
||||
// https://github.com/form-data/form-data/issues/262
|
||||
FormData.prototype.hasKnownLength = function() {
|
||||
var hasKnownLength = true;
|
||||
|
||||
if (this._valuesToMeasure.length) {
|
||||
hasKnownLength = false;
|
||||
}
|
||||
|
||||
return hasKnownLength;
|
||||
};
|
||||
|
||||
FormData.prototype.getLength = function(cb) {
|
||||
var knownLength = this._overheadLength + this._valueLength;
|
||||
|
||||
if (this._streams.length) {
|
||||
knownLength += this._lastBoundary().length;
|
||||
}
|
||||
|
||||
if (!this._valuesToMeasure.length) {
|
||||
process.nextTick(cb.bind(this, null, knownLength));
|
||||
return;
|
||||
}
|
||||
|
||||
asynckit.parallel(this._valuesToMeasure, this._lengthRetriever, function(err, values) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
|
||||
values.forEach(function(length) {
|
||||
knownLength += length;
|
||||
});
|
||||
|
||||
cb(null, knownLength);
|
||||
});
|
||||
};
|
||||
|
||||
FormData.prototype.submit = function(params, cb) {
|
||||
var request
|
||||
, options
|
||||
, defaults = {method: 'post'}
|
||||
;
|
||||
|
||||
// parse provided url if it's string
|
||||
// or treat it as options object
|
||||
if (typeof params == 'string') {
|
||||
|
||||
params = parseUrl(params);
|
||||
options = populate({
|
||||
port: params.port,
|
||||
path: params.pathname,
|
||||
host: params.hostname,
|
||||
protocol: params.protocol
|
||||
}, defaults);
|
||||
|
||||
// use custom params
|
||||
} else {
|
||||
|
||||
options = populate(params, defaults);
|
||||
// if no port provided use default one
|
||||
if (!options.port) {
|
||||
options.port = options.protocol == 'https:' ? 443 : 80;
|
||||
}
|
||||
}
|
||||
|
||||
// put that good code in getHeaders to some use
|
||||
options.headers = this.getHeaders(params.headers);
|
||||
|
||||
// https if specified, fallback to http in any other case
|
||||
if (options.protocol == 'https:') {
|
||||
request = https.request(options);
|
||||
} else {
|
||||
request = http.request(options);
|
||||
}
|
||||
|
||||
// get content length and fire away
|
||||
this.getLength(function(err, length) {
|
||||
if (err && err !== 'Unknown stream') {
|
||||
this._error(err);
|
||||
return;
|
||||
}
|
||||
|
||||
// add content length
|
||||
if (length) {
|
||||
request.setHeader('Content-Length', length);
|
||||
}
|
||||
|
||||
this.pipe(request);
|
||||
if (cb) {
|
||||
var onResponse;
|
||||
|
||||
var callback = function (error, responce) {
|
||||
request.removeListener('error', callback);
|
||||
request.removeListener('response', onResponse);
|
||||
|
||||
return cb.call(this, error, responce);
|
||||
};
|
||||
|
||||
onResponse = callback.bind(this, null);
|
||||
|
||||
request.on('error', callback);
|
||||
request.on('response', onResponse);
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
return request;
|
||||
};
|
||||
|
||||
FormData.prototype._error = function(err) {
|
||||
if (!this.error) {
|
||||
this.error = err;
|
||||
this.pause();
|
||||
this.emit('error', err);
|
||||
}
|
||||
};
|
||||
|
||||
FormData.prototype.toString = function () {
|
||||
return '[object FormData]';
|
||||
};
|
10
node_modules/@discordjs/form-data/lib/populate.js
generated
vendored
Normal file
10
node_modules/@discordjs/form-data/lib/populate.js
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
// populates missing values
|
||||
module.exports = function(dst, src) {
|
||||
|
||||
Object.keys(src).forEach(function(prop)
|
||||
{
|
||||
dst[prop] = dst[prop] || src[prop];
|
||||
});
|
||||
|
||||
return dst;
|
||||
};
|
68
node_modules/@discordjs/form-data/package.json
generated
vendored
Normal file
68
node_modules/@discordjs/form-data/package.json
generated
vendored
Normal file
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
"author": "Felix Geisendörfer <felix@debuggable.com> (http://debuggable.com/)",
|
||||
"name": "@discordjs/form-data",
|
||||
"description": "A library to create readable \"multipart/form-data\" streams. Can be used to submit forms and file uploads to other web applications.",
|
||||
"version": "3.0.1",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/form-data/form-data.git"
|
||||
},
|
||||
"main": "./lib/form_data",
|
||||
"browser": "./lib/browser",
|
||||
"typings": "./index.d.ts",
|
||||
"scripts": {
|
||||
"pretest": "rimraf coverage test/tmp",
|
||||
"test": "istanbul cover test/run.js",
|
||||
"posttest": "istanbul report lcov text",
|
||||
"lint": "eslint lib/*.js test/*.js test/integration/*.js",
|
||||
"report": "istanbul report lcov text",
|
||||
"ci-lint": "is-node-modern 8 && npm run lint || is-node-not-modern 8",
|
||||
"ci-test": "npm run test && npm run browser && npm run report",
|
||||
"predebug": "rimraf coverage test/tmp",
|
||||
"debug": "verbose=1 ./test/run.js",
|
||||
"browser": "browserify -t browserify-istanbul test/run-browser.js | obake --coverage",
|
||||
"check": "istanbul check-coverage coverage/coverage*.json",
|
||||
"files": "pkgfiles --sort=name",
|
||||
"get-version": "node -e \"console.log(require('./package.json').version)\""
|
||||
},
|
||||
"pre-commit": [
|
||||
"lint",
|
||||
"ci-test",
|
||||
"check"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
},
|
||||
"dependencies": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
"mime-types": "^2.1.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^12.0.10",
|
||||
"browserify": "^13.1.1",
|
||||
"browserify-istanbul": "^2.0.0",
|
||||
"coveralls": "^3.0.4",
|
||||
"cross-spawn": "^6.0.5",
|
||||
"eslint": "^6.0.1",
|
||||
"fake": "^0.2.2",
|
||||
"far": "^0.0.7",
|
||||
"formidable": "^1.0.17",
|
||||
"in-publish": "^2.0.0",
|
||||
"is-node-modern": "^1.0.0",
|
||||
"istanbul": "^0.4.5",
|
||||
"obake": "^0.1.2",
|
||||
"puppeteer": "^1.19.0",
|
||||
"pkgfiles": "^2.3.0",
|
||||
"pre-commit": "^1.1.3",
|
||||
"request": "^2.88.0",
|
||||
"rimraf": "^2.7.1",
|
||||
"tape": "^4.6.2",
|
||||
"typescript": "^3.5.2"
|
||||
},
|
||||
"license": "MIT"
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/@discordjs/form-data/-/form-data-3.0.1.tgz"
|
||||
,"_integrity": "sha512-ZfFsbgEXW71Rw/6EtBdrP5VxBJy4dthyC0tpQKGKmYFImlmmrykO14Za+BiIVduwjte0jXEBlhSKf0MWbFp9Eg=="
|
||||
,"_from": "@discordjs/form-data@3.0.1"
|
||||
}
|
190
node_modules/@discordjs/rest/LICENSE
generated
vendored
Normal file
190
node_modules/@discordjs/rest/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,190 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Copyright 2015 - 2021 Amish Shah
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
3
node_modules/@discordjs/rest/README.md
generated
vendored
Normal file
3
node_modules/@discordjs/rest/README.md
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
# `@discordjs/rest`
|
||||
|
||||
> The REST API module for Discord.js
|
7
node_modules/@discordjs/rest/dist/index.d.ts
generated
vendored
Normal file
7
node_modules/@discordjs/rest/dist/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
export * from './lib/CDN';
|
||||
export * from './lib/errors/DiscordAPIError';
|
||||
export * from './lib/errors/HTTPError';
|
||||
export * from './lib/RequestManager';
|
||||
export * from './lib/REST';
|
||||
export * from './lib/utils/constants';
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
node_modules/@discordjs/rest/dist/index.d.ts.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/index.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +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
node_modules/@discordjs/rest/dist/index.js
generated
vendored
Normal file
10
node_modules/@discordjs/rest/dist/index.js
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tslib_1 = require("tslib");
|
||||
tslib_1.__exportStar(require("./lib/CDN"), exports);
|
||||
tslib_1.__exportStar(require("./lib/errors/DiscordAPIError"), exports);
|
||||
tslib_1.__exportStar(require("./lib/errors/HTTPError"), exports);
|
||||
tslib_1.__exportStar(require("./lib/RequestManager"), exports);
|
||||
tslib_1.__exportStar(require("./lib/REST"), exports);
|
||||
tslib_1.__exportStar(require("./lib/utils/constants"), exports);
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@discordjs/rest/dist/index.js.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/index.js.map
generated
vendored
Normal file
|
@ -0,0 +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
node_modules/@discordjs/rest/dist/lib/CDN.d.ts
generated
vendored
Normal file
94
node_modules/@discordjs/rest/dist/lib/CDN.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,94 @@
|
|||
import { ImageExtension, ImageSize } from './utils/constants';
|
||||
export interface ImageURLOptions {
|
||||
extension?: ImageExtension;
|
||||
size?: ImageSize;
|
||||
dynamic?: boolean;
|
||||
}
|
||||
/**
|
||||
* The CDN link builder
|
||||
*/
|
||||
export declare class CDN {
|
||||
private readonly base;
|
||||
constructor(base?: string);
|
||||
/**
|
||||
* Generates an app asset URL for a client's asset.
|
||||
* @param clientID The client ID that has the asset
|
||||
* @param assetHash The hash provided by Discord for this asset
|
||||
* @param options Optional options for the asset
|
||||
*/
|
||||
appAsset(clientID: string, assetHash: string, options?: ImageURLOptions): string;
|
||||
/**
|
||||
* Generates an app icon URL for a client's icon.
|
||||
* @param clientID The client ID that has the icon
|
||||
* @param iconHash The hash provided by Discord for this icon
|
||||
* @param options Optional options for the icon
|
||||
*/
|
||||
appIcon(clientID: string, iconHash: string, options?: ImageURLOptions): string;
|
||||
/**
|
||||
* Generates the default avatar URL for a discriminator.
|
||||
* @param discriminator The discriminator modulo 5
|
||||
*/
|
||||
defaultAvatar(discriminator: number): string;
|
||||
/**
|
||||
* Generates a discovery splash URL for a guild's discovery splash.
|
||||
* @param guildID The guild ID that has the discovery splash
|
||||
* @param splashHash The hash provided by Discord for this splash
|
||||
* @param options Optional options for the splash
|
||||
*/
|
||||
discoverySplash(guildID: string, splashHash: string, options?: ImageURLOptions): string;
|
||||
/**
|
||||
* Generates an emoji's URL for an emoji.
|
||||
* @param emojiID The emoji ID
|
||||
* @param extension The extension of the emoji
|
||||
*/
|
||||
emoji(emojiID: string, extension?: ImageExtension): string;
|
||||
/**
|
||||
* Generates a group DM icon URL for a group DM.
|
||||
* @param channelID The group channel ID that has the icon
|
||||
* @param iconHash The hash provided by Discord for this group DM channel
|
||||
* @param options Optional options for the icon
|
||||
*/
|
||||
groupDMIcon(channelID: string, iconHash: string, options?: ImageURLOptions): string;
|
||||
/**
|
||||
* Generates a banner URL for a guild's banner.
|
||||
* @param guildID The guild ID that has the banner splash
|
||||
* @param bannerHash The hash provided by Discord for this banner
|
||||
* @param options Optional options for the banner
|
||||
*/
|
||||
guildBanner(guildID: string, bannerHash: string, options?: ImageURLOptions): string;
|
||||
/**
|
||||
* Generates an icon URL for a guild's icon.
|
||||
* @param guildID The guild ID that has the icon splash
|
||||
* @param iconHash The hash provided by Discord for this icon
|
||||
* @param options Optional options for the icon
|
||||
*/
|
||||
guildIcon(guildID: string, iconHash: string, options?: ImageURLOptions): string;
|
||||
/**
|
||||
* Generates a guild invite splash URL for a guild's invite splash.
|
||||
* @param guildID The guild ID that has the invite splash
|
||||
* @param splashHash The hash provided by Discord for this splash
|
||||
* @param options Optional options for the splash
|
||||
*/
|
||||
splash(guildID: string, splashHash: string, options?: ImageURLOptions): string;
|
||||
/**
|
||||
* Generates a team icon URL for a team's icon.
|
||||
* @param teamID The team ID that has the icon
|
||||
* @param iconHash The hash provided by Discord for this icon
|
||||
* @param options Optional options for the icon
|
||||
*/
|
||||
teamIcon(teamID: string, iconHash: string, options?: ImageURLOptions): string;
|
||||
/**
|
||||
* Generates a user avatar URL for a user's avatar.
|
||||
* @param userID The user ID that has the icon
|
||||
* @param avatarHash The hash provided by Discord for this avatar
|
||||
* @param options Optional options for the avatar
|
||||
*/
|
||||
userAvatar(userID: string, avatarHash: string, { dynamic, ...options }?: ImageURLOptions): string;
|
||||
/**
|
||||
* Constructs the URL for the resource
|
||||
* @param base The base cdn route
|
||||
* @param options The extension/size options for the link
|
||||
*/
|
||||
private makeURL;
|
||||
}
|
||||
//# sourceMappingURL=CDN.d.ts.map
|
1
node_modules/@discordjs/rest/dist/lib/CDN.d.ts.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/lib/CDN.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +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
node_modules/@discordjs/rest/dist/lib/CDN.js
generated
vendored
Normal file
132
node_modules/@discordjs/rest/dist/lib/CDN.js
generated
vendored
Normal file
|
@ -0,0 +1,132 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CDN = void 0;
|
||||
const constants_1 = require("./utils/constants");
|
||||
/**
|
||||
* The CDN link builder
|
||||
*/
|
||||
class CDN {
|
||||
constructor(base = constants_1.DefaultRestOptions.cdn) {
|
||||
this.base = base;
|
||||
}
|
||||
/**
|
||||
* Generates an app asset URL for a client's asset.
|
||||
* @param clientID The client ID that has the asset
|
||||
* @param assetHash The hash provided by Discord for this asset
|
||||
* @param options Optional options for the asset
|
||||
*/
|
||||
appAsset(clientID, assetHash, options) {
|
||||
return this.makeURL(`/app-assets/${clientID}/${assetHash}`, options);
|
||||
}
|
||||
/**
|
||||
* Generates an app icon URL for a client's icon.
|
||||
* @param clientID The client ID that has the icon
|
||||
* @param iconHash The hash provided by Discord for this icon
|
||||
* @param options Optional options for the icon
|
||||
*/
|
||||
appIcon(clientID, iconHash, options) {
|
||||
return this.makeURL(`/app-icons/${clientID}/${iconHash}`, options);
|
||||
}
|
||||
/**
|
||||
* Generates the default avatar URL for a discriminator.
|
||||
* @param discriminator The discriminator modulo 5
|
||||
*/
|
||||
defaultAvatar(discriminator) {
|
||||
return this.makeURL(`/embed/avatars/${discriminator}`);
|
||||
}
|
||||
/**
|
||||
* Generates a discovery splash URL for a guild's discovery splash.
|
||||
* @param guildID The guild ID that has the discovery splash
|
||||
* @param splashHash The hash provided by Discord for this splash
|
||||
* @param options Optional options for the splash
|
||||
*/
|
||||
discoverySplash(guildID, splashHash, options) {
|
||||
return this.makeURL(`/discovery-splashes/${guildID}/${splashHash}`, options);
|
||||
}
|
||||
/**
|
||||
* Generates an emoji's URL for an emoji.
|
||||
* @param emojiID The emoji ID
|
||||
* @param extension The extension of the emoji
|
||||
*/
|
||||
emoji(emojiID, extension) {
|
||||
return this.makeURL(`/emojis/${emojiID}`, { extension });
|
||||
}
|
||||
/**
|
||||
* Generates a group DM icon URL for a group DM.
|
||||
* @param channelID The group channel ID that has the icon
|
||||
* @param iconHash The hash provided by Discord for this group DM channel
|
||||
* @param options Optional options for the icon
|
||||
*/
|
||||
groupDMIcon(channelID, iconHash, options) {
|
||||
return this.makeURL(`/channel-icons/${channelID}/${iconHash}`, options);
|
||||
}
|
||||
/**
|
||||
* Generates a banner URL for a guild's banner.
|
||||
* @param guildID The guild ID that has the banner splash
|
||||
* @param bannerHash The hash provided by Discord for this banner
|
||||
* @param options Optional options for the banner
|
||||
*/
|
||||
guildBanner(guildID, bannerHash, options) {
|
||||
return this.makeURL(`/banners/${guildID}/${bannerHash}`, options);
|
||||
}
|
||||
/**
|
||||
* Generates an icon URL for a guild's icon.
|
||||
* @param guildID The guild ID that has the icon splash
|
||||
* @param iconHash The hash provided by Discord for this icon
|
||||
* @param options Optional options for the icon
|
||||
*/
|
||||
guildIcon(guildID, iconHash, options) {
|
||||
return this.makeURL(`/icons/${guildID}/${iconHash}`, options);
|
||||
}
|
||||
/**
|
||||
* Generates a guild invite splash URL for a guild's invite splash.
|
||||
* @param guildID The guild ID that has the invite splash
|
||||
* @param splashHash The hash provided by Discord for this splash
|
||||
* @param options Optional options for the splash
|
||||
*/
|
||||
splash(guildID, splashHash, options) {
|
||||
return this.makeURL(`/splashes/${guildID}/${splashHash}`, options);
|
||||
}
|
||||
/**
|
||||
* Generates a team icon URL for a team's icon.
|
||||
* @param teamID The team ID that has the icon
|
||||
* @param iconHash The hash provided by Discord for this icon
|
||||
* @param options Optional options for the icon
|
||||
*/
|
||||
teamIcon(teamID, iconHash, options) {
|
||||
return this.makeURL(`/team-icons/${teamID}/${iconHash}`, options);
|
||||
}
|
||||
/**
|
||||
* Generates a user avatar URL for a user's avatar.
|
||||
* @param userID The user ID that has the icon
|
||||
* @param avatarHash The hash provided by Discord for this avatar
|
||||
* @param options Optional options for the avatar
|
||||
*/
|
||||
userAvatar(userID, avatarHash, { dynamic = false, ...options } = {}) {
|
||||
if (dynamic && avatarHash.startsWith('a_')) {
|
||||
options.extension = 'gif';
|
||||
}
|
||||
return this.makeURL(`/avatars/${userID}/${avatarHash}`, options);
|
||||
}
|
||||
/**
|
||||
* Constructs the URL for the resource
|
||||
* @param base The base cdn route
|
||||
* @param options The extension/size options for the link
|
||||
*/
|
||||
makeURL(base, { extension = 'png', size } = {}) {
|
||||
extension = String(extension).toLowerCase();
|
||||
if (!constants_1.ALLOWED_EXTENSIONS.includes(extension)) {
|
||||
throw new RangeError(`Invalid extension provided: ${extension}\nMust be one of: ${constants_1.ALLOWED_EXTENSIONS.join(', ')}`);
|
||||
}
|
||||
if (size && !constants_1.ALLOWED_SIZES.includes(size)) {
|
||||
throw new RangeError(`Invalid size provided: ${size}\nMust be one of: ${constants_1.ALLOWED_SIZES.join(', ')}`);
|
||||
}
|
||||
const url = new URL(`${this.base}${base}.${extension}`);
|
||||
if (size) {
|
||||
url.searchParams.set('size', String(size));
|
||||
}
|
||||
return url.toString();
|
||||
}
|
||||
}
|
||||
exports.CDN = CDN;
|
||||
//# sourceMappingURL=CDN.js.map
|
1
node_modules/@discordjs/rest/dist/lib/CDN.js.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/lib/CDN.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"CDN.js","sourceRoot":"./","sources":["lib/CDN.ts"],"names":[],"mappings":"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"}
|
140
node_modules/@discordjs/rest/dist/lib/REST.d.ts
generated
vendored
Normal file
140
node_modules/@discordjs/rest/dist/lib/REST.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,140 @@
|
|||
/// <reference types="node" />
|
||||
import { EventEmitter } from 'events';
|
||||
import { CDN } from './CDN';
|
||||
import { InternalRequest, RequestData, RequestManager, RouteLike } from './RequestManager';
|
||||
/**
|
||||
* Options to be passed when creating the REST instance
|
||||
*/
|
||||
export interface RESTOptions {
|
||||
/**
|
||||
* The base api path, without version
|
||||
* @default 'https://discord.com/api'
|
||||
*/
|
||||
api: string;
|
||||
/**
|
||||
* The cdn path
|
||||
* @default 'https://cdn.discordapp.com'
|
||||
*/
|
||||
cdn: string;
|
||||
/**
|
||||
* The extra offset to add to rate limits in milliseconds
|
||||
* @default 50
|
||||
*/
|
||||
offset: number;
|
||||
/**
|
||||
* The number of retries for errors with the 500 code, or errors
|
||||
* that timeout
|
||||
* @default 3
|
||||
*/
|
||||
retries: number;
|
||||
/**
|
||||
* The time to wait in milliseconds before a request is aborted
|
||||
* @default 15_000
|
||||
*/
|
||||
timeout: number;
|
||||
/**
|
||||
* Extra information to add to the user agent
|
||||
* @default `Node.js ${process.version}`
|
||||
*/
|
||||
userAgentAppendix: string;
|
||||
/**
|
||||
* The version of the API to use
|
||||
* @default '8'
|
||||
*/
|
||||
version: string;
|
||||
}
|
||||
/**
|
||||
* Data emitted on `RESTEvents.Debug`
|
||||
*/
|
||||
export interface RatelimitData {
|
||||
/**
|
||||
* The time, in milliseconds, until the request-lock is reset
|
||||
*/
|
||||
timeToReset: number;
|
||||
/**
|
||||
* The amount of requests we can perform before locking requests
|
||||
*/
|
||||
limit: number;
|
||||
/**
|
||||
* The HTTP method being performed
|
||||
*/
|
||||
method: string;
|
||||
/**
|
||||
* The bucket hash for this request
|
||||
*/
|
||||
hash: string;
|
||||
/**
|
||||
* The route being hit in this request
|
||||
*/
|
||||
route: string;
|
||||
/**
|
||||
* The major parameter of the route
|
||||
*
|
||||
* For example, in `/channels/x`, this will be `x`.
|
||||
* If there is no major parameter (e.g: `/bot/gateway`) this will be `global`.
|
||||
*/
|
||||
majorParameter: string;
|
||||
}
|
||||
interface RestEvents {
|
||||
restDebug: [info: string];
|
||||
rateLimited: [rateLimitInfo: RatelimitData];
|
||||
}
|
||||
export interface REST {
|
||||
on<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void): this;
|
||||
on<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void): this;
|
||||
once<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void): this;
|
||||
once<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void): this;
|
||||
emit<K extends keyof RestEvents>(event: K, ...args: RestEvents[K]): boolean;
|
||||
emit<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, ...args: any[]): boolean;
|
||||
off<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void): this;
|
||||
off<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void): this;
|
||||
removeAllListeners<K extends keyof RestEvents>(event?: K): this;
|
||||
removeAllListeners<S extends string | symbol>(event?: Exclude<S, keyof RestEvents>): this;
|
||||
}
|
||||
export declare class REST extends EventEmitter {
|
||||
readonly cdn: CDN;
|
||||
readonly requestManager: RequestManager;
|
||||
constructor(options?: Partial<RESTOptions>);
|
||||
/**
|
||||
* Sets the authorization token that should be used for requests
|
||||
* @param token The authorization token to use
|
||||
*/
|
||||
setToken(token: string): this;
|
||||
/**
|
||||
* Runs a get request from the api
|
||||
* @param fullRoute The full route to query
|
||||
* @param options Optional request options
|
||||
*/
|
||||
get(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||
/**
|
||||
* Runs a delete request from the api
|
||||
* @param fullRoute The full route to query
|
||||
* @param options Optional request options
|
||||
*/
|
||||
delete(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||
/**
|
||||
* Runs a post request from the api
|
||||
* @param fullRoute The full route to query
|
||||
* @param options Optional request options
|
||||
*/
|
||||
post(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||
/**
|
||||
* Runs a put request from the api
|
||||
* @param fullRoute The full route to query
|
||||
* @param options Optional request options
|
||||
*/
|
||||
put(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||
/**
|
||||
* Runs a patch request from the api
|
||||
* @param fullRoute The full route to query
|
||||
* @param options Optional request options
|
||||
*/
|
||||
patch(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
||||
/**
|
||||
* Runs a request from the api
|
||||
* @param options Request options
|
||||
*/
|
||||
request(options: InternalRequest): Promise<unknown>;
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=REST.d.ts.map
|
1
node_modules/@discordjs/rest/dist/lib/REST.d.ts.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/lib/REST.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +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,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,cAAc,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,UAAU;IACnB,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC1B,WAAW,EAAE,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,IAAI;IACpB,EAAE,CAAC,CAAC,SAAS,MAAM,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI,CAAC;IAC3F,EAAE,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;IAE7G,IAAI,CAAC,CAAC,SAAS,MAAM,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI,CAAC;IAC7F,IAAI,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;IAE/G,IAAI,CAAC,CAAC,SAAS,MAAM,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;IAC5E,IAAI,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,UAAU,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IAE9F,GAAG,CAAC,CAAC,SAAS,MAAM,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI,CAAC;IAC5F,GAAG,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;IAE9G,kBAAkB,CAAC,CAAC,SAAS,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;IAChE,kBAAkB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,UAAU,CAAC,GAAG,IAAI,CAAC;CAC1F;AAED,qBAAa,IAAK,SAAQ,YAAY;IACrC,SAAgB,GAAG,EAAE,GAAG,CAAC;IACzB,SAAgB,cAAc,EAAE,cAAc,CAAC;gBAE5B,OAAO,GAAE,OAAO,CAAC,WAAW,CAAM;IAQrD;;;OAGG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM;IAK7B;;;;OAIG;IACI,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,GAAE,WAAgB;IAI1D;;;;OAIG;IACI,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,GAAE,WAAgB;IAI7D;;;;OAIG;IACI,IAAI,CAAC,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
node_modules/@discordjs/rest/dist/lib/REST.js
generated
vendored
Normal file
73
node_modules/@discordjs/rest/dist/lib/REST.js
generated
vendored
Normal file
|
@ -0,0 +1,73 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.REST = void 0;
|
||||
const events_1 = require("events");
|
||||
const CDN_1 = require("./CDN");
|
||||
const RequestManager_1 = require("./RequestManager");
|
||||
const constants_1 = require("./utils/constants");
|
||||
class REST extends events_1.EventEmitter {
|
||||
constructor(options = {}) {
|
||||
super();
|
||||
this.cdn = new CDN_1.CDN(options.cdn ?? constants_1.DefaultRestOptions.cdn);
|
||||
this.requestManager = new RequestManager_1.RequestManager(options)
|
||||
.on("restDebug" /* Debug */, this.emit.bind(this, "restDebug" /* Debug */))
|
||||
.on("rateLimited" /* RateLimited */, this.emit.bind(this, "rateLimited" /* RateLimited */));
|
||||
}
|
||||
/**
|
||||
* Sets the authorization token that should be used for requests
|
||||
* @param token The authorization token to use
|
||||
*/
|
||||
setToken(token) {
|
||||
this.requestManager.setToken(token);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Runs a get request from the api
|
||||
* @param fullRoute The full route to query
|
||||
* @param options Optional request options
|
||||
*/
|
||||
get(fullRoute, options = {}) {
|
||||
return this.request({ ...options, fullRoute, method: "get" /* Get */ });
|
||||
}
|
||||
/**
|
||||
* Runs a delete request from the api
|
||||
* @param fullRoute The full route to query
|
||||
* @param options Optional request options
|
||||
*/
|
||||
delete(fullRoute, options = {}) {
|
||||
return this.request({ ...options, fullRoute, method: "delete" /* Delete */ });
|
||||
}
|
||||
/**
|
||||
* Runs a post request from the api
|
||||
* @param fullRoute The full route to query
|
||||
* @param options Optional request options
|
||||
*/
|
||||
post(fullRoute, options = {}) {
|
||||
return this.request({ ...options, fullRoute, method: "post" /* Post */ });
|
||||
}
|
||||
/**
|
||||
* Runs a put request from the api
|
||||
* @param fullRoute The full route to query
|
||||
* @param options Optional request options
|
||||
*/
|
||||
put(fullRoute, options = {}) {
|
||||
return this.request({ ...options, fullRoute, method: "put" /* Put */ });
|
||||
}
|
||||
/**
|
||||
* Runs a patch request from the api
|
||||
* @param fullRoute The full route to query
|
||||
* @param options Optional request options
|
||||
*/
|
||||
patch(fullRoute, options = {}) {
|
||||
return this.request({ ...options, fullRoute, method: "patch" /* Patch */ });
|
||||
}
|
||||
/**
|
||||
* Runs a request from the api
|
||||
* @param options Request options
|
||||
*/
|
||||
request(options) {
|
||||
return this.requestManager.queueRequest(options);
|
||||
}
|
||||
}
|
||||
exports.REST = REST;
|
||||
//# sourceMappingURL=REST.js.map
|
1
node_modules/@discordjs/rest/dist/lib/REST.js.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/lib/REST.js.map
generated
vendored
Normal file
|
@ -0,0 +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
node_modules/@discordjs/rest/dist/lib/RequestManager.d.ts
generated
vendored
Normal file
142
node_modules/@discordjs/rest/dist/lib/RequestManager.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,142 @@
|
|||
/// <reference types="node" />
|
||||
import Collection from '@discordjs/collection';
|
||||
import { EventEmitter } from 'events';
|
||||
import type { IHandler } from './handlers/IHandler';
|
||||
import type { RESTOptions } from './REST';
|
||||
/**
|
||||
* Represents an attachment to be added to the request
|
||||
*/
|
||||
export interface RawAttachment {
|
||||
fileName: string;
|
||||
rawBuffer: Buffer;
|
||||
}
|
||||
/**
|
||||
* Represents possible data to be given to an endpoint
|
||||
*/
|
||||
export interface RequestData {
|
||||
/**
|
||||
* Files to be attached to this request
|
||||
*/
|
||||
attachments?: RawAttachment[];
|
||||
/**
|
||||
* If this request needs the `Authorization` header
|
||||
* @default true
|
||||
*/
|
||||
auth?: boolean;
|
||||
/**
|
||||
* The authorization prefix to use for this request, useful if you use this with bearer tokens
|
||||
* @default 'Bot'
|
||||
*/
|
||||
authPrefix?: 'Bot' | 'Bearer';
|
||||
/**
|
||||
* The body to send to this request
|
||||
*/
|
||||
body?: unknown;
|
||||
/**
|
||||
* Additional headers to add to this request
|
||||
*/
|
||||
headers?: Record<string, string>;
|
||||
/**
|
||||
* Query string parameters to append to the called endpoint
|
||||
*/
|
||||
query?: URLSearchParams;
|
||||
/**
|
||||
* Reason to show in the audit logs
|
||||
*/
|
||||
reason?: string;
|
||||
/**
|
||||
* If this request should be versioned
|
||||
* @default true
|
||||
*/
|
||||
versioned?: boolean;
|
||||
}
|
||||
/**
|
||||
* Possible headers for an API call
|
||||
*/
|
||||
export interface RequestHeaders {
|
||||
Authorization?: string;
|
||||
'User-Agent': string;
|
||||
'X-Audit-Log-Reason'?: string;
|
||||
}
|
||||
/**
|
||||
* Possible API methods to be used when doing requests
|
||||
*/
|
||||
export declare const enum RequestMethod {
|
||||
Delete = "delete",
|
||||
Get = "get",
|
||||
Patch = "patch",
|
||||
Post = "post",
|
||||
Put = "put"
|
||||
}
|
||||
export declare type RouteLike = `/${string}`;
|
||||
/**
|
||||
* Internal request options
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export interface InternalRequest extends RequestData {
|
||||
method: RequestMethod;
|
||||
fullRoute: RouteLike;
|
||||
}
|
||||
/**
|
||||
* Parsed route data for an endpoint
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export interface RouteData {
|
||||
majorParameter: string;
|
||||
bucketRoute: string;
|
||||
original: string;
|
||||
}
|
||||
/**
|
||||
* Represents the class that manages handlers for endpoints
|
||||
*/
|
||||
export declare class RequestManager extends EventEmitter {
|
||||
#private;
|
||||
/**
|
||||
* A timeout promise that is set when we hit the global rate limit
|
||||
* @default null
|
||||
*/
|
||||
globalTimeout: Promise<void> | null;
|
||||
/**
|
||||
* API bucket hashes that are cached from provided routes
|
||||
*/
|
||||
readonly hashes: Collection<string, string>;
|
||||
/**
|
||||
* Request handlers created from the bucket hash and the major parameters
|
||||
*/
|
||||
readonly handlers: Collection<string, IHandler>;
|
||||
readonly options: RESTOptions;
|
||||
constructor(options: Partial<RESTOptions>);
|
||||
/**
|
||||
* Sets the authorization token that should be used for requests
|
||||
* @param token The authorization token to use
|
||||
*/
|
||||
setToken(token: string): this;
|
||||
/**
|
||||
* Queues a request to be sent
|
||||
* @param request All the information needed to make a request
|
||||
* @returns The response from the api request
|
||||
*/
|
||||
queueRequest(request: InternalRequest): Promise<unknown>;
|
||||
/**
|
||||
* Creates a new rate limit handler from a hash, based on the hash and the major parameter
|
||||
* @param hash The hash for the route
|
||||
* @param majorParameter The major parameter for this handler
|
||||
* @private
|
||||
*/
|
||||
private createHandler;
|
||||
/**
|
||||
* Formats the request data to a usable format for fetch
|
||||
* @param request The request data
|
||||
*/
|
||||
private resolveRequest;
|
||||
/**
|
||||
* Generates route data for an endpoint:method
|
||||
* @param endpoint The raw endpoint to generalize
|
||||
* @param method The HTTP method this endpoint is called without
|
||||
* @private
|
||||
*/
|
||||
private static generateRouteData;
|
||||
}
|
||||
//# sourceMappingURL=RequestManager.d.ts.map
|
1
node_modules/@discordjs/rest/dist/lib/RequestManager.d.ts.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/lib/RequestManager.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +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,aAAa,EAAE,CAAC;IAC9B;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,UAAU,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IAC9B;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC;;OAEG;IACH,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,0BAAkB,aAAa;IAC9B,MAAM,WAAW;IACjB,GAAG,QAAQ;IACX,KAAK,UAAU;IACf,IAAI,SAAS;IACb,GAAG,QAAQ;CACX;AAED,oBAAY,SAAS,GAAG,IAAI,MAAM,EAAE,CAAC;AAErC;;;;GAIG;AACH,MAAM,WAAW,eAAgB,SAAQ,WAAW;IACnD,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,EAAE,SAAS,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,YAAY;;IAC/C;;;OAGG;IACI,aAAa,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAQ;IAElD;;OAEG;IACH,SAAgB,MAAM,6BAAoC;IAE1D;;OAEG;IACH,SAAgB,QAAQ,+BAAsC;IAK9D,SAAgB,OAAO,EAAE,WAAW,CAAC;gBAElB,OAAO,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
node_modules/@discordjs/rest/dist/lib/RequestManager.js
generated
vendored
Normal file
184
node_modules/@discordjs/rest/dist/lib/RequestManager.js
generated
vendored
Normal file
|
@ -0,0 +1,184 @@
|
|||
"use strict";
|
||||
var _RequestManager_token;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RequestManager = exports.RequestMethod = void 0;
|
||||
const tslib_1 = require("tslib");
|
||||
const collection_1 = tslib_1.__importDefault(require("@discordjs/collection"));
|
||||
const form_data_1 = tslib_1.__importDefault(require("form-data"));
|
||||
const snowflake_1 = require("@sapphire/snowflake");
|
||||
const events_1 = require("events");
|
||||
const https_1 = require("https");
|
||||
const SequentialHandler_1 = require("./handlers/SequentialHandler");
|
||||
const constants_1 = require("./utils/constants");
|
||||
const agent = new https_1.Agent({ keepAlive: true });
|
||||
/**
|
||||
* Possible API methods to be used when doing requests
|
||||
*/
|
||||
var RequestMethod;
|
||||
(function (RequestMethod) {
|
||||
RequestMethod["Delete"] = "delete";
|
||||
RequestMethod["Get"] = "get";
|
||||
RequestMethod["Patch"] = "patch";
|
||||
RequestMethod["Post"] = "post";
|
||||
RequestMethod["Put"] = "put";
|
||||
})(RequestMethod = exports.RequestMethod || (exports.RequestMethod = {}));
|
||||
/**
|
||||
* Represents the class that manages handlers for endpoints
|
||||
*/
|
||||
class RequestManager extends events_1.EventEmitter {
|
||||
constructor(options) {
|
||||
super();
|
||||
/**
|
||||
* A timeout promise that is set when we hit the global rate limit
|
||||
* @default null
|
||||
*/
|
||||
this.globalTimeout = null;
|
||||
/**
|
||||
* API bucket hashes that are cached from provided routes
|
||||
*/
|
||||
this.hashes = new collection_1.default();
|
||||
/**
|
||||
* Request handlers created from the bucket hash and the major parameters
|
||||
*/
|
||||
this.handlers = new collection_1.default();
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
|
||||
_RequestManager_token.set(this, null);
|
||||
this.options = { ...constants_1.DefaultRestOptions, ...options };
|
||||
this.options.offset = Math.max(0, this.options.offset);
|
||||
}
|
||||
/**
|
||||
* Sets the authorization token that should be used for requests
|
||||
* @param token The authorization token to use
|
||||
*/
|
||||
setToken(token) {
|
||||
tslib_1.__classPrivateFieldSet(this, _RequestManager_token, token, "f");
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Queues a request to be sent
|
||||
* @param request All the information needed to make a request
|
||||
* @returns The response from the api request
|
||||
*/
|
||||
async queueRequest(request) {
|
||||
// Generalize the endpoint to its route data
|
||||
const routeID = RequestManager.generateRouteData(request.fullRoute, request.method);
|
||||
// Get the bucket hash for the generic route, or point to a global route otherwise
|
||||
const hash = this.hashes.get(`${request.method}:${routeID.bucketRoute}`) ?? `Global(${request.method}:${routeID.bucketRoute})`;
|
||||
// Get the request handler for the obtained hash, with its major parameter
|
||||
const handler = this.handlers.get(`${hash}:${routeID.majorParameter}`) ?? this.createHandler(hash, routeID.majorParameter);
|
||||
// Resolve the request into usable fetch/node-fetch options
|
||||
const { url, fetchOptions } = this.resolveRequest(request);
|
||||
// Queue the request
|
||||
return handler.queueRequest(routeID, url, fetchOptions);
|
||||
}
|
||||
/**
|
||||
* Creates a new rate limit handler from a hash, based on the hash and the major parameter
|
||||
* @param hash The hash for the route
|
||||
* @param majorParameter The major parameter for this handler
|
||||
* @private
|
||||
*/
|
||||
createHandler(hash, majorParameter) {
|
||||
// Create the async request queue to handle requests
|
||||
const queue = new SequentialHandler_1.SequentialHandler(this, hash, majorParameter);
|
||||
// Save the queue based on its ID
|
||||
this.handlers.set(queue.id, queue);
|
||||
return queue;
|
||||
}
|
||||
/**
|
||||
* Formats the request data to a usable format for fetch
|
||||
* @param request The request data
|
||||
*/
|
||||
resolveRequest(request) {
|
||||
const { options } = this;
|
||||
let query = '';
|
||||
// If a query option is passed, use it
|
||||
if (request.query) {
|
||||
query = `?${request.query.toString()}`;
|
||||
}
|
||||
// Create the required headers
|
||||
const headers = {
|
||||
'User-Agent': `${constants_1.DefaultUserAgent} ${options.userAgentAppendix}`.trim(),
|
||||
};
|
||||
// If this request requires authorization (allowing non-"authorized" requests for webhooks)
|
||||
if (request.auth !== false) {
|
||||
// If we haven't received a token, throw an error
|
||||
if (!tslib_1.__classPrivateFieldGet(this, _RequestManager_token, "f")) {
|
||||
throw new Error('Expected token to be set for this request, but none was present');
|
||||
}
|
||||
headers.Authorization = `${request.authPrefix ?? 'Bot'} ${tslib_1.__classPrivateFieldGet(this, _RequestManager_token, "f")}`;
|
||||
}
|
||||
// If a reason was set, set it's appropriate header
|
||||
if (request.reason?.length) {
|
||||
headers['X-Audit-Log-Reason'] = encodeURIComponent(request.reason);
|
||||
}
|
||||
// Format the full request URL (api base, optional version, endpoint, optional querystring)
|
||||
const url = `${options.api}${request.versioned === false ? '' : `/v${options.version}`}${request.fullRoute}${query}`;
|
||||
let finalBody;
|
||||
let additionalHeaders = {};
|
||||
if (request.attachments?.length) {
|
||||
const formData = new form_data_1.default();
|
||||
// Attach all files to the request
|
||||
for (const attachment of request.attachments) {
|
||||
formData.append(attachment.fileName, attachment.rawBuffer, attachment.fileName);
|
||||
}
|
||||
// If a JSON body was added as well, attach it to the form data
|
||||
// eslint-disable-next-line no-eq-null
|
||||
if (request.body != null) {
|
||||
formData.append('payload_json', JSON.stringify(request.body));
|
||||
}
|
||||
// Set the final body to the form data
|
||||
finalBody = formData;
|
||||
// Set the additional headers to the form data ones
|
||||
additionalHeaders = formData.getHeaders();
|
||||
// eslint-disable-next-line no-eq-null
|
||||
}
|
||||
else if (request.body != null) {
|
||||
// Stringify the JSON data
|
||||
finalBody = JSON.stringify(request.body);
|
||||
// Set the additional headers to specify the content-type
|
||||
additionalHeaders = { 'Content-Type': 'application/json' };
|
||||
}
|
||||
const fetchOptions = {
|
||||
agent,
|
||||
body: finalBody,
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
||||
headers: { ...(request.headers ?? {}), ...additionalHeaders, ...headers },
|
||||
method: request.method,
|
||||
};
|
||||
return { url, fetchOptions };
|
||||
}
|
||||
/**
|
||||
* Generates route data for an endpoint:method
|
||||
* @param endpoint The raw endpoint to generalize
|
||||
* @param method The HTTP method this endpoint is called without
|
||||
* @private
|
||||
*/
|
||||
static generateRouteData(endpoint, method) {
|
||||
const majorIDMatch = /^\/(?:channels|guilds|webhooks)\/(\d{16,19})/.exec(endpoint);
|
||||
// Get the major ID for this route - global otherwise
|
||||
const majorID = majorIDMatch?.[1] ?? 'global';
|
||||
const baseRoute = endpoint
|
||||
// Strip out all IDs
|
||||
.replace(/\d{16,19}/g, ':id')
|
||||
// Strip out reaction as they fall under the same bucket
|
||||
.replace(/\/reactions\/(.*)/, '/reactions/:reaction');
|
||||
let exceptions = '';
|
||||
// Hard-Code Old Message Deletion Exception (2 week+ old messages are a different bucket)
|
||||
// https://github.com/discord/discord-api-docs/issues/1295
|
||||
if (method === "delete" /* Delete */ && baseRoute === '/channels/:id/messages/:id') {
|
||||
const id = /\d{16,19}$/.exec(endpoint)[0];
|
||||
const snowflake = snowflake_1.DiscordSnowflake.deconstruct(id);
|
||||
if (Date.now() - Number(snowflake.timestamp) > 1000 * 60 * 60 * 24 * 14) {
|
||||
exceptions += '/Delete Old Message';
|
||||
}
|
||||
}
|
||||
return {
|
||||
majorParameter: majorID,
|
||||
bucketRoute: baseRoute + exceptions,
|
||||
original: endpoint,
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.RequestManager = RequestManager;
|
||||
_RequestManager_token = new WeakMap();
|
||||
//# sourceMappingURL=RequestManager.js.map
|
1
node_modules/@discordjs/rest/dist/lib/RequestManager.js.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/lib/RequestManager.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"RequestManager.js","sourceRoot":"./","sources":["lib/RequestManager.ts"],"names":[],"mappings":"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"}
|
42
node_modules/@discordjs/rest/dist/lib/errors/DiscordAPIError.d.ts
generated
vendored
Normal file
42
node_modules/@discordjs/rest/dist/lib/errors/DiscordAPIError.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
interface DiscordErrorFieldInformation {
|
||||
code: string;
|
||||
message: string;
|
||||
}
|
||||
interface DiscordErrorGroupWrapper {
|
||||
_errors: DiscordError[];
|
||||
}
|
||||
declare type DiscordError = DiscordErrorGroupWrapper | DiscordErrorFieldInformation | {
|
||||
[k: string]: DiscordError;
|
||||
} | string;
|
||||
export interface DiscordErrorData {
|
||||
code: number;
|
||||
message: string;
|
||||
errors?: DiscordError;
|
||||
}
|
||||
/**
|
||||
* Represents an API error returned by Discord
|
||||
* @extends Error
|
||||
*/
|
||||
export declare class DiscordAPIError extends Error {
|
||||
rawError: DiscordErrorData;
|
||||
code: number;
|
||||
status: number;
|
||||
method: string;
|
||||
url: string;
|
||||
/**
|
||||
* @param rawError The error reported by Discord
|
||||
* @param code The error code reported by Discord
|
||||
* @param status The status code of the response
|
||||
* @param method The method of the request that erred
|
||||
* @param url The url of the request that erred
|
||||
*/
|
||||
constructor(rawError: DiscordErrorData, code: number, status: number, method: string, url: string);
|
||||
/**
|
||||
* The name of the error
|
||||
*/
|
||||
get name(): string;
|
||||
private static getMessage;
|
||||
private static flattenDiscordError;
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=DiscordAPIError.d.ts.map
|
1
node_modules/@discordjs/rest/dist/lib/errors/DiscordAPIError.d.ts.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/lib/errors/DiscordAPIError.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +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
node_modules/@discordjs/rest/dist/lib/errors/DiscordAPIError.js
generated
vendored
Normal file
66
node_modules/@discordjs/rest/dist/lib/errors/DiscordAPIError.js
generated
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DiscordAPIError = void 0;
|
||||
function isErrorGroupWrapper(error) {
|
||||
return Reflect.has(error, '_errors');
|
||||
}
|
||||
function isErrorResponse(error) {
|
||||
return typeof Reflect.get(error, 'message') === 'string';
|
||||
}
|
||||
/**
|
||||
* Represents an API error returned by Discord
|
||||
* @extends Error
|
||||
*/
|
||||
class DiscordAPIError extends Error {
|
||||
/**
|
||||
* @param rawError The error reported by Discord
|
||||
* @param code The error code reported by Discord
|
||||
* @param status The status code of the response
|
||||
* @param method The method of the request that erred
|
||||
* @param url The url of the request that erred
|
||||
*/
|
||||
constructor(rawError, code, status, method, url) {
|
||||
super(DiscordAPIError.getMessage(rawError));
|
||||
this.rawError = rawError;
|
||||
this.code = code;
|
||||
this.status = status;
|
||||
this.method = method;
|
||||
this.url = url;
|
||||
}
|
||||
/**
|
||||
* The name of the error
|
||||
*/
|
||||
get name() {
|
||||
return `${DiscordAPIError.name}[${this.code}]`;
|
||||
}
|
||||
static getMessage(error) {
|
||||
let flattened = '';
|
||||
if (error.errors) {
|
||||
flattened = [...this.flattenDiscordError(error.errors)].join('\n');
|
||||
}
|
||||
return error.message && flattened
|
||||
? `${error.message}\n${flattened}`
|
||||
: error.message || flattened || 'Unknown Error';
|
||||
}
|
||||
static *flattenDiscordError(obj, key = '') {
|
||||
if (isErrorResponse(obj)) {
|
||||
return yield `${key.length ? `${key}[${obj.code}]` : `${obj.code}`}: ${obj.message}`.trim();
|
||||
}
|
||||
for (const [k, v] of Object.entries(obj)) {
|
||||
const nextKey = k.startsWith('_') ? key : key ? (Number.isNaN(Number(k)) ? `${key}.${k}` : `${key}[${k}]`) : k;
|
||||
if (typeof v === 'string') {
|
||||
yield v;
|
||||
}
|
||||
else if (isErrorGroupWrapper(v)) {
|
||||
for (const error of v._errors) {
|
||||
yield* this.flattenDiscordError(error, nextKey);
|
||||
}
|
||||
}
|
||||
else {
|
||||
yield* this.flattenDiscordError(v, nextKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.DiscordAPIError = DiscordAPIError;
|
||||
//# sourceMappingURL=DiscordAPIError.js.map
|
1
node_modules/@discordjs/rest/dist/lib/errors/DiscordAPIError.js.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/lib/errors/DiscordAPIError.js.map
generated
vendored
Normal file
|
@ -0,0 +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,MAAc,EACd,MAAc,EACd,GAAW;QAElB,KAAK,CAAC,eAAe,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;QANrC,aAAQ,GAAR,QAAQ,CAAkB;QAC1B,SAAI,GAAJ,IAAI,CAAQ;QACZ,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAAQ;QACd,QAAG,GAAH,GAAG,CAAQ;IAGnB,CAAC;IAED;;OAEG;IACH,IAAW,IAAI;QACd,OAAO,GAAG,eAAe,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC;IAChD,CAAC;IAEO,MAAM,CAAC,UAAU,CAAC,KAAuB;QAChD,IAAI,SAAS,GAAG,EAAE,CAAC;QACnB,IAAI,KAAK,CAAC,MAAM,EAAE;YACjB,SAAS,GAAG,CAAC,GAAG,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACnE;QACD,OAAO,KAAK,CAAC,OAAO,IAAI,SAAS;YAChC,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE;YAClC,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,SAAS,IAAI,eAAe,CAAC;IAClD,CAAC;IAEO,MAAM,CAAC,CAAC,mBAAmB,CAAC,GAAiB,EAAE,GAAG,GAAG,EAAE;QAC9D,IAAI,eAAe,CAAC,GAAG,CAAC,EAAE;YACzB,OAAO,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC;SAC5F;QAED,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YACzC,MAAM,OAAO,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
node_modules/@discordjs/rest/dist/lib/errors/HTTPError.d.ts
generated
vendored
Normal file
18
node_modules/@discordjs/rest/dist/lib/errors/HTTPError.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* Represents a HTTP error
|
||||
*/
|
||||
export declare class HTTPError extends Error {
|
||||
name: string;
|
||||
status: number;
|
||||
method: string;
|
||||
url: string;
|
||||
/**
|
||||
* @param message The error message
|
||||
* @param name The name of the error
|
||||
* @param status The status code of the response
|
||||
* @param method The method of the request that erred
|
||||
* @param url The url of the request that erred
|
||||
*/
|
||||
constructor(message: string, name: string, status: number, method: string, url: string);
|
||||
}
|
||||
//# sourceMappingURL=HTTPError.d.ts.map
|
1
node_modules/@discordjs/rest/dist/lib/errors/HTTPError.d.ts.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/lib/errors/HTTPError.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +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
node_modules/@discordjs/rest/dist/lib/errors/HTTPError.js
generated
vendored
Normal file
24
node_modules/@discordjs/rest/dist/lib/errors/HTTPError.js
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.HTTPError = void 0;
|
||||
/**
|
||||
* Represents a HTTP error
|
||||
*/
|
||||
class HTTPError extends Error {
|
||||
/**
|
||||
* @param message The error message
|
||||
* @param name The name of the error
|
||||
* @param status The status code of the response
|
||||
* @param method The method of the request that erred
|
||||
* @param url The url of the request that erred
|
||||
*/
|
||||
constructor(message, name, status, method, url) {
|
||||
super(message);
|
||||
this.name = name;
|
||||
this.status = status;
|
||||
this.method = method;
|
||||
this.url = url;
|
||||
}
|
||||
}
|
||||
exports.HTTPError = HTTPError;
|
||||
//# sourceMappingURL=HTTPError.js.map
|
1
node_modules/@discordjs/rest/dist/lib/errors/HTTPError.js.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/lib/errors/HTTPError.js.map
generated
vendored
Normal file
|
@ -0,0 +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
node_modules/@discordjs/rest/dist/lib/handlers/IHandler.d.ts
generated
vendored
Normal file
6
node_modules/@discordjs/rest/dist/lib/handlers/IHandler.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
import type { RequestInit } from 'node-fetch';
|
||||
import type { RouteData } from '../RequestManager';
|
||||
export interface IHandler {
|
||||
queueRequest(routeID: RouteData, url: string, options: RequestInit): Promise<unknown>;
|
||||
}
|
||||
//# sourceMappingURL=IHandler.d.ts.map
|
1
node_modules/@discordjs/rest/dist/lib/handlers/IHandler.d.ts.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/lib/handlers/IHandler.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +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
node_modules/@discordjs/rest/dist/lib/handlers/IHandler.js
generated
vendored
Normal file
3
node_modules/@discordjs/rest/dist/lib/handlers/IHandler.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=IHandler.js.map
|
1
node_modules/@discordjs/rest/dist/lib/handlers/IHandler.js.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/lib/handlers/IHandler.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"IHandler.js","sourceRoot":"./","sources":["lib/handlers/IHandler.ts"],"names":[],"mappings":""}
|
66
node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.d.ts
generated
vendored
Normal file
66
node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
import { RequestInit } from 'node-fetch';
|
||||
import type { RequestManager, RouteData } from '../RequestManager';
|
||||
/**
|
||||
* The structure used to handle requests for a given bucket
|
||||
*/
|
||||
export declare class SequentialHandler {
|
||||
#private;
|
||||
private readonly manager;
|
||||
private readonly hash;
|
||||
private readonly majorParameter;
|
||||
/**
|
||||
* The unique ID of the handler
|
||||
*/
|
||||
readonly id: string;
|
||||
/**
|
||||
* The time this rate limit bucket will reset
|
||||
*/
|
||||
private reset;
|
||||
/**
|
||||
* The remaining requests that can be made before we are rate limited
|
||||
*/
|
||||
private remaining;
|
||||
/**
|
||||
* The total number of requests that can be made before we are rate limited
|
||||
*/
|
||||
private limit;
|
||||
/**
|
||||
* @param manager The request manager
|
||||
* @param hash The hash that this RequestHandler handles
|
||||
* @param majorParameter The major parameter for this handler
|
||||
*/
|
||||
constructor(manager: RequestManager, hash: string, majorParameter: string);
|
||||
/**
|
||||
* If the bucket is currently inactive (no pending requests)
|
||||
*/
|
||||
get inactive(): boolean;
|
||||
/**
|
||||
* If the rate limit bucket is currently limited
|
||||
*/
|
||||
private get limited();
|
||||
/**
|
||||
* The time until queued requests can continue
|
||||
*/
|
||||
private get timeToReset();
|
||||
/**
|
||||
* Emits a debug message
|
||||
* @param message The message to debug
|
||||
*/
|
||||
private debug;
|
||||
/**
|
||||
* Queues a request to be sent
|
||||
* @param routeID The generalized api route with literal ids for major parameters
|
||||
* @param url The url to do the request on
|
||||
* @param options All the information needed to make a request
|
||||
*/
|
||||
queueRequest(routeID: RouteData, url: string, options: RequestInit): Promise<unknown>;
|
||||
/**
|
||||
* The method that actually makes the request to the api, and updates info about the bucket accordingly
|
||||
* @param routeID The generalized api route with literal ids for major parameters
|
||||
* @param url The fully resolved url to make the request to
|
||||
* @param options The node-fetch options needed to make the request
|
||||
* @param retries The number of retries this request has already attempted (recursion)
|
||||
*/
|
||||
private runRequest;
|
||||
}
|
||||
//# sourceMappingURL=SequentialHandler.d.ts.map
|
1
node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.d.ts.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +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
node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.js
generated
vendored
Normal file
206
node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.js
generated
vendored
Normal file
|
@ -0,0 +1,206 @@
|
|||
"use strict";
|
||||
var _SequentialHandler_asyncQueue;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SequentialHandler = void 0;
|
||||
const tslib_1 = require("tslib");
|
||||
const promises_1 = require("timers/promises");
|
||||
const async_queue_1 = require("@sapphire/async-queue");
|
||||
const abort_controller_1 = tslib_1.__importDefault(require("abort-controller"));
|
||||
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
||||
const DiscordAPIError_1 = require("../errors/DiscordAPIError");
|
||||
const HTTPError_1 = require("../errors/HTTPError");
|
||||
require("../utils/constants");
|
||||
const utils_1 = require("../utils/utils");
|
||||
/**
|
||||
* The structure used to handle requests for a given bucket
|
||||
*/
|
||||
class SequentialHandler {
|
||||
/**
|
||||
* @param manager The request manager
|
||||
* @param hash The hash that this RequestHandler handles
|
||||
* @param majorParameter The major parameter for this handler
|
||||
*/
|
||||
constructor(manager, hash, majorParameter) {
|
||||
this.manager = manager;
|
||||
this.hash = hash;
|
||||
this.majorParameter = majorParameter;
|
||||
/**
|
||||
* The time this rate limit bucket will reset
|
||||
*/
|
||||
this.reset = -1;
|
||||
/**
|
||||
* The remaining requests that can be made before we are rate limited
|
||||
*/
|
||||
this.remaining = 1;
|
||||
/**
|
||||
* The total number of requests that can be made before we are rate limited
|
||||
*/
|
||||
this.limit = Infinity;
|
||||
/**
|
||||
* The interface used to sequence async requests sequentially
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
|
||||
_SequentialHandler_asyncQueue.set(this, new async_queue_1.AsyncQueue());
|
||||
this.id = `${hash}:${majorParameter}`;
|
||||
}
|
||||
/**
|
||||
* If the bucket is currently inactive (no pending requests)
|
||||
*/
|
||||
get inactive() {
|
||||
return tslib_1.__classPrivateFieldGet(this, _SequentialHandler_asyncQueue, "f").remaining === 0 && !this.limited;
|
||||
}
|
||||
/**
|
||||
* If the rate limit bucket is currently limited
|
||||
*/
|
||||
get limited() {
|
||||
return this.remaining <= 0 && Date.now() < this.reset;
|
||||
}
|
||||
/**
|
||||
* The time until queued requests can continue
|
||||
*/
|
||||
get timeToReset() {
|
||||
return this.reset - Date.now();
|
||||
}
|
||||
/**
|
||||
* Emits a debug message
|
||||
* @param message The message to debug
|
||||
*/
|
||||
debug(message) {
|
||||
this.manager.emit("restDebug" /* Debug */, `[REST ${this.id}] ${message}`);
|
||||
}
|
||||
/**
|
||||
* Queues a request to be sent
|
||||
* @param routeID The generalized api route with literal ids for major parameters
|
||||
* @param url The url to do the request on
|
||||
* @param options All the information needed to make a request
|
||||
*/
|
||||
async queueRequest(routeID, url, options) {
|
||||
// Wait for any previous requests to be completed before this one is run
|
||||
await tslib_1.__classPrivateFieldGet(this, _SequentialHandler_asyncQueue, "f").wait();
|
||||
try {
|
||||
// Wait for any global rate limits to pass before continuing to process requests
|
||||
await this.manager.globalTimeout;
|
||||
// Check if this request handler is currently rate limited
|
||||
if (this.limited) {
|
||||
// Let library users know they have hit a rate limit
|
||||
this.manager.emit("rateLimited" /* RateLimited */, {
|
||||
timeToReset: this.timeToReset,
|
||||
limit: this.limit,
|
||||
method: options.method,
|
||||
hash: this.hash,
|
||||
route: routeID.bucketRoute,
|
||||
majorParameter: this.majorParameter,
|
||||
});
|
||||
this.debug(`Waiting ${this.timeToReset}ms for rate limit to pass`);
|
||||
// Wait the remaining time left before the rate limit resets
|
||||
await promises_1.setTimeout(this.timeToReset);
|
||||
}
|
||||
// Make the request, and return the results
|
||||
return await this.runRequest(routeID, url, options);
|
||||
}
|
||||
finally {
|
||||
// Allow the next request to fire
|
||||
tslib_1.__classPrivateFieldGet(this, _SequentialHandler_asyncQueue, "f").shift();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The method that actually makes the request to the api, and updates info about the bucket accordingly
|
||||
* @param routeID The generalized api route with literal ids for major parameters
|
||||
* @param url The fully resolved url to make the request to
|
||||
* @param options The node-fetch options needed to make the request
|
||||
* @param retries The number of retries this request has already attempted (recursion)
|
||||
*/
|
||||
async runRequest(routeID, url, options, retries = 0) {
|
||||
const controller = new abort_controller_1.default();
|
||||
const timeout = setTimeout(() => controller.abort(), this.manager.options.timeout);
|
||||
let res;
|
||||
try {
|
||||
res = await node_fetch_1.default(url, { ...options, signal: controller.signal });
|
||||
}
|
||||
catch (error) {
|
||||
const err = error;
|
||||
// Retry the specified number of times for possible timed out requests
|
||||
if (err.name === 'AbortError' && retries !== this.manager.options.retries) {
|
||||
return this.runRequest(routeID, url, options, ++retries);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
finally {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
let retryAfter = 0;
|
||||
const method = options.method ?? 'get';
|
||||
const limit = res.headers.get('X-RateLimit-Limit');
|
||||
const remaining = res.headers.get('X-RateLimit-Remaining');
|
||||
const reset = res.headers.get('X-RateLimit-Reset-After');
|
||||
const hash = res.headers.get('X-RateLimit-Bucket');
|
||||
const retry = res.headers.get('Retry-After');
|
||||
// Update the total number of requests that can be made before the rate limit resets
|
||||
this.limit = limit ? Number(limit) : Infinity;
|
||||
// Update the number of remaining requests that can be made before the rate limit resets
|
||||
this.remaining = remaining ? Number(remaining) : 1;
|
||||
// Update the time when this rate limit resets (reset-after is in seconds)
|
||||
this.reset = reset ? Number(reset) * 1000 + Date.now() + this.manager.options.offset : Date.now();
|
||||
// Amount of time in milliseconds until we should retry if rate limited (globally or otherwise)
|
||||
if (retry)
|
||||
retryAfter = Number(retry) * 1000 + this.manager.options.offset;
|
||||
// Handle buckets via the hash header retroactively
|
||||
if (hash && hash !== this.hash) {
|
||||
// Let library users know when rate limit buckets have been updated
|
||||
this.debug(['Received bucket hash update', ` Old Hash : ${this.hash}`, ` New Hash : ${hash}`].join('\n'));
|
||||
// This queue will eventually be eliminated via attrition
|
||||
this.manager.hashes.set(`${method}:${routeID.bucketRoute}`, hash);
|
||||
}
|
||||
// Handle global rate limit
|
||||
if (res.headers.get('X-RateLimit-Global')) {
|
||||
this.debug(`We are globally rate limited, blocking all requests for ${retryAfter}ms`);
|
||||
// Set the manager's global timeout as the promise for other requests to "wait"
|
||||
this.manager.globalTimeout = promises_1.setTimeout(retryAfter).then(() => {
|
||||
// After the timer is up, clear the promise
|
||||
this.manager.globalTimeout = null;
|
||||
});
|
||||
}
|
||||
if (res.ok) {
|
||||
return utils_1.parseResponse(res);
|
||||
}
|
||||
else if (res.status === 429) {
|
||||
// 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
|
||||
this.debug([
|
||||
'Encountered unexpected 429 rate limit',
|
||||
` Bucket : ${routeID.bucketRoute}`,
|
||||
` Major parameter: ${routeID.majorParameter}`,
|
||||
` Hash : ${this.hash}`,
|
||||
` Retry After : ${retryAfter}ms`,
|
||||
].join('\n'));
|
||||
// Wait the retryAfter amount of time before retrying the request
|
||||
await promises_1.setTimeout(retryAfter);
|
||||
// Since this is not a server side issue, the next request should pass, so we don't bump the retries counter
|
||||
return this.runRequest(routeID, url, options, retries);
|
||||
}
|
||||
else if (res.status >= 500 && res.status < 600) {
|
||||
// Retry the specified number of times for possible server side issues
|
||||
if (retries !== this.manager.options.retries) {
|
||||
return this.runRequest(routeID, url, options, ++retries);
|
||||
}
|
||||
// We are out of retries, throw an error
|
||||
throw new HTTPError_1.HTTPError(res.statusText, res.constructor.name, res.status, method, url);
|
||||
}
|
||||
else {
|
||||
// Handle possible malformed requests
|
||||
if (res.status >= 400 && res.status < 500) {
|
||||
// If we receive this status code, it means the token we had is no longer valid.
|
||||
if (res.status === 401) {
|
||||
this.manager.setToken(null);
|
||||
}
|
||||
// The request will not succeed for some reason, parse the error returned from the api
|
||||
const data = (await utils_1.parseResponse(res));
|
||||
// throw the API error
|
||||
throw new DiscordAPIError_1.DiscordAPIError(data, data.code, res.status, method, url);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.SequentialHandler = SequentialHandler;
|
||||
_SequentialHandler_asyncQueue = new WeakMap();
|
||||
//# sourceMappingURL=SequentialHandler.js.map
|
1
node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.js.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
15
node_modules/@discordjs/rest/dist/lib/utils/constants.d.ts
generated
vendored
Normal file
15
node_modules/@discordjs/rest/dist/lib/utils/constants.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
import type { RESTOptions } from '../REST';
|
||||
export declare const DefaultUserAgent: string;
|
||||
export declare const DefaultRestOptions: Required<RESTOptions>;
|
||||
/**
|
||||
* The events that the REST manager emits
|
||||
*/
|
||||
export declare const enum RESTEvents {
|
||||
Debug = "restDebug",
|
||||
RateLimited = "rateLimited"
|
||||
}
|
||||
export declare const ALLOWED_EXTENSIONS: readonly ["webp", "png", "jpg", "jpeg", "gif"];
|
||||
export declare const ALLOWED_SIZES: readonly [16, 32, 64, 128, 256, 512, 1024, 2048, 4096];
|
||||
export declare type ImageExtension = typeof ALLOWED_EXTENSIONS[number];
|
||||
export declare type ImageSize = typeof ALLOWED_SIZES[number];
|
||||
//# sourceMappingURL=constants.d.ts.map
|
1
node_modules/@discordjs/rest/dist/lib/utils/constants.d.ts.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/lib/utils/constants.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +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
node_modules/@discordjs/rest/dist/lib/utils/constants.js
generated
vendored
Normal file
28
node_modules/@discordjs/rest/dist/lib/utils/constants.js
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ALLOWED_SIZES = exports.ALLOWED_EXTENSIONS = exports.RESTEvents = exports.DefaultRestOptions = exports.DefaultUserAgent = void 0;
|
||||
const v8_1 = require("discord-api-types/v8");
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
||||
const Package = require('../../../package.json');
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||
exports.DefaultUserAgent = `DiscordBot (${Package.homepage}, ${Package.version})`;
|
||||
exports.DefaultRestOptions = {
|
||||
api: 'https://discord.com/api',
|
||||
cdn: 'https://cdn.discordapp.com',
|
||||
offset: 50,
|
||||
retries: 3,
|
||||
timeout: 15000,
|
||||
userAgentAppendix: `Node.js ${process.version}`,
|
||||
version: v8_1.APIVersion,
|
||||
};
|
||||
/**
|
||||
* The events that the REST manager emits
|
||||
*/
|
||||
var RESTEvents;
|
||||
(function (RESTEvents) {
|
||||
RESTEvents["Debug"] = "restDebug";
|
||||
RESTEvents["RateLimited"] = "rateLimited";
|
||||
})(RESTEvents = exports.RESTEvents || (exports.RESTEvents = {}));
|
||||
exports.ALLOWED_EXTENSIONS = ['webp', 'png', 'jpg', 'jpeg', 'gif'];
|
||||
exports.ALLOWED_SIZES = [16, 32, 64, 128, 256, 512, 1024, 2048, 4096];
|
||||
//# sourceMappingURL=constants.js.map
|
1
node_modules/@discordjs/rest/dist/lib/utils/constants.js.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/lib/utils/constants.js.map
generated
vendored
Normal file
|
@ -0,0 +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
node_modules/@discordjs/rest/dist/lib/utils/utils.d.ts
generated
vendored
Normal file
7
node_modules/@discordjs/rest/dist/lib/utils/utils.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
import type { Response } from 'node-fetch';
|
||||
/**
|
||||
* Converts the response to usable data
|
||||
* @param res The node-fetch response
|
||||
*/
|
||||
export declare function parseResponse(res: Response): Promise<unknown>;
|
||||
//# sourceMappingURL=utils.d.ts.map
|
1
node_modules/@discordjs/rest/dist/lib/utils/utils.d.ts.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/lib/utils/utils.d.ts.map
generated
vendored
Normal file
|
@ -0,0 +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
node_modules/@discordjs/rest/dist/lib/utils/utils.js
generated
vendored
Normal file
15
node_modules/@discordjs/rest/dist/lib/utils/utils.js
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseResponse = void 0;
|
||||
/**
|
||||
* Converts the response to usable data
|
||||
* @param res The node-fetch response
|
||||
*/
|
||||
function parseResponse(res) {
|
||||
if (res.headers.get('Content-Type')?.startsWith('application/json')) {
|
||||
return res.json();
|
||||
}
|
||||
return res.buffer();
|
||||
}
|
||||
exports.parseResponse = parseResponse;
|
||||
//# sourceMappingURL=utils.js.map
|
1
node_modules/@discordjs/rest/dist/lib/utils/utils.js.map
generated
vendored
Normal file
1
node_modules/@discordjs/rest/dist/lib/utils/utils.js.map
generated
vendored
Normal file
|
@ -0,0 +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
node_modules/@discordjs/rest/package.json
generated
vendored
Normal file
61
node_modules/@discordjs/rest/package.json
generated
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
"$schema": "http://json.schemastore.org/package",
|
||||
"name": "@discordjs/rest",
|
||||
"version": "0.1.0-canary.0",
|
||||
"description": "The REST API for Discord.js",
|
||||
"contributors": [
|
||||
"Amish Shah <amishshah.2k@gmail.com>",
|
||||
"Crawl <icrawltogo@gmail.com>",
|
||||
"SpaceEEC <spaceeec@yahoo.com>",
|
||||
"Vlad Frangu <kingdgrizzle@gmail.com>",
|
||||
"Antonio Roman <kyradiscord@gmail.com>"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||
"build": "tsc --build --force"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/discordjs/discord.js-next.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/discordjs/discord.js-next/issues"
|
||||
},
|
||||
"homepage": "https://github.com/discordjs/discord.js-next/tree/master/packages/rest",
|
||||
"keywords": [
|
||||
"discord",
|
||||
"api",
|
||||
"rest",
|
||||
"discordapp",
|
||||
"discordjs"
|
||||
],
|
||||
"main": "dist/index.js",
|
||||
"directories": {
|
||||
"lib": "src",
|
||||
"test": "__tests__"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"dependencies": {
|
||||
"@discordjs/collection": "^0.1.6",
|
||||
"@sapphire/async-queue": "^1.1.4",
|
||||
"@sapphire/snowflake": "^1.3.5",
|
||||
"abort-controller": "^3.0.0",
|
||||
"discord-api-types": "^0.18.1",
|
||||
"form-data": "^4.0.0",
|
||||
"node-fetch": "^2.6.1",
|
||||
"tslib": "^2.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node-fetch": "^2.5.10"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"gitHead": "2e640a9ffeaecc562f4845ffeebccdb803607ef3"
|
||||
}
|
500
node_modules/@mapbox/node-pre-gyp/CHANGELOG.md
generated
vendored
Normal file
500
node_modules/@mapbox/node-pre-gyp/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,500 @@
|
|||
# node-pre-gyp changelog
|
||||
|
||||
## 1.0.8
|
||||
- Downgraded npmlog to maintain node v10 and v8 support (https://github.com/mapbox/node-pre-gyp/pull/624)
|
||||
|
||||
## 1.0.7
|
||||
- Upgraded nyc and npmlog to address https://github.com/advisories/GHSA-93q8-gq69-wqmw
|
||||
|
||||
## 1.0.6
|
||||
- Added node v17 to the internal node releases listing
|
||||
- Upgraded various dependencies declared in package.json to latest major versions (node-fetch from 2.6.1 to 2.6.5, npmlog from 4.1.2 to 5.01, semver from 7.3.4 to 7.3.5, and tar from 6.1.0 to 6.1.11)
|
||||
- Fixed bug in `staging_host` parameter (https://github.com/mapbox/node-pre-gyp/pull/590)
|
||||
|
||||
|
||||
## 1.0.5
|
||||
- Fix circular reference warning with node >= v14
|
||||
|
||||
## 1.0.4
|
||||
- Added node v16 to the internal node releases listing
|
||||
|
||||
## 1.0.3
|
||||
- Improved support configuring s3 uploads (solves https://github.com/mapbox/node-pre-gyp/issues/571)
|
||||
- New options added in https://github.com/mapbox/node-pre-gyp/pull/576: 'bucket', 'region', and `s3ForcePathStyle`
|
||||
|
||||
## 1.0.2
|
||||
- Fixed regression in proxy support (https://github.com/mapbox/node-pre-gyp/issues/572)
|
||||
|
||||
## 1.0.1
|
||||
- Switched from mkdirp@1.0.4 to make-dir@3.1.0 to avoid this bug: https://github.com/isaacs/node-mkdirp/issues/31
|
||||
|
||||
## 1.0.0
|
||||
- Module is now name-spaced at `@mapbox/node-pre-gyp` and the original `node-pre-gyp` is deprecated.
|
||||
- New: support for staging and production s3 targets (see README.md)
|
||||
- BREAKING: no longer supporting `node_pre_gyp_accessKeyId` & `node_pre_gyp_secretAccessKey`, use `AWS_ACCESS_KEY_ID` & `AWS_SECRET_ACCESS_KEY` instead to authenticate against s3 for `info`, `publish`, and `unpublish` commands.
|
||||
- Dropped node v6 support, added node v14 support
|
||||
- Switched tests to use mapbox-owned bucket for testing
|
||||
- Added coverage tracking and linting with eslint
|
||||
- Added back support for symlinks inside the tarball
|
||||
- Upgraded all test apps to N-API/node-addon-api
|
||||
- New: support for staging and production s3 targets (see README.md)
|
||||
- Added `node_pre_gyp_s3_host` env var which has priority over the `--s3_host` option or default.
|
||||
- Replaced needle with node-fetch
|
||||
- Added proxy support for node-fetch
|
||||
- Upgraded to mkdirp@1.x
|
||||
|
||||
## 0.17.0
|
||||
- Got travis + appveyor green again
|
||||
- Added support for more node versions
|
||||
|
||||
## 0.16.0
|
||||
|
||||
- Added Node 15 support in the local database (https://github.com/mapbox/node-pre-gyp/pull/520)
|
||||
|
||||
## 0.15.0
|
||||
|
||||
- Bump dependency on `mkdirp` from `^0.5.1` to `^0.5.3` (https://github.com/mapbox/node-pre-gyp/pull/492)
|
||||
- Bump dependency on `needle` from `^2.2.1` to `^2.5.0` (https://github.com/mapbox/node-pre-gyp/pull/502)
|
||||
- Added Node 14 support in the local database (https://github.com/mapbox/node-pre-gyp/pull/501)
|
||||
|
||||
## 0.14.0
|
||||
|
||||
- Defer modules requires in napi.js (https://github.com/mapbox/node-pre-gyp/pull/434)
|
||||
- Bump dependency on `tar` from `^4` to `^4.4.2` (https://github.com/mapbox/node-pre-gyp/pull/454)
|
||||
- Support extracting compiled binary from local offline mirror (https://github.com/mapbox/node-pre-gyp/pull/459)
|
||||
- Added Node 13 support in the local database (https://github.com/mapbox/node-pre-gyp/pull/483)
|
||||
|
||||
## 0.13.0
|
||||
|
||||
- Added Node 12 support in the local database (https://github.com/mapbox/node-pre-gyp/pull/449)
|
||||
|
||||
## 0.12.0
|
||||
|
||||
- Fixed double-build problem with node v10 (https://github.com/mapbox/node-pre-gyp/pull/428)
|
||||
- Added node 11 support in the local database (https://github.com/mapbox/node-pre-gyp/pull/422)
|
||||
|
||||
## 0.11.0
|
||||
|
||||
- Fixed double-install problem with node v10
|
||||
- Significant N-API improvements (https://github.com/mapbox/node-pre-gyp/pull/405)
|
||||
|
||||
## 0.10.3
|
||||
|
||||
- Now will use `request` over `needle` if request is installed. By default `needle` is used for `https`. This should unbreak proxy support that regressed in v0.9.0
|
||||
|
||||
## 0.10.2
|
||||
|
||||
- Fixed rc/deep-extent security vulnerability
|
||||
- Fixed broken reinstall script do to incorrectly named get_best_napi_version
|
||||
|
||||
## 0.10.1
|
||||
|
||||
- Fix needle error event (@medns)
|
||||
|
||||
## 0.10.0
|
||||
|
||||
- Allow for a single-level module path when packing @allenluce (https://github.com/mapbox/node-pre-gyp/pull/371)
|
||||
- Log warnings instead of errors when falling back @xzyfer (https://github.com/mapbox/node-pre-gyp/pull/366)
|
||||
- Add Node.js v10 support to tests (https://github.com/mapbox/node-pre-gyp/pull/372)
|
||||
- Remove retire.js from CI (https://github.com/mapbox/node-pre-gyp/pull/372)
|
||||
- Remove support for Node.js v4 due to [EOL on April 30th, 2018](https://github.com/nodejs/Release/blob/7dd52354049cae99eed0e9fe01345b0722a86fde/schedule.json#L14)
|
||||
- Update appveyor tests to install default NPM version instead of NPM v2.x for all Windows builds (https://github.com/mapbox/node-pre-gyp/pull/375)
|
||||
|
||||
## 0.9.1
|
||||
|
||||
- Fixed regression (in v0.9.0) with support for http redirects @allenluce (https://github.com/mapbox/node-pre-gyp/pull/361)
|
||||
|
||||
## 0.9.0
|
||||
|
||||
- Switched from using `request` to `needle` to reduce size of module deps (https://github.com/mapbox/node-pre-gyp/pull/350)
|
||||
|
||||
## 0.8.0
|
||||
|
||||
- N-API support (@inspiredware)
|
||||
|
||||
## 0.7.1
|
||||
|
||||
- Upgraded to tar v4.x
|
||||
|
||||
## 0.7.0
|
||||
|
||||
- Updated request and hawk (#347)
|
||||
- Dropped node v0.10.x support
|
||||
|
||||
## 0.6.40
|
||||
|
||||
- Improved error reporting if an install fails
|
||||
|
||||
## 0.6.39
|
||||
|
||||
- Support for node v9
|
||||
- Support for versioning on `{libc}` to allow binaries to work on non-glic linux systems like alpine linux
|
||||
|
||||
|
||||
## 0.6.38
|
||||
|
||||
- Maintaining compatibility (for v0.6.x series) with node v0.10.x
|
||||
|
||||
## 0.6.37
|
||||
|
||||
- Solved one part of #276: now now deduce the node ABI from the major version for node >= 2 even when not stored in the abi_crosswalk.json
|
||||
- Fixed docs to avoid mentioning the deprecated and dangerous `prepublish` in package.json (#291)
|
||||
- Add new node versions to crosswalk
|
||||
- Ported tests to use tape instead of mocha
|
||||
- Got appveyor tests passing by downgrading npm and node-gyp
|
||||
|
||||
## 0.6.36
|
||||
|
||||
- Removed the running of `testbinary` during install. Because this was regressed for so long, it is too dangerous to re-enable by default. Developers needing validation can call `node-pre-gyp testbinary` directory.
|
||||
- Fixed regression in v0.6.35 for electron installs (now skipping binary validation which is not yet supported for electron)
|
||||
|
||||
## 0.6.35
|
||||
|
||||
- No longer recommending `npm ls` in `prepublish` (#291)
|
||||
- Fixed testbinary command (#283) @szdavid92
|
||||
|
||||
## 0.6.34
|
||||
|
||||
- Added new node versions to crosswalk, including v8
|
||||
- Upgraded deps to latest versions, started using `^` instead of `~` for all deps.
|
||||
|
||||
## 0.6.33
|
||||
|
||||
- Improved support for yarn
|
||||
|
||||
## 0.6.32
|
||||
|
||||
- Honor npm configuration for CA bundles (@heikkipora)
|
||||
- Add node-pre-gyp and npm versions to user agent (@addaleax)
|
||||
- Updated various deps
|
||||
- Add known node version for v7.x
|
||||
|
||||
## 0.6.31
|
||||
|
||||
- Updated various deps
|
||||
|
||||
## 0.6.30
|
||||
|
||||
- Update to npmlog@4.x and semver@5.3.x
|
||||
- Add known node version for v6.5.0
|
||||
|
||||
## 0.6.29
|
||||
|
||||
- Add known node versions for v0.10.45, v0.12.14, v4.4.4, v5.11.1, and v6.1.0
|
||||
|
||||
## 0.6.28
|
||||
|
||||
- Now more verbose when remote binaries are not available. This is needed since npm is increasingly more quiet by default
|
||||
and users need to know why builds are falling back to source compiles that might then error out.
|
||||
|
||||
## 0.6.27
|
||||
|
||||
- Add known node version for node v6
|
||||
- Stopped bundling dependencies
|
||||
- Documented method for module authors to avoid bundling node-pre-gyp
|
||||
- See https://github.com/mapbox/node-pre-gyp/tree/master#configuring for details
|
||||
|
||||
## 0.6.26
|
||||
|
||||
- Skip validation for nw runtime (https://github.com/mapbox/node-pre-gyp/pull/181) via @fleg
|
||||
|
||||
## 0.6.25
|
||||
|
||||
- Improved support for auto-detection of electron runtime in `node-pre-gyp.find()`
|
||||
- Pull request from @enlight - https://github.com/mapbox/node-pre-gyp/pull/187
|
||||
- Add known node version for 4.4.1 and 5.9.1
|
||||
|
||||
## 0.6.24
|
||||
|
||||
- Add known node version for 5.8.0, 5.9.0, and 4.4.0.
|
||||
|
||||
## 0.6.23
|
||||
|
||||
- Add known node version for 0.10.43, 0.12.11, 4.3.2, and 5.7.1.
|
||||
|
||||
## 0.6.22
|
||||
|
||||
- Add known node version for 4.3.1, and 5.7.0.
|
||||
|
||||
## 0.6.21
|
||||
|
||||
- Add known node version for 0.10.42, 0.12.10, 4.3.0, and 5.6.0.
|
||||
|
||||
## 0.6.20
|
||||
|
||||
- Add known node version for 4.2.5, 4.2.6, 5.4.0, 5.4.1,and 5.5.0.
|
||||
|
||||
## 0.6.19
|
||||
|
||||
- Add known node version for 4.2.4
|
||||
|
||||
## 0.6.18
|
||||
|
||||
- Add new known node versions for 0.10.x, 0.12.x, 4.x, and 5.x
|
||||
|
||||
## 0.6.17
|
||||
|
||||
- Re-tagged to fix packaging problem of `Error: Cannot find module 'isarray'`
|
||||
|
||||
## 0.6.16
|
||||
|
||||
- Added known version in crosswalk for 5.1.0.
|
||||
|
||||
## 0.6.15
|
||||
|
||||
- Upgraded tar-pack (https://github.com/mapbox/node-pre-gyp/issues/182)
|
||||
- Support custom binary hosting mirror (https://github.com/mapbox/node-pre-gyp/pull/170)
|
||||
- Added known version in crosswalk for 4.2.2.
|
||||
|
||||
## 0.6.14
|
||||
|
||||
- Added node 5.x version
|
||||
|
||||
## 0.6.13
|
||||
|
||||
- Added more known node 4.x versions
|
||||
|
||||
## 0.6.12
|
||||
|
||||
- Added support for [Electron](http://electron.atom.io/). Just pass the `--runtime=electron` flag when building/installing. Thanks @zcbenz
|
||||
|
||||
## 0.6.11
|
||||
|
||||
- Added known node and io.js versions including more 3.x and 4.x versions
|
||||
|
||||
## 0.6.10
|
||||
|
||||
- Added known node and io.js versions including 3.x and 4.x versions
|
||||
- Upgraded `tar` dep
|
||||
|
||||
## 0.6.9
|
||||
|
||||
- Upgraded `rc` dep
|
||||
- Updated known io.js version: v2.4.0
|
||||
|
||||
## 0.6.8
|
||||
|
||||
- Upgraded `semver` and `rimraf` deps
|
||||
- Updated known node and io.js versions
|
||||
|
||||
## 0.6.7
|
||||
|
||||
- Fixed `node_abi` versions for io.js 1.1.x -> 1.8.x (should be 43, but was stored as 42) (refs https://github.com/iojs/build/issues/94)
|
||||
|
||||
## 0.6.6
|
||||
|
||||
- Updated with known io.js 2.0.0 version
|
||||
|
||||
## 0.6.5
|
||||
|
||||
- Now respecting `npm_config_node_gyp` (https://github.com/npm/npm/pull/4887)
|
||||
- Updated to semver@4.3.2
|
||||
- Updated known node v0.12.x versions and io.js 1.x versions.
|
||||
|
||||
## 0.6.4
|
||||
|
||||
- Improved support for `io.js` (@fengmk2)
|
||||
- Test coverage improvements (@mikemorris)
|
||||
- Fixed support for `--dist-url` that regressed in 0.6.3
|
||||
|
||||
## 0.6.3
|
||||
|
||||
- Added support for passing raw options to node-gyp using `--` separator. Flags passed after
|
||||
the `--` to `node-pre-gyp configure` will be passed directly to gyp while flags passed
|
||||
after the `--` will be passed directly to make/visual studio.
|
||||
- Added `node-pre-gyp configure` command to be able to call `node-gyp configure` directly
|
||||
- Fix issue with require validation not working on windows 7 (@edgarsilva)
|
||||
|
||||
## 0.6.2
|
||||
|
||||
- Support for io.js >= v1.0.2
|
||||
- Deferred require of `request` and `tar` to help speed up command line usage of `node-pre-gyp`.
|
||||
|
||||
## 0.6.1
|
||||
|
||||
- Fixed bundled `tar` version
|
||||
|
||||
## 0.6.0
|
||||
|
||||
- BREAKING: node odd releases like v0.11.x now use `major.minor.patch` for `{node_abi}` instead of `NODE_MODULE_VERSION` (#124)
|
||||
- Added support for `toolset` option in versioning. By default is an empty string but `--toolset` can be passed to publish or install to select alternative binaries that target a custom toolset like C++11. For example to target Visual Studio 2014 modules like node-sqlite3 use `--toolset=v140`.
|
||||
- Added support for `--no-rollback` option to request that a failed binary test does not remove the binary module leaves it in place.
|
||||
- Added support for `--update-binary` option to request an existing binary be re-installed and the check for a valid local module be skipped.
|
||||
- Added support for passing build options from `npm` through `node-pre-gyp` to `node-gyp`: `--nodedir`, `--disturl`, `--python`, and `--msvs_version`
|
||||
|
||||
## 0.5.31
|
||||
|
||||
- Added support for deducing node_abi for node.js runtime from previous release if the series is even
|
||||
- Added support for --target=0.10.33
|
||||
|
||||
## 0.5.30
|
||||
|
||||
- Repackaged with latest bundled deps
|
||||
|
||||
## 0.5.29
|
||||
|
||||
- Added support for semver `build`.
|
||||
- Fixed support for downloading from urls that include `+`.
|
||||
|
||||
## 0.5.28
|
||||
|
||||
- Now reporting unix style paths only in reveal command
|
||||
|
||||
## 0.5.27
|
||||
|
||||
- Fixed support for auto-detecting s3 bucket name when it contains `.` - @taavo
|
||||
- Fixed support for installing when path contains a `'` - @halfdan
|
||||
- Ported tests to mocha
|
||||
|
||||
## 0.5.26
|
||||
|
||||
- Fix node-webkit support when `--target` option is not provided
|
||||
|
||||
## 0.5.25
|
||||
|
||||
- Fix bundling of deps
|
||||
|
||||
## 0.5.24
|
||||
|
||||
- Updated ABI crosswalk to incldue node v0.10.30 and v0.10.31
|
||||
|
||||
## 0.5.23
|
||||
|
||||
- Added `reveal` command. Pass no options to get all versioning data as json. Pass a second arg to grab a single versioned property value
|
||||
- Added support for `--silent` (shortcut for `--loglevel=silent`)
|
||||
|
||||
## 0.5.22
|
||||
|
||||
- Fixed node-webkit versioning name (NOTE: node-webkit support still experimental)
|
||||
|
||||
## 0.5.21
|
||||
|
||||
- New package to fix `shasum check failed` error with v0.5.20
|
||||
|
||||
## 0.5.20
|
||||
|
||||
- Now versioning node-webkit binaries based on major.minor.patch - assuming no compatible ABI across versions (#90)
|
||||
|
||||
## 0.5.19
|
||||
|
||||
- Updated to know about more node-webkit releases
|
||||
|
||||
## 0.5.18
|
||||
|
||||
- Updated to know about more node-webkit releases
|
||||
|
||||
## 0.5.17
|
||||
|
||||
- Updated to know about node v0.10.29 release
|
||||
|
||||
## 0.5.16
|
||||
|
||||
- Now supporting all aws-sdk configuration parameters (http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html) (#86)
|
||||
|
||||
## 0.5.15
|
||||
|
||||
- Fixed installation of windows packages sub directories on unix systems (#84)
|
||||
|
||||
## 0.5.14
|
||||
|
||||
- Finished support for cross building using `--target_platform` option (#82)
|
||||
- Now skipping binary validation on install if target arch/platform do not match the host.
|
||||
- Removed multi-arch validing for OS X since it required a FAT node.js binary
|
||||
|
||||
## 0.5.13
|
||||
|
||||
- Fix problem in 0.5.12 whereby the wrong versions of mkdirp and semver where bundled.
|
||||
|
||||
## 0.5.12
|
||||
|
||||
- Improved support for node-webkit (@Mithgol)
|
||||
|
||||
## 0.5.11
|
||||
|
||||
- Updated target versions listing
|
||||
|
||||
## 0.5.10
|
||||
|
||||
- Fixed handling of `-debug` flag passed directory to node-pre-gyp (#72)
|
||||
- Added optional second arg to `node_pre_gyp.find` to customize the default versioning options used to locate the runtime binary
|
||||
- Failed install due to `testbinary` check failure no longer leaves behind binary (#70)
|
||||
|
||||
## 0.5.9
|
||||
|
||||
- Fixed regression in `testbinary` command causing installs to fail on windows with 0.5.7 (#60)
|
||||
|
||||
## 0.5.8
|
||||
|
||||
- Started bundling deps
|
||||
|
||||
## 0.5.7
|
||||
|
||||
- Fixed the `testbinary` check, which is used to determine whether to re-download or source compile, to work even in complex dependency situations (#63)
|
||||
- Exposed the internal `testbinary` command in node-pre-gyp command line tool
|
||||
- Fixed minor bug so that `fallback_to_build` option is always respected
|
||||
|
||||
## 0.5.6
|
||||
|
||||
- Added support for versioning on the `name` value in `package.json` (#57).
|
||||
- Moved to using streams for reading tarball when publishing (#52)
|
||||
|
||||
## 0.5.5
|
||||
|
||||
- Improved binary validation that also now works with node-webkit (@Mithgol)
|
||||
- Upgraded test apps to work with node v0.11.x
|
||||
- Improved test coverage
|
||||
|
||||
## 0.5.4
|
||||
|
||||
- No longer depends on external install of node-gyp for compiling builds.
|
||||
|
||||
## 0.5.3
|
||||
|
||||
- Reverted fix for debian/nodejs since it broke windows (#45)
|
||||
|
||||
## 0.5.2
|
||||
|
||||
- Support for debian systems where the node binary is named `nodejs` (#45)
|
||||
- Added `bin/node-pre-gyp.cmd` to be able to run command on windows locally (npm creates an .npm automatically when globally installed)
|
||||
- Updated abi-crosswalk with node v0.10.26 entry.
|
||||
|
||||
## 0.5.1
|
||||
|
||||
- Various minor bug fixes, several improving windows support for publishing.
|
||||
|
||||
## 0.5.0
|
||||
|
||||
- Changed property names in `binary` object: now required are `module_name`, `module_path`, and `host`.
|
||||
- Now `module_path` supports versioning, which allows developers to opt-in to using a versioned install path (#18).
|
||||
- Added `remote_path` which also supports versioning.
|
||||
- Changed `remote_uri` to `host`.
|
||||
|
||||
## 0.4.2
|
||||
|
||||
- Added support for `--target` flag to request cross-compile against a specific node/node-webkit version.
|
||||
- Added preliminary support for node-webkit
|
||||
- Fixed support for `--target_arch` option being respected in all cases.
|
||||
|
||||
## 0.4.1
|
||||
|
||||
- Fixed exception when only stderr is available in binary test (@bendi / #31)
|
||||
|
||||
## 0.4.0
|
||||
|
||||
- Enforce only `https:` based remote publishing access.
|
||||
- Added `node-pre-gyp info` command to display listing of published binaries
|
||||
- Added support for changing the directory node-pre-gyp should build in with the `-C/--directory` option.
|
||||
- Added support for S3 prefixes.
|
||||
|
||||
## 0.3.1
|
||||
|
||||
- Added `unpublish` command.
|
||||
- Fixed module path construction in tests.
|
||||
- Added ability to disable falling back to build behavior via `npm install --fallback-to-build=false` which overrides setting in a depedencies package.json `install` target.
|
||||
|
||||
## 0.3.0
|
||||
|
||||
- Support for packaging all files in `module_path` directory - see `app4` for example
|
||||
- Added `testpackage` command.
|
||||
- Changed `clean` command to only delete `.node` not entire `build` directory since node-gyp will handle that.
|
||||
- `.node` modules must be in a folder of there own since tar-pack will remove everything when it unpacks.
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue