aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--.vscode/settings.json2
-rw-r--r--commands/info.js4
-rw-r--r--config/fpexperience.txt2
-rw-r--r--config/icons/gen_4.txt1
-rw-r--r--config/icons/gen_5.txt1
-rw-r--r--config/icons/gen_unknown.txt1
-rw-r--r--config/icons/kind_alicorn.txt1
-rw-r--r--config/icons/kind_earth.txt1
-rw-r--r--config/icons/kind_other.txt1
-rw-r--r--config/icons/kind_pegasus.txt1
-rw-r--r--config/icons/kind_unicorn.txt1
-rw-r--r--config/version.txt2
-rw-r--r--handler/button.js2
-rw-r--r--handler/errors.js8
-rw-r--r--handler/menu.js2
-rw-r--r--modules/embed.js6
-rw-r--r--modules/generation.js18
-rw-r--r--modules/icons.js16
-rw-r--r--modules/kind.js24
-rw-r--r--modules/result.js2
-rw-r--r--update/infobox.js15
-rw-r--r--update/parse.js3
23 files changed, 102 insertions, 14 deletions
diff --git a/.gitignore b/.gitignore
index 4e9fb79..429f249 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,6 +14,8 @@ data
node_modules
test.json
user/userdata.json
+user/servers.json
+user/spoilers.json
demo.json
modules/translate.php
reports \ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..7a73a41
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,2 @@
+{
+} \ No newline at end of file
diff --git a/commands/info.js b/commands/info.js
index 21a1803..11d7c35 100644
--- a/commands/info.js
+++ b/commands/info.js
@@ -45,7 +45,7 @@ module.exports = async (interaction) => {
suffix = ".official-" + (interaction.guild ? interaction.guild.id : 0);
} else {
if ((interaction.guild ? interaction.guild.id : 0) === fpserver) {
- suffix = ".francoponies-epk" + fs.readFileSync("./config/fpexperience.txt").toString();
+ suffix = ".francoponies-exp" + fs.readFileSync("./config/fpexperience.txt").toString();
}
}
@@ -72,7 +72,7 @@ module.exports = async (interaction) => {
.setTitle(l("Bot stats", "Statistiques du robot", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
.setDescription(l("Ponyfind is a Discord bot that helps you get easy and fast access to data relative to My Little Pony (generations 4 and 5).", "Ponyfind est un robot Discord qui vous aide à obtenir un accès simple et rapide à des données relatives à My Little Pony (générations 4 et 5).", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
.addFields(fields)
- .setFooter(l("made with ♥ by Minteck, a My Little Pony fan", "fait avec ♥ par Minteck, une fan de My Little Pony", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setFooter({ text: l("made with ♥ by Minteck, a My Little Pony fan", "fait avec ♥ par Minteck, une fan de My Little Pony", interaction.user.id, interaction.guild ? interaction.guild.id : 0) })
]
});
} \ No newline at end of file
diff --git a/config/fpexperience.txt b/config/fpexperience.txt
index e440e5c..7813681 100644
--- a/config/fpexperience.txt
+++ b/config/fpexperience.txt
@@ -1 +1 @@
-3 \ No newline at end of file
+5 \ No newline at end of file
diff --git a/config/icons/gen_4.txt b/config/icons/gen_4.txt
new file mode 100644
index 0000000..2b21581
--- /dev/null
+++ b/config/icons/gen_4.txt
@@ -0,0 +1 @@
+<:gen_4:931540621016072232> \ No newline at end of file
diff --git a/config/icons/gen_5.txt b/config/icons/gen_5.txt
new file mode 100644
index 0000000..dbf6ec6
--- /dev/null
+++ b/config/icons/gen_5.txt
@@ -0,0 +1 @@
+<:gen_5:931540621221568552> \ No newline at end of file
diff --git a/config/icons/gen_unknown.txt b/config/icons/gen_unknown.txt
new file mode 100644
index 0000000..21b769e
--- /dev/null
+++ b/config/icons/gen_unknown.txt
@@ -0,0 +1 @@
+<:gen_unknown:931540621330612254> \ No newline at end of file
diff --git a/config/icons/kind_alicorn.txt b/config/icons/kind_alicorn.txt
new file mode 100644
index 0000000..45cf486
--- /dev/null
+++ b/config/icons/kind_alicorn.txt
@@ -0,0 +1 @@
+<:kind_alicorn:931534759534927872> \ No newline at end of file
diff --git a/config/icons/kind_earth.txt b/config/icons/kind_earth.txt
new file mode 100644
index 0000000..8f7b4dd
--- /dev/null
+++ b/config/icons/kind_earth.txt
@@ -0,0 +1 @@
+<:kind_earth:931534759627194418> \ No newline at end of file
diff --git a/config/icons/kind_other.txt b/config/icons/kind_other.txt
new file mode 100644
index 0000000..ccebfe8
--- /dev/null
+++ b/config/icons/kind_other.txt
@@ -0,0 +1 @@
+<:kind_other:931534760147296256> \ No newline at end of file
diff --git a/config/icons/kind_pegasus.txt b/config/icons/kind_pegasus.txt
new file mode 100644
index 0000000..9851228
--- /dev/null
+++ b/config/icons/kind_pegasus.txt
@@ -0,0 +1 @@
+<:kind_pegasus:931534759908220968> \ No newline at end of file
diff --git a/config/icons/kind_unicorn.txt b/config/icons/kind_unicorn.txt
new file mode 100644
index 0000000..138c40b
--- /dev/null
+++ b/config/icons/kind_unicorn.txt
@@ -0,0 +1 @@
+<:kind_unicorn:931534759904051220> \ No newline at end of file
diff --git a/config/version.txt b/config/version.txt
index da2ac9c..5e65966 100644
--- a/config/version.txt
+++ b/config/version.txt
@@ -1 +1 @@
-0.7.5 \ No newline at end of file
+0.8.19 \ No newline at end of file
diff --git a/handler/button.js b/handler/button.js
index 9cfbf95..3837a81 100644
--- a/handler/button.js
+++ b/handler/button.js
@@ -203,7 +203,7 @@ module.exports = async (interaction) => {
.setColor('#28dc46')
.setTitle(l("Thanks for suggesting", "Merci d'avoir proposé", interaction.user.id, interaction.guild ? interaction.guild.id : 0) + " \"" + keys[1] + "\"" + l("!", " !", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
.setDescription(l("Your suggestion has been sent to the developers. They can contact you later if your settings allow this to ask you more about your request.\nThanks for your help!", "Votre suggestion a bien été envoyée aux développeurs. Ils pourront vous recontacter si vos paramètres le permettent afin de vous poser plus de questions sur votre requête.\nMerci d'aider à améliorer notre système !", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- .setFooter("Ticket ID: " + tid)
+ .setFooter({ text: "Ticket ID: " + tid })
]
});
} else {
diff --git a/handler/errors.js b/handler/errors.js
index 44c216b..989adc4 100644
--- a/handler/errors.js
+++ b/handler/errors.js
@@ -13,7 +13,7 @@ module.exports = async (interaction, e) => {
.setColor('#dc2828')
.setTitle(l("An internal exception occurred", "Une erreur interne s'est produite", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
.setDescription(l("That's not your fault! The developers have already been informed about the issue and will resolve it as soon as possible.", "Ce n'est pas votre faute ! Les développeurs ont déjà été informés du problème et il sera corrigé aussi vite que possible.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- .setFooter("Ticket ID: " + tid)
+ .setFooter({ text: "Ticket ID: " + tid })
]
});
} catch (e2) {
@@ -27,7 +27,7 @@ module.exports = async (interaction, e) => {
.setColor('#dc2828')
.setTitle("2 internal exceptions occurred")
.setDescription("That's not your fault! The developers have already been informed about the issue and will resolve it as soon as possible. We additionally weren't able to deliver you a localized error message.")
- .setFooter("Ticket ID: " + tid)
+ .setFooter({ text: "Ticket ID: " + tid })
]
});
} catch (e3) {
@@ -38,7 +38,7 @@ module.exports = async (interaction, e) => {
.setColor('#dc2828')
.setTitle("3 internal exceptions occurred")
.setDescription("That's not your fault! The developers have already been informed about the issue and will resolve it as soon as possible. We additionally weren't able to deliver you a localized error message and/or through a reply to your command.")]
- .setFooter("Ticket ID: " + tid)
+ .setFooter({ text: "Ticket ID: " + tid })
}).catch((e4) => {
tid = "./reports/Telemetry-Crash-" + (new Date().toISOString().replace(/[^a-zA-Z0-9]/gm, "-")) + ".txt";
fs.writeFileSync(tid, "-------------------------\nPonyfind Telemetry Report\n-------------------------\n\nReport Type:\n System Crash Report\n\n-------------------------\n\nReporter:\n " + interaction.user.tag + " (" + interaction.user.id + ")\n\nServer:\n " + (interaction.guild ? interaction.guild.name : "[Direct Messages]") + " (" + (interaction.guild ? interaction.guild.id : 0) + ")\n\nChannel:\n " + (interaction.channel ? interaction.channel.name : "[Direct Messages]") + " (" + (interaction.channel ? interaction.channel.id : 0) + ")\n\nItem:\n -\n\nReport Type:\n Automated Error Report (chained with " + e.message + ", " + e2.message + " and " + e3.message + ")\n\n-------------------------\n\n" + e4.stack)
@@ -47,7 +47,7 @@ module.exports = async (interaction, e) => {
.setColor('#dc2828')
.setTitle("4 internal exceptions occurred")
.setDescription("That's not your fault! The developers have already been informed about the issue and will resolve it as soon as possible. We additionally weren't able to deliver you a localized error message, through a reply to your command and/or through the channel you initially executed the command.")]
- .setFooter("Ticket ID: " + tid)
+ .setFooter({ text: "Ticket ID: " + tid })
})
})
} catch (e) {}
diff --git a/handler/menu.js b/handler/menu.js
index 4b0f313..6552735 100644
--- a/handler/menu.js
+++ b/handler/menu.js
@@ -15,7 +15,7 @@ module.exports = async (interaction) => {
.setColor('#28dc46')
.setTitle(l("Thanks for reporting an issue with", "Merci d'avoir signalé un problème avec", interaction.user.id, interaction.guild ? interaction.guild.id : 0) + " \"" + keys[1] + "\"" + l("!", " !", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
.setDescription(l("Your report has been sent to the developers. They can contact you later if your settings allow this to ask you more about your issue.\nThanks for your help!", "Votre rapport a bien été envoyé aux développeurs. Ils pourront vous recontacter si vos paramètres le permettent afin de vous poser plus de questions sur le problème que vous rencontrez.\nMerci d'aider à améliorer notre système !", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- .setFooter("Ticket ID: " + tid)
+ .setFooter({ text: "Ticket ID: " + tid })
]
});
} else {
diff --git a/modules/embed.js b/modules/embed.js
index 49ab4a3..b3b1a79 100644
--- a/modules/embed.js
+++ b/modules/embed.js
@@ -2,6 +2,7 @@ const { MessageEmbed } = require("discord.js");
const fs = require('fs');
const data = require('../data/data.json');
+const getKindIcon = require("./kind");
const cuties = fs.readFileSync("./config/cuties.txt").toString();
module.exports = (page, id, gid, isPublic, user) => {
@@ -184,8 +185,9 @@ module.exports = (page, id, gid, isPublic, user) => {
let fields = [
{ name: l("Nicknames", "Surnoms", id, gid), value: naming, inline: true },
- { name: l("Sex", "Sexe", id, gid), value: d.sex === "F" ? "♀" : "♂", inline: true },
- { name: l("Kind", "Type", id, gid), value: kind, inline: true },
+ { name: l("Sex", "Sexe", id, gid), value: d.sex === "F" ? "♀ " + l("Female", "Fille", id, gid) : "♂ " + l("Male", "Garçon", id, gid), inline: true },
+ { name: l("Kind", "Type", id, gid), value: getKindIcon(page) + " " + kind, inline: true },
+ { name: l("Generation", "Génération", id, gid), value: getGeneration(page, id, gid) + " " + kind, inline: true },
];
if (spoils[id] === 1 && !isPublic) {
diff --git a/modules/generation.js b/modules/generation.js
new file mode 100644
index 0000000..afb044d
--- /dev/null
+++ b/modules/generation.js
@@ -0,0 +1,18 @@
+const fs = require('fs');
+const db = JSON.parse(fs.readFileSync("./data/data.json").toString());
+
+const icons = require('./icons.js');
+
+module.exports = (pony, uid, gid) => {
+ sel = db[pony];
+ switch (d.generation) {
+ case 4:
+ return icons.generations.g4 + " " + l("Friendship is Magic", "Les amies c'est magique", uid, gid);
+
+ case 5:
+ return icons.generations.g5 + " " + l("A New Generation", "Nouvelle Génération", uid, gid);
+
+ default:
+ return icons.generations.other + " " + l("Other/Unknown", "Autre/inconnu", uid, gid);
+ }
+} \ No newline at end of file
diff --git a/modules/icons.js b/modules/icons.js
new file mode 100644
index 0000000..dde0879
--- /dev/null
+++ b/modules/icons.js
@@ -0,0 +1,16 @@
+const fs = require('fs');
+
+module.exports = {
+ kind: {
+ alicorn: fs.readFileSync("./config/icons/kind_alicorn.txt").toString().trim(),
+ earth: fs.readFileSync("./config/icons/kind_earth.txt").toString().trim(),
+ other: fs.readFileSync("./config/icons/kind_other.txt").toString().trim(),
+ pegasus: fs.readFileSync("./config/icons/kind_pegasus.txt").toString().trim(),
+ unicorn: fs.readFileSync("./config/icons/kind_unicorn.txt").toString().trim(),
+ },
+ generations: {
+ g4: fs.readFileSync("./config/icons/gen_4.txt").toString().trim(),
+ g5: fs.readFileSync("./config/icons/gen_5.txt").toString().trim(),
+ other: fs.readFileSync("./config/icons/unknown.txt").toString().trim(),
+ }
+} \ No newline at end of file
diff --git a/modules/kind.js b/modules/kind.js
new file mode 100644
index 0000000..205014e
--- /dev/null
+++ b/modules/kind.js
@@ -0,0 +1,24 @@
+const fs = require('fs');
+const db = JSON.parse(fs.readFileSync("./data/data.json").toString());
+
+const icons = require('./icons.js');
+
+module.exports = (pony) => {
+ sel = db[pony];
+ switch (d.kind) {
+ case "Pegasus":
+ return icons.kind.pegasus;
+
+ case "Earth":
+ return icons.kind.earth;
+
+ case "Unicorn":
+ return icons.kind.unicorn;
+
+ case "Alicorn":
+ return icons.kind.alicorn;
+
+ default:
+ return icons.kind.other;
+ }
+} \ No newline at end of file
diff --git a/modules/result.js b/modules/result.js
index 42419ec..d83c550 100644
--- a/modules/result.js
+++ b/modules/result.js
@@ -32,8 +32,6 @@ module.exports = (query) => {
}
}
- console.log(first);
-
return {
results,
first,
diff --git a/update/infobox.js b/update/infobox.js
index e27177e..b94080c 100644
--- a/update/infobox.js
+++ b/update/infobox.js
@@ -12,6 +12,7 @@ console.log("Gathering infobox for each page...");
try {
let data = (await axios.get("https://mlp.fandom.com/api.php?action=query&prop=revisions&titles=" + page.name + "&rvslots=*&rvprop=content&formatversion=2&format=json")).data;
let mwextracts = (await axios.get("https://mlp.fandom.com/api.php?format=json&action=query&prop=extracts&exlimit=max&explaintext&exintro&titles=" + encodeURI(page.name) + "&redirects=")).data;
+ let mwtext = (await axios.get("https://mlp.fandom.com/api.php?format=json&action=query&prop=extracts&exlimit=max&explaintext&titles=" + encodeURI(page.name) + "&redirects=")).data;
let extracts = "";
try {
sentences = mwextracts.query.pages[Object.keys(mwextracts.query.pages)[0]].extract.replace(/(.*)\n(.*)/, "$2").replace(/(.*)\n\n(.*)/gm, "$2").replace(/([.?!])\s*(?=[A-Z])/g, "$1|").split("|");
@@ -47,6 +48,20 @@ console.log("Gathering infobox for each page...");
} else {
console.log("No results found, ignoring name");
}
+ try {
+ if (mwtext.query.pages[Object.keys(mwextracts.query.pages)[0]].extract.toLowerCase().includes("friendship is magic")
+ || mwtext.query.pages[Object.keys(mwextracts.query.pages)[0]].extract.toLowerCase().includes("fim")
+ ) {
+ infoboxes[page.name]["_gen"] = 4;
+ } else if (mwtext.query.pages[Object.keys(mwextracts.query.pages)[0]].extract.toLowerCase().includes("a new generation")
+ || mwtext.query.pages[Object.keys(mwextracts.query.pages)[0]].extract.toLowerCase().includes("ang")
+ || mwtext.query.pages[Object.keys(mwextracts.query.pages)[0]].extract.toLowerCase().includes("ang")
+ ) {
+ infoboxes[page.name]["_gen"] = 5;
+ } else {
+ infoboxes[page.name]["_gen"] = -1;
+ }
+ } catch(e) {}
} catch (e) {
console.error(e);
}
diff --git a/update/parse.js b/update/parse.js
index 088e8d2..ebcd9e3 100644
--- a/update/parse.js
+++ b/update/parse.js
@@ -13,6 +13,7 @@ let ponies = {};
names: [title],
extract: "",
extract_fr: "",
+ generation: -1,
color: "000000",
image: "https://example.com",
kind: "Pony",
@@ -22,6 +23,8 @@ let ponies = {};
mark: "https://example.com"
}
+ if (typeof box._gen !== "undefined") data.generation = box._gen;
+
if (typeof box.name2 !== "undefined") data.names.push(box.name2.replace(/<!--[\s\S]*?-->/g, ""));
if (typeof box.name3 !== "undefined") data.names.push(box.name3.replace(/<!--[\s\S]*?-->/g, ""));
if (typeof box.name4 !== "undefined") data.names.push(box.name4.replace(/<!--[\s\S]*?-->/g, ""));