From 69de612d1e811d6f65ce97093139b289b6d2587c Mon Sep 17 00:00:00 2001 From: DJj123dj <80536295+DJj123dj@users.noreply.github.com> Date: Sat, 3 Sep 2022 13:20:00 +0200 Subject: [PATCH] added close with reason --- README.md | 6 +- config.json | 2 +- core/checker.js | 2 +- .../interactionHandlers/buttons/verifyBars.js | 8 ++ .../handlers/accepted/closingReason.js | 100 ++++++++++++++++++ core/interactionHandlers/handlers/handlers.js | 1 + core/languageManager.js | 2 + language/portuguese.json | 75 +++++++++++++ package.json | 2 +- 9 files changed, 192 insertions(+), 6 deletions(-) create mode 100644 core/interactionHandlers/handlers/accepted/closingReason.js create mode 100644 language/portuguese.json diff --git a/README.md b/README.md index 9a6a6ed..3f303fd 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ make a ticket in our server to start! *if you translate, you will come in the credits* # open-ticket -[![discord](https://img.shields.io/badge/discord-join%20our%20server-5865F2.svg?style=flat-square&logo=discord)](https://discord.com/invite/26vT9wt3n3) [![version](https://img.shields.io/badge/version-2.5.1-brightgreen.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/releases/tag/v2.5.1) [![npm](https://img.shields.io/badge/npm-external%20libraries%20needed-CB3837.svg?style=flat-square&logo=npm)](#packages) [![license](https://img.shields.io/badge/license-GPL%203.0-important.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/blob/main/LICENSE) +[![discord](https://img.shields.io/badge/discord-join%20our%20server-5865F2.svg?style=flat-square&logo=discord)](https://discord.com/invite/26vT9wt3n3) [![version](https://img.shields.io/badge/version-3.0.0-brightgreen.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/releases/tag/v3.0.0) [![npm](https://img.shields.io/badge/npm-external%20libraries%20needed-CB3837.svg?style=flat-square&logo=npm)](#packages) [![license](https://img.shields.io/badge/license-GPL%203.0-important.svg?style=flat-square)](https://github.com/DJj123dj/open-ticket/blob/main/LICENSE) This is an open-source discord ticket bot, you can configure it and it comes with cool features like transcripts & custom options! @@ -69,7 +69,7 @@ if there are any errors, you can open an **issue on github** or **contact me in ### config Our config documentation is moved to another file: -[click here to view](https://www.github.com/DJj123dj/open-ticket/wiki/config-v2.5.1) +[click here to view](https://www.github.com/DJj123dj/open-ticket/wiki/config-v3.0.0) ### intents & permissions In the discord developer portal in the "bot" panel you will find 3 switches under the title "Gateaway Intents". The following switches should always be turned on @@ -81,7 +81,7 @@ You can also configure your own permissions ## information -_v2.5.1 stable_ +_v3.0.0_ changelog: [click here](https://www.github.com/DJj123dj/open-ticket/wiki/Changelog) diff --git a/config.json b/config.json index 1bc5f79..4f6a05b 100644 --- a/config.json +++ b/config.json @@ -79,7 +79,7 @@ "description":"You can click one of the buttons below!", "enableFooter":false, - "footer":"Open Ticket v2.5.1 - I'm a footer!", + "footer":"Open Ticket v3.0.0 - I'm a footer!", "enableThumbnail":false, "thumbnail":"https://www.example.com/catmemes/cat.png", diff --git a/core/checker.js b/core/checker.js index 64a69ef..4f2e803 100644 --- a/core/checker.js +++ b/core/checker.js @@ -260,7 +260,7 @@ exports.checker = async () => { //languagefile checkType(config.languagefile,"string","languagefile") const lf = config.languagefile - if (!lf.startsWith("custom") && !lf.startsWith("english") && !lf.startsWith("dutch") && !lf.startsWith("romanian") && !lf.startsWith("german") && !lf.startsWith("arabic") && !lf.startsWith("spanish")){ + if (!lf.startsWith("custom") && !lf.startsWith("english") && !lf.startsWith("dutch") && !lf.startsWith("romanian") && !lf.startsWith("german") && !lf.startsWith("arabic") && !lf.startsWith("spanish") && !lf.startsWith("portuguese")){ createError("'languagefile' | invalid language, more info in the wiki") } diff --git a/core/interactionHandlers/buttons/verifyBars.js b/core/interactionHandlers/buttons/verifyBars.js index 7d1b864..75c56ce 100644 --- a/core/interactionHandlers/buttons/verifyBars.js +++ b/core/interactionHandlers/buttons/verifyBars.js @@ -15,6 +15,14 @@ const arb = discord.ActionRowBuilder const bs = discord.ButtonStyle exports.closeVerifyBar = new arb() + .addComponents( + new button() + .setCustomId("OTcloseTicketReason") + .setDisabled(false) + .setStyle(bs.Primary) + .setEmoji("💬") + .setLabel("close with reason") + ) .addComponents( new button() .setCustomId("OTcloseTicketTrue") diff --git a/core/interactionHandlers/handlers/accepted/closingReason.js b/core/interactionHandlers/handlers/accepted/closingReason.js new file mode 100644 index 0000000..721672a --- /dev/null +++ b/core/interactionHandlers/handlers/accepted/closingReason.js @@ -0,0 +1,100 @@ +const discord = require('discord.js') +const bot = require('../../../../index') +const client = bot.client +const config = bot.config +const l = bot.language +const log = bot.errorLog.log + +const getconfigoptions = require("../../../getoptions") +const permissionChecker = require("../../../utils/permisssionChecker") +const storage = bot.storage +const hiddendata = bot.hiddenData +const embed = discord.EmbedBuilder +const mc = config.main_color + +const button = discord.ButtonBuilder +const arb = discord.ActionRowBuilder +const bs = discord.ButtonStyle + +const modal = discord.ModalBuilder +const tis = discord.TextInputStyle +const tib = discord.TextInputBuilder + +module.exports = () => { + //theModal + const reasonModal = new modal() + .setTitle("close with reason") + .setCustomId("OTCloseReasonModal") + + const reasonInput = new arb() + .addComponents([ + new tib() + .setCustomId('OTreasonInput') + .setLabel("What is the reason for closing this ticket?") + .setStyle(tis.Short) + .setMaxLength(100) + .setRequired(true) + .setValue("") + .setPlaceholder("reason") + ]) + + reasonModal.addComponents(reasonInput) + + + + + + + //CLOSE WITH REASON + var closeTicketButtonChecker = false + + client.on("interactionCreate",async interaction => { + if (!interaction.isButton()) return + if (interaction.customId != "OTcloseTicketReason") return + + if (closeTicketButtonChecker == true) return interaction.deferUpdate() + closeTicketButtonChecker = true + + const firstcomponents = interaction.message.components + + if (config.system.closeMode == "adminonly"){ + if (!permissionChecker.command(interaction.user.id,interaction.guild.id)){ + if (!permissionChecker.sendUserNoPerms(interaction.user)){ + permissionChecker.sendChannelNoPerms(interaction.channel,interaction.user) + } + interaction.message.edit({components:[firstcomponents]}) + closeTicketButtonChecker = false + return interaction.deferUpdate() + } + } + + interaction.message.edit({components:[bot.buttons.close.openRowDisabled]}) + await interaction.showModal(reasonModal) + + }) + + client.on("interactionCreate",async (interaction) => { + if (interaction.type != discord.InteractionType.ModalSubmit) return + if (interaction.customId != "OTCloseReasonModal") return + + interaction.reply({embeds:[bot.embeds.commands.closeEmbed(interaction.user)],components:[bot.buttons.close.closeCommandRow]}) + + const reason = interaction.fields.getTextInputValue("OTreasonInput") + + /** + * @type {String} + */ + const name = interaction.channel.name + var prefix = "" + const tickets = config.options + tickets.forEach((ticket) => { + if (name.startsWith(ticket.channelprefix)){ + prefix = ticket.channelprefix + } + }) + + //interaction.channel.send({embeds:[bot.embeds.commands.closeEmbed(interaction.user)],components:[bot.buttons.close.closeCommandRow]}) + await require("../../../ticketCloser").NEWcloseTicket(interaction.member,interaction.channel,prefix,"close",reason,true) + closeTicketButtonChecker = false + }) +} \ No newline at end of file diff --git a/core/interactionHandlers/handlers/handlers.js b/core/interactionHandlers/handlers/handlers.js index 6685c5d..5dea097 100644 --- a/core/interactionHandlers/handlers/handlers.js +++ b/core/interactionHandlers/handlers/handlers.js @@ -7,4 +7,5 @@ module.exports = () => { require("./accepted/closing")() require("./accepted/reopening")() require("./accepted/deleting")() + require("./accepted/closingReason")() } \ No newline at end of file diff --git a/core/languageManager.js b/core/languageManager.js index 9e5f103..467f1d5 100644 --- a/core/languageManager.js +++ b/core/languageManager.js @@ -14,6 +14,8 @@ else if (config.languagefile.startsWith("french")) localLanguage = require("../l else if (config.languagefile.startsWith("romanian")) localLanguage = require("../language/romanian.json") else if (config.languagefile.startsWith("arabic")) localLanguage = require("../language/arabic.json") else if (config.languagefile.startsWith("spanish")) localLanguage = require("../language/spanish.json") +else if (config.languagefile.startsWith("portuguese")) localLanguage = require("../language/portuguese.json") + const errorLog = async () => { const chalk = await (await import("chalk")).default diff --git a/language/portuguese.json b/language/portuguese.json new file mode 100644 index 0000000..3a24109 --- /dev/null +++ b/language/portuguese.json @@ -0,0 +1,75 @@ +{ + "errors":{ + "missingArgsTitle":"Argumentos inválidos!", + "missingArgsDescription":"Argumento ausente", + "noPermsTitle":"Sem permissões!", + "noPermsDescription":"Você precisa da permissão `ADMINISTRATOR` ou estar na lista de funções permitidas!", + "noPermsDelete":"Somente administradores podem deletar um ticket!", + "chooseFromListTitle":"ID inválido", + "chooseFromListDescription":"Escolha um dos IDs abaixo:", + "boterror":"Erro de bot!", + "notInTicketTitle":"Você não está em um ticket!", + "notInTicketDescription":"Este comando não funciona fora dos tickets!", + "ticketDoesntExist":"Este ticket não existe mais!", + "roleDoesntExist":"Esta função não existe mais!", + "anotherOption":"Esta opção não é um ticket, mas sim outro tipo!", + "maxAmountTitle":"Quantidade máxima atingida!", + "maxAmountDescription":"Você atingiu o número máximo de tickets permitidos!\nEntão você não pode criar um novo!", + "somethingWentWrong":"**Algo deu errado!**\nPor favor, tente novamente outra vez!", + "somethingWentWrongTranscript":"Algo deu errado ao fazer a transcrição!**\nPor favor, tente novamente outra vez!" + }, + "commands":{ + "userAddedTitle":"Adicionado {0} a este ticket!", + "userRemovedTitle":"Removido {0} deste ticket!", + "renameTitle":"Mudou o nome para {0}!", + "closeTitle":"Fechado este ticket!", + "deleteTitle":"Excluindo este ticket...", + "reopenTitle":"Reabriu este ticket!", + + "ticketWarning":"A incorporação está na mensagem abaixo!", + "maxTicketWarning":"**Cuidado:** _Você só pode criar {0} tickets) de cada vez!!_" + }, + "helpMenu":{ + "title":"Comandos Disponíveis:", + "header1":"**Vá para {0} para criar um ticket!**\n\n", + "header2":"**Execute o comando `/new` ou `/ticket` para criar um ticket!**\n\n", + + "msgCmd":"Gerar uma incorporação com botões. (somente administradores)", + "renameCmd":"Renomear um ticket. (sem espaços)", + "closeCmd":"Fechar um ticket.", + "deleteCmd":"Excluir um ticket.", + "addCmd":"Adicionar um usuário ao ticket.", + "removeCmd":"Remover um usuário do ticket.", + "reopenCmd":"Reabra um ticket depois que ele foi fechado." + }, + "buttons":{ + "close":"Fechar Ticket", + "delete":"Excluir Ticket", + "reopen":"Reabrir Ticket", + "sendTranscript":"Transcrição" + }, + "messages":{ + "reopenTitle":"Reabriu este ticket!", + "reopenDescription":"Sinta-se à vontade para falar novamente!", + "closedTitle":"Fechado este ticket!", + "closedDescription":"Somente administradores podem falar neste ticket agora!\n\n*Clique no botão abaixo para excluir ou reabrir este ticket!*", + "createdTitle":"Ticket criado!", + "createdDescription":"Seu ticket foi criado, você pode detectá-lo com um ping!", + + "newTicketDmTitle":"Novo Ticket!", + "closedTicketDmTitle":"Ticket fechado!", + "deletedTicketDmTitle":"Ticket excluído!", + "closedTicketDmDescription":"Seu ticket está fechado!", + "deletedTicketDmDescription":"Seu bilhete foi excluído!", + "reopenTicketDmTitle":"Ticket reaberto!", + "reopenTicketDmDescription":"Seu ticket foi reaberto!", + "newTranscriptTitle":"Uma nova transcrição está aqui!", + "hereIsTheTranscript":"Aqui está a transcrição:", + + "chooseCategory":"Escolha a categoria:", + "gettingdeleted":"Ticket está sendo deletado...", + + "none":"none", + "reason":"reason" + } +} \ No newline at end of file diff --git a/package.json b/package.json index 5a7e4ee..68219c0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "open-ticket", - "version": "2.5.1", + "version": "3.0.0", "description": "This is an open-source discord ticket bot, you can configure it and it comes with cool features like a transcript.", "main": "index.js", "scripts": {