From 193299d89e82c020daa6e7561f17f9c76e415e55 Mon Sep 17 00:00:00 2001 From: VanillaChanny <39040261+VanillaChan6571@users.noreply.github.com> Date: Mon, 8 Apr 2024 03:45:23 -0600 Subject: [PATCH] Idk What Im Doin --- .idea/.gitignore | 8 ++ .idea/Discord_API_Bot.iml | 8 ++ .idea/discord.xml | 12 ++ .idea/modules.xml | 8 ++ .idea/php.xml | 19 +++ .idea/vcs.xml | 6 + slash-commands/create-question.js | 226 ++++++++++++++---------------- 7 files changed, 164 insertions(+), 123 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/Discord_API_Bot.iml create mode 100644 .idea/discord.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/php.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/Discord_API_Bot.iml b/.idea/Discord_API_Bot.iml new file mode 100644 index 0000000..c956989 --- /dev/null +++ b/.idea/Discord_API_Bot.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/discord.xml b/.idea/discord.xml new file mode 100644 index 0000000..9b28b4a --- /dev/null +++ b/.idea/discord.xml @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..f339fe5 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 0000000..f324872 --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/slash-commands/create-question.js b/slash-commands/create-question.js index 9afd6c5..a380aa1 100644 --- a/slash-commands/create-question.js +++ b/slash-commands/create-question.js @@ -1,132 +1,112 @@ -const a8_0x474e1e = function () { - let _0x4c0a0e = true; - return function (_0x5d79a8, _0x1f27c1) { - const _0x3f8b2f = _0x4c0a0e ? function () { - if (_0x1f27c1) { - const _0x2b4a77 = _0x1f27c1.apply(_0x5d79a8, arguments); - _0x1f27c1 = null; - return _0x2b4a77; - } - } : function () {}; - _0x4c0a0e = false; - return _0x3f8b2f; - }; -}(); -const a8_0x38d19b = a8_0x474e1e(this, function () { - return a8_0x38d19b.toString().search("(((.+)+)+)+$").toString().constructor(a8_0x38d19b).search("(((.+)+)+)+$"); -}); -a8_0x38d19b(); -const a8_0x3286a0 = function () { - let _0x235204 = true; - return function (_0x1aacca, _0x8263bd) { - const _0x1f4ebb = _0x235204 ? function () { - if (_0x8263bd) { - const _0x587b1f = _0x8263bd.apply(_0x1aacca, arguments); - _0x8263bd = null; - return _0x587b1f; - } - } : function () {}; - _0x235204 = false; - return _0x1f4ebb; - }; -}(); -(function () { - a8_0x3286a0(this, function () { - const _0x324afa = new RegExp("function *\\( *\\)"); - const _0x5e3476 = new RegExp("\\+\\+ *(?:[a-zA-Z_$][0-9a-zA-Z_$]*)", 'i'); - const _0x1f4ede = a8_0x17bfc5("init"); - if (!_0x324afa.test(_0x1f4ede + "chain") || !_0x5e3476.test(_0x1f4ede + "input")) { - _0x1f4ede('0'); - } else { - a8_0x17bfc5(); - } - })(); -})(); -const { - ticket_settings -} = require('../config'); -const { - queryMulti -} = require("../helpers/helper"); +const { ticket_settings } = require('../config'); +const { queryMulti } = require("../helpers/helper"); const { SlashCommandBuilder, PermissionFlagsBits, EmbedBuilder } = require("discord.js"); -const a8_0x4ed738 = { - "name": "Short", - "value": "Short" -}; -const a8_0xad3c43 = { - "name": "Paragraph", - "value": "Paragraph" -}; -const a8_0x410cbe = { - "name": "Yes", - "value": "Yes" -}; -const a8_0x3e2f57 = { - name: 'No', - "value": 'No' -}; + +const answerTypeChoices = [ + { + name: "Short", + value: "Short" + }, + { + name: "Paragraph", + value: "Paragraph" + } +]; + +const answerRequiredChoices = [ + { + name: "Yes", + value: "Yes" + }, + { + name: "No", + value: "No" + } +]; + module.exports = { - 'data': new SlashCommandBuilder().setName("create-question").setDescription("Create new question form ticket form").addStringOption(_0xd18c4d => _0xd18c4d.setName("option").setRequired(true).setAutocomplete(true).setDescription("Select the ticket option.")).addStringOption(_0xc292be => _0xc292be.setMaxLength(0x2d).setRequired(true).setName('question').setDescription("Enter a question.")).addStringOption(_0x25b049 => _0x25b049.setRequired(true).setName("place-holder").setDescription("Enter a place holder for answer area.")).addStringOption(_0x5d88ac => _0x5d88ac.setRequired(true).setName("answer-type").addChoices(a8_0x4ed738, a8_0xad3c43).setDescription("Select type of the answer.")).addStringOption(_0x3b630d => _0x3b630d.setRequired(true).setName("answer-required").addChoices(a8_0x410cbe, a8_0x3e2f57).setDescription("Select whether the answer is required or not.")).setDefaultMemberPermissions(PermissionFlagsBits.Administrator), - async 'run'(_0x493d1f, _0x498f14) { - let { - options: _0x303722 - } = _0x498f14; - const _0x966cc8 = { - "ephemeral": true + data: new SlashCommandBuilder() + .setName("create-question") + .setDescription("Create new question form ticket form") + .addStringOption(option => + option + .setName("option") + .setRequired(true) + .setAutocomplete(true) + .setDescription("Select the ticket option.") + ) + .addStringOption(option => + option + .setMaxLength(45) + .setRequired(true) + .setName('question') + .setDescription("Enter a question.") + ) + .addStringOption(option => + option + .setRequired(true) + .setName("place-holder") + .setDescription("Enter a place holder for answer area.") + ) + .addStringOption(option => + option + .setRequired(true) + .setName("answer-type") + .addChoices(...answerTypeChoices) + .setDescription("Select type of the answer.") + ) + .addStringOption(option => + option + .setRequired(true) + .setName("answer-required") + .addChoices(...answerRequiredChoices) + .setDescription("Select whether the answer is required or not.") + ) + .setDefaultMemberPermissions(PermissionFlagsBits.Administrator), + + async run(client, interaction) { + const { options } = interaction; + const ephemeral = true; + + await interaction.deferReply({ ephemeral }); + + const ticketOption = options.getString("option"); + const question = options.getString('question'); + const placeHolder = options.getString("place-holder"); + const answerType = options.getString("answer-type"); + const answerRequired = options.getString("answer-required") === "Yes"; + + const authorName = { + name: interaction.guild.name }; - await _0x498f14.deferReply(_0x966cc8); - let _0xef5166 = _0x303722.getString("option"); - let _0x231340 = _0x303722.getString('question'); - let _0x337111 = _0x303722.getString("place-holder"); - let _0x46dc09 = _0x303722.getString("answer-type"); - let _0x4272a7 = !!(_0x303722.getString("answer-required") == "Yes"); - const _0x2889c5 = { - 'name': _0x498f14.guild.name - }; - let _0x4532b4 = new EmbedBuilder().setColor(ticket_settings.embed_color).setAuthor(_0x2889c5).setThumbnail(ticket_settings.ticket_thumbnail).setDescription("You can't have more than 5 questions at the ticket form!"); - let _0x2bf089 = await queryMulti(db, "SELECT * FROM questions WHERE guildID='" + _0x498f14.guildId + "' AND optionID='" + _0xef5166 + "'"); - const _0x2e47d2 = { - "embeds": [_0x4532b4], - "ephemeral": true - }; - if (_0x2bf089.length > 0x5) { - return _0x498f14.editReply(_0x2e47d2); + + let embed = new EmbedBuilder() + .setColor(ticket_settings.embed_color) + .setAuthor(authorName) + .setThumbnail(ticket_settings.ticket_thumbnail) + .setDescription("You can't have more than 5 questions at the ticket form!"); + + const existingQuestions = await queryMulti( + db, + "SELECT * FROM questions WHERE guildID=? AND optionID=?", + [interaction.guildId, ticketOption] + ); + + if (existingQuestions.length > 5) { + return interaction.editReply({ embeds: [embed], ephemeral }); } - db.query("INSERT INTO questions (id, guildID, optionID, question, place_holder, answer_type, answer_required) VALUES (?, ?, ?, ?, ?, ?, ?)", [_0x498f14.id, _0x498f14.guildId, _0xef5166, _0x231340, _0x337111, _0x46dc09, _0x4272a7]); - _0x4532b4.setDescription("You successfully added new question to ticket form!"); - const _0x36a251 = { - "embeds": [_0x4532b4], - "ephemeral": true - }; - return _0x498f14.editReply(_0x36a251); + + await db.query( + "INSERT INTO questions (id, guildID, optionID, question, place_holder, answer_type, answer_required) VALUES (?, ?, ?, ?, ?, ?, ?)", + [interaction.id, interaction.guildId, ticketOption, question, placeHolder, answerType, answerRequired] + ); + + embed.setDescription("You successfully added new question to ticket form!"); + + return interaction.editReply({ embeds: [embed], ephemeral }); } -}; -function a8_0x17bfc5(_0x305cb3) { - function _0x220f08(_0x54a7b0) { - if (typeof _0x54a7b0 === 'string') { - return function (_0x31a1c0) {}.constructor("while (true) {}").apply("counter"); - } else { - if (('' + _0x54a7b0 / _0x54a7b0).length !== 0x1 || _0x54a7b0 % 0x14 === 0x0) { - (function () { - return true; - }).constructor("debugger").call('action'); - } else { - (function () { - return false; - }).constructor("debugger").apply("stateObject"); - } - } - _0x220f08(++_0x54a7b0); - } - try { - if (_0x305cb3) { - return _0x220f08; - } else { - _0x220f08(0x0); - } - } catch (_0x4b05c7) {} -} \ No newline at end of file +}; \ No newline at end of file