1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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);
}
}
|