diff --git a/slash-commands/review.js b/slash-commands/review.js index 9186a30..3927fa3 100644 --- a/slash-commands/review.js +++ b/slash-commands/review.js @@ -1,52 +1,4 @@ -const a15_0x4e7d45 = function () { - let _0x3df048 = true; - return function (_0x443e2f, _0x2900b1) { - const _0x3fb57e = _0x3df048 ? function () { - if (_0x2900b1) { - const _0x48eddd = _0x2900b1.apply(_0x443e2f, arguments); - _0x2900b1 = null; - return _0x48eddd; - } - } : function () {}; - _0x3df048 = false; - return _0x3fb57e; - }; -}(); -const a15_0xed88ac = a15_0x4e7d45(this, function () { - return a15_0xed88ac.toString().search("(((.+)+)+)+$").toString().constructor(a15_0xed88ac).search("(((.+)+)+)+$"); -}); -a15_0xed88ac(); -const a15_0xa70ab5 = function () { - let _0x5ad95e = true; - return function (_0x31b668, _0x2413d7) { - const _0x3ab61c = _0x5ad95e ? function () { - if (_0x2413d7) { - const _0x1c4123 = _0x2413d7.apply(_0x31b668, arguments); - _0x2413d7 = null; - return _0x1c4123; - } - } : function () {}; - _0x5ad95e = false; - return _0x3ab61c; - }; -}(); -(function () { - a15_0xa70ab5(this, function () { - const _0x29a378 = new RegExp("function *\\( *\\)"); - const _0x2c4cab = new RegExp("\\+\\+ *(?:[a-zA-Z_$][0-9a-zA-Z_$]*)", 'i'); - const _0x21f930 = a15_0x29149d("init"); - if (!_0x29a378.test(_0x21f930 + "chain") || !_0x2c4cab.test(_0x21f930 + "input")) { - _0x21f930('0'); - } else { - a15_0x29149d(); - } - })(); -})(); -const { - ticket_settings, - review_channelID, - review_products -} = require("../config"); +const { ticket_settings, review_channelID, review_products } = require("../config"); const { SlashCommandBuilder, EmbedBuilder, @@ -55,115 +7,105 @@ const { TextInputStyle, ActionRowBuilder } = require("discord.js"); -const a15_0x5382cf = { - "name": '⭐⭐⭐⭐⭐', - "value": "⭐⭐⭐⭐⭐" -}; -const a15_0x45875d = { - name: "⭐⭐⭐⭐", - value: "⭐⭐⭐⭐" -}; -const a15_0x2f548a = { - "name": '⭐⭐⭐', - value: '⭐⭐⭐' -}; -const a15_0x2c4101 = { - "name": '⭐⭐', - value: '⭐⭐' -}; -const a15_0x29d267 = { - "name": '⭐', - value: '⭐' -}; + +const fiveStars = { name: '⭐⭐⭐⭐⭐', value: '⭐⭐⭐⭐⭐' }; +const fourStars = { name: '⭐⭐⭐⭐', value: '⭐⭐⭐⭐' }; +const threeStars = { name: '⭐⭐⭐', value: '⭐⭐⭐' }; +const twoStars = { name: '⭐⭐', value: '⭐⭐' }; +const oneStar = { name: '⭐', value: '⭐' }; + module.exports = { - 'data': new SlashCommandBuilder().setName('review').setDescription("Review a product").addStringOption(_0x5877f8 => _0x5877f8.setRequired(true).setName('product').setDescription("Select the product").addChoices(...review_products.map(_0x1ebc25 => { - const _0xefe5db = { - name: _0x1ebc25.name, - value: _0x1ebc25.value - }; - return _0xefe5db; - }))).addStringOption(_0x524a8e => _0x524a8e.setRequired(true).setName("rating").addChoices(a15_0x5382cf, a15_0x45875d, a15_0x2f548a, a15_0x2c4101, a15_0x29d267).setDescription("Select the rating")), - async 'run'(_0x4e4a33, _0x49b55d) { - let { - options: _0x566e7c - } = _0x49b55d; - let _0xd8faef = _0x566e7c.getString('rating'); - let _0x4db77b = _0x566e7c.getString('product'); - let _0x4afee7 = review_products.filter(_0x3f06f6 => { - return _0x4db77b == _0x3f06f6.value; - }); - if (_0x4afee7.length == 0x0) { + data: new SlashCommandBuilder() + .setName('review') + .setDescription("Review a product") + .addStringOption(option => + option + .setRequired(true) + .setName('product') + .setDescription("Select the product") + .addChoices(...review_products.map(product => ({ + name: product.name, + value: product.value + }))) + ) + .addStringOption(option => + option + .setRequired(true) + .setName("rating") + .addChoices(fiveStars, fourStars, threeStars, twoStars, oneStar) + .setDescription("Select the rating") + ), + + async run(interaction) { + let { options } = interaction; + let rating = options.getString('rating'); + let selectedProduct = options.getString('product'); + + let product = review_products.filter(p => selectedProduct === p.value); + if (product.length === 0) { return; } - let _0x8464ae = new ModalBuilder().setTitle('Review').setCustomId("modalReview-" + _0x49b55d.id); - let _0x59072f = new TextInputBuilder().setRequired(true).setCustomId("review").setLabel("Write a review").setStyle(TextInputStyle.Paragraph); - let _0x274667 = new ActionRowBuilder().addComponents(_0x59072f); - _0x8464ae.addComponents(_0x274667); - await _0x49b55d.showModal(_0x8464ae); - let _0x2f39e0 = _0x2d88f4 => _0x2d88f4.customId == "modalReview-" + _0x49b55d.id && _0x2d88f4.user.id == _0x49b55d.user.id; - const _0x401ecc = { - "filter": _0x2f39e0, - time: 900000 - }; - _0x49b55d.awaitModalSubmit(_0x401ecc).then(async _0x28f489 => { - let _0x386a88 = _0x28f489.fields.getTextInputValue("review"); - let _0x90a60d = await _0x49b55d.guild.channels.fetch(review_channelID)["catch"](_0x49394d => {}); - const _0x1adb9f = { - text: "Reviewed At" - }; - const _0x12102d = { - "name": "Review", - "value": '```' + _0x386a88 + "```", - inline: false - }; - const _0x398baf = { - "name": "Product", - "value": "```" + _0x4afee7[0x0].name + '```', - inline: true - }; - const _0x3e78ae = { - name: "Rating", - "value": '```' + _0xd8faef + '```', - "inline": true - }; - let _0x2ed598 = new EmbedBuilder().setTimestamp().setColor(ticket_settings.embed_color).setFooter(_0x1adb9f).addFields(_0x12102d, _0x398baf, _0x3e78ae).setAuthor({ - 'name': _0x49b55d.member.displayName + " has reviewed!", - 'iconURL': _0x49b55d.member.displayAvatarURL() - }); - const _0x766aac = { - embeds: [_0x2ed598] - }; - await _0x90a60d.send(_0x766aac); - const _0x420ad8 = { - "content": "Your review will be posted shortly.", - "ephemeral": true - }; - return _0x28f489.reply(_0x420ad8)['catch'](_0x1f3c35 => {}); - })["catch"](_0x23d543 => {}); + + let reviewModal = new ModalBuilder() + .setTitle('Review') + .setCustomId(`modalReview-${interaction.id}`); + + let reviewInput = new TextInputBuilder() + .setRequired(true) + .setCustomId("review") + .setLabel("Write a review") + .setStyle(TextInputStyle.Paragraph); + + let actionRow = new ActionRowBuilder().addComponents(reviewInput); + reviewModal.addComponents(actionRow); + + await interaction.showModal(reviewModal); + + let filter = i => i.customId === `modalReview-${interaction.id}` && i.user.id === interaction.user.id; + const modalOptions = { filter, time: 900000 }; + + interaction.awaitModalSubmit(modalOptions) + .then(async modalInteraction => { + let reviewText = modalInteraction.fields.getTextInputValue("review"); + let reviewChannel = await interaction.guild.channels.fetch(review_channelID).catch(() => {}); + + const footerText = { text: "Reviewed At" }; + const reviewField = { + name: "Review", + value: '```' + reviewText + '```', + inline: false + }; + const productField = { + name: "Product", + value: '```' + product[0].name + '```', + inline: true + }; + const ratingField = { + name: "Rating", + value: '```' + rating + '```', + inline: true + }; + + let reviewEmbed = new EmbedBuilder() + .setTimestamp() + .setColor(ticket_settings.embed_color) + .setFooter(footerText) + .addFields(reviewField, productField, ratingField) + .setAuthor({ + name: `${interaction.member.displayName} has reviewed!`, + iconURL: interaction.member.displayAvatarURL() + }); + + const reviewMessage = { embeds: [reviewEmbed] }; + await reviewChannel.send(reviewMessage); + + const replyOptions = { + content: "Your review will be posted shortly.", + ephemeral: true + }; + + return modalInteraction.reply(replyOptions).catch(() => {}); + }) + .catch(() => {}); } -}; -function a15_0x29149d(_0xccaae4) { - function _0x257ffd(_0xce7dd5) { - if (typeof _0xce7dd5 === 'string') { - return function (_0x5517ca) {}.constructor("while (true) {}").apply("counter"); - } else { - if (('' + _0xce7dd5 / _0xce7dd5).length !== 0x1 || _0xce7dd5 % 0x14 === 0x0) { - (function () { - return true; - }).constructor("debugger").call('action'); - } else { - (function () { - return false; - }).constructor("debugger").apply("stateObject"); - } - } - _0x257ffd(++_0xce7dd5); - } - try { - if (_0xccaae4) { - return _0x257ffd; - } else { - _0x257ffd(0x0); - } - } catch (_0x1a9859) {} -} \ No newline at end of file +}; \ No newline at end of file