The Cat Is Happy

This commit is contained in:
VanillaChanny 2024-04-08 04:12:41 -06:00
parent f07c8d010f
commit 5713bb389e
6 changed files with 685 additions and 904 deletions

View file

@ -1,189 +1,141 @@
const a0_0x1c225b = function () {
let _0x26ff6f = true;
return function (_0x3098f9, _0x33f4a0) {
const _0x4039b1 = _0x26ff6f ? function () {
if (_0x33f4a0) {
const _0x1febc4 = _0x33f4a0.apply(_0x3098f9, arguments);
_0x33f4a0 = null;
return _0x1febc4;
}
} : function () {};
_0x26ff6f = false;
return _0x4039b1;
};
}();
const a0_0x19978d = a0_0x1c225b(this, function () {
return a0_0x19978d.toString().search("(((.+)+)+)+$").toString().constructor(a0_0x19978d).search("(((.+)+)+)+$");
});
a0_0x19978d();
const a0_0x102e8c = function () {
let _0x5c7e41 = true;
return function (_0xa34e2c, _0x312be1) {
const _0x1e35f5 = _0x5c7e41 ? function () {
if (_0x312be1) {
const _0x245e03 = _0x312be1.apply(_0xa34e2c, arguments);
_0x312be1 = null;
return _0x245e03;
}
} : function () {};
_0x5c7e41 = false;
return _0x1e35f5;
};
}();
(function () {
a0_0x102e8c(this, function () {
const _0xbf92e = new RegExp("function *\\( *\\)");
const _0x35370f = new RegExp("\\+\\+ *(?:[a-zA-Z_$][0-9a-zA-Z_$]*)", 'i');
const _0x339327 = a0_0x4ec4cc("init");
if (!_0xbf92e.test(_0x339327 + 'chain') || !_0x35370f.test(_0x339327 + 'input')) {
_0x339327('0');
} else {
a0_0x4ec4cc();
}
})();
})();
const axios = require("axios"); const axios = require("axios");
const { const { api_url, api_token } = require("../config");
api_url,
api_token
} = require("../config");
module.exports = { module.exports = {
'getUser': async function (_0x3587a7) { getUser: async function (email) {
const _0x18e41e = { const headers = {
Authorization: "Bearer " + api_token Authorization: `Bearer ${api_token}`
}; };
const _0x50a9eb = { const options = {
"method": "GET",
"url": api_url + "/users?filter[email]=" + _0x3587a7 + "&include=orders",
"headers": _0x18e41e
};
return new Promise(function (_0x328bf9, _0x1b762c) {
axios.request(_0x50a9eb).then(_0xf8546a => {
_0x328bf9(_0xf8546a.data);
})["catch"](_0x1e9c4a => {
_0x328bf9(false);
});
});
},
'getDiscordUser': async function (_0x17a450) {
const _0x108855 = {
Authorization: "Bearer " + api_token
};
const _0x14dab5 = {
method: "GET", method: "GET",
"url": api_url + "/oauth-connections?filter[data->id]=" + _0x17a450, url: `${api_url}/users?filter[email]=${email}&include=orders`,
"headers": _0x108855 headers: headers
}; };
return new Promise(function (_0x2fe4ec, _0x11e844) { return new Promise((resolve, reject) => {
axios.request(_0x14dab5).then(_0x54a58b => { axios.request(options)
_0x2fe4ec(_0x54a58b.data); .then(response => {
})["catch"](_0xa96b95 => { resolve(response.data);
_0x2fe4ec(false); })
.catch(error => {
resolve(false);
}); });
}); });
}, },
'getNewOauths': async function () {
const _0x447e11 = { getDiscordUser: async function (discordId) {
Authorization: "Bearer " + api_token const headers = {
Authorization: `Bearer ${api_token}`
}; };
const _0x239a7a = { const options = {
method: "GET", method: "GET",
"url": api_url + "/oauth-connections?date=3days", url: `${api_url}/oauth-connections?filter[data->id]=${discordId}`,
headers: _0x447e11 headers: headers
}; };
return new Promise(function (_0x1a2033, _0x3efbb7) { return new Promise((resolve, reject) => {
axios.request(_0x239a7a).then(_0x11e80d => { axios.request(options)
_0x1a2033(_0x11e80d.data); .then(response => {
})["catch"](_0x432895 => { resolve(response.data);
_0x1a2033(false); })
.catch(error => {
resolve(false);
}); });
}); });
}, },
'getOauthUsers': async function () {
let _0x4450b1 = 0x1; getNewOauths: async function () {
let _0x51c057 = []; const headers = {
let _0x1795bb = false; Authorization: `Bearer ${api_token}`
while (!_0x1795bb) { };
let _0x1a365c = await pagination("oauth-connections?page=" + _0x4450b1); const options = {
_0x51c057.push(..._0x1a365c.data); method: "GET",
if (!_0x1a365c.next_page_url) { url: `${api_url}/oauth-connections?date=3days`,
_0x1795bb = true; headers: headers
} else { };
_0x4450b1 = _0x1a365c.next_page_url.split("page=")[0x1]; return new Promise((resolve, reject) => {
} axios.request(options)
} .then(response => {
return _0x51c057; resolve(response.data);
})
.catch(error => {
resolve(false);
});
});
}, },
'getActiveOrders': async function () {
let _0x23c335 = 0x1; getOauthUsers: async function () {
let _0x3becc5 = []; let page = 1;
let _0x55415c = false; let oauthUsers = [];
while (!_0x55415c) { let hasMorePages = true;
let _0x43ec80 = await pagination("orders?filter[status]=active&page=" + _0x23c335);
_0x3becc5.push(..._0x43ec80.data); while (hasMorePages) {
if (!_0x43ec80.next_page_url) { const data = await pagination(`oauth-connections?page=${page}`);
_0x55415c = true; oauthUsers.push(...data.data);
if (!data.next_page_url) {
hasMorePages = false;
} else { } else {
_0x23c335 = _0x43ec80.next_page_url.split('page=')[0x1]; page = data.next_page_url.split("page=")[1];
} }
} }
return _0x3becc5;
return oauthUsers;
}, },
'getAllUsers': async function () {
let _0x66b7e9 = 0x1; getActiveOrders: async function () {
let _0x4dd437 = []; let page = 1;
let _0x3d3b75 = false; let activeOrders = [];
while (!_0x3d3b75) { let hasMorePages = true;
let _0x3e0308 = await pagination("users?page=" + _0x66b7e9);
_0x4dd437.push(..._0x3e0308.data); while (hasMorePages) {
if (!_0x3e0308.next_page_url) { const data = await pagination(`orders?filter[status]=active&page=${page}`);
_0x3d3b75 = true; activeOrders.push(...data.data);
if (!data.next_page_url) {
hasMorePages = false;
} else { } else {
_0x66b7e9 = _0x3e0308.next_page_url.split("page=")[0x1]; page = data.next_page_url.split('page=')[1];
} }
} }
return _0x4dd437;
return activeOrders;
},
getAllUsers: async function () {
let page = 1;
let allUsers = [];
let hasMorePages = true;
while (hasMorePages) {
const data = await pagination(`users?page=${page}`);
allUsers.push(...data.data);
if (!data.next_page_url) {
hasMorePages = false;
} else {
page = data.next_page_url.split("page=")[1];
}
}
return allUsers;
} }
}; };
async function pagination(_0x555d30) {
const _0x24eb29 = { async function pagination(endpoint) {
Authorization: "Bearer " + api_token const headers = {
Authorization: `Bearer ${api_token}`
}; };
const _0x1d8596 = { const options = {
"method": "GET", method: "GET",
"url": api_url + '/' + _0x555d30, url: `${api_url}/${endpoint}`,
"headers": _0x24eb29 headers: headers
}; };
return new Promise(function (_0x69b493, _0x598a19) { return new Promise((resolve, reject) => {
axios.request(_0x1d8596).then(async _0x571fc2 => { axios.request(options)
return _0x69b493(_0x571fc2.data); .then(async response => {
})['catch'](_0x584f23 => { return resolve(response.data);
_0x69b493(false); })
.catch(error => {
resolve(false);
}); });
}); });
} }
function a0_0x4ec4cc(_0x3b9e64) {
function _0x36cc4c(_0xf1d4d7) {
if (typeof _0xf1d4d7 === "string") {
return function (_0x15b4cd) {}.constructor("while (true) {}").apply("counter");
} else {
if (('' + _0xf1d4d7 / _0xf1d4d7).length !== 0x1 || _0xf1d4d7 % 0x14 === 0x0) {
(function () {
return true;
}).constructor("debugger").call("action");
} else {
(function () {
return false;
}).constructor("debugger").apply("stateObject");
}
}
_0x36cc4c(++_0xf1d4d7);
}
try {
if (_0x3b9e64) {
return _0x36cc4c;
} else {
_0x36cc4c(0x0);
}
} catch (_0x3c7595) {}
}

