From 9d19c7053bd40bff111c457015486e6ff35deb91 Mon Sep 17 00:00:00 2001 From: DJj123dj <80536295+DJj123dj@users.noreply.github.com> Date: Tue, 21 Jun 2022 12:11:09 +0200 Subject: [PATCH] v2.1.0 push 7 Added LanguageManager.js (yep this is for language stuff in the future) --- commands/add.js | 1 + commands/close.js | 1 + commands/delete.js | 1 + commands/help.js | 1 + commands/remove.js | 1 + commands/rename.js | 1 + commands/reopen.js | 1 + commands/ticket.js | 5 +---- config.json | 2 +- core/closebuttons.js | 1 + core/errorLogSystem.js | 1 + core/languageManager.js | 37 +++++++++++++++++++++++++++++++++ core/reactionRoles.js | 2 +- core/ticketCloser.js | 2 +- core/ticketMessageEmbed.js | 1 + core/ticketOpener.js | 1 + core/ticketReopener.js | 2 +- core/transcript.js | 1 + core/utils/getButton.js | 1 + core/utils/getTicketMessages.js | 2 ++ index.js | 5 ++++- 21 files changed, 61 insertions(+), 9 deletions(-) create mode 100644 core/languageManager.js diff --git a/commands/add.js b/commands/add.js index 8534a8c..e67daf0 100644 --- a/commands/add.js +++ b/commands/add.js @@ -3,6 +3,7 @@ const bot = require('../index') const client = bot.client const config = bot.config const log = bot.errorLog.log +const l = bot.language module.exports = () => { client.on("messageCreate",msg => { diff --git a/commands/close.js b/commands/close.js index ca191c6..2c033c2 100644 --- a/commands/close.js +++ b/commands/close.js @@ -3,6 +3,7 @@ const bot = require('../index') const client = bot.client const config = bot.config const log = bot.errorLog.log +const l = bot.language module.exports = () => { client.on("messageCreate",msg => { diff --git a/commands/delete.js b/commands/delete.js index a3aa927..f10186f 100644 --- a/commands/delete.js +++ b/commands/delete.js @@ -3,6 +3,7 @@ const bot = require('../index') const client = bot.client const config = bot.config const log = bot.errorLog.log +const l = bot.language module.exports = () => { client.on("messageCreate",msg => { diff --git a/commands/help.js b/commands/help.js index c3da72f..e700382 100644 --- a/commands/help.js +++ b/commands/help.js @@ -3,6 +3,7 @@ const bot = require('../index') const client = bot.client const config = bot.config const log = bot.errorLog.log +const l = bot.language module.exports = () => { const helpEmbed = new discord.MessageEmbed() diff --git a/commands/remove.js b/commands/remove.js index 5cc5d6b..0d90524 100644 --- a/commands/remove.js +++ b/commands/remove.js @@ -3,6 +3,7 @@ const bot = require('../index') const client = bot.client const config = bot.config const log = bot.errorLog.log +const l = bot.language module.exports = () => { client.on("messageCreate",msg => { diff --git a/commands/rename.js b/commands/rename.js index fec2edb..ebc0d43 100644 --- a/commands/rename.js +++ b/commands/rename.js @@ -3,6 +3,7 @@ const bot = require('../index') const client = bot.client const config = bot.config const log = bot.errorLog.log +const l = bot.language module.exports = () => { client.on("messageCreate",msg => { diff --git a/commands/reopen.js b/commands/reopen.js index 07a8c12..c39c840 100644 --- a/commands/reopen.js +++ b/commands/reopen.js @@ -3,6 +3,7 @@ const bot = require('../index') const client = bot.client const config = bot.config const log = bot.errorLog.log +const l = bot.language module.exports = () => { var reopenCommandBar = new discord.MessageActionRow() diff --git a/commands/ticket.js b/commands/ticket.js index bd706a1..f7fea85 100644 --- a/commands/ticket.js +++ b/commands/ticket.js @@ -3,10 +3,7 @@ const bot = require('../index') const client = bot.client const config = bot.config const log = bot.errorLog.log - -/** ============================= - ** NOT READY YET - ** =============================*/ +const l = bot.language module.exports = () => { /**@type {String[]} */ diff --git a/config.json b/config.json index 7f5f6f8..31ed4dd 100644 --- a/config.json +++ b/config.json @@ -5,7 +5,7 @@ "auth_token":"auth token", "main_adminroles":["discord role id"], "prefix":"!ticket ", - "languagefile":"english.json (currently not working)", + "languagefile":"english", "credits":true, "status":{ diff --git a/core/closebuttons.js b/core/closebuttons.js index 351968d..fb8173a 100644 --- a/core/closebuttons.js +++ b/core/closebuttons.js @@ -2,6 +2,7 @@ const discord = require('discord.js') const bot = require('../index') const client = bot.client const config = bot.config +const l = bot.language module.exports = () => { diff --git a/core/errorLogSystem.js b/core/errorLogSystem.js index 085282b..2b8b9d1 100644 --- a/core/errorLogSystem.js +++ b/core/errorLogSystem.js @@ -2,6 +2,7 @@ const discord = require('discord.js') const bot = require('../index') const client = bot.client const config = bot.config +const l = bot.language const loadChalk = async () => { return await (await import("chalk")).default diff --git a/core/languageManager.js b/core/languageManager.js new file mode 100644 index 0000000..1fcd01f --- /dev/null +++ b/core/languageManager.js @@ -0,0 +1,37 @@ +const index = require("../index") + +if (index.developerMode){ + var config = require("../devConfig.json") +}else{var config = require("../config.json")} + + +var localLanguage = require("../language/english.json") +if (config.languagefile.startsWith("custom")) localLanguage = require("../language/custom.json") +else if (config.languagefile.startsWith("dutch")) localLanguage = require("../language/dutch.json") +else if (config.languagefile.startsWith("english")) localLanguage = require("../language/english.json") +else if (config.languagefile.startsWith("deutsch")) localLanguage = require("../language/deutsch.json") +else if (config.languagefile.startsWith("french")) localLanguage = require("../language/french.json") + + +const errorLog = async () => { + const chalk = await (await import("chalk")).default + + console.log(chalk.red("Something went wrong when loading the language!")+"\nCheck the config file or create a ticket in our server!") +} + +const successLog = async () => { + const chalk = await (await import("chalk")).default + + console.log(chalk.green("loaded language file...")) +} + +if (!localLanguage){ + const runError = async () => { + await errorLog() + process.exit(1) + } + runError() +}else{ + exports.language = localLanguage + successLog() +} \ No newline at end of file diff --git a/core/reactionRoles.js b/core/reactionRoles.js index aa4417b..40af0c4 100644 --- a/core/reactionRoles.js +++ b/core/reactionRoles.js @@ -3,7 +3,7 @@ const bot = require('../index') const client = bot.client const config = bot.config const log = bot.errorLog.log - +const l = bot.language const storage = bot.storage module.exports = async () => { diff --git a/core/ticketCloser.js b/core/ticketCloser.js index 8b4edd9..b66f2a8 100644 --- a/core/ticketCloser.js +++ b/core/ticketCloser.js @@ -3,7 +3,7 @@ const bot = require('../index') const client = bot.client const config = bot.config const log = bot.errorLog.log - +const l = bot.language const storage = bot.storage /** diff --git a/core/ticketMessageEmbed.js b/core/ticketMessageEmbed.js index 573f13c..317d04b 100644 --- a/core/ticketMessageEmbed.js +++ b/core/ticketMessageEmbed.js @@ -3,6 +3,7 @@ const bot = require('../index') const client = bot.client const config = bot.config const getButton = require("./utils/getButton") +const l = bot.language /** * diff --git a/core/ticketOpener.js b/core/ticketOpener.js index 3b8bbd5..43ef70f 100644 --- a/core/ticketOpener.js +++ b/core/ticketOpener.js @@ -2,6 +2,7 @@ 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") diff --git a/core/ticketReopener.js b/core/ticketReopener.js index 26aa440..2a4b8e4 100644 --- a/core/ticketReopener.js +++ b/core/ticketReopener.js @@ -3,7 +3,7 @@ const bot = require('../index') const client = bot.client const config = bot.config const log = bot.errorLog.log - +const l = bot.language const storage = bot.storage module.exports = () => { diff --git a/core/transcript.js b/core/transcript.js index a290c69..1ffe463 100644 --- a/core/transcript.js +++ b/core/transcript.js @@ -2,6 +2,7 @@ const discord = require('discord.js') const bot = require('../index') const client = bot.client const config = bot.config +const l = bot.language /** * diff --git a/core/utils/getButton.js b/core/utils/getButton.js index af89802..2223414 100644 --- a/core/utils/getButton.js +++ b/core/utils/getButton.js @@ -2,6 +2,7 @@ const discord = require("discord.js") const bot = require("../../index") const config = bot.config const getoptions = require("../getoptions") +const l = bot.language /**@returns {"DANGER"|"SUCCESS"|"PRIMARY"|"SECONDARY"} */ const getColor = (color) => { diff --git a/core/utils/getTicketMessages.js b/core/utils/getTicketMessages.js index 22ed608..bd97d14 100644 --- a/core/utils/getTicketMessages.js +++ b/core/utils/getTicketMessages.js @@ -1,5 +1,7 @@ const bot = require("../../index") const config = bot.config +const l = bot.language + exports.getTicketMessage = (input) => { var returned = config.messages.find(a => a.id == input) if (returned){ diff --git a/index.js b/index.js index 9070fe2..9cb4394 100644 --- a/index.js +++ b/index.js @@ -13,7 +13,7 @@ if (process.argv[2]){ }else{var isDev = false} }else{var isDev = false} - +exports.developerMode = isDev if (isDev){ try { var config = require('./devConfig.json') @@ -26,6 +26,9 @@ exports.config = config exports.errorLog = require("./core/errorLogSystem") const log = this.errorLog.log +const language = require("./core/languageManager").language +exports.language = language + client.on('ready',async () => { const chalk = await (await import("chalk")).default