aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO1
-rw-r--r--bot.js2
-rw-r--r--commands/config.js159
-rw-r--r--commands/eval.js49
-rw-r--r--commands/help.js33
-rw-r--r--commands/info.js78
-rw-r--r--commands/pony.js73
-rw-r--r--commands/random.js43
-rw-r--r--config/cuties.txt1
-rw-r--r--config/version.txt2
-rw-r--r--handler/button.js118
-rw-r--r--handler/command.js341
-rw-r--r--modules/embed.js24
-rw-r--r--modules/registers.js3
-rw-r--r--update/infobox.js9
-rw-r--r--user/spoilers.json3
16 files changed, 588 insertions, 351 deletions
diff --git a/TODO b/TODO
index ba163a6..e69de29 100644
--- a/TODO
+++ b/TODO
@@ -1 +0,0 @@
-- /random \ No newline at end of file
diff --git a/bot.js b/bot.js
index 978544b..2cdcce8 100644
--- a/bot.js
+++ b/bot.js
@@ -25,6 +25,7 @@ const errorHandler = require('./handler/errors');
global.langs = JSON.parse(fs.readFileSync("./user/userdata.json"));
global.spoils = JSON.parse(fs.readFileSync("./user/spoilers.json"));
global.servers = JSON.parse(fs.readFileSync("./user/servers.json"));
+global.cooldowns = {};
global.l = (en, fr, id, gid) => {
if (typeof servers[gid] !== "undefined") {
@@ -45,6 +46,7 @@ global.l = (en, fr, id, gid) => {
const commands = require('./modules/registers');
client.on('ready', async () => {
+ client.user.setActivity("/help", { type: "LISTENING" })
console.log(`Logged in as ${client.user.tag}!`);
console.log("Started refreshing application (/) commands globally");
diff --git a/commands/config.js b/commands/config.js
new file mode 100644
index 0000000..d8e8d16
--- /dev/null
+++ b/commands/config.js
@@ -0,0 +1,159 @@
+const fs = require('fs');
+const { MessageActionRow, MessageButton, MessageSelectMenu, MessageEmbed } = require('discord.js');
+
+const admin = fs.readFileSync("./config/admin.txt").toString().trim();
+const list = Object.keys(JSON.parse(fs.readFileSync("./data/data.json").toString()));
+
+const getResult = require('../modules/result');
+const getEmbed = require('../modules/embed');
+const getPixel = require("../modules/pixel");
+
+const official = fs.readFileSync("./config/official.txt").toString().replace(/\r\n/g, "\n").split("\n");
+const fpserver = fs.readFileSync("./config/fpserver.txt").toString().trim();
+
+module.exports = async (interaction) => {
+ if (interaction.options.getSubcommand() === 'serverlang') {
+ if (interaction.guild === null) {
+ await interaction.reply({
+ ephemeral: false,
+ embeds: [
+ new MessageEmbed()
+ .setColor('#dc2828')
+ .setTitle(l("Not a server", "Pas un serveur", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setDescription(l("You are trying to run a server-exclusive command in a direct message chat. Please run this command again on a server.", "Vous essayez d'exécuter une commande exclusive aux serveurs dans une conversation en messages privés. Veuillez réessayer cette commande sur un serveur.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ ]
+ });
+ return;
+ }
+
+ if (!interaction.guild.members.resolve(interaction.user).permissions.has("MANAGE_SERVER") && interaction.user.id !== admin) {
+ await interaction.reply({
+ ephemeral: interaction.guild !== null,
+ embeds: [
+ new MessageEmbed()
+ .setColor('#dc2828')
+ .setTitle(l("Permission denied", "Accès refusé", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setDescription(l("You don't have sufficient permission to run this command. You need to be a bot administrator, or have the **Manage Server** permission.", "Vous ne disposez pas de permissions suffisantes pour exécuter cette commande. Vous devez être administrateur(ice) de robot, ou avoir la permission **Gérer le serveur**.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ ]
+ });
+ return;
+ }
+
+ lang = interaction.options.getString('locale');
+ if (lang === "fr") {
+ servers[interaction.guild ? interaction.guild.id : 0] = "fr";
+ } else if (lang === "en") {
+ servers[interaction.guild ? interaction.guild.id : 0] = "en";
+ } else {
+ delete servers[interaction.guild ? interaction.guild.id : 0];
+ }
+ fs.writeFileSync("./user/servers.json", JSON.stringify(servers, null, 4));
+ if (lang === "en" || lang === "fr") {
+ await interaction.reply({
+ ephemeral: interaction.guild !== null,
+ embeds: [
+ new MessageEmbed()
+ .setColor('#28dc46')
+ .setTitle(l("Server language settings", "Paramètres de langue du serveur", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setDescription(l("This server's enforced language is now **English**.", "La langue forcée sur ce serveur est maintenant le **français**.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ ]
+ });
+ } else {
+ await interaction.reply({
+ ephemeral: interaction.guild !== null,
+ embeds: [
+ new MessageEmbed()
+ .setColor('#28dc46')
+ .setTitle(l("Server language settings", "Paramètres de langue du serveur", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setDescription(l("This server's enforced language is the user's prefered language.", "La langue forcée sur ce serveur est la langue de l'utilisateur.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ ]
+ });
+ }
+ }
+
+ if (interaction.options.getSubcommand() === 'lang') {
+ lang = interaction.options.getString('locale');
+ if (lang === "fr") {
+ langs[interaction.user.id] = "fr";
+ } else {
+ langs[interaction.user.id] = "en";
+ }
+ fs.writeFileSync("./user/userdata.json", JSON.stringify(langs, null, 4));
+ if (typeof servers[interaction.guild ? interaction.guild.id : 0] !== "undefined") {
+ if (lang === "fr") {
+ await interaction.reply({
+ ephemeral: interaction.guild !== null,
+ embeds: [
+ new MessageEmbed()
+ .setColor('#28dc46')
+ .setTitle(l("Language settings", "Paramètres de langue", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setDescription(l("Your preferred language is now **French**.\n\n> **Note:** This server enforces English for all users, your personal preferred language won't apply here.", "Votre langue principale est maintenant le **français**.\n\n> **Note :** Ce serveur oblige l'utilisation du français pour tous les utilisateurs, votre option de langue personelle ne s'appliquera pas ici.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ ]
+ });
+ } else {
+ await interaction.reply({
+ ephemeral: interaction.guild !== null,
+ embeds: [
+ new MessageEmbed()
+ .setColor('#28dc46')
+ .setTitle(l("Language settings", "Paramètres de langue", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setDescription(l("Your preferred language is now **English**.\n\n> **Note:** This server enforces English for all users, your personal preferred language won't apply here.", "Votre langue principale est maintenant le **anglais**.\n\n> **Note :** Ce serveur oblige l'utilisation du français pour tous les utilisateurs, votre option de langue personelle ne s'appliquera pas ici.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ ]
+ });
+ }
+ } else {
+ await interaction.reply({
+ ephemeral: interaction.guild !== null,
+ embeds: [
+ new MessageEmbed()
+ .setColor('#28dc46')
+ .setTitle(l("Language settings", "Paramètres de langue", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setDescription(l("Your preferred language is now **English**.", "Votre langue principale est maintenant le **français**.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ ]
+ });
+ }
+ }
+
+ if (interaction.options.getSubcommand() === 'spoilers') {
+ v = interaction.options.getString('status');
+ if (v === "yes") {
+ spoils[interaction.user.id] = 2;
+ } else if (v === "no") {
+ spoils[interaction.user.id] = 0;
+ } else {
+ spoils[interaction.user.id] = 1;
+ }
+ fs.writeFileSync("./user/spoilers.json", JSON.stringify(spoils, null, 4));
+ if (v === "yes") {
+ await interaction.reply({
+ ephemeral: interaction.guild !== null,
+ embeds: [
+ new MessageEmbed()
+ .setColor('#28dc46')
+ .setTitle(l("Spoilers settings", "Paramètres des révélations", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setDescription(l("Spoilers are now **always shown**.", "Les révélations sont désormais **toujours affichées**.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ ]
+ });
+ } else if (v === "no") {
+ await interaction.reply({
+ ephemeral: interaction.guild !== null,
+ embeds: [
+ new MessageEmbed()
+ .setColor('#28dc46')
+ .setTitle(l("Spoilers settings", "Paramètres des révélations", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setDescription(l("Spoilers are now **always hidden**.", "Les révélations sont désormais **toujours masquées**.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ ]
+ });
+ } else {
+ await interaction.reply({
+ ephemeral: interaction.guild !== null,
+ embeds: [
+ new MessageEmbed()
+ .setColor('#28dc46')
+ .setTitle(l("Spoilers settings", "Paramètres des révélations", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setDescription(l("Spoilers are now **hidden under spoiler tags**.", "Les révélations sont désormais **masqués derrière des tags révélation**.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ ]
+ });
+ }
+ }
+} \ No newline at end of file
diff --git a/commands/eval.js b/commands/eval.js
new file mode 100644
index 0000000..49c8162
--- /dev/null
+++ b/commands/eval.js
@@ -0,0 +1,49 @@
+const fs = require('fs');
+const { MessageActionRow, MessageButton, MessageSelectMenu, MessageEmbed } = require('discord.js');
+
+const admin = fs.readFileSync("./config/admin.txt").toString().trim();
+const list = Object.keys(JSON.parse(fs.readFileSync("./data/data.json").toString()));
+
+const getResult = require('../modules/result');
+const getEmbed = require('../modules/embed');
+const getPixel = require("../modules/pixel");
+
+const official = fs.readFileSync("./config/official.txt").toString().replace(/\r\n/g, "\n").split("\n");
+const fpserver = fs.readFileSync("./config/fpserver.txt").toString().trim();
+
+module.exports = async (interaction) => {
+ if (interaction.user.id !== admin) {
+ await interaction.reply({
+ ephemeral: interaction.guild !== null,
+ embeds: [
+ new MessageEmbed()
+ .setColor('#dc2828')
+ .setTitle(l("Permission denied", "Accès refusé", interaction.user.id, 0))
+ .setDescription(l("You don't have sufficient permission to run this command. You need to be a bot administrator, or have the **Manage Server** permission.", "Vous ne disposez pas de permissions suffisantes pour exécuter cette commande. Vous devez être administrateur(ice) de robot, ou avoir la permission **Gérer le serveur**.", interaction.user.id, 0))
+ ]
+ });
+ return;
+ }
+
+ try {
+ await interaction.reply({
+ ephemeral: interaction.guild !== null,
+ embeds: [
+ new MessageEmbed()
+ .setColor('#28dc46')
+ .setTitle("JavaScript")
+ .setDescription("```\n" + await eval(interaction.options.getString("code")).toString().replace(/`/g, "\\`") + "\n```")
+ ]
+ });
+ } catch (e) {
+ await interaction.reply({
+ ephemeral: interaction.guild !== null,
+ embeds: [
+ new MessageEmbed()
+ .setColor('#dc2828')
+ .setTitle("JavaScript")
+ .setDescription("```\n" + e.stack + "\n```")
+ ]
+ });
+ }
+} \ No newline at end of file
diff --git a/commands/help.js b/commands/help.js
new file mode 100644
index 0000000..2f9524e
--- /dev/null
+++ b/commands/help.js
@@ -0,0 +1,33 @@
+const fs = require('fs');
+const { MessageActionRow, MessageButton, MessageSelectMenu, MessageEmbed } = require('discord.js');
+
+const admin = fs.readFileSync("./config/admin.txt").toString().trim();
+const list = Object.keys(JSON.parse(fs.readFileSync("./data/data.json").toString()));
+
+const getResult = require('../modules/result');
+const getEmbed = require('../modules/embed');
+const getPixel = require("../modules/pixel");
+
+const official = fs.readFileSync("./config/official.txt").toString().replace(/\r\n/g, "\n").split("\n");
+const fpserver = fs.readFileSync("./config/fpserver.txt").toString().trim();
+
+module.exports = async (interaction) => {
+ let fields = [
+ { name: l("Search for a pony", "Rechercher un poney", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: l("With the `/pony` command, you can search for any known pony from My Little Pony generations 4 and 5.", "Avec la commande `/pony`, vous pouvez chercher n'importe quel poney de My Little Pony générations 4 ou 5.", interaction.user.id, interaction.guild ? interaction.guild.id : 0) },
+ { name: l("Enable or disable spoilers", "Activer ou désactiver le révélations", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: l("With `/config spoilers`, you can adjust whether or not you want to see spoilers.", "Avec `/config spoilers`, vous pouvez ajuster si vous voulez ou non voir des révélations.", interaction.user.id, interaction.guild ? interaction.guild.id : 0) },
+ { name: l("Get stats about the bot", "Obtenir des statistiques sur le robot", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: l("`/info` helps you get stats and other useful information about the bot and its inner workings.", "`/info` vous permet d'obtenir des statistiques ainsi que d'autres informations utiles à propos du robot et de son fonctionnement.", interaction.user.id, interaction.guild ? interaction.guild.id : 0) },
+ { name: l("Add some more magic!", "Ajouter encore plus de magie !", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: l("Try `/random`, you will be surprised!.", "Essayez `/random`, vous serez surpris(e) !", interaction.user.id, interaction.guild ? interaction.guild.id : 0) },
+ ];
+
+ await interaction.reply({
+ ephemeral: interaction.guild !== null,
+ embeds: [
+ new MessageEmbed()
+ .setColor('#d6dc28')
+ .setTitle(l("Ponyfind help", "Aide de Ponyfind", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setDescription(l("Thanks for using Ponyfind! If you're confused or don't know where to start, you've executed the right command.", "Merci d'utiliser Ponyfind ! Si vous êtes confus(e) et/ou que vous ne savez pas par où commencer, vous êtes au bon endroit.", interaction.user.id, interaction.guild ? interaction.guild.id : 0) + "\n\n> :information_source: " + l("**Vous parlez français ?** Exécutez `/config lang Français` pour changer la langue", "**You speak English?** Run `/config lang English` to change the language", 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))
+ ]
+ });
+} \ No newline at end of file
diff --git a/commands/info.js b/commands/info.js
new file mode 100644
index 0000000..d6d25b0
--- /dev/null
+++ b/commands/info.js
@@ -0,0 +1,78 @@
+const fs = require('fs');
+const { MessageActionRow, MessageButton, MessageSelectMenu, MessageEmbed } = require('discord.js');
+
+const admin = fs.readFileSync("./config/admin.txt").toString().trim();
+const list = Object.keys(JSON.parse(fs.readFileSync("./data/data.json").toString()));
+
+const getResult = require('../modules/result');
+const getEmbed = require('../modules/embed');
+const getPixel = require("../modules/pixel");
+
+const official = fs.readFileSync("./config/official.txt").toString().replace(/\r\n/g, "\n").split("\n");
+const fpserver = fs.readFileSync("./config/fpserver.txt").toString().trim();
+
+function bytesToPretty(bytes) {
+ if (bytes > 1000) {
+ if (bytes > 1000000) {
+ return (bytes / 1000000).toFixed(2) + " MB";
+ } else {
+ return (bytes / 1000).toFixed(2) + " KB";
+ }
+ } else {
+ return bytes + " B";
+ }
+}
+
+function secondsToPretty(seconds) {
+ if (seconds > 60) {
+ if (seconds > 3600) {
+ if (seconds > 216000) {
+ return Math.floor(seconds / 216000) + " day" + (Math.floor(seconds / 216000) > 1 ? "s" : "");
+ } else {
+ return Math.floor(seconds / 3600) + " hour" + (Math.floor(seconds / 3600) > 1 ? "s" : "");
+ }
+ } else {
+ return Math.floor(seconds / 60) + " minute" + (Math.floor(seconds / 60) > 1 ? "s" : "");
+ }
+ } else {
+ return Math.floor(seconds) + " second" + (Math.floor(seconds) > 1 ? "s" : "");
+ }
+}
+
+module.exports = async (interaction) => {
+ let suffix = "";
+ if (official.includes(interaction.guild ? interaction.guild.id : 0)) {
+ 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();
+ }
+ }
+
+ let size = 0;
+ for (let file of fs.readdirSync("./data")) size += fs.readFileSync("./data/" + file).length;
+ let sizep = bytesToPretty(size);
+
+ let fields = [
+ { name: l("Software version", "Version du logiciel", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: "v" + fs.readFileSync("./config/version.txt") + "." + fs.readFileSync("./.git/refs/heads/trunk").toString().substr(0, 8) + suffix + " (#" + client.shard.count + ")", inline: false },
+ { name: l("Kernel version", "Version du noyau", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: process.version, inline: true },
+ { name: l("Experience channel", "Canal d'expériences", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: channel, inline: true },
+ { name: l("Known ponies", "Poneys connus", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: Object.keys(JSON.parse(fs.readFileSync("./data/data.json").toString())).length.toString(), inline: true },
+ { name: l("Awaiting issue reports", "Rapports de problèmes en attente", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: fs.readdirSync("./reports").length.toString(), inline: true },
+ { name: l("Database size", "Taille de la base de données", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: sizep, inline: true },
+ { name: l("Memory usage", "Utilisation de la mémoire", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: bytesToPretty(process.memoryUsage().rss + process.memoryUsage().heapTotal + process.memoryUsage().external + process.memoryUsage().arrayBuffers), inline: true },
+ { name: l("Uptime", "Durée de fonctionnement", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: secondsToPretty(process.uptime()), inline: true },
+ ];
+
+ await interaction.reply({
+ ephemeral: interaction.guild !== null,
+ embeds: [
+ new MessageEmbed()
+ .setColor('#d6dc28')
+ .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))
+ ]
+ });
+} \ No newline at end of file
diff --git a/commands/pony.js b/commands/pony.js
new file mode 100644
index 0000000..c386107
--- /dev/null
+++ b/commands/pony.js
@@ -0,0 +1,73 @@
+const fs = require('fs');
+const { MessageActionRow, MessageButton, MessageSelectMenu, MessageEmbed } = require('discord.js');
+
+const admin = fs.readFileSync("./config/admin.txt").toString().trim();
+const list = Object.keys(JSON.parse(fs.readFileSync("./data/data.json").toString()));
+
+const getResult = require('../modules/result');
+const getEmbed = require('../modules/embed');
+const getPixel = require("../modules/pixel");
+
+const official = fs.readFileSync("./config/official.txt").toString().replace(/\r\n/g, "\n").split("\n");
+const fpserver = fs.readFileSync("./config/fpserver.txt").toString().trim();
+
+module.exports = async (interaction) => {
+ query = interaction.options.getString('query');
+ result = getResult(query);
+
+ if (result.results.length > 0 && getEmbed(result.results[0], interaction.user.id, interaction.guild ? interaction.guild.id : 0) !== false) {
+ await interaction.reply({
+ ephemeral: interaction.guild !== null,
+ embeds: [
+ new MessageEmbed()
+ .setColor('#d6dc28')
+ .setTitle(l("Results for", "Résultats pour", interaction.user.id, interaction.guild ? interaction.guild.id : 0) + " \"" + query + "\"")
+ .setDescription(l("Here are the 3 first results corresponding to your query.", "Voici les 3 premiers résultats correspondants à votre recherche.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ ],
+ components: [
+ new MessageActionRow()
+ .addComponents(
+ new MessageButton()
+ .setCustomId("pony.display|" + result.first[0])
+ .setLabel(result.first[0])
+ .setStyle("PRIMARY"),
+ new MessageButton()
+ .setCustomId("pony.display|" + result.first[1])
+ .setLabel(result.first[1])
+ .setStyle("PRIMARY"),
+ new MessageButton()
+ .setCustomId("pony.display|" + result.first[2])
+ .setLabel(result.first[2])
+ .setStyle("PRIMARY"),
+ new MessageButton()
+ .setCustomId("result.report|" + query)
+ .setLabel(l("Report an issue", "Signaler un problème", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setStyle("DANGER")
+ )
+ ]
+ });
+ } else {
+ await interaction.reply({
+ ephemeral: interaction.guild !== null,
+ embeds: [
+ new MessageEmbed()
+ .setColor('#dc2828')
+ .setTitle(l("Results for", "Résultats pour", interaction.user.id, interaction.guild ? interaction.guild.id : 0) + " \"" + query + "\"")
+ .setDescription(l("No results found. Please try with other keywords.", "Aucun résultat trouvé. Essayez avec d'autres mots clés.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ ],
+ components: [
+ new MessageActionRow()
+ .addComponents(
+ new MessageButton()
+ .setCustomId("result.suggest|" + query)
+ .setLabel(l("Suggest a missing pony", "Proposer un poney manquant", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setStyle("SECONDARY"),
+ new MessageButton()
+ .setCustomId("result.report|" + query)
+ .setLabel(l("Report an issue", "Signaler un problème", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setStyle("DANGER")
+ )
+ ]
+ });
+ }
+} \ No newline at end of file
diff --git a/commands/random.js b/commands/random.js
new file mode 100644
index 0000000..9ac50e2
--- /dev/null
+++ b/commands/random.js
@@ -0,0 +1,43 @@
+const fs = require('fs');
+const { MessageActionRow, MessageButton, MessageSelectMenu, MessageEmbed } = require('discord.js');
+
+const admin = fs.readFileSync("./config/admin.txt").toString().trim();
+const list = Object.keys(JSON.parse(fs.readFileSync("./data/data.json").toString()));
+
+const getResult = require('../modules/result');
+const getEmbed = require('../modules/embed');
+const getPixel = require("../modules/pixel");
+
+const official = fs.readFileSync("./config/official.txt").toString().replace(/\r\n/g, "\n").split("\n");
+const fpserver = fs.readFileSync("./config/fpserver.txt").toString().trim();
+
+module.exports = async (interaction) => {
+ keys = [
+ null,
+ list[Math.floor(Math.random() * list.length)]
+ ]
+ await interaction.reply({
+ ephemeral: interaction.guild !== null,
+ embeds: [
+ getEmbed(keys[1], interaction.user.id, interaction.guild ? interaction.guild.id : 0)
+ ],
+ components: [
+ new MessageActionRow()
+ .addComponents(
+ new MessageButton()
+ .setLabel(l("Read More", "Lire plus", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setStyle("LINK")
+ .setURL("https://mlp.fandom.com/wiki/" + encodeURI(keys[1])),
+ new MessageButton()
+ .setCustomId("pony.pixel|" + keys[1])
+ .setLabel("Pixel Art")
+ .setDisabled(!fs.existsSync("./pixel/" + keys[1].toLowerCase()))
+ .setStyle("SECONDARY"),
+ new MessageButton()
+ .setCustomId("result.report|" + keys[1])
+ .setLabel(l("Report an issue", "Signaler un problème", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setStyle("DANGER")
+ )
+ ]
+ });
+} \ No newline at end of file
diff --git a/config/cuties.txt b/config/cuties.txt
new file mode 100644
index 0000000..c9750d6
--- /dev/null
+++ b/config/cuties.txt
@@ -0,0 +1 @@
+<:cutie_mark_crusaders:929783547944923288> \ No newline at end of file
diff --git a/config/version.txt b/config/version.txt
index b1d7abc..bcaffe1 100644
--- a/config/version.txt
+++ b/config/version.txt
@@ -1 +1 @@
-0.6.2 \ No newline at end of file
+0.7.0 \ No newline at end of file
diff --git a/handler/button.js b/handler/button.js
index c159071..9cfbf95 100644
--- a/handler/button.js
+++ b/handler/button.js
@@ -9,30 +9,114 @@ module.exports = async (interaction) => {
keys = interaction.customId.split("|")
if (keys[0] === "pony.display") {
+ let row;
+ if (interaction.guild) {
+ row = new MessageActionRow()
+ .addComponents(
+ new MessageButton()
+ .setCustomId("pony.public|" + keys[1])
+ .setLabel(l("Show to everypony", "Afficher à tous", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setStyle("PRIMARY"),
+ new MessageButton()
+ .setLabel(l("Read More", "Lire plus", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setStyle("LINK")
+ .setURL("https://mlp.fandom.com/wiki/" + encodeURI(keys[1])),
+ new MessageButton()
+ .setCustomId("pony.pixel|" + keys[1])
+ .setLabel("Pixel Art")
+ .setDisabled(!fs.existsSync("./pixel/" + keys[1].toLowerCase()))
+ .setStyle("SECONDARY"),
+ new MessageButton()
+ .setCustomId("result.report|" + keys[1])
+ .setLabel(l("Report an issue", "Signaler un problème", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setStyle("DANGER")
+ )
+ } else {
+ row = new MessageActionRow()
+ .addComponents(
+ new MessageButton()
+ .setLabel(l("Read More", "Lire plus", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setStyle("LINK")
+ .setURL("https://mlp.fandom.com/wiki/" + encodeURI(keys[1])),
+ new MessageButton()
+ .setCustomId("pony.pixel|" + keys[1])
+ .setLabel("Pixel Art")
+ .setDisabled(!fs.existsSync("./pixel/" + keys[1].toLowerCase()))
+ .setStyle("SECONDARY"),
+ new MessageButton()
+ .setCustomId("result.report|" + keys[1])
+ .setLabel(l("Report an issue", "Signaler un problème", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setStyle("DANGER")
+ )
+ }
await interaction.reply({
ephemeral: interaction.guild !== null,
embeds: [
- getEmbed(keys[1], interaction.user.id, interaction.guild ? interaction.guild.id : 0)
+ getEmbed(keys[1], interaction.user.id, interaction.guild ? interaction.guild.id : 0, false, interaction.user)
],
components: [
- new MessageActionRow()
- .addComponents(
- new MessageButton()
- .setLabel(l("Read More", "Lire plus", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- .setStyle("LINK")
- .setURL("https://mlp.fandom.com/wiki/" + encodeURI(keys[1])),
- new MessageButton()
- .setCustomId("pony.pixel|" + keys[1])
- .setLabel("Pixel Art")
- .setDisabled(!fs.existsSync("./pixel/" + keys[1].toLowerCase()))
- .setStyle("SECONDARY"),
- new MessageButton()
- .setCustomId("result.report|" + keys[1])
- .setLabel(l("Report an issue", "Signaler un problème", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- .setStyle("DANGER")
- )
+ row
]
});
+ } else if (keys[0] === "pony.public") {
+ if (typeof cooldowns[interaction.user.id] !== "undefined" && new Date() - cooldowns[interaction.user.id] < 30000) {
+ await interaction.reply({
+ ephemeral: interaction.guild !== null,
+ embeds: [
+ new MessageEmbed()
+ .setColor('#dc2828')
+ .setTitle(l("Calm down!", "Calmez-vous !", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setDescription(l("Please wait " + Math.ceil((30000 - (new Date() - cooldowns[interaction.user.id]))/1000) + " seconds before you can use this again.", "Patientez encore " + Math.ceil((30000 - (new Date() - cooldowns[interaction.user.id]))/1000) + " secondes avant de pouvoir réutiliser ça.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ ]
+ });
+ } else {
+ try {
+ await interaction.channel.send({
+ ephemeral: false,
+ embeds: [
+ getEmbed(keys[1], interaction.user.id, interaction.guild ? interaction.guild.id : 0, true, interaction.user)
+ ],
+ components: [
+ new MessageActionRow()
+ .addComponents(
+ new MessageButton()
+ .setLabel(l("Read More", "Lire plus", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setStyle("LINK")
+ .setURL("https://mlp.fandom.com/wiki/" + encodeURI(keys[1])),
+ new MessageButton()
+ .setCustomId("pony.pixel|" + keys[1])
+ .setLabel("Pixel Art")
+ .setDisabled(!fs.existsSync("./pixel/" + keys[1].toLowerCase()))
+ .setStyle("SECONDARY"),
+ new MessageButton()
+ .setCustomId("result.report|" + keys[1])
+ .setLabel(l("Report an issue", "Signaler un problème", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setStyle("DANGER")
+ )
+ ]
+ });
+ await interaction.reply({
+ ephemeral: interaction.guild !== null,
+ embeds: [
+ new MessageEmbed()
+ .setColor('#28dc46')
+ .setTitle(l("Show to everypony", "Afficher à tous", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setDescription(l("This pony has been sent publicly to this channel.", "Ce poney a été envoyé publiquement dans ce salon.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ ]
+ });
+ cooldowns[interaction.user.id] = new Date();
+ } catch (e) {
+ await interaction.reply({
+ ephemeral: interaction.guild !== null,
+ embeds: [
+ new MessageEmbed()
+ .setColor('#dc2828')
+ .setTitle(l("Show to everypony", "Afficher à tous", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setDescription(l("We are unable to send a message to this channel, make sure the bot have sufficient permissions.", "Nous ne parvenons pas à envoyer un message dans ce salon, assurez-vous que le robot dispose de sufficient de permissions.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ ]
+ });
+ }
+ }
} else if (keys[0] === "result.report") {
await interaction.reply({
ephemeral: interaction.guild !== null,
diff --git a/handler/command.js b/handler/command.js
index d263204..1447332 100644
--- a/handler/command.js
+++ b/handler/command.js
@@ -11,346 +11,35 @@ const getPixel = require("../modules/pixel");
const official = fs.readFileSync("./config/official.txt").toString().replace(/\r\n/g, "\n").split("\n");
const fpserver = fs.readFileSync("./config/fpserver.txt").toString().trim();
-function bytesToPretty(bytes) {
- if (bytes > 1000) {
- if (bytes > 1000000) {
- return (bytes / 1000000).toFixed(2) + " MB";
- } else {
- return (bytes / 1000).toFixed(2) + " KB";
- }
- } else {
- return bytes + " B";
- }
-}
-
-function secondsToPretty(seconds) {
- if (seconds > 60) {
- if (seconds > 3600) {
- if (seconds > 216000) {
- return Math.floor(seconds / 216000) + " day" + (Math.floor(seconds / 216000) > 1 ? "s" : "");
- } else {
- return Math.floor(seconds / 3600) + " hour" + (Math.floor(seconds / 3600) > 1 ? "s" : "");
- }
- } else {
- return Math.floor(seconds / 60) + " minute" + (Math.floor(seconds / 60) > 1 ? "s" : "");
- }
- } else {
- return Math.floor(seconds) + " second" + (Math.floor(seconds) > 1 ? "s" : "");
- }
-}
+const commandRandom = require('../commands/random');
+const commandInfo = require('../commands/info');
+const commandEval = require('../commands/eval');
+const commandConfig = require('../commands/config');
+const commandPony = require('../commands/pony');
+const commandHelp = require('../commands/help');
module.exports = async (interaction) => {
if (interaction.commandName === 'random') {
- keys = [
- null,
- list[Math.floor(Math.random() * list.length)]
- ]
- await interaction.reply({
- ephemeral: interaction.guild !== null,
- embeds: [
- getEmbed(keys[1], interaction.user.id, interaction.guild ? interaction.guild.id : 0)
- ],
- components: [
- new MessageActionRow()
- .addComponents(
- new MessageButton()
- .setLabel(l("Read More", "Lire plus", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- .setStyle("LINK")
- .setURL("https://mlp.fandom.com/wiki/" + encodeURI(keys[1])),
- new MessageButton()
- .setCustomId("pony.pixel|" + keys[1])
- .setLabel("Pixel Art")
- .setDisabled(!fs.existsSync("./pixel/" + keys[1].toLowerCase()))
- .setStyle("SECONDARY"),
- new MessageButton()
- .setCustomId("result.report|" + keys[1])
- .setLabel(l("Report an issue", "Signaler un problème", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- .setStyle("DANGER")
- )
- ]
- });
+ await commandRandom(interaction);
}
- if (interaction.commandName === 'info') {
- let suffix = "";
- if (official.includes(interaction.guild ? interaction.guild.id : 0)) {
- 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();
- }
- }
-
- let size = 0;
- for (let file of fs.readdirSync("./data")) size += fs.readFileSync("./data/" + file).length;
- let sizep = bytesToPretty(size);
-
- let fields = [
- { name: l("Software version", "Version du logiciel", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: "v" + fs.readFileSync("./config/version.txt") + "." + fs.readFileSync("./.git/refs/heads/trunk").toString().substr(0, 8) + suffix + " (#" + client.shard.count + ")", inline: false },
- { name: l("Kernel version", "Version du noyau", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: process.version, inline: true },
- { name: l("Experience channel", "Canal d'expériences", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: channel, inline: true },
- { name: l("Known ponies", "Poneys connus", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: Object.keys(JSON.parse(fs.readFileSync("./data/data.json").toString())).length.toString(), inline: true },
- { name: l("Awaiting issue reports", "Rapports de problèmes en attente", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: fs.readdirSync("./reports").length.toString(), inline: true },
- { name: l("Database size", "Taille de la base de données", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: sizep, inline: true },
- { name: l("Memory usage", "Utilisation de la mémoire", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: bytesToPretty(process.memoryUsage().rss + process.memoryUsage().heapTotal + process.memoryUsage().external + process.memoryUsage().arrayBuffers), inline: true },
- { name: l("Uptime", "Durée de fonctionnement", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: secondsToPretty(process.uptime()), inline: true },
- ];
+ if (interaction.commandName === 'help') {
+ await commandHelp(interaction);
+ }
- await interaction.reply({
- ephemeral: interaction.guild !== null,
- embeds: [
- new MessageEmbed()
- .setColor('#d6dc28')
- .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))
- ]
- });
+ if (interaction.commandName === 'info') {
+ await commandInfo(interaction);
}
if (interaction.commandName === 'eval') {
- if (interaction.user.id !== admin) {
- await interaction.reply({
- ephemeral: interaction.guild !== null,
- embeds: [
- new MessageEmbed()
- .setColor('#dc2828')
- .setTitle(l("Permission denied", "Accès refusé", interaction.user.id, 0))
- .setDescription(l("You don't have sufficient permission to run this command. You need to be a bot administrator, or have the **Manage Server** permission.", "Vous ne disposez pas de permissions suffisantes pour exécuter cette commande. Vous devez être administrateur(ice) de robot, ou avoir la permission **Gérer le serveur**.", interaction.user.id, 0))
- ]
- });
- return;
- }
-
- try {
- await interaction.reply({
- ephemeral: interaction.guild !== null,
- embeds: [
- new MessageEmbed()
- .setColor('#28dc46')
- .setTitle("JavaScript")
- .setDescription("```\n" + await eval(interaction.options.getString("code")).toString().replace(/`/g, "\\`") + "\n```")
- ]
- });
- } catch (e) {
- await interaction.reply({
- ephemeral: interaction.guild !== null,
- embeds: [
- new MessageEmbed()
- .setColor('#dc2828')
- .setTitle("JavaScript")
- .setDescription("```\n" + e.stack + "\n```")
- ]
- });
- }
+ await commandEval(interaction);
}
if (interaction.commandName === 'config') {
- if (interaction.options.getSubcommand() === 'serverlang') {
- if (interaction.guild === null) {
- await interaction.reply({
- ephemeral: false,
- embeds: [
- new MessageEmbed()
- .setColor('#dc2828')
- .setTitle(l("Not a server", "Pas un serveur", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- .setDescription(l("You are trying to run a server-exclusive command in a direct message chat. Please run this command again on a server.", "Vous essayez d'exécuter une commande exclusive aux serveurs dans une conversation en messages privés. Veuillez réessayer cette commande sur un serveur.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- ]
- });
- return;
- }
-
- if (!interaction.guild.members.resolve(interaction.user).permissions.has("MANAGE_SERVER") && interaction.user.id !== admin) {
- await interaction.reply({
- ephemeral: interaction.guild !== null,
- embeds: [
- new MessageEmbed()
- .setColor('#dc2828')
- .setTitle(l("Permission denied", "Accès refusé", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- .setDescription(l("You don't have sufficient permission to run this command. You need to be a bot administrator, or have the **Manage Server** permission.", "Vous ne disposez pas de permissions suffisantes pour exécuter cette commande. Vous devez être administrateur(ice) de robot, ou avoir la permission **Gérer le serveur**.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- ]
- });
- return;
- }
-
- lang = interaction.options.getString('locale');
- if (lang === "fr") {
- servers[interaction.guild ? interaction.guild.id : 0] = "fr";
- } else if (lang === "en") {
- servers[interaction.guild ? interaction.guild.id : 0] = "en";
- } else {
- delete servers[interaction.guild ? interaction.guild.id : 0];
- }
- fs.writeFileSync("./user/servers.json", JSON.stringify(servers, null, 4));
- if (lang === "en" || lang === "fr") {
- await interaction.reply({
- ephemeral: interaction.guild !== null,
- embeds: [
- new MessageEmbed()
- .setColor('#28dc46')
- .setTitle(l("Server language settings", "Paramètres de langue du serveur", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- .setDescription(l("This server's enforced language is now **English**.", "La langue forcée sur ce serveur est maintenant le **français**.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- ]
- });
- } else {
- await interaction.reply({
- ephemeral: interaction.guild !== null,
- embeds: [
- new MessageEmbed()
- .setColor('#28dc46')
- .setTitle(l("Server language settings", "Paramètres de langue du serveur", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- .setDescription(l("This server's enforced language is the user's prefered language.", "La langue forcée sur ce serveur est la langue de l'utilisateur.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- ]
- });
- }
- }
-
- if (interaction.options.getSubcommand() === 'lang') {
- lang = interaction.options.getString('locale');
- if (lang === "fr") {
- langs[interaction.user.id] = "fr";
- } else {
- langs[interaction.user.id] = "en";
- }
- fs.writeFileSync("./user/userdata.json", JSON.stringify(langs, null, 4));
- if (typeof servers[interaction.guild ? interaction.guild.id : 0] !== "undefined") {
- if (lang === "fr") {
- await interaction.reply({
- ephemeral: interaction.guild !== null,
- embeds: [
- new MessageEmbed()
- .setColor('#28dc46')
- .setTitle(l("Language settings", "Paramètres de langue", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- .setDescription(l("Your preferred language is now **French**.\n\n> **Note:** This server enforces English for all users, your personal preferred language won't apply here.", "Votre langue principale est maintenant le **français**.\n\n> **Note :** Ce serveur oblige l'utilisation du français pour tous les utilisateurs, votre option de langue personelle ne s'appliquera pas ici.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- ]
- });
- } else {
- await interaction.reply({
- ephemeral: interaction.guild !== null,
- embeds: [
- new MessageEmbed()
- .setColor('#28dc46')
- .setTitle(l("Language settings", "Paramètres de langue", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- .setDescription(l("Your preferred language is now **English**.\n\n> **Note:** This server enforces English for all users, your personal preferred language won't apply here.", "Votre langue principale est maintenant le **anglais**.\n\n> **Note :** Ce serveur oblige l'utilisation du français pour tous les utilisateurs, votre option de langue personelle ne s'appliquera pas ici.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- ]
- });
- }
- } else {
- await interaction.reply({
- ephemeral: interaction.guild !== null,
- embeds: [
- new MessageEmbed()
- .setColor('#28dc46')
- .setTitle(l("Language settings", "Paramètres de langue", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- .setDescription(l("Your preferred language is now **English**.", "Votre langue principale est maintenant le **français**.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- ]
- });
- }
- }
-
- if (interaction.options.getSubcommand() === 'spoilers') {
- v = interaction.options.getString('status');
- if (v === "yes") {
- spoils[interaction.user.id] = 2;
- } else if (v === "no") {
- spoils[interaction.user.id] = 0;
- } else {
- spoils[interaction.user.id] = 1;
- }
- fs.writeFileSync("./user/spoilers.json", JSON.stringify(spoils, null, 4));
- if (v === "yes") {
- await interaction.reply({
- ephemeral: interaction.guild !== null,
- embeds: [
- new MessageEmbed()
- .setColor('#28dc46')
- .setTitle(l("Spoilers settings", "Paramètres des révélations", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- .setDescription(l("Spoilers are now **always shown**.", "Les révélations sont désormais **toujours affichées**.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- ]
- });
- } else if (v === "no") {
- await interaction.reply({
- ephemeral: interaction.guild !== null,
- embeds: [
- new MessageEmbed()
- .setColor('#28dc46')
- .setTitle(l("Spoilers settings", "Paramètres des révélations", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- .setDescription(l("Spoilers are now **always hidden**.", "Les révélations sont désormais **toujours masquées**.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- ]
- });
- } else {
- await interaction.reply({
- ephemeral: interaction.guild !== null,
- embeds: [
- new MessageEmbed()
- .setColor('#28dc46')
- .setTitle(l("Spoilers settings", "Paramètres des révélations", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- .setDescription(l("Spoilers are now **hidden under spoiler tags**.", "Les révélations sont désormais **masqués derrière des tags révélation**.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- ]
- });
- }
- }
+ await commandConfig(interaction);
}
if (interaction.commandName === 'pony') {
- query = interaction.options.getString('query');
- result = getResult(query);
-
- if (result.results.length > 0 && getEmbed(result.results[0], interaction.user.id, interaction.guild ? interaction.guild.id : 0) !== false) {
- await interaction.reply({
- ephemeral: interaction.guild !== null,
- embeds: [
- new MessageEmbed()
- .setColor('#d6dc28')
- .setTitle(l("Results for", "Résultats pour", interaction.user.id, interaction.guild ? interaction.guild.id : 0) + " \"" + query + "\"")
- .setDescription(l("Here are the 3 first results corresponding to your query.", "Voici les 3 premiers résultats correspondants à votre recherche.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- ],
- components: [
- new MessageActionRow()
- .addComponents(
- new MessageButton()
- .setCustomId("pony.display|" + result.first[0])
- .setLabel(result.first[0])
- .setStyle("PRIMARY"),
- new MessageButton()
- .setCustomId("pony.display|" + result.first[1])
- .setLabel(result.first[1])
- .setStyle("PRIMARY"),
- new MessageButton()
- .setCustomId("pony.display|" + result.first[2])
- .setLabel(result.first[2])
- .setStyle("PRIMARY"),
- new MessageButton()
- .setCustomId("result.report|" + query)
- .setLabel(l("Report an issue", "Signaler un problème", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- .setStyle("DANGER")
- )
- ]
- });
- } else {
- await interaction.reply({
- ephemeral: interaction.guild !== null,
- embeds: [
- new MessageEmbed()
- .setColor('#dc2828')
- .setTitle(l("Results for", "Résultats pour", interaction.user.id, interaction.guild ? interaction.guild.id : 0) + " \"" + query + "\"")
- .setDescription(l("No results found. Please try with other keywords.", "Aucun résultat trouvé. Essayez avec d'autres mots clés.", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- ],
- components: [
- new MessageActionRow()
- .addComponents(
- new MessageButton()
- .setCustomId("result.suggest|" + query)
- .setLabel(l("Suggest a missing pony", "Proposer un poney manquant", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- .setStyle("SECONDARY"),
- new MessageButton()
- .setCustomId("result.report|" + query)
- .setLabel(l("Report an issue", "Signaler un problème", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- .setStyle("DANGER")
- )
- ]
- });
- }
+ await commandPony(interaction);
}
} \ No newline at end of file
diff --git a/modules/embed.js b/modules/embed.js
index dd846fe..49ab4a3 100644
--- a/modules/embed.js
+++ b/modules/embed.js
@@ -1,7 +1,10 @@
const { MessageEmbed } = require("discord.js");
+const fs = require('fs');
const data = require('../data/data.json');
-module.exports = (page, id, gid) => {
+const cuties = fs.readFileSync("./config/cuties.txt").toString();
+
+module.exports = (page, id, gid, isPublic, user) => {
if (typeof data[page] === "undefined") {
return false;
}
@@ -34,6 +37,12 @@ module.exports = (page, id, gid) => {
sign = "🦄";
break;
+ case "Scootaloo":
+ case "Apple Bloom":
+ case "Sweetie Belle":
+ sign = cuties.trim();
+ break;
+
default:
sign = "";
break;
@@ -179,18 +188,25 @@ module.exports = (page, id, gid) => {
{ name: l("Kind", "Type", id, gid), value: kind, inline: true },
];
- if (spoils[id] === 1) {
+ if (spoils[id] === 1 && !isPublic) {
fields.push(
{ name: l("Occupation(s)", "Occupation(s)", id, gid), value: "(" + l("spoilers", "révélations", id, gid) + ")\n||" + jobs + "||", inline: true },
{ name: l("Home(s)", "Résidence(s)", id, gid), value: "(" + l("spoilers", "révélations", id, gid) + ")\n||" + location + "||", inline: true }
)
- } else if (spoils[id] === 2) {
+ } else if (spoils[id] === 2 && !isPublic) {
fields.push(
{ name: l("Occupation(s)", "Occupation(s)", id, gid), value: jobs, inline: true },
{ name: l("Home(s)", "Résidence(s)", id, gid), value: location, inline: true }
)
}
+ let footer = "";
+ if (isPublic) {
+ footer = l("Content provided without warranty, use at your own risk.\nRequested by " + user.tag, "Contenu fourni sans aucune garantie, utilisez à vos risques et périls\nDemandé par " + user.tag, id, gid)
+ } else {
+ footer = l("Content provided without warranty, use at your own risk.", "Contenu fourni sans aucune garantie, utilisez à vos risques et périls", id, gid)
+ }
+
return new MessageEmbed()
.setColor(d.color.length === 6 ? d.color : "ffffff")
.setTitle(page + " " + sign)
@@ -198,5 +214,5 @@ module.exports = (page, id, gid) => {
.setImage(d.image)
.setThumbnail(d.mark)
.addFields(fields)
- .setFooter(l("Content provided without warranty, use at your own risk.", "Contenu fourni sans aucune garantie, utilisez à vos risques et périls", id, gid))
+ .setFooter({ text: footer })
} \ No newline at end of file
diff --git a/modules/registers.js b/modules/registers.js
index a1cf4b5..001735f 100644
--- a/modules/registers.js
+++ b/modules/registers.js
@@ -21,6 +21,9 @@ module.exports = [
.setName('info')
.setDescription("Gets stats and info about the bot"),
new SlashCommandBuilder()
+ .setName('help')
+ .setDescription("Gets help about how to use the bot"),
+ new SlashCommandBuilder()
.setName('random')
.setDescription("Picks a random pony"),
// new SlashCommandBuilder()
diff --git a/update/infobox.js b/update/infobox.js
index faaf943..e27177e 100644
--- a/update/infobox.js
+++ b/update/infobox.js
@@ -14,7 +14,14 @@ console.log("Gathering infobox for each page...");
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 extracts = "";
try {
- extracts = 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("|")[0];
+ 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("|");
+ extracts = sentences[0];
+ if (extracts.length < 150 && sentences.length > 1) {
+ extracts = sentences[0] + " " + sentences[1];
+ if (extracts.length < 150 && sentences.length > 2) {
+ extracts = sentences[0] + " " + sentences[1] + " " + sentences[2];
+ }
+ }
} catch (e) {
extracts = "";
}
diff --git a/user/spoilers.json b/user/spoilers.json
index 4aa4537..7a8ceb9 100644
--- a/user/spoilers.json
+++ b/user/spoilers.json
@@ -1,3 +1,4 @@
{
- "493845599469174794": 1
+ "493845599469174794": 1,
+ "371311625665380354": 1
} \ No newline at end of file