diff options
author | Minteck <contact@minteck.org> | 2022-01-09 18:22:55 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-01-09 18:22:55 +0100 |
commit | 7d0d6272c8bf5260da53210c8ed327980e396397 (patch) | |
tree | 6812176231961767e9b7aa731193abb387bbc107 /commands/random.js | |
parent | dc65563df84d80bcc0970febef6a5f9a7759bdcb (diff) | |
download | ponyfind-7d0d6272c8bf5260da53210c8ed327980e396397.tar.gz ponyfind-7d0d6272c8bf5260da53210c8ed327980e396397.tar.bz2 ponyfind-7d0d6272c8bf5260da53210c8ed327980e396397.zip |
Update
Diffstat (limited to 'commands/random.js')
-rw-r--r-- | commands/random.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/commands/random.js b/commands/random.js new file mode 100644 index 0000000..9ac50e2 --- /dev/null +++ b/commands/random.js @@ -0,0 +1,43 @@ +const fs = require('fs'); +const { MessageActionRow, MessageButton, MessageSelectMenu, MessageEmbed } = require('discord.js'); + +const admin = fs.readFileSync("./config/admin.txt").toString().trim(); +const list = Object.keys(JSON.parse(fs.readFileSync("./data/data.json").toString())); + +const getResult = require('../modules/result'); +const getEmbed = require('../modules/embed'); +const getPixel = require("../modules/pixel"); + +const official = fs.readFileSync("./config/official.txt").toString().replace(/\r\n/g, "\n").split("\n"); +const fpserver = fs.readFileSync("./config/fpserver.txt").toString().trim(); + +module.exports = async (interaction) => { + keys = [ + null, + list[Math.floor(Math.random() * list.length)] + ] + await interaction.reply({ + ephemeral: interaction.guild !== null, + embeds: [ + getEmbed(keys[1], interaction.user.id, interaction.guild ? interaction.guild.id : 0) + ], + 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") + ) + ] + }); +}
\ No newline at end of file |