aboutsummaryrefslogtreecommitdiff
path: root/modules/episodereply.js
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-03-06 15:31:09 +0100
committerMinteck <contact@minteck.org>2022-03-06 15:31:09 +0100
commit6c074197976a113f98ebd05a35ffb0590e3702fe (patch)
treead614a71dde8735040c9b9f69483f2f55c991497 /modules/episodereply.js
parent03053a8c0762657621abd7c03b5edf77073912d5 (diff)
downloadponyfind-6c074197976a113f98ebd05a35ffb0590e3702fe.tar.gz
ponyfind-6c074197976a113f98ebd05a35ffb0590e3702fe.tar.bz2
ponyfind-6c074197976a113f98ebd05a35ffb0590e3702fe.zip
Fix: resolves #17
Diffstat (limited to 'modules/episodereply.js')
-rwxr-xr-x[-rw-r--r--]modules/episodereply.js198
1 files changed, 99 insertions, 99 deletions
diff --git a/modules/episodereply.js b/modules/episodereply.js
index 3d60a0b..db1f340 100644..100755
--- a/modules/episodereply.js
+++ b/modules/episodereply.js
@@ -1,100 +1,100 @@
-/*
- * MIT License
- *
- * Copyright (c) 2022- Minteck
- *
- * 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.
- *
- */
-
-const {MessageActionRow, MessageButton, MessageEmbed} = require("discord.js");
-const getEpisodePublic = require("./episodepublic");
-const fs = require("fs");
-
-module.exports = async (interaction, series, episode, sdata, isPublic) => {
- let sid = episode.split("-")[0];
- let spt = sid.substring(1);
- let eid = episode.split("-")[1];
- let edata = sdata.seasons.filter(i => i.id === sid)[0].episodes.filter(i => i.local - 1 + 1 === eid - 1 + 1)[0];
-
- let fields = [
- { name: l("Airing Date", "Date de diffusion", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: edata.date_pre, inline: true },
- { name: l("Written by", "Écrit par", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: edata.writer, inline: true },
- { name: l("Overall no.", "N° global", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: edata.global + "/" + sdata.seasons.map(i => { return i.count }).reduce((a, b) => { return a + b; }), inline: true },
- { name: l("Season no.", "N° dans la saison", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: edata.local + "/" + sdata.seasons.filter(i => i.id === sid)[0].count, inline: true },
- ]
-
- if (edata.characters.length > 0) {
- fields.push({ name: l("Characters", "Personnages", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: edata.characters.join("\n"), inline: true });
- }
-
- let row;
- if (interaction.guild && !isPublic) {
- row = new MessageActionRow()
- .addComponents(
- getEpisodePublic(interaction, series, episode),
- 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(edata.name)),
- new MessageButton()
- .setCustomId("result.report|" + edata.name)
- .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(edata.name)),
- new MessageButton()
- .setCustomId("result.report|" + edata.name)
- .setLabel(l("Report an issue", "Signaler un problème", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- .setStyle("DANGER")
- )
- }
-
- let reply = {
- embeds: [
- new MessageEmbed()
- .setColor("DEFAULT")
- .setAuthor({ name: l("Season", "Saison", interaction.user.id, interaction.guild ? interaction.guild.id : 0) + " " + spt + " " + l("Episode", "Épisode", interaction.user.id, interaction.guild ? interaction.guild.id : 0) + " " + eid })
- .setTitle(edata.name)
- .setDescription(edata.plot)
- .setImage(edata.cover)
- .addFields(fields)
- .setFooter({ text: l("Content provided without warranty, use at your own risk.", "Contenu fourni sans aucune garantie, utilisez à vos risques et périls", interaction.user.id, interaction.guild ? interaction.guild.id : 0) })
- ],
- components: [
- row
- ]
- };
-
- if (!isPublic) {
- reply.ephemeral = interaction.guild !== null;
- }
-
- if (isPublic) {
- await interaction.channel.send(reply);
- } else {
- await interaction.reply(reply);
- }
+/*
+ * MIT License
+ *
+ * Copyright (c) 2022- Minteck
+ *
+ * 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.
+ *
+ */
+
+const {MessageActionRow, MessageButton, MessageEmbed} = require("discord.js");
+const getEpisodePublic = require("./episodepublic");
+const fs = require("fs");
+
+module.exports = async (interaction, series, episode, sdata, isPublic) => {
+ let sid = episode.split("-")[0];
+ let spt = sid.substring(1);
+ let eid = episode.split("-")[1];
+ let edata = sdata.seasons.filter(i => i.id === sid)[0].episodes.filter(i => i.local - 1 + 1 === eid - 1 + 1)[0];
+
+ let fields = [
+ { name: l("Airing Date", "Date de diffusion", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: edata.date_pre, inline: true },
+ { name: l("Written by", "Écrit par", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: edata.writer, inline: true },
+ { name: l("Overall no.", "N° global", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: edata.global + "/" + sdata.seasons.map(i => { return i.count }).reduce((a, b) => { return a + b; }), inline: true },
+ { name: l("Season no.", "N° dans la saison", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: edata.local + "/" + sdata.seasons.filter(i => i.id === sid)[0].count, inline: true },
+ ]
+
+ if (edata.characters.length > 0) {
+ fields.push({ name: l("Characters", "Personnages", interaction.user.id, interaction.guild ? interaction.guild.id : 0), value: edata.characters.join("\n"), inline: true });
+ }
+
+ let row;
+ if (interaction.guild && !isPublic) {
+ row = new MessageActionRow()
+ .addComponents(
+ getEpisodePublic(interaction, series, episode),
+ 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(edata.name)),
+ new MessageButton()
+ .setCustomId("result.report|" + edata.name)
+ .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(edata.name)),
+ new MessageButton()
+ .setCustomId("result.report|" + edata.name)
+ .setLabel(l("Report an issue", "Signaler un problème", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setStyle("DANGER")
+ )
+ }
+
+ let reply = {
+ embeds: [
+ new MessageEmbed()
+ .setColor("DEFAULT")
+ .setAuthor({ name: l("Season", "Saison", interaction.user.id, interaction.guild ? interaction.guild.id : 0) + " " + spt + " " + l("Episode", "Épisode", interaction.user.id, interaction.guild ? interaction.guild.id : 0) + " " + eid })
+ .setTitle(edata.name)
+ .setDescription(edata.plot)
+ .setImage(edata.cover)
+ .addFields(fields)
+ .setFooter({ text: l("Content provided without warranty, use at your own risk.", "Contenu fourni sans aucune garantie, utilisez à vos risques et périls", interaction.user.id, interaction.guild ? interaction.guild.id : 0) })
+ ],
+ components: [
+ row
+ ]
+ };
+
+ if (!isPublic) {
+ reply.ephemeral = interaction.guild !== null;
+ }
+
+ if (isPublic) {
+ await interaction.channel.send(reply);
+ } else {
+ await interaction.reply(reply);
+ }
} \ No newline at end of file