diff options
author | Minteck <contact@minteck.org> | 2022-02-13 22:03:16 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-02-13 22:03:16 +0100 |
commit | 1fab479bb2cc8d730096442701e60caaa7f5ed90 (patch) | |
tree | e92ff28daca6acd4b987dd649b5a26382ae76fdc /modules/episodepublic.js | |
parent | 888a39829d7bc1d63357832b8ce07abddd755478 (diff) | |
download | ponyfind-1fab479bb2cc8d730096442701e60caaa7f5ed90.tar.gz ponyfind-1fab479bb2cc8d730096442701e60caaa7f5ed90.tar.bz2 ponyfind-1fab479bb2cc8d730096442701e60caaa7f5ed90.zip |
Add warning for some episodes
Diffstat (limited to 'modules/episodepublic.js')
-rw-r--r-- | modules/episodepublic.js | 39 |
1 files changed, 29 insertions, 10 deletions
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 |