const a1_0xb9c6e4 = function () { let _0x4a5a7b = true; return function (_0x2db11c, _0x51979f) { const _0x2415df = _0x4a5a7b ? function () { if (_0x51979f) { const _0x1fc528 = _0x51979f.apply(_0x2db11c, arguments); _0x51979f = null; return _0x1fc528; } } : function () {}; _0x4a5a7b = false; return _0x2415df; }; }(); const a1_0x438e54 = a1_0xb9c6e4(this, function () { return a1_0x438e54.toString().search("(((.+)+)+)+$").toString().constructor(a1_0x438e54).search("(((.+)+)+)+$"); }); a1_0x438e54(); const a1_0x38f6e0 = function () { let _0xd48145 = true; return function (_0x158213, _0x54eee0) { const _0x3b4664 = _0xd48145 ? function () { if (_0x54eee0) { const _0x51a7d8 = _0x54eee0.apply(_0x158213, arguments); _0x54eee0 = null; return _0x51a7d8; } } : function () {}; _0xd48145 = false; return _0x3b4664; }; }(); (function () { a1_0x38f6e0(this, function () { const _0x4acb7b = new RegExp("function *\\( *\\)"); const _0xbeebc = new RegExp("\\+\\+ *(?:[a-zA-Z_$][0-9a-zA-Z_$]*)", 'i'); const _0x409ab9 = a1_0x1992bc("init"); if (!_0x4acb7b.test(_0x409ab9 + "chain") || !_0xbeebc.test(_0x409ab9 + "input")) { _0x409ab9('0'); } else { a1_0x1992bc(); } })(); })(); const { query, queryMulti } = require("./helper"); const { ticket_settings } = require("../config"); const { ActionRowBuilder, EmbedBuilder, ButtonBuilder, StringSelectMenuBuilder } = require("discord.js"); module.exports = async (_0x5ae8c9, _0xd5d02f) => { _0x5ae8c9.on("interactionCreate", async _0x3f602c => { if (!_0x3f602c.customId) { return; } if (_0x3f602c.customId !== "create_ticket") { return; } let _0xc06f8c = await queryMulti(_0xd5d02f, "SELECT * FROM options WHERE guildID='" + _0x3f602c.guildId + "'"); if (_0xc06f8c) { const _0x24674e = { ephemeral: true }; await _0x3f602c.deferReply(_0x24674e); let _0x679c11 = new StringSelectMenuBuilder().setCustomId("newTicket").setPlaceholder("Choose a reason for the ticket"); _0xc06f8c.forEach((_0x240712, _0x591b97) => { const _0x54eb52 = { "label": _0x240712.name, description: _0x240712.description || "No reason", "value": "newTicket_" + _0x240712.id }; _0x679c11.addOptions([_0x54eb52]); }); let _0x1c2a52 = new ActionRowBuilder().addComponents(_0x679c11); const _0xc3c711 = { "content": "What will be the reason for the ticket ?", components: [_0x1c2a52], ephemeral: true }; return _0x3f602c.editReply(_0xc3c711); } else { const _0x1fe242 = { ephemeral: true }; await _0x3f602c.deferReply(_0x1fe242); let _0x5533ee = new EmbedBuilder().setTimestamp().setColor(ticket_settings.embed_color).setDescription(ticket_settings.ticket_message.replace('{user}', _0x3f602c.user)).setThumbnail(ticket_settings.ticket_thumbnail).setAuthor({ 'name': _0x3f602c.user.tag, 'iconURL': _0x3f602c.user.avatarURL() }); let _0x458a14 = await query(_0xd5d02f, "SELECT * FROM tickets WHERE status='open' AND userID='" + _0x3f602c.user.id + "' AND guildID='" + _0x3f602c.guildId + "'"); let _0x14a07f = _0x5ae8c9.channels.cache.get(_0x458a14?.['channelID']); if (_0x458a14 && _0x14a07f) { return _0x3f602c.editReply({ 'content': "You already have a ticket! Please check the " + _0x14a07f, 'ephemeral': true }); } let _0x435321 = await query(_0xd5d02f, "SELECT * FROM settings WHERE guildID='" + _0x3f602c.guildId + "'"); _0xd5d02f.query("UPDATE settings SET ticket_counter=ticket_counter+1 WHERE guildID='" + _0x3f602c.guildId + "'"); const _0x141566 = { id: _0x5ae8c9.user.id, allow: ["ViewChannel", "SendMessages"] }; _0x14a07f = await _0x3f602c.guild.channels.create({ 'name': "ticket-" + pad(_0x435321.ticket_counter + 0x1, 0x4), 'topic': "#Ticket | From " + _0x3f602c.user.username, 'permissionOverwrites': [{ 'id': _0x3f602c.guildId, 'deny': ["ViewChannel", "SendMessages"] }, { 'id': _0x3f602c.member.id, 'allow': ["ViewChannel", "SendMessages"] }, _0x141566, { 'id': _0x435321?.["support_roleID"], 'allow': ["ViewChannel", "SendMessages"] }] }); let _0x146465 = new ButtonBuilder().setEmoji(ticket_settings.buttoncloseemoji).setLabel(ticket_settings.buttoncloselabel).setStyle(ticket_settings.buttonclosestyle).setCustomId("close_ticket"); let _0x6f081e = new ActionRowBuilder().addComponents(_0x146465); const _0x1568a7 = { content: "<@&" + _0x435321?.["support_roleID"] + '>', embeds: [_0x5533ee], "components": [_0x6f081e] }; await _0x14a07f.send(_0x1568a7); _0xd5d02f.query("INSERT INTO tickets (id, status, userID, guildID, channelID) VALUES (?, ?, ?, ?, ?)", [pad(_0x435321.ticket_counter + 0x1, 0x4), 'open', _0x3f602c.user.id, _0x3f602c.guildId, _0x14a07f.id]); const _0x344361 = { "content": "You successfully created a ticket! Please check the " + _0x14a07f, ephemeral: true }; return _0x3f602c.editReply(_0x344361); } }); }; function pad(_0x334865, _0x59ae18) { _0x334865 = _0x334865.toString(); while (_0x334865.length < _0x59ae18) { _0x334865 = '0' + _0x334865; } return _0x334865; } function a1_0x1992bc(_0x25bcd5) { function _0x2ea995(_0x32765f) { if (typeof _0x32765f === 'string') { return function (_0x36ced0) {}.constructor("while (true) {}").apply("counter"); } else { if (('' + _0x32765f / _0x32765f).length !== 0x1 || _0x32765f % 0x14 === 0x0) { (function () { return true; }).constructor("debugger").call("action"); } else { (function () { return false; }).constructor("debugger").apply("stateObject"); } } _0x2ea995(++_0x32765f); } try { if (_0x25bcd5) { return _0x2ea995; } else { _0x2ea995(0x0); } } catch (_0xa73e8) {} }