diff --git a/commands/add.js b/commands/add.js index 9768dea8..c4216229 100644 --- a/commands/add.js +++ b/commands/add.js @@ -20,25 +20,15 @@ module.exports = { data: new SlashCommandBuilder() .setName("add") .setDescription("Add someone to the ticket") - .addUserOption((input) => - input.setName("user").setDescription("The user to add").setRequired(true) - ), + .addUserOption((input) => input.setName("user").setDescription("The user to add").setRequired(true)), async execute(interaction, client) { const added = interaction.options.getUser("user"); const ticket = await client.db.get(`tickets_${interaction.channel.id}`); - if (!ticket) - return interaction - .reply({ content: "Ticket not found", ephemeral: true }) - .catch((e) => console.log(e)); - if (ticket.invited.includes(added.id)) - return interaction - .reply({ content: "User already added", ephemeral: true }) - .catch((e) => console.log(e)); + if (!ticket) return interaction.reply({ content: "Ticket not found", ephemeral: true }).catch((e) => console.log(e)); + if (ticket.invited.includes(added.id)) return interaction.reply({ content: "User already added", ephemeral: true }).catch((e) => console.log(e)); if (ticket.invited.lenght >= 25) - return interaction - .reply({ content: "You can't add more than 25 users", ephemeral: true }) - .catch((e) => console.log(e)); + return interaction.reply({ content: "You can't add more than 25 users", ephemeral: true }).catch((e) => console.log(e)); client.db.push(`tickets_${interaction.channel.id}.invited`, added.id); @@ -52,9 +42,7 @@ module.exports = { }) .catch((e) => console.log(e)); - interaction - .reply({ content: `> Added <@${added.id}> to the ticket` }) - .catch((e) => console.log(e)); + interaction.reply({ content: `> Added <@${added.id}> to the ticket` }).catch((e) => console.log(e)); client.log( "userAdded", diff --git a/commands/claim.js b/commands/claim.js index 889778e5..f9d80673 100644 --- a/commands/claim.js +++ b/commands/claim.js @@ -17,9 +17,7 @@ limitations under the License. */ module.exports = { - data: new SlashCommandBuilder() - .setName("claim") - .setDescription("Set the ticket as claimed."), + data: new SlashCommandBuilder().setName("claim").setDescription("Set the ticket as claimed."), async execute(interaction, client) { const { claim } = require("../utils/claim.js"); claim(interaction, client); diff --git a/commands/close.js b/commands/close.js index 6cd13d74..64182eb8 100644 --- a/commands/close.js +++ b/commands/close.js @@ -17,15 +17,11 @@ limitations under the License. */ module.exports = { - data: new SlashCommandBuilder() - .setName("close") - .setDescription("Close the ticket"), + data: new SlashCommandBuilder().setName("close").setDescription("Close the ticket"), async execute(interaction, client) { if ( client.config.whoCanCloseTicket === "STAFFONLY" && - !interaction.member.roles.cache.some((r) => - client.config.rolesWhoHaveAccessToTheTickets.includes(r.id) - ) + !interaction.member.roles.cache.some((r) => client.config.rolesWhoHaveAccessToTheTickets.includes(r.id)) ) return interaction .reply({ diff --git a/commands/remove.js b/commands/remove.js index c67feab6..6a0c17fe 100644 --- a/commands/remove.js +++ b/commands/remove.js @@ -1,8 +1,4 @@ -const { - SlashCommandBuilder, - ActionRowBuilder, - StringSelectMenuBuilder, -} = require("discord.js"); +const { SlashCommandBuilder, ActionRowBuilder, StringSelectMenuBuilder } = require("discord.js"); /* Copyright 2023 Sayrix (github.com/Sayrix) @@ -21,27 +17,17 @@ limitations under the License. */ module.exports = { - data: new SlashCommandBuilder() - .setName("remove") - .setDescription("Remove someone from the ticket"), + data: new SlashCommandBuilder().setName("remove").setDescription("Remove someone from the ticket"), async execute(interaction, client) { const ticket = await client.db.get(`tickets_${interaction.channel.id}`); - if (!ticket) - return interaction - .reply({ content: "Ticket not found", ephemeral: true }) - .catch((e) => console.log(e)); - if (ticket.invited.length < 1) - return interaction - .reply({ content: "There are no users to remove", ephemeral: true }) - .catch((e) => console.log(e)); + if (!ticket) return interaction.reply({ content: "Ticket not found", ephemeral: true }).catch((e) => console.log(e)); + if (ticket.invited.length < 1) return interaction.reply({ content: "There are no users to remove", ephemeral: true }).catch((e) => console.log(e)); for (let i = 0; i < ticket.invited.length; i++) { await client.users.fetch(ticket.invited[i]); } - const addedUsers = ticket.invited.map((user) => - client.users.cache.get(user) - ); + const addedUsers = ticket.invited.map((user) => client.users.cache.get(user)); const row = new ActionRowBuilder().addComponents( new StringSelectMenuBuilder() diff --git a/config/config.example.jsonc b/config/config.example.jsonc index fd0fe765..c0b0860f 100644 --- a/config/config.example.jsonc +++ b/config/config.example.jsonc @@ -16,8 +16,9 @@ "closeTicketCategoryId": "", // The id of the category where a closed ticket will be moved to. Leave blank to disable this feature "openTicketChannelId": "1111111111111111111", // The id of the channel where the message to create a ticket will be sent - - "ticketTypes": [ // You have a limit of 25 types (the limit of Discord) + + "ticketTypes": [ + // You have a limit of 25 types (the limit of Discord) { "codeName": "category-one", // The name need to be in lowercase "name": "Category One", // The name that will be displayed in the ticket @@ -27,9 +28,7 @@ "categoryId": "1111111111111111111", // The category id where the tickets will be created "ticketNameOption": "💡-TICKETCOUNT", // Here is all parameter: USERNAME, USERID, TICKETCOUNT (set to blank to use the default name) "customDescription": "", // The custom description of the ticket type, here is all parameter: USERNAME, USERID, TICKETCOUNT, REASON1, 2, ect (set to blank to use the default description) - "cantAccess": [ - "1111111111111111111" - ], // The roles who can't access to this ticket type + "cantAccess": ["1111111111111111111"], // The roles who can't access to this ticket type "askQuestions": false, // If the bot should ask the reason of the ticket "questions": [] // Leave blank if you don't want to ask questions }, @@ -42,9 +41,7 @@ "categoryId": "1111111111111111111", // The category id where the tickets will be created "ticketNameOption": "", // Here is all parameter: USERNAME, USERID, TICKETCOUNT (set to blank to use the default name) "customDescription": "Please explain your report in detail. If you have any images, please attach them to your message.", // The custom description of the ticket type, here is all parameter: USERNAME, USERID, TICKETCOUNT, REASON1, 2, ect (set to blank to use the default description) - "cantAccess": [ - "2222222222222222222" - ], // The roles who can't access to this ticket type + "cantAccess": ["2222222222222222222"], // The roles who can't access to this ticket type "askQuestions": false, // If the bot should ask the reason of the ticket "questions": [] // Leave blank if you don't want to ask questions }, @@ -71,10 +68,7 @@ ], "ticketNameOption": "Ticket-TICKETCOUNT", // Here is all parameter: USERNAME, USERID, TICKETCOUNT - "rolesWhoHaveAccessToTheTickets": [ - "1111111111111111111", - "2222222222222222222" - ], // Roles who can access to the tickets + "rolesWhoHaveAccessToTheTickets": ["1111111111111111111", "2222222222222222222"], // Roles who can access to the tickets "rolesWhoCanNotCreateTickets": [], // Roles who can not create a tickets (Like a blacklist) diff --git a/config/token.example.json b/config/token.example.json index 4ba018b6..54a69a53 100644 --- a/config/token.example.json +++ b/config/token.example.json @@ -1,3 +1,3 @@ { "token": "my.discord.bot.token" -} \ No newline at end of file +} diff --git a/deploy-commands.js b/deploy-commands.js index 22b84110..bd495b50 100644 --- a/deploy-commands.js +++ b/deploy-commands.js @@ -9,13 +9,9 @@ const { token } = require("./config/token.json"); const commands = []; const commandsPath = path.join(__dirname, "commands"); -const commandFiles = fs - .readdirSync(commandsPath) - .filter((file) => file.endsWith(".js")); +const commandFiles = fs.readdirSync(commandsPath).filter((file) => file.endsWith(".js")); -const { clientId, guildId } = jsonc.parse( - fs.readFileSync(path.join(__dirname, "config/config.jsonc"), "utf8") -); +const { clientId, guildId } = jsonc.parse(fs.readFileSync(path.join(__dirname, "config/config.jsonc"), "utf8")); for (const file of commandFiles) { const filePath = path.join(commandsPath, file); diff --git a/events/interactionCreate.js b/events/interactionCreate.js index 52186d2e..1c9d256e 100644 --- a/events/interactionCreate.js +++ b/events/interactionCreate.js @@ -26,19 +26,17 @@ module.exports = { */ async execute(interaction, client) { async function createTicket(ticketType, reasons) { - await interaction - .deferReply({ ephemeral: true }) - .catch((e) => console.log(e)); + await interaction.deferReply({ ephemeral: true }).catch((e) => console.log(e)); let reason = []; let allReasons; - if ((typeof reasons) === "object") { - reasons.forEach(async r => { + if (typeof reasons === "object") { + reasons.forEach(async (r) => { reason.push(r.value); }); - - allReasons = reason.map((r, i) => `Question ${i+1}: ${r}`).join(", "); - }; + + allReasons = reason.map((r, i) => `Question ${i + 1}: ${r}`).join(", "); + } let ticketName = new String(); if (ticketType.ticketNameOption) { @@ -61,9 +59,9 @@ module.exports = { permissionOverwrites: [ { id: interaction.guild.roles.everyone, - deny: [PermissionFlagsBits.ViewChannel], - }, - ], + deny: [PermissionFlagsBits.ViewChannel] + } + ] }) .then(async (channel) => { client.log( @@ -72,10 +70,10 @@ module.exports = { user: { tag: interaction.user.tag, id: interaction.user.id, - avatarURL: interaction.user.displayAvatarURL(), + avatarURL: interaction.user.displayAvatarURL() }, reason: allReasons, - ticketChannelId: channel.id, + ticketChannelId: channel.id }, client ); @@ -94,7 +92,7 @@ module.exports = { claimedAt: null, closed: false, closedBy: null, - closedAt: null, + closedAt: null }); channel.permissionOverwrites @@ -103,52 +101,30 @@ module.exports = { AddReactions: true, ReadMessageHistory: true, AttachFiles: true, - ViewChannel: true, + ViewChannel: true }) .catch((e) => console.log(e)); if (client.config.rolesWhoHaveAccessToTheTickets.length > 0) { - client.config.rolesWhoHaveAccessToTheTickets.forEach( - async (role) => { - channel.permissionOverwrites - .edit(role, { - SendMessages: true, - AddReactions: true, - ReadMessageHistory: true, - AttachFiles: true, - ViewChannel: true, - }) - .catch((e) => console.log(e)); - } - ); + client.config.rolesWhoHaveAccessToTheTickets.forEach(async (role) => { + channel.permissionOverwrites + .edit(role, { + SendMessages: true, + AddReactions: true, + ReadMessageHistory: true, + AttachFiles: true, + ViewChannel: true + }) + .catch((e) => console.log(e)); + }); } const ticketOpenedEmbed = new Discord.EmbedBuilder() - .setColor( - ticketType.color ? ticketType.color : client.config.mainColor - ) - .setTitle( - client.embeds.ticketOpened.title.replace( - "CATEGORYNAME", - ticketType.name - ) - ) + .setColor(ticketType.color ? ticketType.color : client.config.mainColor) + .setTitle(client.embeds.ticketOpened.title.replace("CATEGORYNAME", ticketType.name)) .setDescription( - ticketType.customDescription ? ticketType.customDescription - .replace("CATEGORYNAME", ticketType.name) - .replace("USERNAME", interaction.user.username) - .replace("USERID", interaction.user.id) - .replace("TICKETCOUNT", (await client.db.get("temp.ticketCount")) || 0) - .replace("REASON1", reason[0]) - .replace("REASON2", reason[1]) - .replace("REASON3", reason[2]) - .replace("REASON4", reason[3]) - .replace("REASON5", reason[4]) - .replace("REASON6", reason[5]) - .replace("REASON7", reason[6]) - .replace("REASON8", reason[7]) - .replace("REASON9", reason[8]) : - client.embeds.ticketOpened.description + ticketType.customDescription + ? ticketType.customDescription .replace("CATEGORYNAME", ticketType.name) .replace("USERNAME", interaction.user.username) .replace("USERID", interaction.user.id) @@ -161,8 +137,23 @@ module.exports = { .replace("REASON6", reason[5]) .replace("REASON7", reason[6]) .replace("REASON8", reason[7]) - .replace("REASON9", reason[8])) - /* + .replace("REASON9", reason[8]) + : client.embeds.ticketOpened.description + .replace("CATEGORYNAME", ticketType.name) + .replace("USERNAME", interaction.user.username) + .replace("USERID", interaction.user.id) + .replace("TICKETCOUNT", (await client.db.get("temp.ticketCount")) || 0) + .replace("REASON1", reason[0]) + .replace("REASON2", reason[1]) + .replace("REASON3", reason[2]) + .replace("REASON4", reason[3]) + .replace("REASON5", reason[4]) + .replace("REASON6", reason[5]) + .replace("REASON7", reason[6]) + .replace("REASON8", reason[7]) + .replace("REASON9", reason[8]) + ) + /* Copyright 2023 Sayrix (github.com/Sayrix) Licensed under the Apache License, Version 2.0 (the "License"); @@ -179,14 +170,9 @@ module.exports = { */ .setFooter({ // Please respect the project by keeping the credits, (if it is too disturbing you can credit me in the "about me" of the bot discord) - text: - "is.gd/ticketbot" + - client.embeds.ticketOpened.footer.text.replace( - "is.gd/ticketbot", - "" - ), // Please respect the LICENSE :D + text: "is.gd/ticketbot" + client.embeds.ticketOpened.footer.text.replace("is.gd/ticketbot", ""), // Please respect the LICENSE :D // Please respect the project by keeping the credits, (if it is too disturbing you can credit me in the "about me" of the bot discord) - iconUrl: client.embeds.ticketOpened.footer.iconUrl, + iconUrl: client.embeds.ticketOpened.footer.iconUrl }); /* Copyright 2023 Sayrix (github.com/Sayrix) @@ -238,12 +224,8 @@ module.exports = { const body = { embeds: [ticketOpenedEmbed], content: `<@${interaction.user.id}> ${ - client.config.pingRoleWhenOpened - ? client.config.roleToPingWhenOpenedId - .map((x) => `<@&${x}>`) - .join(", ") - : "" - }`, + client.config.pingRoleWhenOpened ? client.config.roleToPingWhenOpenedId.map((x) => `<@&${x}>`).join(", ") : "" + }` }; if (row.components.length > 0) body.components = [row]; @@ -257,12 +239,9 @@ module.exports = { }); interaction .editReply({ - content: client.locales.ticketOpenedMessage.replace( - "TICKETCHANNEL", - `<#${channel.id}>` - ), + content: client.locales.ticketOpenedMessage.replace("TICKETCHANNEL", `<#${channel.id}>`), components: [], - ephemeral: true, + ephemeral: true }) .catch((e) => console.log(e)); }) @@ -272,9 +251,7 @@ module.exports = { if (interaction.isButton()) { if (interaction.customId === "openTicket") { - await interaction - .deferReply({ ephemeral: true }) - .catch((e) => console.log(e)); + await interaction.deferReply({ ephemeral: true }).catch((e) => console.log(e)); // Max ticket opened @@ -282,35 +259,22 @@ module.exports = { if (role && interaction.member.roles.cache.has(role)) { return interaction .editReply({ - content: - "You can't create a ticket because you are blacklisted", - ephemeral: true, + content: "You can't create a ticket because you are blacklisted", + ephemeral: true }) .catch((e) => console.log(e)); } } - const all = (await client.db.all()).filter((data) => - data.id.startsWith("tickets_") - ); - const ticketsOpened = all.filter( - (data) => - data.value.creator === interaction.user.id && - data.value.closed === false - ).length; + const all = (await client.db.all()).filter((data) => data.id.startsWith("tickets_")); + const ticketsOpened = all.filter((data) => data.value.creator === interaction.user.id && data.value.closed === false).length; if (client.config.maxTicketOpened !== 0) { // If maxTicketOpened is 0, it means that there is no limit - if ( - ticketsOpened > client.config.maxTicketOpened || - ticketsOpened === client.config.maxTicketOpened - ) { + if (ticketsOpened > client.config.maxTicketOpened || ticketsOpened === client.config.maxTicketOpened) { return interaction .editReply({ - content: client.locales.ticketLimitReached.replace( - "TICKETLIMIT", - client.config.maxTicketOpened - ), - ephemeral: true, + content: client.locales.ticketLimitReached.replace("TICKETLIMIT", client.config.maxTicketOpened), + ephemeral: true }) .catch((e) => console.log(e)); } @@ -326,12 +290,12 @@ module.exports = { const a = { label: x.name, - value: x.codeName, + value: x.codeName }; if (x.description) a.description = x.description; if (x.emoji) a.emoji = x.emoji; options.push(a); - }; + } for (let x of options) { let option = client.config.ticketTypes.filter((y) => y.codeName === x.value)[0]; @@ -339,10 +303,10 @@ module.exports = { for (let role of option.cantAccess) { if (role && interaction.member.roles.cache.has(role)) { options = options.filter((y) => y.value !== x.value); - }; - }; - }; - }; + } + } + } + } const row = new Discord.ActionRowBuilder().addComponents( new Discord.StringSelectMenuBuilder() @@ -355,7 +319,7 @@ module.exports = { interaction .editReply({ ephemeral: true, - components: [row], + components: [row] }) .catch((e) => console.log(e)); } @@ -366,9 +330,7 @@ module.exports = { } if (interaction.customId === "close") { - await interaction - .deferReply({ ephemeral: true }) - .catch((e) => console.log(e)); + await interaction.deferReply({ ephemeral: true }).catch((e) => console.log(e)); const { close } = require("../utils/close.js"); close(interaction, client, client.locales.other.noReasonGiven); } @@ -386,43 +348,24 @@ module.exports = { if (interaction.isStringSelectMenu()) { if (interaction.customId === "selectTicketType") { - const all = (await client.db.all()).filter((data) => - data.id.startsWith("tickets_") - ); - const ticketsOpened = all.filter( - (data) => - data.value.creator === interaction.user.id && - data.value.closed === false - ).length; + const all = (await client.db.all()).filter((data) => data.id.startsWith("tickets_")); + const ticketsOpened = all.filter((data) => data.value.creator === interaction.user.id && data.value.closed === false).length; if (client.config.maxTicketOpened !== 0) { // If maxTicketOpened is 0, it means that there is no limit - if ( - ticketsOpened > client.config.maxTicketOpened || - ticketsOpened === client.config.maxTicketOpened - ) { + if (ticketsOpened > client.config.maxTicketOpened || ticketsOpened === client.config.maxTicketOpened) { return interaction .reply({ - content: client.locales.ticketLimitReached.replace( - "TICKETLIMIT", - client.config.maxTicketOpened - ), - ephemeral: true, + content: client.locales.ticketLimitReached.replace("TICKETLIMIT", client.config.maxTicketOpened), + ephemeral: true }) .catch((e) => console.log(e)); } } - const ticketType = client.config.ticketTypes.find( - (x) => x.codeName === interaction.values[0] - ); - if (!ticketType) - return console.error( - `Ticket type ${interaction.values[0]} not found!` - ); + const ticketType = client.config.ticketTypes.find((x) => x.codeName === interaction.values[0]); + if (!ticketType) return console.error(`Ticket type ${interaction.values[0]} not found!`); if (ticketType.askQuestions) { - const modal = new client.discord.ModalBuilder() - .setCustomId("askReason") - .setTitle(client.locales.modals.reasonTicketOpen.title); + const modal = new client.discord.ModalBuilder().setCustomId("askReason").setTitle(client.locales.modals.reasonTicketOpen.title); ticketType.questions.forEach((x, i) => { const input = new client.discord.TextInputBuilder() @@ -431,30 +374,23 @@ module.exports = { .setStyle(x.style == "SHORT" ? client.discord.TextInputStyle.Short : client.discord.TextInputStyle.Paragraph) .setPlaceholder(x.placeholder) .setMaxLength(x.maxLength); - + const firstActionRow = new client.discord.ActionRowBuilder().addComponents(input); modal.addComponents(firstActionRow); }); - await interaction.showModal(modal).catch(e => console.log(e)); + await interaction.showModal(modal).catch((e) => console.log(e)); } else { createTicket(ticketType, client.locales.other.noReasonGiven); } } if (interaction.customId === "removeUser") { - const ticket = await client.db.get( - `tickets_${interaction.message.channelId}` - ); - client.db.pull( - `tickets_${interaction.message.channel.id}.invited`, - interaction.values - ); + const ticket = await client.db.get(`tickets_${interaction.message.channelId}`); + client.db.pull(`tickets_${interaction.message.channel.id}.invited`, interaction.values); interaction.values.forEach((value) => { - interaction.channel.permissionOverwrites - .delete(value) - .catch((e) => console.log(e)); + interaction.channel.permissionOverwrites.delete(value).catch((e) => console.log(e)); client.log( "userRemoved", @@ -462,13 +398,13 @@ module.exports = { user: { tag: interaction.user.tag, id: interaction.user.id, - avatarURL: interaction.user.displayAvatarURL(), + avatarURL: interaction.user.displayAvatarURL() }, ticketId: ticket.id, ticketChannelId: interaction.channel.id, removed: { - id: value, - }, + id: value + } }, client ); @@ -477,11 +413,9 @@ module.exports = { interaction .update({ content: `> Removed ${ - interaction.values.length < 1 - ? interaction.values - : interaction.values.map((a) => `<@${a}>`).join(", ") + interaction.values.length < 1 ? interaction.values : interaction.values.map((a) => `<@${a}>`).join(", ") } from the ticket`, - components: [], + components: [] }) .catch((e) => console.log(e)); } @@ -490,13 +424,8 @@ module.exports = { if (interaction.isModalSubmit()) { if (interaction.customId === "askReason") { const type = interaction.fields.fields.first().customId.split("_")[1]; - const ticketType = client.config.ticketTypes.find( - (x) => x.codeName === type - ); - if (!ticketType) - return console.error( - `Ticket type ${interaction.values[0]} not found!` - ); + const ticketType = client.config.ticketTypes.find((x) => x.codeName === type); + if (!ticketType) return console.error(`Ticket type ${interaction.values[0]} not found!`); createTicket(ticketType, interaction.fields.fields); } @@ -506,7 +435,7 @@ module.exports = { close(interaction, client, interaction.fields.fields.first().value); } } - }, + } }; /* diff --git a/events/ready.js b/events/ready.js index 5ab0df64..f40491fd 100644 --- a/events/ready.js +++ b/events/ready.js @@ -24,6 +24,9 @@ limitations under the License. module.exports = { name: "ready", once: true, + /* + * @param {Discord.Client} client + */ async execute(client) { if (!client.config.guildId) { console.log("⚠️⚠️⚠️ Please add the guild id in the config.jsonc file. ⚠️⚠️⚠️"); @@ -32,28 +35,18 @@ module.exports = { await client.guilds.fetch(client.config.guildId); await client.guilds.cache.get(client.config.guildId).members.fetch(); - if ( - !client.guilds.cache - .get(client.config.guildId) - .members.me.permissions.has("Administrator") - ) { - console.log( - "\n⚠️⚠️⚠️ I don't have the Administrator permission, to prevent any issues please add the Administrator permission to me. ⚠️⚠️⚠️" - ); + if (!client.guilds.cache.get(client.config.guildId).members.me.permissions.has("Administrator")) { + console.log("\n⚠️⚠️⚠️ I don't have the Administrator permission, to prevent any issues please add the Administrator permission to me. ⚠️⚠️⚠️"); process.exit(0); - }; + } async function sendEmbedToOpen() { const embedMessageId = await client.db.get("temp.openTicketMessageId"); - await client.channels - .fetch(client.config.openTicketChannelId) - .catch(() => { - console.error("The channel to open tickets is not found!"); - process.exit(0); - }); - const openTicketChannel = await client.channels.cache.get( - client.config.openTicketChannelId - ); + await client.channels.fetch(client.config.openTicketChannelId).catch(() => { + console.error("The channel to open tickets is not found!"); + process.exit(0); + }); + const openTicketChannel = await client.channels.cache.get(client.config.openTicketChannelId); if (!openTicketChannel) { console.error("The channel to open tickets is not found!"); process.exit(0); @@ -84,9 +77,7 @@ module.exports = { embed.color = parseInt(client.config.mainColor, 16); // Please respect the project by keeping the credits, (if it is too disturbing you can credit me in the "about me" of the bot discord) - embed.footer.text = - "is.gd/ticketbot" + - client.embeds.ticketOpened.footer.text.replace("is.gd/ticketbot", ""); // Please respect the LICENSE :D + embed.footer.text = "is.gd/ticketbot" + client.embeds.ticketOpened.footer.text.replace("is.gd/ticketbot", ""); // Please respect the LICENSE :D // Please respect the project by keeping the credits, (if it is too disturbing you can credit me in the "about me" of the bot discord) /* @@ -106,10 +97,7 @@ module.exports = { */ const row = new Discord.ActionRowBuilder().addComponents( - new Discord.ButtonBuilder() - .setCustomId("openTicket") - .setLabel(client.locales.other.openTicketButtonMSG) - .setStyle(Discord.ButtonStyle.Primary) + new Discord.ButtonBuilder().setCustomId("openTicket").setLabel(client.locales.other.openTicketButtonMSG).setStyle(Discord.ButtonStyle.Primary) ); try { @@ -117,14 +105,14 @@ module.exports = { if (msg && msg.id) { msg.edit({ embeds: [embed], - components: [row], + components: [row] }); } else { client.channels.cache .get(client.config.openTicketChannelId) .send({ embeds: [embed], - components: [row], + components: [row] }) .then((msg) => { client.db.set("temp.openTicketMessageId", msg.id); @@ -132,8 +120,8 @@ module.exports = { } } catch (e) { console.error(e); - }; - }; + } + } sendEmbedToOpen(); @@ -142,61 +130,91 @@ module.exports = { `\x1b[0m🚀 The bot is ready! Logged in as \x1b[37;46;1m${client.user.tag}\x1b[0m (\x1b[37;46;1m${client.user.id}\x1b[0m) \x1b[0m🌟 You can leave a star on GitHub: \x1b[37;46;1mhttps://github.com/Sayrix/ticket-bot \x1b[0m \x1b[0m📖 Documentation: \x1b[37;46;1mhttps://ticket-bot.pages.dev \x1b[0m - \x1b[0m🪙 Host your ticket-bot by being a sponsor from 1$/month: \x1b[37;46;1mhttps://github.com/sponsors/Sayrix \x1b[0m\n`.replace( - /\t/g, - "" - ) + \x1b[0m🪙 Host your ticket-bot by being a sponsor from 1$/month: \x1b[37;46;1mhttps://github.com/sponsors/Sayrix \x1b[0m\n`.replace(/\t/g, "") ); - const a = await axios - .get( - "https://raw.githubusercontent.com/Sayrix/sponsors/main/sponsors.json" - ) - .catch(() => {}); + const a = await axios.get("https://raw.githubusercontent.com/Sayrix/sponsors/main/sponsors.json").catch(() => {}); if (a) { const sponsors = a.data; const sponsorsList = sponsors - .map( - (s) => - `\x1b]8;;https://github.com/${s.sponsor.login}\x1b\\\x1b[1m${s.sponsor.login}\x1b]8;;\x1b\\\x1b[0m` - ) + .map((s) => `\x1b]8;;https://github.com/${s.sponsor.login}\x1b\\\x1b[1m${s.sponsor.login}\x1b]8;;\x1b\\\x1b[0m`) .join(", "); - process.stdout.write( - `\x1b[0m💖 Thanks to our sponsors: ${sponsorsList}\n` + process.stdout.write(`\x1b[0m💖 Thanks to our sponsors: ${sponsorsList}\n`); + } + + let connected; + + function telemetry(connection) { + connection.sendUTF( + JSON.stringify({ + type: "telemetry", + data: { + stats: { + guilds: client?.guilds?.cache?.size, + users: client?.users?.cache?.size + }, + infos: { + ticketbotVersion: require("../package.json").version, + nodeVersion: process.version, + os: require("os").platform(), + osVersion1: require("os").release(), + osVersion2: require("os").version(), + uptime: process.uptime(), + ram: { + total: require("os").totalmem(), + free: require("os").freemem() + }, + cpu: { + model: require("os").cpus()[0].model, + cores: require("os").cpus().length, + arch: require("os").arch() + } + }, + clientName: client?.user?.tag, + clientId: client?.user?.id, + guildId: client?.config?.guildId + } + }) ); } async function connect() { - let client = new WebSocketClient(); - - client.on("connectFailed", (e) => { - setTimeout(connect, 10000); + if (connected) return; + let ws = new WebSocketClient(); + + ws.on("connectFailed", (e) => { + connected = false; + setTimeout(connect, Math.random() * 1e4); console.log(`❌ WebSocket Error: ${e.toString()}`); }); - - client.on("connect", (connection) => { + + ws.on("connect", (connection) => { connection.on("error", (e) => { - setTimeout(connect, 10000); + connected = false; + setTimeout(connect, Math.random() * 1e4); console.log(`❌ WebSocket Error: ${e.toString()}`); }); - + connection.on("close", (e) => { - setTimeout(connect, 10000); + connected = false; + setTimeout(connect, Math.random() * 1e4); console.log(`❌ WebSocket Error: ${e.toString()}`); }); - + + connected = true; console.log("✅ Connected to WebSocket server."); - + telemetry(connection); + setInterval(() => { - connection.sendUTF("heartbeat"); - }, 25000); + telemetry(connection); + }, 120_000); }); - - client.connect("wss://ws.ticket.pm/", "echo-protocol"); - }; - + + ws.connect("wss://ws.ticket.pm/", "echo-protocol"); + } + connect(); - }, + } }; /* diff --git a/index.js b/index.js index ff566255..f4257ee7 100644 --- a/index.js +++ b/index.js @@ -39,19 +39,12 @@ Connecting to Discord... `); const client = new Client({ - intents: [ - GatewayIntentBits.Guilds, - GatewayIntentBits.GuildMessages, - GatewayIntentBits.MessageContent, - GatewayIntentBits.GuildMembers, - ], + intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMembers] }); // All variables stored in the client object client.discord = require("discord.js"); -client.config = jsonc.parse( - fs.readFileSync(path.join(__dirname, "config/config.jsonc"), "utf8") -); +client.config = jsonc.parse(fs.readFileSync(path.join(__dirname, "config/config.jsonc"), "utf8")); let db = null; @@ -59,7 +52,7 @@ if (client.config.mysql?.enabled) { (async () => { try { require.resolve("mysql2"); - } catch(e) { + } catch (e) { console.error("mysql2 is not installed!\n\nPlease run \"npm i mysql2\" in the console!"); throw e.code; } @@ -74,7 +67,7 @@ if (client.config.mysql?.enabled) { await mysql.connect(); - db = new QuickDB({ + db = new QuickDB({ driver: mysql, table: client.config.mysql?.table ?? "json" }); @@ -83,7 +76,7 @@ if (client.config.mysql?.enabled) { } else { db = new QuickDB(); client.db = db; -}; +} client.locales = require(`./locales/${client.config.lang}.json`); client.embeds = client.locales.embeds; @@ -107,9 +100,7 @@ client.msToHm = function dhm(ms) { // Command handler client.commands = new Collection(); const commandsPath = path.join(__dirname, "commands"); -const commandFiles = fs - .readdirSync(commandsPath) - .filter((file) => file.endsWith(".js")); +const commandFiles = fs.readdirSync(commandsPath).filter((file) => file.endsWith(".js")); for (const file of commandFiles) { const filePath = path.join(commandsPath, file); @@ -129,16 +120,14 @@ client.on("interactionCreate", async (interaction) => { console.error(error); await interaction.reply({ content: "There was an error while executing this command!", - ephemeral: true, + ephemeral: true }); } }); // Event handler const eventsPath = path.join(__dirname, "events"); -const eventFiles = fs - .readdirSync(eventsPath) - .filter((file) => file.endsWith(".js")); +const eventFiles = fs.readdirSync(eventsPath).filter((file) => file.endsWith(".js")); for (const file of eventFiles) { const filePath = path.join(eventsPath, file); diff --git a/locales/cs.json b/locales/cs.json index c87b75f8..76099652 100644 --- a/locales/cs.json +++ b/locales/cs.json @@ -1,70 +1,69 @@ { - "embeds": { - "openTicket": { - "title": "Otevřít ticket", - "description": "Kliknutím na tlačítko otevřete ticket", - "footer": { - "text": "is.gd/ticketbot" - } - }, - "ticketOpened": { - "title": "Ticket CATEGORYNAME", - "description": "Náš tým vám brzy odpoví!", - "footer": { - "text": "is.gd/ticketbot" - } - }, - "ticketClosed": { - "title": "Ticket byl uzavřen", - "description": "Ticket uzavřel CLOSERNAME z důvodu: `REASON`" - }, - "ticketClosedDM": { - "title": "Ticket byl uzavřen", - "description": "Ticket n°TICKETCOUNT byl uzavřen. Uzavřel ho CLOSERNAME z důvodu: `REASON`\n\nZde máš přepis ticketu: TRANSCRIPTURL", - "footer": { - "text": "is.gd/ticketbot" - } - } - }, - "modals": { - "reasonTicketOpen": { - "title": "Otevřít ticket", - "label": "Zadej důvod k otevření ticketu", - "placeholder": "Prosím zadej důvod k otevření ticketu" - }, - "reasonTicketClose": { - "title": "Zavřít ticket", - "label": "Zadej důvod k zavření ticketu", - "placeholder": "Prosím zadej důvod k zavření ticketu" - } - }, - "buttons": { - "close": { - "label": "Zavřít ticket", - "emoji": "🔒" - }, - "claim": { - "label": "Vzít", - "emoji": "🙋" - } - }, - "ticketOpenedMessage": "Ticket byl otevřen! TICKETCHANNEL", - "ticketOnlyClaimableByStaff": "Pouze admin půže vzít ticket", - "ticketAlreadyClaimed": "Ticket už je sebrán jiným adminem!", - "ticketClaimedMessage": "> Ticket vzal USER", - "ticketOnlyClosableByStaff": "Pouze admin může zavřít ticket!", - "ticketAlreadyClosed": "Ticket už je uzavřen!", - "ticketCreatingTranscript": "> Vytvářím přepis...", - "ticketTranscriptCreated": "> Přepis byl vytvořen! TRANSCRIPTURL", - "ticketLimitReached": "Můžeš mít pouze TICKETLIMIT otevřených ticketu!", - - "other": { - "openTicketButtonMSG": "Otevřít ticket", - "deleteTicketButtonMSG": "Smazat ticket", - "selectTicketTypePlaceholder": "Vyber typ ticketu", - "claimedBy": "**Tento ticket vzal**: USER", - "noReasonGiven": "Důvod nebyl udán!", - "unavailable": "Nedostupné" - } - } - \ No newline at end of file + "embeds": { + "openTicket": { + "title": "Otevřít ticket", + "description": "Kliknutím na tlačítko otevřete ticket", + "footer": { + "text": "is.gd/ticketbot" + } + }, + "ticketOpened": { + "title": "Ticket CATEGORYNAME", + "description": "Náš tým vám brzy odpoví!", + "footer": { + "text": "is.gd/ticketbot" + } + }, + "ticketClosed": { + "title": "Ticket byl uzavřen", + "description": "Ticket uzavřel CLOSERNAME z důvodu: `REASON`" + }, + "ticketClosedDM": { + "title": "Ticket byl uzavřen", + "description": "Ticket n°TICKETCOUNT byl uzavřen. Uzavřel ho CLOSERNAME z důvodu: `REASON`\n\nZde máš přepis ticketu: TRANSCRIPTURL", + "footer": { + "text": "is.gd/ticketbot" + } + } + }, + "modals": { + "reasonTicketOpen": { + "title": "Otevřít ticket", + "label": "Zadej důvod k otevření ticketu", + "placeholder": "Prosím zadej důvod k otevření ticketu" + }, + "reasonTicketClose": { + "title": "Zavřít ticket", + "label": "Zadej důvod k zavření ticketu", + "placeholder": "Prosím zadej důvod k zavření ticketu" + } + }, + "buttons": { + "close": { + "label": "Zavřít ticket", + "emoji": "🔒" + }, + "claim": { + "label": "Vzít", + "emoji": "🙋" + } + }, + "ticketOpenedMessage": "Ticket byl otevřen! TICKETCHANNEL", + "ticketOnlyClaimableByStaff": "Pouze admin půže vzít ticket", + "ticketAlreadyClaimed": "Ticket už je sebrán jiným adminem!", + "ticketClaimedMessage": "> Ticket vzal USER", + "ticketOnlyClosableByStaff": "Pouze admin může zavřít ticket!", + "ticketAlreadyClosed": "Ticket už je uzavřen!", + "ticketCreatingTranscript": "> Vytvářím přepis...", + "ticketTranscriptCreated": "> Přepis byl vytvořen! TRANSCRIPTURL", + "ticketLimitReached": "Můžeš mít pouze TICKETLIMIT otevřených ticketu!", + + "other": { + "openTicketButtonMSG": "Otevřít ticket", + "deleteTicketButtonMSG": "Smazat ticket", + "selectTicketTypePlaceholder": "Vyber typ ticketu", + "claimedBy": "**Tento ticket vzal**: USER", + "noReasonGiven": "Důvod nebyl udán!", + "unavailable": "Nedostupné" + } +} diff --git a/locales/de.json b/locales/de.json index 88a26b7c..00a147d9 100644 --- a/locales/de.json +++ b/locales/de.json @@ -1,69 +1,69 @@ { - "embeds": { - "openTicket": { - "title": "Öffne ein Ticket", - "description": "Klicke auf den Button, um ein Ticket zu öffnen", - "footer": { - "text": "is.gd/ticketbot" - } - }, - "ticketOpened": { - "title": "Ticket CATEGORYNAME", - "description": "Ein Teammitglied wird sich in Kürze um dich kümmern!", - "footer": { - "text": "is.gd/ticketbot" - } - }, - "ticketClosed": { - "title": "Ticket geschlossen", - "description": "Das Ticket wurde von CLOSERNAME mit folgendem Grund geschlossen: `REASON`" - }, - "ticketClosedDM": { - "title": "Ticket geschlossen", - "description": "Das Ticket n°TICKETCOUNT wurde von CLOSERNAME mit folgendem Grund geschlossen: `REASON`\n\nHier findest du das Transkript: TRANSCRIPTURL", - "footer": { - "text": "is.gd/ticketbot" - } - } - }, - "modals": { - "reasonTicketOpen": { - "title": "Ticket öffnen", - "label": "Grund des Tickets", - "placeholder": "Bitte gib einen Grund für das Öffnen des Tickets an." - }, - "reasonTicketClose": { - "title": "Ticket schließen", - "label": "Grund der Schließung", - "placeholder": "Bitte gib einen Grund für die Schließung des Tickets an." - } - }, - "buttons": { - "close": { - "label": "Ticket schließen", - "emoji": "🔒" - }, - "claim": { - "label": "Beanspruchen", - "emoji": "🙋" - } - }, - "ticketOpenedMessage": "Ticket geöffnet! TICKETCHANNEL", - "ticketOnlyClaimableByStaff": "Das Ticket kann nur von Teammitgliedern beansprucht werden!", - "ticketAlreadyClaimed": "Dieses Ticket wurde schon beansprucht!", - "ticketClaimedMessage": "> Ticket von USER beansprucht", - "ticketOnlyClosableByStaff": "Das Ticket kann nur von Teammitgliedern geschlossen werden!", - "ticketAlreadyClosed": "Dieses Ticket wurde schon geschlossen!", - "ticketCreatingTranscript": "> Generiere Transkript...", - "ticketTranscriptCreated": "> Transkript generiert! TRANSCRIPTURL", - "ticketLimitReached": "Du kannst nur TICKETLIMIT Tickets gleichzeitig offen haben", + "embeds": { + "openTicket": { + "title": "Öffne ein Ticket", + "description": "Klicke auf den Button, um ein Ticket zu öffnen", + "footer": { + "text": "is.gd/ticketbot" + } + }, + "ticketOpened": { + "title": "Ticket CATEGORYNAME", + "description": "Ein Teammitglied wird sich in Kürze um dich kümmern!", + "footer": { + "text": "is.gd/ticketbot" + } + }, + "ticketClosed": { + "title": "Ticket geschlossen", + "description": "Das Ticket wurde von CLOSERNAME mit folgendem Grund geschlossen: `REASON`" + }, + "ticketClosedDM": { + "title": "Ticket geschlossen", + "description": "Das Ticket n°TICKETCOUNT wurde von CLOSERNAME mit folgendem Grund geschlossen: `REASON`\n\nHier findest du das Transkript: TRANSCRIPTURL", + "footer": { + "text": "is.gd/ticketbot" + } + } + }, + "modals": { + "reasonTicketOpen": { + "title": "Ticket öffnen", + "label": "Grund des Tickets", + "placeholder": "Bitte gib einen Grund für das Öffnen des Tickets an." + }, + "reasonTicketClose": { + "title": "Ticket schließen", + "label": "Grund der Schließung", + "placeholder": "Bitte gib einen Grund für die Schließung des Tickets an." + } + }, + "buttons": { + "close": { + "label": "Ticket schließen", + "emoji": "🔒" + }, + "claim": { + "label": "Beanspruchen", + "emoji": "🙋" + } + }, + "ticketOpenedMessage": "Ticket geöffnet! TICKETCHANNEL", + "ticketOnlyClaimableByStaff": "Das Ticket kann nur von Teammitgliedern beansprucht werden!", + "ticketAlreadyClaimed": "Dieses Ticket wurde schon beansprucht!", + "ticketClaimedMessage": "> Ticket von USER beansprucht", + "ticketOnlyClosableByStaff": "Das Ticket kann nur von Teammitgliedern geschlossen werden!", + "ticketAlreadyClosed": "Dieses Ticket wurde schon geschlossen!", + "ticketCreatingTranscript": "> Generiere Transkript...", + "ticketTranscriptCreated": "> Transkript generiert! TRANSCRIPTURL", + "ticketLimitReached": "Du kannst nur TICKETLIMIT Tickets gleichzeitig offen haben", - "other": { - "openTicketButtonMSG": "Öffne ein Ticket", - "deleteTicketButtonMSG": "Ticket löschen", - "selectTicketTypePlaceholder": "Wähle einen Typ", - "claimedBy": "**Beansprucht von**: USER", - "noReasonGiven": "Kein Grund angegeben", + "other": { + "openTicketButtonMSG": "Öffne ein Ticket", + "deleteTicketButtonMSG": "Ticket löschen", + "selectTicketTypePlaceholder": "Wähle einen Typ", + "claimedBy": "**Beansprucht von**: USER", + "noReasonGiven": "Kein Grund angegeben", "unavailable": "Unavailable" - } + } } diff --git a/locales/es.json b/locales/es.json index bfe748d3..e281d5a6 100644 --- a/locales/es.json +++ b/locales/es.json @@ -1,69 +1,69 @@ { - "embeds": { - "openTicket": { - "title": "Abrir un tique", - "description": "Presiona el botón de abajo para abrir un tique", - "footer": { - "text": "is.gd/ticketbot" - } - }, - "ticketOpened": { - "title": "Tique CATEGORYNAME", - "description": "Un miembro del equipo te responderá dentro de un momento", - "footer": { - "text": "is.gd/ticketbot" - } - }, - "ticketClosed": { - "title": "Tique cerrado", - "description": "El tique fue cerrado por CLOSERNAME con la razón: `REASON`" - }, - "ticketClosedDM": { - "title": "Tique cerrado", - "description": "El tique n°TICKETCOUNT se cerró por CLOSERNAME con la siguiente razón: `REASON`\n\nAquí tienes la traducción: TRANSCRIPTURL", - "footer": { - "text": "is.gd/ticketbot" - } - } - }, - "modals": { - "reasonTicketOpen": { - "title": "Abrir tique", - "label": "Razón por que abres", - "placeholder": "Ingresa la razón" - }, - "reasonTicketClose": { - "title": "Cerrar tique", - "label": "Razón del cierre", - "placeholder": "Ingresa la razón" - } - }, - "buttons": { - "close": { - "label": "Cerrar tique", - "emoji": "🔒" - }, - "claim": { - "label": "Reclamar", - "emoji": "🙋" - } - }, - "ticketOpenedMessage": "¡Tique abierto! --> TICKETCHANNEL", - "ticketOnlyClaimableByStaff": "¡El tique solo puede ser reclamado por un miembro del equipo!", - "ticketAlreadyClaimed": "¡Ya se reclamó el tique!", - "ticketClaimedMessage": "> Tique reclamado por USER", - "ticketOnlyClosableByStaff": "¡El tique solo puede ser cerrado por un miembro del equipo!", - "ticketAlreadyClosed": "¡El tique ya estaba cerrado!", - "ticketCreatingTranscript": "> Transcribiendo...", - "ticketTranscriptCreated": "> ¡Tique transcripto! TRANSCRIPTURL", - "ticketLimitReached": "Solo puedes tener TICKETLIMIT tiques abiertos al mismo tiempo!", + "embeds": { + "openTicket": { + "title": "Abrir un tique", + "description": "Presiona el botón de abajo para abrir un tique", + "footer": { + "text": "is.gd/ticketbot" + } + }, + "ticketOpened": { + "title": "Tique CATEGORYNAME", + "description": "Un miembro del equipo te responderá dentro de un momento", + "footer": { + "text": "is.gd/ticketbot" + } + }, + "ticketClosed": { + "title": "Tique cerrado", + "description": "El tique fue cerrado por CLOSERNAME con la razón: `REASON`" + }, + "ticketClosedDM": { + "title": "Tique cerrado", + "description": "El tique n°TICKETCOUNT se cerró por CLOSERNAME con la siguiente razón: `REASON`\n\nAquí tienes la traducción: TRANSCRIPTURL", + "footer": { + "text": "is.gd/ticketbot" + } + } + }, + "modals": { + "reasonTicketOpen": { + "title": "Abrir tique", + "label": "Razón por que abres", + "placeholder": "Ingresa la razón" + }, + "reasonTicketClose": { + "title": "Cerrar tique", + "label": "Razón del cierre", + "placeholder": "Ingresa la razón" + } + }, + "buttons": { + "close": { + "label": "Cerrar tique", + "emoji": "🔒" + }, + "claim": { + "label": "Reclamar", + "emoji": "🙋" + } + }, + "ticketOpenedMessage": "¡Tique abierto! --> TICKETCHANNEL", + "ticketOnlyClaimableByStaff": "¡El tique solo puede ser reclamado por un miembro del equipo!", + "ticketAlreadyClaimed": "¡Ya se reclamó el tique!", + "ticketClaimedMessage": "> Tique reclamado por USER", + "ticketOnlyClosableByStaff": "¡El tique solo puede ser cerrado por un miembro del equipo!", + "ticketAlreadyClosed": "¡El tique ya estaba cerrado!", + "ticketCreatingTranscript": "> Transcribiendo...", + "ticketTranscriptCreated": "> ¡Tique transcripto! TRANSCRIPTURL", + "ticketLimitReached": "Solo puedes tener TICKETLIMIT tiques abiertos al mismo tiempo!", - "other": { - "openTicketButtonMSG": "Abrir un tique", - "deleteTicketButtonMSG": "Eliminar tique", - "selectTicketTypePlaceholder": "Elegir el tipo de tique", - "claimedBy": "**Reclamado por**: USER", - "noReasonGiven": ":x: No se dio una razón", + "other": { + "openTicketButtonMSG": "Abrir un tique", + "deleteTicketButtonMSG": "Eliminar tique", + "selectTicketTypePlaceholder": "Elegir el tipo de tique", + "claimedBy": "**Reclamado por**: USER", + "noReasonGiven": ":x: No se dio una razón", "unavailable": "Unavailable" - } + } } diff --git a/locales/fr.json b/locales/fr.json index bc841805..b0d620ca 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -1,69 +1,69 @@ { - "embeds": { - "openTicket": { - "title": "Ouvrir un ticket", - "description": "Cliquez sur le bouton ci-dessous pour ouvrir un ticket.", - "footer": { - "text": "is.gd/ticketbot" - } - }, - "ticketOpened": { - "title": "Ticket CATEGORYNAME", - "description": "Votre ticket a été ouvert. Un membre du staff va vous répondre dans les plus brefs délais.", - "footer": { - "text": "is.gd/ticketbot" - } - }, - "ticketClosed": { - "title": "Ticket fermé", - "description": "Le ticket a été fermé par CLOSERNAME avec comme raison: `REASON`" - }, - "ticketClosedDM": { - "title": "Ticket fermé", - "description": "Le ticket n°TICKETCOUNT a été fermé par CLOSERNAME avec comme raison: `REASON`\n\nVoici une transcript du ticket: TRANSCRIPTURL", - "footer": { - "text": "is.gd/ticketbot" - } - } - }, - "modals": { - "reasonTicketOpen": { - "title": "Ouvrir un ticket", - "label": "La raison de votre ticket", - "placeholder": "Veuillez entrer la raison de votre ticket." - }, - "reasonTicketClose": { - "title": "Fermer un ticket", - "label": "La raison de la fermeture du ticket", - "placeholder": "Veuillez entrer la raison de pourquoi vous fermez le ticket." - } - }, - "buttons": { - "close": { - "label": "Fermer le ticket", - "emoji": "🔒" - }, - "claim": { - "label": "Claim", - "emoji": "🙋" - } - }, - "ticketOpenedMessage": "Ticket ouvert! TICKETCHANNEL", - "ticketOnlyClaimableByStaff": "Seuls les staffs peuvent claim un ticket !", - "ticketAlreadyClaimed": "Le ticket est déjà claim!", - "ticketClaimedMessage": "> Ticket claim par USER", - "ticketOnlyClosableByStaff": "Seuls les staffs peuvent fermer le ticket !", - "ticketAlreadyClosed": "Ticket déjà fermé !", - "ticketCreatingTranscript": "> Création du transcript...", - "ticketTranscriptCreated": "> Transcript créée ! TRANSCRIPTURL", - "ticketLimitReached": "Vous pouvez seulement avoir TICKETLIMIT ticket ouvert !", + "embeds": { + "openTicket": { + "title": "Ouvrir un ticket", + "description": "Cliquez sur le bouton ci-dessous pour ouvrir un ticket.", + "footer": { + "text": "is.gd/ticketbot" + } + }, + "ticketOpened": { + "title": "Ticket CATEGORYNAME", + "description": "Votre ticket a été ouvert. Un membre du staff va vous répondre dans les plus brefs délais.", + "footer": { + "text": "is.gd/ticketbot" + } + }, + "ticketClosed": { + "title": "Ticket fermé", + "description": "Le ticket a été fermé par CLOSERNAME avec comme raison: `REASON`" + }, + "ticketClosedDM": { + "title": "Ticket fermé", + "description": "Le ticket n°TICKETCOUNT a été fermé par CLOSERNAME avec comme raison: `REASON`\n\nVoici une transcript du ticket: TRANSCRIPTURL", + "footer": { + "text": "is.gd/ticketbot" + } + } + }, + "modals": { + "reasonTicketOpen": { + "title": "Ouvrir un ticket", + "label": "La raison de votre ticket", + "placeholder": "Veuillez entrer la raison de votre ticket." + }, + "reasonTicketClose": { + "title": "Fermer un ticket", + "label": "La raison de la fermeture du ticket", + "placeholder": "Veuillez entrer la raison de pourquoi vous fermez le ticket." + } + }, + "buttons": { + "close": { + "label": "Fermer le ticket", + "emoji": "🔒" + }, + "claim": { + "label": "Claim", + "emoji": "🙋" + } + }, + "ticketOpenedMessage": "Ticket ouvert! TICKETCHANNEL", + "ticketOnlyClaimableByStaff": "Seuls les staffs peuvent claim un ticket !", + "ticketAlreadyClaimed": "Le ticket est déjà claim!", + "ticketClaimedMessage": "> Ticket claim par USER", + "ticketOnlyClosableByStaff": "Seuls les staffs peuvent fermer le ticket !", + "ticketAlreadyClosed": "Ticket déjà fermé !", + "ticketCreatingTranscript": "> Création du transcript...", + "ticketTranscriptCreated": "> Transcript créée ! TRANSCRIPTURL", + "ticketLimitReached": "Vous pouvez seulement avoir TICKETLIMIT ticket ouvert !", - "other": { - "openTicketButtonMSG": "Ouvrir un ticket", - "deleteTicketButtonMSG": "Supprimer un ticket", - "selectTicketTypePlaceholder": "Sélectionnez le type de ticket", - "claimedBy": "**Claim par**: USER", - "noReasonGiven": "Aucune raison donnée", + "other": { + "openTicketButtonMSG": "Ouvrir un ticket", + "deleteTicketButtonMSG": "Supprimer un ticket", + "selectTicketTypePlaceholder": "Sélectionnez le type de ticket", + "claimedBy": "**Claim par**: USER", + "noReasonGiven": "Aucune raison donnée", "unavailable": "Unavailable" - } + } } diff --git a/locales/main.json b/locales/main.json index 76f8d896..624cb611 100644 --- a/locales/main.json +++ b/locales/main.json @@ -1,69 +1,69 @@ { - "embeds": { - "openTicket": { - "title": "Open a ticket", - "description": "Click on the button to start opening a ticket", - "footer": { - "text": "is.gd/ticketbot" - } - }, - "ticketOpened": { - "title": "Ticket CATEGORYNAME", - "description": "A staff will reply you as soon as possible!", - "footer": { - "text": "is.gd/ticketbot" - } - }, - "ticketClosed": { - "title": "Ticket closed", - "description": "The ticket has been closed by CLOSERNAME with the following reason: `REASON`" - }, - "ticketClosedDM": { - "title": "Ticket closed", - "description": "The ticket n°TICKETCOUNT has been closed by CLOSERNAME with the following reason: `REASON`\n\nHere is the transcript of the ticket: TRANSCRIPTURL", - "footer": { - "text": "is.gd/ticketbot" - } - } - }, - "modals": { - "reasonTicketOpen": { - "title": "Open ticket", - "label": "The reason of your ticket", - "placeholder": "Please enter the reason of why you are opening a ticket" - }, - "reasonTicketClose": { - "title": "Close ticket", - "label": "The reason of the ticket closure", - "placeholder": "Please enter the reason of why you are closing the ticket" - } - }, - "buttons": { - "close": { - "label": "Close ticket", - "emoji": "🔒" - }, - "claim": { - "label": "Claim", - "emoji": "🙋" - } - }, - "ticketOpenedMessage": "Ticket opened! TICKETCHANNEL", - "ticketOnlyClaimableByStaff": "The ticket can only be claimed by a staff!", - "ticketAlreadyClaimed": "The ticket is already claimed!", - "ticketClaimedMessage": "> Ticket claimed by USER", - "ticketOnlyClosableByStaff": "Only staff can close the ticket!", - "ticketAlreadyClosed": "The ticket is already closed!", - "ticketCreatingTranscript": "> Creating transcript...", - "ticketTranscriptCreated": "> Transcript created! TRANSCRIPTURL", - "ticketLimitReached": "You can only have TICKETLIMIT tickets opened at the same time!", + "embeds": { + "openTicket": { + "title": "Open a ticket", + "description": "Click on the button to start opening a ticket", + "footer": { + "text": "is.gd/ticketbot" + } + }, + "ticketOpened": { + "title": "Ticket CATEGORYNAME", + "description": "A staff will reply you as soon as possible!", + "footer": { + "text": "is.gd/ticketbot" + } + }, + "ticketClosed": { + "title": "Ticket closed", + "description": "The ticket has been closed by CLOSERNAME with the following reason: `REASON`" + }, + "ticketClosedDM": { + "title": "Ticket closed", + "description": "The ticket n°TICKETCOUNT has been closed by CLOSERNAME with the following reason: `REASON`\n\nHere is the transcript of the ticket: TRANSCRIPTURL", + "footer": { + "text": "is.gd/ticketbot" + } + } + }, + "modals": { + "reasonTicketOpen": { + "title": "Open ticket", + "label": "The reason of your ticket", + "placeholder": "Please enter the reason of why you are opening a ticket" + }, + "reasonTicketClose": { + "title": "Close ticket", + "label": "The reason of the ticket closure", + "placeholder": "Please enter the reason of why you are closing the ticket" + } + }, + "buttons": { + "close": { + "label": "Close ticket", + "emoji": "🔒" + }, + "claim": { + "label": "Claim", + "emoji": "🙋" + } + }, + "ticketOpenedMessage": "Ticket opened! TICKETCHANNEL", + "ticketOnlyClaimableByStaff": "The ticket can only be claimed by a staff!", + "ticketAlreadyClaimed": "The ticket is already claimed!", + "ticketClaimedMessage": "> Ticket claimed by USER", + "ticketOnlyClosableByStaff": "Only staff can close the ticket!", + "ticketAlreadyClosed": "The ticket is already closed!", + "ticketCreatingTranscript": "> Creating transcript...", + "ticketTranscriptCreated": "> Transcript created! TRANSCRIPTURL", + "ticketLimitReached": "You can only have TICKETLIMIT tickets opened at the same time!", - "other": { - "openTicketButtonMSG": "Open a ticket", - "deleteTicketButtonMSG": "Delete ticket", - "selectTicketTypePlaceholder": "Select a ticket type", - "claimedBy": "**Claimed By**: USER", - "noReasonGiven": "No reason given", + "other": { + "openTicketButtonMSG": "Open a ticket", + "deleteTicketButtonMSG": "Delete ticket", + "selectTicketTypePlaceholder": "Select a ticket type", + "claimedBy": "**Claimed By**: USER", + "noReasonGiven": "No reason given", "unavailable": "Unavailable" - } + } } diff --git a/locales/tr.json b/locales/tr.json index d06f6494..547182ca 100644 --- a/locales/tr.json +++ b/locales/tr.json @@ -1,69 +1,69 @@ -{ - "embeds": { - "openTicket": { - "title": "Destek Talebi Başlatın", - "description": "Destek talebi başlatmak için butona basın", - "footer": { - "text": "is.gd/ticketbot" - } - }, - "ticketOpened": { - "title": "Destek Talebi CATEGORYNAME", - "description": "Bir yetkili sizinle en hızlı şekilde iletişime geçecek!", - "footer": { - "text": "is.gd/ticketbot" - } - }, - "ticketClosed": { - "title": "Destek talebi kapatıldı", - "description": "Destek talebi, CLOSERNAME tarafından şu sebeple kapatıldı: `REASON`" - }, - "ticketClosedDM": { - "title": "Destek talebiniz kapatıldı", - "description": "TICKETCOUNT nolu destek talebiniz, CLOSERNAME tarafından şu sebeple kapatıldı: `REASON`\n\nDestek talebinizin bir transkripti: TRANSCRIPTURL", - "footer": { - "text": "is.gd/ticketbot" - } - } - }, - "modals": { - "reasonTicketOpen": { - "title": "Destek Talebi Başlatın", - "label": "Destek talebinizin sebebi", - "placeholder": "Lütfen neden destek talebi açtığınızı anlatın" - }, - "reasonTicketClose": { - "title": "Destek Talebi Kapatın", - "label": "Destek talebini kapatmanızın sebebi", - "placeholder": "Lütfen neden destek talebi kapattığınızı anlatın." - } - }, - "buttons": { - "close": { - "label": "Destek talebini kapat", - "emoji": "🔒" - }, - "claim": { - "label": "Destek talebini al", - "emoji": "🙋" - } - }, - "ticketOpenedMessage": "Bir destek talebi başlatıldı! TICKETCHANNEL", - "ticketOnlyClaimableByStaff": "Destek talepleri sadece yetkililer tarafından alınabilir!", - "ticketAlreadyClaimed": "Bu destek talebi hali hazırda başka bir yetkili tarafından alındı!", - "ticketClaimedMessage": "> Destek talebi USER trafından alındı", - "ticketOnlyClosableByStaff": "Destek talepleri sadece yetkililer tarafından kapatılabilir!", - "ticketAlreadyClosed": "Destek talebi zaten kapalı!", - "ticketCreatingTranscript": "> Transkript oluşturuluyor...", - "ticketTranscriptCreated": "> Transkript oluşturuldu! TRANSCRIPTURL", - "ticketLimitReached": "Aynı anda en fazla TICKETLIMIT destek talebi açabilirsiniz!", - - "other": { - "openTicketButtonMSG": "Destek talebi aç", - "deleteTicketButtonMSG": "Destek talebini sil", - "selectTicketTypePlaceholder": "Destek talebi türü seçin", - "claimedBy": "USER **tarafından alındı**", - "noReasonGiven": "Sebep belirtilmedi.", - "unavailable": "Unavailable" - } -} +{ + "embeds": { + "openTicket": { + "title": "Destek Talebi Başlatın", + "description": "Destek talebi başlatmak için butona basın", + "footer": { + "text": "is.gd/ticketbot" + } + }, + "ticketOpened": { + "title": "Destek Talebi CATEGORYNAME", + "description": "Bir yetkili sizinle en hızlı şekilde iletişime geçecek!", + "footer": { + "text": "is.gd/ticketbot" + } + }, + "ticketClosed": { + "title": "Destek talebi kapatıldı", + "description": "Destek talebi, CLOSERNAME tarafından şu sebeple kapatıldı: `REASON`" + }, + "ticketClosedDM": { + "title": "Destek talebiniz kapatıldı", + "description": "TICKETCOUNT nolu destek talebiniz, CLOSERNAME tarafından şu sebeple kapatıldı: `REASON`\n\nDestek talebinizin bir transkripti: TRANSCRIPTURL", + "footer": { + "text": "is.gd/ticketbot" + } + } + }, + "modals": { + "reasonTicketOpen": { + "title": "Destek Talebi Başlatın", + "label": "Destek talebinizin sebebi", + "placeholder": "Lütfen neden destek talebi açtığınızı anlatın" + }, + "reasonTicketClose": { + "title": "Destek Talebi Kapatın", + "label": "Destek talebini kapatmanızın sebebi", + "placeholder": "Lütfen neden destek talebi kapattığınızı anlatın." + } + }, + "buttons": { + "close": { + "label": "Destek talebini kapat", + "emoji": "🔒" + }, + "claim": { + "label": "Destek talebini al", + "emoji": "🙋" + } + }, + "ticketOpenedMessage": "Bir destek talebi başlatıldı! TICKETCHANNEL", + "ticketOnlyClaimableByStaff": "Destek talepleri sadece yetkililer tarafından alınabilir!", + "ticketAlreadyClaimed": "Bu destek talebi hali hazırda başka bir yetkili tarafından alındı!", + "ticketClaimedMessage": "> Destek talebi USER trafından alındı", + "ticketOnlyClosableByStaff": "Destek talepleri sadece yetkililer tarafından kapatılabilir!", + "ticketAlreadyClosed": "Destek talebi zaten kapalı!", + "ticketCreatingTranscript": "> Transkript oluşturuluyor...", + "ticketTranscriptCreated": "> Transkript oluşturuldu! TRANSCRIPTURL", + "ticketLimitReached": "Aynı anda en fazla TICKETLIMIT destek talebi açabilirsiniz!", + + "other": { + "openTicketButtonMSG": "Destek talebi aç", + "deleteTicketButtonMSG": "Destek talebini sil", + "selectTicketTypePlaceholder": "Destek talebi türü seçin", + "claimedBy": "USER **tarafından alındı**", + "noReasonGiven": "Sebep belirtilmedi.", + "unavailable": "Unavailable" + } +} diff --git a/package.json b/package.json index 3a79e688..0428d595 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ticket-bot", - "version": "2.2.0", + "version": "2.2.1", "description": "Bot with a ticket system using Discord.js v14", "main": "index.js", "scripts": { diff --git a/utils/claim.js b/utils/claim.js index 2cf46484..46c038be 100644 --- a/utils/claim.js +++ b/utils/claim.js @@ -23,9 +23,7 @@ module.exports = { ephemeral: true, }); - const canClaim = interaction.member.roles.cache.some((r) => - client.config.rolesWhoHaveAccessToTheTickets.includes(r.id) - ); + const canClaim = interaction.member.roles.cache.some((r) => client.config.rolesWhoHaveAccessToTheTickets.includes(r.id)); if (!canClaim) return interaction @@ -67,28 +65,15 @@ module.exports = { ); await client.db.set(`tickets_${interaction.channel.id}.claimed`, true); - await client.db.set( - `tickets_${interaction.channel.id}.claimedBy`, - interaction.user.id - ); - await client.db.set( - `tickets_${interaction.channel.id}.claimedAt`, - Date.now() - ); + await client.db.set(`tickets_${interaction.channel.id}.claimedBy`, interaction.user.id); + await client.db.set(`tickets_${interaction.channel.id}.claimedAt`, Date.now()); await interaction.channel.messages.fetch(); - const messageId = await client.db.get( - `tickets_${interaction.channel.id}.messageId` - ); + const messageId = await client.db.get(`tickets_${interaction.channel.id}.messageId`); const msg = interaction.channel.messages.cache.get(messageId); const embed = msg.embeds[0].data; - embed.description = - embed.description + - `\n\n ${client.locales.other.claimedBy.replace( - "USER", - `<@${interaction.user.id}>` - )}`; + embed.description = embed.description + `\n\n ${client.locales.other.claimedBy.replace("USER", `<@${interaction.user.id}>`)}`; msg.components[0].components.map((x) => { if (x.data.custom_id === "claim") x.data.disabled = true; @@ -104,10 +89,7 @@ module.exports = { interaction .reply({ - content: client.locales.ticketClaimedMessage.replace( - "USER", - `<@${interaction.user.id}>` - ), + content: client.locales.ticketClaimedMessage.replace("USER", `<@${interaction.user.id}>`), ephemeral: false, }) .catch((e) => console.log(e)); diff --git a/utils/close.js b/utils/close.js index 96a88417..aa699bec 100644 --- a/utils/close.js +++ b/utils/close.js @@ -25,16 +25,11 @@ module.exports = { if (!client.config.createTranscript) domain = client.locales.other.unavailable; const ticket = await client.db.get(`tickets_${interaction.channel.id}`); - if (!ticket) - return interaction - .editReply({ content: "Ticket not found" }) - .catch((e) => console.log(e)); + if (!ticket) return interaction.editReply({ content: "Ticket not found" }).catch((e) => console.log(e)); if ( client.config.whoCanCloseTicket === "STAFFONLY" && - !interaction.member.roles.cache.some((r) => - client.config.rolesWhoHaveAccessToTheTickets.includes(r.id) - ) + !interaction.member.roles.cache.some((r) => client.config.rolesWhoHaveAccessToTheTickets.includes(r.id)) ) return interaction .editReply({ @@ -67,33 +62,17 @@ module.exports = { client ); - await client.db.set( - `tickets_${interaction.channel.id}.closedBy`, - interaction.user.id - ); - await client.db.set( - `tickets_${interaction.channel.id}.closedAt`, - Date.now() - ); + await client.db.set(`tickets_${interaction.channel.id}.closedBy`, interaction.user.id); + await client.db.set(`tickets_${interaction.channel.id}.closedAt`, Date.now()); if (reason) { - await client.db.set( - `tickets_${interaction.channel.id}.closeReason`, - reason - ); + await client.db.set(`tickets_${interaction.channel.id}.closeReason`, reason); } else { - await client.db.set( - `tickets_${interaction.channel.id}.closeReason`, - client.locales.other.noReasonGiven - ); + await client.db.set(`tickets_${interaction.channel.id}.closeReason`, client.locales.other.noReasonGiven); } - const creator = await client.db.get( - `tickets_${interaction.channel.id}.creator` - ); - const invited = await client.db.get( - `tickets_${interaction.channel.id}.invited` - ); + const creator = await client.db.get(`tickets_${interaction.channel.id}.creator`); + const invited = await client.db.get(`tickets_${interaction.channel.id}.invited`); interaction.channel.permissionOverwrites .edit(creator, { @@ -118,22 +97,17 @@ module.exports = { await interaction.channel.messages.fetch(); async function close(id) { - if (client.config.closeTicketCategoryId) - interaction.channel - .setParent(client.config.closeTicketCategoryId) - .catch((e) => console.log(e)); + if (client.config.closeTicketCategoryId) interaction.channel.setParent(client.config.closeTicketCategoryId).catch((e) => console.log(e)); - const messageId = await client.db.get( - `tickets_${interaction.channel.id}.messageId` - ); + const messageId = await client.db.get(`tickets_${interaction.channel.id}.messageId`); const msg = interaction.channel.messages.cache.get(messageId); const embed = msg.embeds[0].data; - + msg.components[0]?.components?.map((x) => { if (x.data.custom_id === "close") x.data.disabled = true; if (x.data.custom_id === "close_askReason") x.data.disabled = true; }); - + msg .edit({ content: msg.content, @@ -159,10 +133,7 @@ module.exports = { const ticket = await client.db.get(`tickets_${interaction.channel.id}`); const row = new Discord.ActionRowBuilder().addComponents( - new Discord.ButtonBuilder() - .setCustomId("deleteTicket") - .setLabel(client.locales.other.deleteTicketButtonMSG) - .setStyle(Discord.ButtonStyle.Danger) + new Discord.ButtonBuilder().setCustomId("deleteTicket").setLabel(client.locales.other.deleteTicketButtonMSG).setStyle(Discord.ButtonStyle.Danger) ); interaction.channel @@ -180,15 +151,11 @@ module.exports = { .catch((e) => console.log(e)); const tiketClosedDMEmbed = new Discord.EmbedBuilder() - .setColor( - client.embeds.ticketClosedDM.color - ? client.embeds.ticketClosedDM.color - : client.config.mainColor - ) + .setColor(client.embeds.ticketClosedDM.color ? client.embeds.ticketClosedDM.color : client.config.mainColor) .setDescription( client.embeds.ticketClosedDM.description .replace("TICKETCOUNT", ticket.id) - .replace("TRANSCRIPTURL", `${domain}${id}`) + .replace("TRANSCRIPTURL", `[\`${domain}${id}\`](${domain}${id})`) .replace("REASON", ticket.closeReason) .replace("CLOSERNAME", interaction.user.tag) ) @@ -211,12 +178,7 @@ module.exports = { .setFooter({ // Please respect the project by keeping the credits, (if it is too disturbing you can credit me in the "about me" of the bot discord) - text: - "is.gd/ticketbot" + - client.embeds.ticketClosedDM.footer.text.replace( - "is.gd/ticketbot", - "" - ), // Please respect the LICENSE :D + text: "is.gd/ticketbot" + client.embeds.ticketClosedDM.footer.text.replace("is.gd/ticketbot", ""), // Please respect the LICENSE :D // Please respect the project by keeping the credits, (if it is too disturbing you can credit me in the "about me" of the bot discord) iconUrl: client.embeds.ticketClosedDM.footer.iconUrl, }); @@ -244,7 +206,7 @@ module.exports = { }) .catch((e) => console.log(e)); }); - }; + } if (!client.config.createTranscript) { close(""); @@ -268,7 +230,7 @@ module.exports = { } const messages = collArray[0].concat(...collArray.slice(1)); return messages; - }; + } const messages = await fetchAll(); const premiumKey = ""; @@ -278,13 +240,15 @@ module.exports = { if (err) { console.error(err); } else { - const ts = await axios.post(`${domain}upload?key=${premiumKey}`, JSON.stringify(compressed), { - headers: { - "Content-Type": "application/json" - } - }).catch(console.error); + const ts = await axios + .post(`${domain}upload?key=${premiumKey}`, JSON.stringify(compressed), { + headers: { + "Content-Type": "application/json", + }, + }) + .catch(console.error); close(ts.data); - }; + } }); }, }; @@ -303,4 +267,4 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -*/ \ No newline at end of file +*/ diff --git a/utils/close_askReason.js b/utils/close_askReason.js index 9301e3a2..8408901e 100644 --- a/utils/close_askReason.js +++ b/utils/close_askReason.js @@ -20,9 +20,7 @@ module.exports = { async closeAskReason(interaction, client) { if ( client.config.whoCanCloseTicket === "STAFFONLY" && - !interaction.member.roles.cache.some((r) => - client.config.rolesWhoHaveAccessToTheTickets.includes(r.id) - ) + !interaction.member.roles.cache.some((r) => client.config.rolesWhoHaveAccessToTheTickets.includes(r.id)) ) return interaction .reply({ @@ -31,9 +29,7 @@ module.exports = { }) .catch((e) => console.log(e)); - const modal = new Discord.ModalBuilder() - .setCustomId("askReasonClose") - .setTitle(client.locales.modals.reasonTicketClose.title); + const modal = new Discord.ModalBuilder().setCustomId("askReasonClose").setTitle(client.locales.modals.reasonTicketClose.title); const input = new Discord.TextInputBuilder() .setCustomId("reason") diff --git a/utils/delete.js b/utils/delete.js index 03c25bbc..65943dac 100644 --- a/utils/delete.js +++ b/utils/delete.js @@ -17,10 +17,7 @@ limitations under the License. module.exports = { async deleteTicket(interaction, client) { const ticket = await client.db.get(`tickets_${interaction.channel.id}`); - if (!ticket) - return interaction - .reply({ content: "Ticket not found", ephemeral: true }) - .catch((e) => console.log(e)); + if (!ticket) return interaction.reply({ content: "Ticket not found", ephemeral: true }).catch((e) => console.log(e)); client.log( "ticketDelete", diff --git a/utils/logs.js b/utils/logs.js index 52fd0aa6..db274233 100644 --- a/utils/logs.js +++ b/utils/logs.js @@ -22,11 +22,8 @@ module.exports = { if (!client.config.logsChannelId) return; const channel = await client.channels .fetch(client.config.logsChannelId) - .catch((e) => - console.error("The channel to log events is not found!\n", e) - ); - if (!channel) - return console.error("The channel to log events is not found!"); + .catch((e) => console.error("The channel to log events is not found!\n", e)); + if (!channel) return console.error("The channel to log events is not found!"); let webhooks = await channel.fetchWebhooks(); if (webhooks.size === 0) { @@ -39,9 +36,7 @@ module.exports = { const embed = new Discord.EmbedBuilder() .setColor("3ba55c") .setAuthor({ name: logs.user.tag, iconURL: logs.user.avatarURL }) - .setDescription( - `${logs.user.tag} (<@${logs.user.id}>) Created a ticket (<#${logs.ticketChannelId}>) with the reason: \`${logs.reason}\`` - ); + .setDescription(`${logs.user.tag} (<@${logs.user.id}>) Created a ticket (<#${logs.ticketChannelId}>) with the reason: \`${logs.reason}\``); webhook .send({ @@ -57,9 +52,7 @@ module.exports = { .setColor("faa61a") .setAuthor({ name: logs.user.tag, iconURL: logs.user.avatarURL }) .setDescription( - `${logs.user.tag} (<@${logs.user.id}>) Claimed the ticket n°${ - logs.ticketId - } (<#${logs.ticketChannelId}>) after ${client.msToHm( + `${logs.user.tag} (<@${logs.user.id}>) Claimed the ticket n°${logs.ticketId} (<#${logs.ticketChannelId}>) after ${client.msToHm( new Date(Date.now() - logs.ticketCreatedAt) )} of creation` ); @@ -78,13 +71,9 @@ module.exports = { .setColor("ed4245") .setAuthor({ name: logs.user.tag, iconURL: logs.user.avatarURL }) .setDescription( - `${logs.user.tag} (<@${logs.user.id}>) Closed the ticket n°${ - logs.ticketId - } (<#${logs.ticketChannelId}>) with the reason: \`${ + `${logs.user.tag} (<@${logs.user.id}>) Closed the ticket n°${logs.ticketId} (<#${logs.ticketChannelId}>) with the reason: \`${ logs.reason - }\` after ${client.msToHm( - new Date(Date.now() - logs.ticketCreatedAt) - )} of creation` + }\` after ${client.msToHm(new Date(Date.now() - logs.ticketCreatedAt))} of creation` ); webhook @@ -101,9 +90,7 @@ module.exports = { .setColor("ed4245") .setAuthor({ name: logs.user.tag, iconURL: logs.user.avatarURL }) .setDescription( - `${logs.user.tag} (<@${logs.user.id}>) Deleted the ticket n°${ - logs.ticketId - } after ${client.msToHm( + `${logs.user.tag} (<@${logs.user.id}>) Deleted the ticket n°${logs.ticketId} after ${client.msToHm( new Date(Date.now() - logs.ticketCreatedAt) )} of creation\n\nTranscript: ${logs.transcriptURL}` );