aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/version.txt2
-rw-r--r--handler/button.js32
-rw-r--r--handler/errors.js2
-rw-r--r--modules/episodepublic.js39
4 files changed, 63 insertions, 12 deletions
diff --git a/config/version.txt b/config/version.txt
index 33b655a..2c54684 100644
--- a/config/version.txt
+++ b/config/version.txt
@@ -1 +1 @@
-2.0.55 \ No newline at end of file
+2.0.56 \ No newline at end of file
diff --git a/handler/button.js b/handler/button.js
index 4a8a343..cdc7247 100644
--- a/handler/button.js
+++ b/handler/button.js
@@ -19,7 +19,37 @@ module.exports = async (interaction) => {
fs.writeFile("./stats/buttons.json", JSON.stringify(statsButtons), () => {
});
- if (keys[0] === "episode.public") {
+ if (keys[0] === "episode.public.cancel") {
+ await interaction.message.delete();
+ } else if (keys[0] === "episode.public.warn") {
+ let ep = keys[2].split("-")[1];
+ let se = keys[2].split("-")[0];
+ let sep = keys[2].split("-")[0].substring(1);
+
+ await interaction.reply({
+ ephemeral: interaction.guild !== null,
+ embeds: [
+ new MessageEmbed()
+ .setColor('#dcbe28')
+ .setTitle(l("Are you sure about that?", "Êtes-vous sûr(e) de ça ?", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setDescription(l("Some people in this channel might not have seen this episode yet, displaying this episode publicly may spoil them. Are you sure you want to do that?", "Certaines personnes dans ce salon peuvent ne pas encore avoir vu cet épisode, l'afficher publiquement pourrait leur révéler l'histoire. Êtes-vous sûr(e) de vouloir faire cela ?", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setFooter({ text: l("Selected episode:", "Épisode sélectionné :", interaction.user.id, interaction.guild ? interaction.guild.id : 0) + " S" + sep + "E" + ep + " (" + series.filter(i => i.command.toLowerCase() === keys[1])[0].seasons.filter(i => i.id === se)[0].episodes.filter(i => i.local - 1 + 1 === ep - 1 + 1)[0].name + ")" })
+ ],
+ components: [
+ new MessageActionRow()
+ .addComponents(
+ new MessageButton()
+ .setCustomId("episode.public|" + keys[1] + "|" + keys[2])
+ .setLabel(l("Yes", "Oui", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setStyle("SUCCESS"),
+ new MessageButton()
+ .setCustomId("episode.public.cancel|" + keys[1] + "|" + keys[2])
+ .setLabel(l("Oui", "Non", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setStyle("DANGER")
+ )
+ ]
+ });
+ } else if (keys[0] === "episode.public") {
if (typeof cooldowns[interaction.user.id] !== "undefined" && new Date() - cooldowns[interaction.user.id] < 30000) {
await interaction.reply({
ephemeral: interaction.guild !== null,
diff --git a/handler/errors.js b/handler/errors.js
index 989adc4..9924353 100644
--- a/handler/errors.js
+++ b/handler/errors.js
@@ -2,6 +2,8 @@ const fs = require('fs');
const { MessageActionRow, MessageButton, MessageSelectMenu, MessageEmbed } = require('discord.js');
module.exports = async (interaction, e) => {
+ if (e.name === "DiscordAPIError") { return; }
+
console.error(e);
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\n\n-------------------------\n\n" + e.stack)
diff --git a/modules/episodepublic.js b/modules/episodepublic.js
index 73318f5..26c03ff 100644
--- a/modules/episodepublic.js
+++ b/modules/episodepublic.js
@@ -1,16 +1,35 @@
const { MessageButton } = require("discord.js");
module.exports = (interaction, series, episode) => {
- if (typeof cooldowns[interaction.user.id] !== "undefined" && new Date() - cooldowns[interaction.user.id] < 30000) {
- return new MessageButton()
- .setCustomId("episode.public|" + series + "|" + episode)
- .setLabel(l("Wait " + Math.ceil((30000 - (new Date() - cooldowns[interaction.user.id]))/1000) + " seconds", "Patientez " + Math.ceil((30000 - (new Date() - cooldowns[interaction.user.id]))/1000) + " secondes", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- .setStyle("PRIMARY")
- .setDisabled(true);
+ let ep = episode.split("-")[1] - 1 + 1;
+ let se = episode.split("-")[0].substring(1) - 1 + 1;
+
+ console.log(episode, se, ep);
+ if (se > 3 || se === 3 && ep === 13) {
+ if (typeof cooldowns[interaction.user.id] !== "undefined" && new Date() - cooldowns[interaction.user.id] < 30000) {
+ return new MessageButton()
+ .setCustomId("episode.public.warn|" + series + "|" + episode)
+ .setLabel(l("Wait " + Math.ceil((30000 - (new Date() - cooldowns[interaction.user.id]))/1000) + " seconds", "Patientez " + Math.ceil((30000 - (new Date() - cooldowns[interaction.user.id]))/1000) + " secondes", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setStyle("PRIMARY")
+ .setDisabled(true);
+ } else {
+ return new MessageButton()
+ .setCustomId("episode.public.warn|" + series + "|" + episode)
+ .setLabel(l("Show to everypony", "Afficher à tous", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setStyle("PRIMARY")
+ }
} else {
- return new MessageButton()
- .setCustomId("episode.public|" + series + "|" + episode)
- .setLabel(l("Show to everypony", "Afficher à tous", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
- .setStyle("PRIMARY")
+ if (typeof cooldowns[interaction.user.id] !== "undefined" && new Date() - cooldowns[interaction.user.id] < 30000) {
+ return new MessageButton()
+ .setCustomId("episode.public|" + series + "|" + episode)
+ .setLabel(l("Wait " + Math.ceil((30000 - (new Date() - cooldowns[interaction.user.id]))/1000) + " seconds", "Patientez " + Math.ceil((30000 - (new Date() - cooldowns[interaction.user.id]))/1000) + " secondes", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setStyle("PRIMARY")
+ .setDisabled(true);
+ } else {
+ return new MessageButton()
+ .setCustomId("episode.public|" + series + "|" + episode)
+ .setLabel(l("Show to everypony", "Afficher à tous", interaction.user.id, interaction.guild ? interaction.guild.id : 0))
+ .setStyle("PRIMARY")
+ }
}
} \ No newline at end of file