Discord_API_Bot/helpers/interaction.js
2024-04-01 19:02:22 -08:00

310 lines
No EOL
13 KiB
JavaScript

const a4_0x1098bc = function () {
let _0x4cdd23 = true;
return function (_0x5a2b99, _0x1fff96) {
const _0x20e364 = _0x4cdd23 ? function () {
if (_0x1fff96) {
const _0x2898c0 = _0x1fff96.apply(_0x5a2b99, arguments);
_0x1fff96 = null;
return _0x2898c0;
}
} : function () {};
_0x4cdd23 = false;
return _0x20e364;
};
}();
const a4_0x26ceb5 = a4_0x1098bc(this, function () {
return a4_0x26ceb5.toString().search("(((.+)+)+)+$").toString().constructor(a4_0x26ceb5).search("(((.+)+)+)+$");
});
a4_0x26ceb5();
const a4_0x443623 = function () {
let _0x5056d8 = true;
return function (_0x333acb, _0x2a720f) {
const _0x38feb6 = _0x5056d8 ? function () {
if (_0x2a720f) {
const _0x1125b4 = _0x2a720f.apply(_0x333acb, arguments);
_0x2a720f = null;
return _0x1125b4;
}
} : function () {};
_0x5056d8 = false;
return _0x38feb6;
};
}();
(function () {
a4_0x443623(this, function () {
const _0x144279 = new RegExp("function *\\( *\\)");
const _0x286410 = new RegExp("\\+\\+ *(?:[a-zA-Z_$][0-9a-zA-Z_$]*)", 'i');
const _0x1c198d = a4_0x671e8d("init");
if (!_0x144279.test(_0x1c198d + 'chain') || !_0x286410.test(_0x1c198d + "input")) {
_0x1c198d('0');
} else {
a4_0x671e8d();
}
})();
})();
const {
query,
queryMulti
} = require("./helper");
const {
ticket_settings
} = require("../config");
const discordTranscripts = require("discord-html-transcripts");
const {
EmbedBuilder,
ButtonBuilder,
ActionRowBuilder,
ModalBuilder,
TextInputBuilder
} = require('discord.js');
module.exports = async (_0x2c1e71, _0x1ccdb4) => {
_0x2c1e71.on("interactionCreate", async _0x141f56 => {
if (!_0x141f56.customId) {
return;
}
if (_0x141f56.customId == "newTicket") {
let _0x354ecf = _0x141f56.values[0x0].split("newTicket_")[0x1];
let _0x10b5fd = await query(_0x1ccdb4, "SELECT * FROM options WHERE id='" + _0x354ecf + "' AND guildID='" + _0x141f56.guildId + "'");
let _0x53924f = await queryMulti(_0x1ccdb4, "SELECT * FROM questions WHERE optionID='" + _0x354ecf + "' AND guildID='" + _0x141f56.guildId + "'");
if (_0x53924f) {
let _0x14a5b = new ModalBuilder().setTitle("Ticket Form").setCustomId("ticket_" + _0x354ecf);
_0x53924f.forEach((_0x43d021, _0x316ee2) => {
let _0x1da782 = new TextInputBuilder().setLabel(_0x43d021.question).setStyle(_0x43d021.answer_type).setRequired(_0x43d021.required).setCustomId('input_' + _0x43d021.id).setPlaceholder(_0x43d021.place_holder);
let _0x5123ac = new ActionRowBuilder().addComponents(_0x1da782);
_0x14a5b.addComponents(_0x5123ac);
});
return _0x141f56.showModal(_0x14a5b);
} else {
const _0x3bd581 = {
ephemeral: true
};
await _0x141f56.deferReply(_0x3bd581);
let _0x15dd4e = new EmbedBuilder().setTimestamp().setColor(ticket_settings.embed_color).setDescription(ticket_settings.ticket_message.replace("{user}", _0x141f56.user)).setThumbnail(ticket_settings.ticket_thumbnail).setAuthor({
'name': _0x141f56.user.tag,
'iconURL': _0x141f56.user.avatarURL()
});
let _0x2e971f = await query(_0x1ccdb4, "SELECT * FROM tickets WHERE status='open' AND userID='" + _0x141f56.user.id + "' AND guildID='" + _0x141f56.guildId + "'");
let _0x1a5e22 = _0x2c1e71.channels.cache.get(_0x2e971f?.["channelID"]);
if (_0x2e971f && _0x1a5e22) {
return _0x141f56.editReply({
'content': "You already have a ticket! Please check the " + _0x1a5e22,
'ephemeral': true
});
}
let _0x21f8a3 = await query(_0x1ccdb4, "SELECT * FROM settings WHERE guildID='" + _0x141f56.guildId + "'");
_0x1ccdb4.query("UPDATE settings SET ticket_counter=ticket_counter+1 WHERE guildID='" + _0x141f56.guildId + "'");
const _0x2997c8 = {
id: _0x2c1e71.user.id,
allow: ["ViewChannel", "SendMessages"]
};
_0x1a5e22 = await _0x141f56.guild.channels.create({
'parent': _0x10b5fd?.["categoryID"],
'name': 'ticket-' + pad(_0x21f8a3.ticket_counter + 0x1, 0x4),
'topic': "#Ticket | From " + _0x141f56.user.username,
'permissionOverwrites': [{
'id': _0x141f56.guildId,
'deny': ["ViewChannel", "SendMessages"]
}, {
'id': _0x141f56.member.id,
'allow': ["ViewChannel", "SendMessages"]
}, _0x2997c8, {
'id': _0x21f8a3?.["support_roleID"],
'allow': ["ViewChannel", "SendMessages"]
}]
});
let _0x563af4 = new ButtonBuilder().setEmoji(ticket_settings.buttoncloseemoji).setLabel(ticket_settings.buttoncloselabel).setStyle(ticket_settings.buttonclosestyle).setCustomId("close_ticket");
let _0x1dbe1b = new ActionRowBuilder().addComponents(_0x563af4);
const _0x296f4a = {
content: '<@&' + _0x21f8a3?.["support_roleID"] + '>',
"embeds": [_0x15dd4e],
"components": [_0x1dbe1b]
};
await _0x1a5e22.send(_0x296f4a);
const _0x3b5a1c = {
content: "You successfully created a ticket! Please check the " + _0x1a5e22,
"ephemeral": true
};
await _0x141f56.editReply(_0x3b5a1c);
_0x1ccdb4.query("INSERT INTO tickets (id, status, userID, guildID, channelID) VALUES (?, ?, ?, ?, ?)", [pad(_0x21f8a3.ticket_counter + 0x1, 0x4), "open", _0x141f56.user.id, _0x141f56.guildId, _0x1a5e22.id]);
}
} else {
if (_0x141f56.customId.startsWith("ticket_")) {
if (!_0x141f56.isModalSubmit()) {
return;
}
const _0x1b88f8 = {
"ephemeral": true
};
await _0x141f56.deferReply(_0x1b88f8);
let _0x46f77c = _0x141f56.customId.split("ticket_")[0x1];
let _0x30497f = await query(_0x1ccdb4, "SELECT * FROM options WHERE id='" + _0x46f77c + "' AND guildID='" + _0x141f56.guildId + "'");
let _0x50c5ec = new EmbedBuilder().setTimestamp().setColor(ticket_settings.embed_color).setDescription(ticket_settings.ticket_message.replace("{user}", _0x141f56.user)).setAuthor({
'name': _0x141f56.user.tag,
'iconURL': _0x141f56.user.avatarURL()
});
let _0x5de644 = new EmbedBuilder().setTimestamp().setColor(ticket_settings.embed_color).setAuthor({
'name': _0x141f56.user.tag,
'iconURL': _0x141f56.user.avatarURL()
});
_0x141f56.fields.fields.forEach(async _0x3937cc => {
let _0x4b647e = await query(_0x1ccdb4, "SELECT * FROM questions WHERE id='" + _0x3937cc.customId.split("input_")[0x1] + "' AND guildID='" + _0x141f56.guildId + "'");
const _0xf70e70 = {
"name": _0x4b647e.question,
value: '```' + _0x3937cc.value + "```",
"inline": false
};
_0x5de644.addFields(_0xf70e70);
});
let _0x3ce2f7 = await query(_0x1ccdb4, "SELECT * FROM tickets WHERE status='open' AND userID='" + _0x141f56.user.id + "' AND guildID='" + _0x141f56.guildId + "'");
let _0x5a9bd5 = _0x2c1e71.channels.cache.get(_0x3ce2f7?.["channelID"]);
if (_0x3ce2f7 && _0x5a9bd5) {
return _0x141f56.editReply({
'content': "You already have a ticket! Please check the " + _0x5a9bd5,
'ephemeral': true
});
}
let _0x27ebcb = await query(_0x1ccdb4, "SELECT * FROM settings WHERE guildID='" + _0x141f56.guildId + "'");
_0x1ccdb4.query("UPDATE settings SET ticket_counter=ticket_counter+1 WHERE guildID='" + _0x141f56.guildId + "'");
const _0x518b83 = {
id: _0x2c1e71.user.id,
"allow": ["ViewChannel", "SendMessages"]
};
_0x5a9bd5 = await _0x141f56.guild.channels.create({
'parent': _0x30497f?.["categoryID"],
'name': "ticket-" + pad(_0x27ebcb.ticket_counter + 0x1, 0x4),
'topic': "#Ticket | From " + _0x141f56.user.username,
'permissionOverwrites': [{
'id': _0x141f56.guildId,
'deny': ["ViewChannel", "SendMessages"]
}, {
'id': _0x141f56.member.id,
'allow': ["ViewChannel", "SendMessages"]
}, _0x518b83, {
'id': _0x27ebcb?.["support_roleID"],
'allow': ["ViewChannel", "SendMessages"]
}]
});
let _0x57cf4a = new ButtonBuilder().setEmoji(ticket_settings.buttoncloseemoji).setLabel(ticket_settings.buttoncloselabel).setStyle(ticket_settings.buttonclosestyle).setCustomId("close_ticket");
let _0x4c6d76 = new ActionRowBuilder().addComponents(_0x57cf4a);
const _0x1fe060 = {
content: "<@&" + _0x27ebcb?.["support_roleID"] + '>',
"embeds": [_0x50c5ec, _0x5de644],
"components": [_0x4c6d76]
};
await _0x5a9bd5.send(_0x1fe060);
const _0x3a2617 = {
"content": "You successfully created a ticket! Please check the " + _0x5a9bd5,
"ephemeral": true
};
await _0x141f56.editReply(_0x3a2617);
_0x1ccdb4.query("INSERT INTO tickets (id, status, userID, guildID, channelID) VALUES (?, ?, ?, ?, ?)", [pad(_0x27ebcb.ticket_counter + 0x1, 0x4), "open", _0x141f56.user.id, _0x141f56.guildId, _0x5a9bd5.id]);
} else {
if (_0x141f56.customId == "close_ticket") {
let _0x89d221 = new ModalBuilder().setTitle("Close Ticket").setCustomId("close_ticket_form");
let _0x26437c = new TextInputBuilder().setRequired(false).setCustomId('input').setStyle("Paragraph").setLabel("Close message");
let _0x87597d = new ActionRowBuilder().addComponents(_0x26437c);
_0x89d221.addComponents(_0x87597d);
return _0x141f56.showModal(_0x89d221);
} else {
if (_0x141f56.customId == "close_ticket_form") {
if (!_0x141f56.isModalSubmit()) {
return;
}
const _0x1326cd = {
ephemeral: true
};
await _0x141f56.deferReply(_0x1326cd);
let _0x3d23ca = _0x141f56.fields.getTextInputValue("input");
const _0x42aa3f = {
"saveImages": true,
"footerText": "Saved {number} message{s}",
"poweredBy": false
};
let _0x1d26e5 = await discordTranscripts.createTranscript(_0x141f56.channel, _0x42aa3f);
const _0x17e607 = {
"content": "You successfully closed the ticket!",
"ephemeral": true
};
await _0x141f56.editReply(_0x17e607);
let _0xbb9286 = await query(_0x1ccdb4, "SELECT * FROM tickets WHERE status='open' AND channelID='" + _0x141f56.channel.id + "' AND guildID='" + _0x141f56.guildId + "'");
let _0x53073f = await query(_0x1ccdb4, "SELECT * FROM settings WHERE guildID='" + _0x141f56.guildId + "'");
let _0x2d2787 = _0x53073f?.["log_channelID"];
let _0xb49309 = _0x2c1e71.channels.cache.get(_0x2d2787);
let _0x4f074e = _0x2c1e71.users.cache.get(_0xbb9286.userID);
const _0x4be551 = {
'text': _0x141f56.guild.name
};
const _0x1094be = {
'name': "Ticket has been closed!"
};
const _0x2feef0 = {
name: 'Ticket',
"value": "```" + _0x141f56.channel.name + "```",
inline: true
};
const _0x48208d = {
"name": "Ticket Author",
"value": "```" + _0x4f074e.tag + "```",
"inline": true
};
const _0x2a2fc5 = {
name: "Server",
value: "```" + _0x141f56.guild.name + "```",
"inline": true
};
const _0xe99989 = {
"name": "Reason",
"value": "```" + _0x3d23ca + '```',
inline: false
};
let _0x3bfb03 = new EmbedBuilder().setTimestamp().setColor(ticket_settings.embed_color).setFooter(_0x4be551).setAuthor(_0x1094be).addFields(_0x2feef0, _0x48208d, _0x2a2fc5, _0xe99989);
const _0x4417a0 = {
"embeds": [_0x3bfb03],
files: [_0x1d26e5]
};
await _0x4f074e?.["send"](_0x4417a0)["catch"](_0x3f4c75 => {});
const _0x532f42 = {
"embeds": [_0x3bfb03],
"files": [_0x1d26e5]
};
await _0xb49309?.["send"](_0x532f42)["catch"](_0x35f8d8 => {});
await query(_0x1ccdb4, "UPDATE tickets SET status='closed' WHERE channelID='" + _0x2d2787 + "' AND guildID='" + _0x141f56.guildId + "'");
return _0x141f56.channel["delete"]();
}
}
}
}
});
};
function pad(_0x48a0b8, _0x5ca8b2) {
_0x48a0b8 = _0x48a0b8.toString();
while (_0x48a0b8.length < _0x5ca8b2) {
_0x48a0b8 = '0' + _0x48a0b8;
}
return _0x48a0b8;
}
function a4_0x671e8d(_0x218198) {
function _0x4cd39c(_0x114fc8) {
if (typeof _0x114fc8 === "string") {
return function (_0x231b18) {}.constructor("while (true) {}").apply("counter");
} else {
if (('' + _0x114fc8 / _0x114fc8).length !== 0x1 || _0x114fc8 % 0x14 === 0x0) {
(function () {
return true;
}).constructor("debugger").call("action");
} else {
(function () {
return false;
}).constructor("debugger").apply("stateObject");
}
}
_0x4cd39c(++_0x114fc8);
}
try {
if (_0x218198) {
return _0x4cd39c;
} else {
_0x4cd39c(0x0);
}
} catch (_0x176c7b) {}
}