View file

@ -1,173 +1,129 @@
const a1_0xb9c6e4 = function () { const { query, queryMulti } = require("./helper");
let _0x4a5a7b = true; const { ticket_settings } = require("../config");
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 { const {
ActionRowBuilder, ActionRowBuilder,
EmbedBuilder, EmbedBuilder,
ButtonBuilder, ButtonBuilder,
StringSelectMenuBuilder StringSelectMenuBuilder
} = require("discord.js"); } = require("discord.js");
module.exports = async (_0x5ae8c9, _0xd5d02f) => {
_0x5ae8c9.on("interactionCreate", async _0x3f602c => { module.exports = async (client, db) => {
if (!_0x3f602c.customId) { client.on("interactionCreate", async interaction => {
if (!interaction.customId || interaction.customId !== "create_ticket") {
return; return;
} }
if (_0x3f602c.customId !== "create_ticket") {
return; const options = await queryMulti(db, `SELECT * FROM options WHERE guildID='${interaction.guildId}'`);
if (options) {
await interaction.deferReply({ ephemeral: true });
const selectMenu = new StringSelectMenuBuilder()
.setCustomId("newTicket")
.setPlaceholder("Choose a reason for the ticket");
options.forEach((option, index) => {
selectMenu.addOptions([
{
label: option.name,
description: option.description || "No reason",
value: `newTicket_${option.id}`
} }
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 = { const actionRow = new ActionRowBuilder().addComponents(selectMenu);
"content": "What will be the reason for the ticket ?",
components: [_0x1c2a52], return interaction.editReply({
content: "What will be the reason for the ticket?",
components: [actionRow],
ephemeral: true ephemeral: true
}; });
return _0x3f602c.editReply(_0xc3c711);
} else { } else {
const _0x1fe242 = { await interaction.deferReply({ ephemeral: true });
ephemeral: true
}; const embed = new EmbedBuilder()
await _0x3f602c.deferReply(_0x1fe242); .setTimestamp()
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({ .setColor(ticket_settings.embed_color)
'name': _0x3f602c.user.tag, .setDescription(ticket_settings.ticket_message.replace('{user}', interaction.user))
'iconURL': _0x3f602c.user.avatarURL() .setThumbnail(ticket_settings.ticket_thumbnail)
.setAuthor({
name: interaction.user.tag,
iconURL: interaction.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']); const existingTicket = await query(
if (_0x458a14 && _0x14a07f) { db,
return _0x3f602c.editReply({ `SELECT * FROM tickets WHERE status='open' AND userID='${interaction.user.id}' AND guildID='${interaction.guildId}'`
'content': "You already have a ticket! Please check the " + _0x14a07f, );
'ephemeral': true const existingChannel = client.channels.cache.get(existingTicket?.channelID);
if (existingTicket && existingChannel) {
return interaction.editReply({
content: `You already have a ticket! Please check the ${existingChannel}`,
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 settings = await query(db, `SELECT * FROM settings WHERE guildID='${interaction.guildId}'`);
const _0x141566 = { db.query(`UPDATE settings SET ticket_counter=ticket_counter+1 WHERE guildID='${interaction.guildId}'`);
id: _0x5ae8c9.user.id,
const permissions = [
{
id: interaction.guildId,
deny: ["ViewChannel", "SendMessages"]
},
{
id: interaction.member.id,
allow: ["ViewChannel", "SendMessages"] allow: ["ViewChannel", "SendMessages"]
}; },
_0x14a07f = await _0x3f602c.guild.channels.create({ {
'name': "ticket-" + pad(_0x435321.ticket_counter + 0x1, 0x4), id: client.user.id,
'topic': "#Ticket | From " + _0x3f602c.user.username, allow: ["ViewChannel", "SendMessages"]
'permissionOverwrites': [{ },
'id': _0x3f602c.guildId, {
'deny': ["ViewChannel", "SendMessages"] id: settings?.support_roleID,
}, { allow: ["ViewChannel", "SendMessages"]
'id': _0x3f602c.member.id, }
'allow': ["ViewChannel", "SendMessages"] ];
}, _0x141566, {
'id': _0x435321?.["support_roleID"], const channel = await interaction.guild.channels.create({
'allow': ["ViewChannel", "SendMessages"] name: `ticket-${pad(settings.ticket_counter + 1, 4)}`,
}] topic: `#Ticket | From ${interaction.user.username}`,
permissionOverwrites: permissions
}); });
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 closeButton = new ButtonBuilder()
const _0x1568a7 = { .setEmoji(ticket_settings.buttoncloseemoji)
content: "<@&" + _0x435321?.["support_roleID"] + '>', .setLabel(ticket_settings.buttoncloselabel)
embeds: [_0x5533ee], .setStyle(ticket_settings.buttonclosestyle)
"components": [_0x6f081e] .setCustomId("close_ticket");
};
await _0x14a07f.send(_0x1568a7); const actionRow = new ActionRowBuilder().addComponents(closeButton);
_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 = { await channel.send({
"content": "You successfully created a ticket! Please check the " + _0x14a07f, content: `<@&${settings?.support_roleID}>`,
embeds: [embed],
components: [actionRow]
});
db.query(
"INSERT INTO tickets (id, status, userID, guildID, channelID) VALUES (?, ?, ?, ?, ?)",
[pad(settings.ticket_counter + 1, 4), 'open', interaction.user.id, interaction.guildId, channel.id]
);
return interaction.editReply({
content: `You successfully created a ticket! Please check the ${channel}`,
ephemeral: true ephemeral: true
}; });
return _0x3f602c.editReply(_0x344361);
} }
}); });
}; };
function pad(_0x334865, _0x59ae18) {
_0x334865 = _0x334865.toString(); function pad(num, size) {
while (_0x334865.length < _0x59ae18) { let numStr = num.toString();
_0x334865 = '0' + _0x334865; while (numStr.length < size) {
numStr = '0' + numStr;
} }
return _0x334865; return numStr;
}
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) {}
} }

View file

@ -1,169 +1,116 @@
const a2_0x169aa3 = function () {
let _0x51ee3c = true;
return function (_0x1b5fb3, _0x19916f) {
const _0x1d2c7c = _0x51ee3c ? function () {
if (_0x19916f) {
const _0x2cd5a2 = _0x19916f.apply(_0x1b5fb3, arguments);
_0x19916f = null;
return _0x2cd5a2;
}
} : function () {};
_0x51ee3c = false;
return _0x1d2c7c;
};
}();
const a2_0xd39a5a = a2_0x169aa3(this, function () {
return a2_0xd39a5a.toString().search("(((.+)+)+)+$").toString().constructor(a2_0xd39a5a).search("(((.+)+)+)+$");
});
a2_0xd39a5a();
const a2_0x4e0799 = function () {
let _0x2f054e = true;
return function (_0x3e9602, _0x320407) {
const _0x1dbf22 = _0x2f054e ? function () {
if (_0x320407) {
const _0x117310 = _0x320407.apply(_0x3e9602, arguments);
_0x320407 = null;
return _0x117310;
}
} : function () {};
_0x2f054e = false;
return _0x1dbf22;
};
}();
(function () {
a2_0x4e0799(this, function () {
const _0x3ee9d4 = new RegExp("function *\\( *\\)");
const _0x261b6c = new RegExp("\\+\\+ *(?:[a-zA-Z_$][0-9a-zA-Z_$]*)", 'i');
const _0xb9a3 = a2_0x4716e7('init');
if (!_0x3ee9d4.test(_0xb9a3 + "chain") || !_0x261b6c.test(_0xb9a3 + "input")) {
_0xb9a3('0');
} else {
a2_0x4716e7();
}
})();
})();
const api = require("./api"); const api = require("./api");
const { const { guild_id, api_role_id, package_roles } = require("../config");
guild_id,
api_role_id,
package_roles
} = require("../config");
const users = {}; const users = {};
module.exports = async _0x2bfb16 => {
const _0x2adaa9 = await _0x2bfb16.guilds.fetch(guild_id)["catch"](_0x5751d0 => {}); module.exports = async client => {
if (!_0x2adaa9) { const guild = await client.guilds.fetch(guild_id).catch(() => {});
if (!guild) {
return; return;
} }
let _0x212782 = await api.getOauthUsers();
_0x212782.forEach(_0x70d746 => { let oauthUsers = await api.getOauthUsers();
users[_0x70d746.user_id] = _0x70d746.data.id; oauthUsers.forEach(user => {
users[user.user_id] = user.data.id;
}); });
_0xc3192a();
async function _0xc3192a() { checkNewOauths();
setTimeout(_0xc3192a, 120000); async function checkNewOauths() {
let _0x2f80b5 = await api.getNewOauths(); setTimeout(checkNewOauths, 120000);
if (!_0x2f80b5) { const newOauths = await api.getNewOauths();
if (!newOauths) {
return; return;
} }
_0x2f80b5.data.forEach(async _0x5a41c5 => {
users[_0x5a41c5.user_id] = _0x5a41c5.data.id; newOauths.data.forEach(async oauth => {
let _0x86b501 = await _0x2adaa9.members.fetch(_0x5a41c5.data.id)['catch'](_0x1db7d6 => {}); users[oauth.user_id] = oauth.data.id;
if (!_0x86b501) { const member = await guild.members.fetch(oauth.data.id).catch(() => {});
if (!member) {
return; return;
} }
if (_0x86b501.roles.cache.has(api_role_id)) {
if (member.roles.cache.has(api_role_id)) {
return; return;
} }
return _0x86b501.roles.add(api_role_id)["catch"](_0x3ad98e => {});
return member.roles.add(api_role_id).catch(() => {});
}); });
} }
_0x352284();
async function _0x352284() { checkActiveOrders();
setTimeout(_0x352284, 300000); async function checkActiveOrders() {
let _0x54df73 = await api.getActiveOrders(); setTimeout(checkActiveOrders, 300000);
if (!_0x54df73) { const activeOrders = await api.getActiveOrders();
if (!activeOrders) {
return; return;
} }
_0x54df73.forEach(async _0x1bc8eb => {
let _0xd8d4d6 = users[_0x1bc8eb.user_id]; activeOrders.forEach(async order => {
if (!_0xd8d4d6) { const discordId = users[order.user_id];
if (!discordId) {
return; return;
} }
let _0x27c968 = await _0x2adaa9.members.fetch(_0xd8d4d6)["catch"](_0xfc46f => {});
if (!_0x27c968) { const member = await guild.members.fetch(discordId).catch(() => {});
if (!member) {
return; return;
} }
let _0x1a17bf = package_roles.filter(_0x43ee6e => {
return _0x43ee6e.packageID == _0x1bc8eb.package_id; const packageRole = package_roles.find(role => role.packageID === order.package_id);
})?.[0x0]; if (!packageRole) {
if (!_0x1a17bf) {
return; return;
} }
return _0x27c968.roles.add(_0x1a17bf.roleID)['catch'](_0x54ff9c => {});
return member.roles.add(packageRole.roleID).catch(() => {});
}); });
} }
_0x1603d3();
async function _0x1603d3() { checkPackageRoles();
setTimeout(_0x1603d3, 1800000); async function checkPackageRoles() {
package_roles.forEach(async _0x34bf1d => { setTimeout(checkPackageRoles, 1800000);
let _0x1a2632 = await _0x2adaa9.roles.fetch(_0x34bf1d.roleID)["catch"](_0x3b05eb => {
for (const packageRole of package_roles) {
const role = await guild.roles.fetch(packageRole.roleID).catch(() => {
console.log("Role not found."); console.log("Role not found.");
}); });
if (!_0x1a2632) { if (!role) {
return;
}
let _0x8dd2f2 = _0x1a2632.members.keys();
if (_0x8dd2f2.size == 0x0) {
return;
}
for (const _0x56650c of _0x8dd2f2) {
let _0x658564 = _0x212782.filter(_0x1db0da => _0x1db0da.data.id == _0x56650c)?.[0x0];
if (!_0x658564) {
continue; continue;
} }
await delay(5000);
let _0x3707a4 = await api.getUser(_0x658564.email); const memberIds = role.members.keys();
if (!_0x3707a4 || _0x3707a4.data.length == 0x0) { if (memberIds.size === 0) {
continue; continue;
} }
let _0x41f7bd = _0x3707a4?.["data"][0x0]?.["orders"]['filter'](_0x3277fc => {
return _0x3277fc.package_id == _0x34bf1d.packageID && _0x3277fc.status == "active"; for (const memberId of memberIds) {
})?.[0x0]; const oauthUser = oauthUsers.find(user => user.data.id === memberId);
if (!_0x41f7bd) { if (!oauthUser) {
let _0x483ad1 = await _0x2adaa9.members.fetch(_0x56650c)["catch"](_0x364b6a => {}); continue;
if (_0x483ad1) { }
await delay(5000); await delay(5000);
await _0x483ad1.roles.remove(_0x34bf1d.roleID)['catch'](_0x3a7f5f => { const apiUser = await api.getUser(oauthUser.email);
console.log("Role couldn't found."); if (!apiUser || apiUser.data.length === 0) {
continue;
}
const activeOrder = apiUser?.data[0]?.orders.find(order => {
return order.package_id === packageRole.packageID && order.status === "active";
}); });
console.log("Removed " + _0x1a2632.name + " from " + _0x483ad1.displayName);
} if (!activeOrder) {
} const member = await guild.members.fetch(memberId).catch(() => {});
} if (member) {
await delay(5000);
await member.roles.remove(packageRole.roleID).catch(() => {
console.log("Role couldn't be found.");
}); });
console.log(`Removed ${role.name} from ${member.displayName}`);
}
}
}
}
} }
}; };
const delay = _0x4f18b0 => new Promise(_0x59dc75 => setTimeout(_0x59dc75, _0x4f18b0));
function a2_0x4716e7(_0x582940) { const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
function _0x20350a(_0x2252ba) {
if (typeof _0x2252ba === "string") {
return function (_0x4559e3) {}.constructor("while (true) {}").apply('counter');
} else if (('' + _0x2252ba / _0x2252ba).length !== 0x1 || _0x2252ba % 0x14 === 0x0) {
(function () {
return true;
}).constructor("debugger").call('action');
} else {
(function () {
return false;
}).constructor("debugger").apply("stateObject");
}
_0x20350a(++_0x2252ba);
}
try {
if (_0x582940) {
return _0x20350a;
} else {
_0x20350a(0x0);
}
} catch (_0x28989b) {}
}

View file

@ -1,99 +1,33 @@
var a3_0x57f3db = function () {
var _0x17256c = true;
return function (_0x15b4d6, _0x38152f) {
var _0x5c944f = _0x17256c ? function () {
if (_0x38152f) {
var _0x26b6b9 = _0x38152f.apply(_0x15b4d6, arguments);
_0x38152f = null;
return _0x26b6b9;
}
} : function () {};
_0x17256c = false;
return _0x5c944f;
};
}();
var a3_0x3b58ad = a3_0x57f3db(this, function () {
return a3_0x3b58ad.toString().search("(((.+)+)+)+$").toString().constructor(a3_0x3b58ad).search("(((.+)+)+)+$");
});
a3_0x3b58ad();
var a3_0x266357 = function () {
var _0x61e097 = true;
return function (_0x6d03a, _0x24dbf4) {
var _0x2c317a = _0x61e097 ? function () {
if (_0x24dbf4) {
var _0x217a12 = _0x24dbf4.apply(_0x6d03a, arguments);
_0x24dbf4 = null;
return _0x217a12;
}
} : function () {};
_0x61e097 = false;
return _0x2c317a;
};
}();
(function () {
a3_0x266357(this, function () {
var _0x673e54 = new RegExp("function *\\( *\\)");
var _0x34001d = new RegExp("\\+\\+ *(?:[a-zA-Z_$][0-9a-zA-Z_$]*)", 'i');
var _0x38dc35 = a3_0x454870("init");
if (!_0x673e54.test(_0x38dc35 + "chain") || !_0x34001d.test(_0x38dc35 + "input")) {
_0x38dc35('0');
} else {
a3_0x454870();
}
})();
})();
module.exports = { module.exports = {
'query': async function (_0x1b7403, _0x87526f) { query: async function (db, sql) {
return new Promise(function (_0x3474cc, _0x13489a) { return new Promise((resolve, reject) => {
_0x1b7403.query(_0x87526f, async function (_0x4e0b4c, _0xf1b0fa) { db.query(sql, async (error, results) => {
if (_0x4e0b4c) { if (error) {
throw _0x4e0b4c; throw error;
} }
if (_0xf1b0fa.length > 0x0) {
_0x3474cc(_0xf1b0fa[0x0]); if (results.length > 0) {
resolve(results[0]);
} else { } else {
_0x3474cc(false); resolve(false);
} }
}); });
}); });
}, },
'queryMulti': async function (_0x5c7f4e, _0x2481bd) {
return new Promise(function (_0x1e5738, _0x4b5ba3) { queryMulti: async function (db, sql) {
_0x5c7f4e.query(_0x2481bd, async function (_0x60e5cb, _0x10dfa3) { return new Promise((resolve, reject) => {
if (_0x60e5cb) { db.query(sql, async (error, results) => {
throw _0x60e5cb; if (error) {
throw error;
} }
if (_0x10dfa3.length > 0x0) {
_0x1e5738(_0x10dfa3); if (results.length > 0) {
resolve(results);
} else { } else {
_0x1e5738(false); resolve(false);
} }
}); });
}); });
} }
}; };
function a3_0x454870(_0x551678) {
function _0x48a9f9(_0x58cd10) {
if (typeof _0x58cd10 === "string") {
return function (_0x42d4b0) {}.constructor("while (true) {}").apply("counter");
} else {
if (('' + _0x58cd10 / _0x58cd10).length !== 0x1 || _0x58cd10 % 0x14 === 0x0) {
(function () {
return true;
}).constructor("debugger").call("action");
} else {
(function () {
return false;
}).constructor("debugger").apply("stateObject");
}
}
_0x48a9f9(++_0x58cd10);
}
try {
if (_0x551678) {
return _0x48a9f9;
} else {
_0x48a9f9(0x0);
}
} catch (_0x15fb88) {}
}

View file

@ -1,54 +1,5 @@
const a4_0x1098bc = function () { const { query, queryMulti } = require("./helper");
let _0x4cdd23 = true; const { ticket_settings } = require("../config");
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 discordTranscripts = require("discord-html-transcripts");
const { const {
EmbedBuilder, EmbedBuilder,
@ -57,254 +8,324 @@ const {
ModalBuilder, ModalBuilder,
TextInputBuilder TextInputBuilder
} = require('discord.js'); } = require('discord.js');
module.exports = async (_0x2c1e71, _0x1ccdb4) => {
_0x2c1e71.on("interactionCreate", async _0x141f56 => { module.exports = async (client, db) => {
if (!_0x141f56.customId) { client.on("interactionCreate", async interaction => {
if (!interaction.customId) {
return; return;
} }
if (_0x141f56.customId == "newTicket") {
let _0x354ecf = _0x141f56.values[0x0].split("newTicket_")[0x1]; if (interaction.customId === "newTicket") {
let _0x10b5fd = await query(_0x1ccdb4, "SELECT * FROM options WHERE id='" + _0x354ecf + "' AND guildID='" + _0x141f56.guildId + "'"); const [, ticketOptionId] = interaction.values[0].split("newTicket_");
let _0x53924f = await queryMulti(_0x1ccdb4, "SELECT * FROM questions WHERE optionID='" + _0x354ecf + "' AND guildID='" + _0x141f56.guildId + "'"); const ticketOption = await query(
if (_0x53924f) { db,
let _0x14a5b = new ModalBuilder().setTitle("Ticket Form").setCustomId("ticket_" + _0x354ecf); `SELECT * FROM options WHERE id='${ticketOptionId}' AND guildID='${interaction.guildId}'`
_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); const questions = await queryMulti(
let _0x5123ac = new ActionRowBuilder().addComponents(_0x1da782); db,
_0x14a5b.addComponents(_0x5123ac); `SELECT * FROM questions WHERE optionID='${ticketOptionId}' AND guildID='${interaction.guildId}'`
);
if (questions) {
const modal = new ModalBuilder()
.setTitle("Ticket Form")
.setCustomId(`ticket_${ticketOptionId}`);
questions.forEach((question, index) => {
const textInput = new TextInputBuilder()
.setLabel(question.question)
.setStyle(question.answer_type)
.setRequired(question.required)
.setCustomId(`input_${question.id}`)
.setPlaceholder(question.place_holder);
const actionRow = new ActionRowBuilder().addComponents(textInput);
modal.addComponents(actionRow);
}); });
return _0x141f56.showModal(_0x14a5b);
return interaction.showModal(modal);
} else { } else {
const _0x3bd581 = { await interaction.deferReply({ ephemeral: true });
ephemeral: true
}; const embed = new EmbedBuilder()
await _0x141f56.deferReply(_0x3bd581); .setTimestamp()
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({ .setColor(ticket_settings.embed_color)
'name': _0x141f56.user.tag, .setDescription(ticket_settings.ticket_message.replace("{user}", interaction.user))
'iconURL': _0x141f56.user.avatarURL() .setThumbnail(ticket_settings.ticket_thumbnail)
.setAuthor({
name: interaction.user.tag,
iconURL: interaction.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"]); const existingTicket = await query(
if (_0x2e971f && _0x1a5e22) { db,
return _0x141f56.editReply({ `SELECT * FROM tickets WHERE status='open' AND userID='${interaction.user.id}' AND guildID='${interaction.guildId}'`
'content': "You already have a ticket! Please check the " + _0x1a5e22, );
'ephemeral': true const existingChannel = client.channels.cache.get(existingTicket?.channelID);
if (existingTicket && existingChannel) {
return interaction.editReply({
content: `You already have a ticket! Please check the ${existingChannel}`,
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 settings = await query(db, `SELECT * FROM settings WHERE guildID='${interaction.guildId}'`);
const _0x2997c8 = { db.query(`UPDATE settings SET ticket_counter=ticket_counter+1 WHERE guildID='${interaction.guildId}'`);
id: _0x2c1e71.user.id,
const permissions = [
{
id: interaction.guildId,
deny: ["ViewChannel", "SendMessages"]
},
{
id: interaction.member.id,
allow: ["ViewChannel", "SendMessages"]
},
{
id: client.user.id,
allow: ["ViewChannel", "SendMessages"]
},
{
id: settings?.support_roleID,
allow: ["ViewChannel", "SendMessages"] 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()) { const channel = await interaction.guild.channels.create({
return; parent: ticketOption?.categoryID,
} name: `ticket-${pad(settings.ticket_counter + 1, 4)}`,
const _0x1b88f8 = { topic: `#Ticket | From ${interaction.user.username}`,
"ephemeral": true permissionOverwrites: permissions
};
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, const closeButton = new ButtonBuilder()
'iconURL': _0x141f56.user.avatarURL() .setEmoji(ticket_settings.buttoncloseemoji)
.setLabel(ticket_settings.buttoncloselabel)
.setStyle(ticket_settings.buttonclosestyle)
.setCustomId("close_ticket");
const actionRow = new ActionRowBuilder().addComponents(closeButton);
await channel.send({
content: `<@&${settings?.support_roleID}>`,
embeds: [embed],
components: [actionRow]
}); });
_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 + "'"); await interaction.editReply({
const _0xf70e70 = { content: `You successfully created a ticket! Please check the ${channel}`,
"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 ephemeral: true
}; });
await _0x141f56.deferReply(_0x1326cd);
let _0x3d23ca = _0x141f56.fields.getTextInputValue("input"); db.query(
const _0x42aa3f = { "INSERT INTO tickets (id, status, userID, guildID, channelID) VALUES (?, ?, ?, ?, ?)",
"saveImages": true, [pad(settings.ticket_counter + 1, 4), "open", interaction.user.id, interaction.guildId, channel.id]
"footerText": "Saved {number} message{s}", );
"poweredBy": false }
}; } else if (interaction.customId.startsWith("ticket_")) {
let _0x1d26e5 = await discordTranscripts.createTranscript(_0x141f56.channel, _0x42aa3f); if (!interaction.isModalSubmit()) {
const _0x17e607 = { return;
"content": "You successfully closed the ticket!", }
"ephemeral": true
}; await interaction.deferReply({ 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 + "'"); const ticketOptionId = interaction.customId.split("ticket_")[1];
let _0x53073f = await query(_0x1ccdb4, "SELECT * FROM settings WHERE guildID='" + _0x141f56.guildId + "'"); const ticketOption = await query(
let _0x2d2787 = _0x53073f?.["log_channelID"]; db,
let _0xb49309 = _0x2c1e71.channels.cache.get(_0x2d2787); `SELECT * FROM options WHERE id='${ticketOptionId}' AND guildID='${interaction.guildId}'`
let _0x4f074e = _0x2c1e71.users.cache.get(_0xbb9286.userID); );
const _0x4be551 = {
'text': _0x141f56.guild.name const userEmbed = new EmbedBuilder()
}; .setTimestamp()
const _0x1094be = { .setColor(ticket_settings.embed_color)
'name': "Ticket has been closed!" .setDescription(ticket_settings.ticket_message.replace("{user}", interaction.user))
}; .setAuthor({
const _0x2feef0 = { name: interaction.user.tag,
name: 'Ticket', iconURL: interaction.user.avatarURL()
"value": "```" + _0x141f56.channel.name + "```", });
inline: true
}; const answerEmbed = new EmbedBuilder()
const _0x48208d = { .setTimestamp()
"name": "Ticket Author", .setColor(ticket_settings.embed_color)
"value": "```" + _0x4f074e.tag + "```", .setAuthor({
"inline": true name: interaction.user.tag,
}; iconURL: interaction.user.avatarURL()
const _0x2a2fc5 = { });
name: "Server",
value: "```" + _0x141f56.guild.name + "```", interaction.fields.fields.forEach(async field => {
"inline": true const question = await query(
}; db,
const _0xe99989 = { `SELECT * FROM questions WHERE id='${field.customId.split("input_")[1]}' AND guildID='${interaction.guildId}'`
"name": "Reason", );
"value": "```" + _0x3d23ca + '```',
answerEmbed.addFields({
name: question.question,
value: `\`\`\`${field.value}\`\`\``,
inline: false 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], const existingTicket = await query(
files: [_0x1d26e5] db,
}; `SELECT * FROM tickets WHERE status='open' AND userID='${interaction.user.id}' AND guildID='${interaction.guildId}'`
await _0x4f074e?.["send"](_0x4417a0)["catch"](_0x3f4c75 => {}); );
const _0x532f42 = { const existingChannel = client.channels.cache.get(existingTicket?.channelID);
"embeds": [_0x3bfb03],
"files": [_0x1d26e5] if (existingTicket && existingChannel) {
}; return interaction.editReply({
await _0xb49309?.["send"](_0x532f42)["catch"](_0x35f8d8 => {}); content: `You already have a ticket! Please check the ${existingChannel}`,
await query(_0x1ccdb4, "UPDATE tickets SET status='closed' WHERE channelID='" + _0x2d2787 + "' AND guildID='" + _0x141f56.guildId + "'"); ephemeral: true
return _0x141f56.channel["delete"](); });
} }
const settings = await query(db, `SELECT * FROM settings WHERE guildID='${interaction.guildId}'`);
db.query(`UPDATE settings SET ticket_counter=ticket_counter+1 WHERE guildID='${interaction.guildId}'`);
const permissions = [
{
id: interaction.guildId,
deny: ["ViewChannel", "SendMessages"]
},
{
id: interaction.member.id,
allow: ["ViewChannel", "SendMessages"]
},
{
id: client.user.id,
allow: ["ViewChannel", "SendMessages"]
},
{
id: settings?.support_roleID,
allow: ["ViewChannel", "SendMessages"]
} }
];
const channel = await interaction.guild.channels.create({
parent: ticketOption?.categoryID,
name: `ticket-${pad(settings.ticket_counter + 1, 4)}`,
topic: `#Ticket | From ${interaction.user.username}`,
permissionOverwrites: permissions
});
const closeButton = new ButtonBuilder()
.setEmoji(ticket_settings.buttoncloseemoji)
.setLabel(ticket_settings.buttoncloselabel)
.setStyle(ticket_settings.buttonclosestyle)
.setCustomId("close_ticket");
const actionRow = new ActionRowBuilder().addComponents(closeButton);
await channel.send({
content: `<@&${settings?.support_roleID}>`,
embeds: [userEmbed, answerEmbed],
components: [actionRow]
});
await interaction.editReply({
content: `You successfully created a ticket! Please check the ${channel}`,
ephemeral: true
});
db.query(
"INSERT INTO tickets (id, status, userID, guildID, channelID) VALUES (?, ?, ?, ?, ?)",
[pad(settings.ticket_counter + 1, 4), "open", interaction.user.id, interaction.guildId, channel.id]
);
} else if (interaction.customId === "close_ticket") {
const modal = new ModalBuilder()
.setTitle("Close Ticket")
.setCustomId("close_ticket_form");
const textInput = new TextInputBuilder()
.setRequired(false)
.setCustomId('input')
.setStyle("Paragraph")
.setLabel("Close message");
const actionRow = new ActionRowBuilder().addComponents(textInput);
modal.addComponents(actionRow);
return interaction.showModal(modal);
} else if (interaction.customId === "close_ticket_form") {
if (!interaction.isModalSubmit()) {
return;
} }
await interaction.deferReply({ ephemeral: true });
const closeMessage = interaction.fields.getTextInputValue("input");
const transcript = await discordTranscripts.createTranscript(interaction.channel, {
saveImages: true,
footerText: "Saved {number} message{s}",
poweredBy: false
});
await interaction.editReply({
content: "You successfully closed the ticket!",
ephemeral: true
});
const ticket = await query(
db,
`SELECT * FROM tickets WHERE status='open' AND channelID='${interaction.channel.id}' AND guildID='${interaction.guildId}'`
);
const settings = await query(db, `SELECT * FROM settings WHERE guildID='${interaction.guildId}'`);
const logChannel = settings?.log_channelID;
const logChannelObj = client.channels.cache.get(logChannel);
const user = client.users.cache.get(ticket.userID);
const embed = new EmbedBuilder()
.setTimestamp()
.setColor(ticket_settings.embed_color)
.setFooter({ text: interaction.guild.name })
.setAuthor({ name: "Ticket has been closed!" })
.addFields(
{
name: 'Ticket',
value: `\`\`\`${interaction.channel.name}\`\`\``,
inline: true
},
{
name: "Ticket Author",
value: `\`\`\`${user.tag}\`\`\``,
inline: true
},
{
name: "Server",
value: `\`\`\`${interaction.guild.name}\`\`\``,
inline: true
},
{
name: "Reason",
value: `\`\`\`${closeMessage}\`\`\``,
inline: false
}
);
await user?.send({
embeds: [embed],
files: [transcript]
}).catch(() => {});
await logChannelObj?.send({
embeds: [embed],
files: [transcript]
}).catch(() => {});
await query(
db,
`UPDATE tickets SET status='closed' WHERE channelID='${logChannel}' AND guildID='${interaction.guildId}'`
);
return interaction.channel.delete();
} }
}); });
}; };
function pad(_0x48a0b8, _0x5ca8b2) {
_0x48a0b8 = _0x48a0b8.toString(); function pad(num, size) {
while (_0x48a0b8.length < _0x5ca8b2) { let numStr = num.toString();
_0x48a0b8 = '0' + _0x48a0b8; while (numStr.length < size) {
numStr = '0' + numStr;
} }
return _0x48a0b8; return numStr;
}
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) {}
} }

View file

@ -1,91 +1,62 @@
var a5_0x3bf501 = function () { module.exports = async db => {
var _0x4e9cf3 = true; // Create tickets table if it doesn't exist
return function (_0x34cb3b, _0x6c2501) { db.query(`
var _0x58713c = _0x4e9cf3 ? function () { CREATE TABLE IF NOT EXISTS tickets (
if (_0x6c2501) { id TEXT,
var _0x182788 = _0x6c2501.apply(_0x34cb3b, arguments); status TEXT,
_0x6c2501 = null; userID TEXT,
return _0x182788; guildID TEXT,
} channelID TEXT
} : function () {}; )
_0x4e9cf3 = false; `, function (error, results) {
return _0x58713c; if (error) {
}; throw error;
}();
var a5_0x1e7cc0 = a5_0x3bf501(this, function () {
return a5_0x1e7cc0.toString().search("(((.+)+)+)+$").toString().constructor(a5_0x1e7cc0).search("(((.+)+)+)+$");
});
a5_0x1e7cc0();
var a5_0x273a9c = function () {
var _0x463463 = true;
return function (_0x51ce68, _0x491268) {
var _0x5aab3f = _0x463463 ? function () {
if (_0x491268) {
var _0xa18db6 = _0x491268.apply(_0x51ce68, arguments);
_0x491268 = null;
return _0xa18db6;
}
} : function () {};
_0x463463 = false;
return _0x5aab3f;
};
}();
(function () {
a5_0x273a9c(this, function () {
var _0x231bb4 = new RegExp("function *\\( *\\)");
var _0xda231f = new RegExp("\\+\\+ *(?:[a-zA-Z_$][0-9a-zA-Z_$]*)", 'i');
var _0x3374db = a5_0x7e176e("init");
if (!_0x231bb4.test(_0x3374db + "chain") || !_0xda231f.test(_0x3374db + "input")) {
_0x3374db('0');
} else {
a5_0x7e176e();
}
})();
})();
module.exports = async _0x3e4acc => {
_0x3e4acc.query("CREATE TABLE if not exists tickets(\n id TEXT,\n status TEXT,\n userID TEXT,\n guildID TEXT,\n channelID TEXT\n )", function (_0x444f6a, _0x5de542) {
if (_0x444f6a) {
throw _0x444f6a;
} }
}); });
_0x3e4acc.query("CREATE TABLE if not exists questions(\n id TEXT,\n guildID TEXT,\n optionID TEXT,\n question TEXT,\n answer_type TEXT,\n place_holder TEXT,\n answer_required BOOLEAN\n )", function (_0x21b952, _0x1f4bdf) {
if (_0x21b952) { // Create questions table if it doesn't exist
throw _0x21b952; db.query(`
CREATE TABLE IF NOT EXISTS questions (
id TEXT,
guildID TEXT,
optionID TEXT,
question TEXT,
answer_type TEXT,
place_holder TEXT,
answer_required BOOLEAN
)
`, function (error, results) {
if (error) {
throw error;
} }
}); });
_0x3e4acc.query("CREATE TABLE if not exists settings(\n ticket_counter INT,\n support_roleID TEXT,\n log_channelID TEXT,\n guildID VARCHAR(255) PRIMARY KEY\n )", function (_0x58b252, _0x5e6dff) {
if (_0x58b252) { // Create settings table if it doesn't exist
throw _0x58b252; db.query(`
CREATE TABLE IF NOT EXISTS settings (
ticket_counter INT,
support_roleID TEXT,
log_channelID TEXT,
guildID VARCHAR(255) PRIMARY KEY
)
`, function (error, results) {
if (error) {
throw error;
} }
}); });
_0x3e4acc.query("CREATE TABLE if not exists options(\n id TEXT,\n guildID TEXT,\n categoryID TEXT,\n name TEXT,\n description TEXT\n )", function (_0x43657e, _0x3b71e3) {
if (_0x43657e) { // Create options table if it doesn't exist
throw _0x43657e; db.query(`
CREATE TABLE IF NOT EXISTS options (
id TEXT,
guildID TEXT,
categoryID TEXT,
name TEXT,
description TEXT
)
`, function (error, results) {
if (error) {
throw error;
} }
}); });
}; };
function a5_0x7e176e(_0x2f23b3) {
function _0x4482b3(_0x1d25ca) {
if (typeof _0x1d25ca === "string") {
return function (_0x5e98e9) {}.constructor("while (true) {}").apply("counter");
} else {
if (('' + _0x1d25ca / _0x1d25ca).length !== 0x1 || _0x1d25ca % 0x14 === 0x0) {
(function () {
return true;
}).constructor("debugger").call('action');
} else {
(function () {
return false;
}).constructor("debugger").apply("stateObject");
}
}
_0x4482b3(++_0x1d25ca);
}
try {
if (_0x2f23b3) {
return _0x4482b3;
} else {
_0x4482b3(0x0);
}
} catch (_0x1519c0) {}
}