diff options
Diffstat (limited to 'handler/button.js')
-rw-r--r-- | handler/button.js | 118 |
1 files changed, 101 insertions, 17 deletions
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,
|