diff --git a/bot.js b/bot.js index 132e3d0..329091e 100644 --- a/bot.js +++ b/bot.js @@ -66,28 +66,51 @@ global.tick = setInterval(function() { } }, 2000) -/*/ +const oldConsole = console.log + // Redefining the console console.log = function (d) { - let newString = d.split('') // Put the array into a string with the sepperator being that weird char - if (newString.length != 1) { // If the array is one long dont do anything cause then it will have no formatting - // Loop through everything and remove the first 4 chars so the formatting is removed - for (let index = 0; index < newString.length; index++) { - newString[index] = newString[index].substring(4) - } - } - // Put the new array into a string - newString = newString.join('') + let newString = "" + switch (typeof d) { + case "string": + newString = d.split('') // Put the array into a string with the sepperator being that weird char + if (newString.length != 1) { // If the array is one long dont do anything cause then it will have no formatting + // Loop through everything and remove the first 4 chars so the formatting is removed + for (let index = 0; index < newString.length; index++) { + newString[index] = newString[index].substring(4) + } + } + // Put the new array into a string + newString = newString.join('') + if (nocolour) d = newString; + break; + case "boolean": + newString = "" + if (d) { newString = "True"} else {newString = "False"} + break; + case "number": + case "function": + case "bigint": + case "symbol": + newString = d.toString() + break; + case "object": + newString = JSON.stringify(d) + break; + case "undefined": + newString = "Undefined" + break; + } if (logconsole) { // If the console should be logged f.log(newString, 3, { // Log the console message writeLog: true }, "CONSOLE >"); } - if (nocolour) d = newString; - if (!noconsole) process.stdout.write(d + '\n'); // If the console is enabled write to the console. + if (!noconsole) { + oldConsole(d) + } }; -/*/ let createDB = false let convert = false @@ -118,7 +141,7 @@ for (let index = 0; index < args.length; index++) { }) break; case "convert": - if (createDB) return + if (createDB) break; convert = true returnBoot = true clearErrorLog("Convert.").then(() => { @@ -207,12 +230,14 @@ global.client = new discord.Client({ partials: ["CHANNEL"] }); // discord client -console.log("Deleting error files...") -const files = fs.readdirSync('./files/log') -for (let index = 0; index < files.length; index++) { - if (files[index] != "latest.log") { - fs.unlinkSync(`./files/log/${files[index]}`) - f.log(`Deleted file: ${files[index]}`) +if (errdelete) { + console.log("Deleting error files...") + const files = fs.readdirSync('./files/log') + for (let index = 0; index < files.length; index++) { + if (files[index] != "latest.log") { + fs.unlinkSync(`./files/log/${files[index]}`) + f.log(`Deleted file: ${files[index]}`) + } } } diff --git a/commands/searchbyname.js b/commands/searchbyname.js index 9859616..ffa66e5 100644 --- a/commands/searchbyname.js +++ b/commands/searchbyname.js @@ -76,7 +76,7 @@ module.exports = { let newName = f.replaceAllCaseInsensitve(name, `**${name}**`,finds[i].name) - embed.addField(f.localization("slashcommands", "searchbyname", "field",[time(date,"R"),expired.trim(),newName.trim(),finds[i].id.toString().trim(),type,finds[i].grund.trim(),extra,finds[i].warnid,finds[i].punkte])) + embed.addField(f.localization("slashcommands", "searchbyname", "fieldHeader", [time(date, "R")]), f.localization("slashcommands","searchbyname","field",[expired.trim(),newName.trim(),finds[i].id.toString().trim(),type,finds[i].grund.trim(),extra,finds[i].warnid,finds[i].punkte])) itemsCount++ } } else { diff --git a/eventhandler/WShandler.js b/eventhandler/WShandler.js index baab592..921c6f6 100644 --- a/eventhandler/WShandler.js +++ b/eventhandler/WShandler.js @@ -9,6 +9,10 @@ module.exports = { console.log('Client connected!') console.log(`Authed for user ${client.user.username}`); }); + client.on('shardResume', () => { + client.user.setActivity("auf DayLight Gaming", {type: "PLAYING"}) + f.log('Client reconnected.') + }) client.on('shardDisconnect', () => { f.log('Client disconnected.') }); diff --git a/eventhandler/warnMessage.js b/eventhandler/warnMessage.js index 4b33636..7af4f24 100644 --- a/eventhandler/warnMessage.js +++ b/eventhandler/warnMessage.js @@ -77,7 +77,7 @@ module.exports = { for (let index = 0; index < lastWarn.length; index++) { if (lastWarn[index].extra) { - if (lastWarn.extra.includes("HIDDEN")) { + if (lastWarn[index].extra.includes("HIDDEN")) { lastWarn.splice(index,1) } } diff --git a/files/important files/changelog.txt b/files/important files/changelog.txt index 507fbe8..05c2ef3 100644 --- a/files/important files/changelog.txt +++ b/files/important files/changelog.txt @@ -1,2 +1,3 @@ -Version 2.6.8 -- Rechtschreibung gefixt. \ No newline at end of file +Version 2.6.9 +- Alles war Kaputt, jetzt nicht mehr. +- Ping Shell-Command hinzugefĆ¼gt. \ No newline at end of file diff --git a/files/important files/version.txt b/files/important files/version.txt index 4484c2b..e0e1b46 100644 --- a/files/important files/version.txt +++ b/files/important files/version.txt @@ -1 +1 @@ -2.6.8 \ No newline at end of file +2.6.9 \ No newline at end of file diff --git a/files/strings/de_lang.json b/files/strings/de_lang.json index dae6e5c..73d806f 100644 --- a/files/strings/de_lang.json +++ b/files/strings/de_lang.json @@ -212,7 +212,8 @@ "title": "Verwarnungen von `%0`", "expired": "**__Diese Verwarnung ist abgelaufen!__**\n", "extra": "Extra: *%0*\n", - "field": "Verwarnung %0`, `%1\nName: *%2*\nID: *%3%4*\nGrund: *%5*\n%6Warn ID: *%6*\nPunkte: *%7*" + "fieldHeader": "Verwarnung %0", + "field": "%0\nName: *%1*\nID: *%2%3*\nGrund: *%4*\n%5Warn ID: *%6*\nPunkte: *%7*" }, "modifywarn": { "noargs": "Bitte gebe den Befehl richtig ein.", diff --git a/functions.js b/functions.js index 50695e3..7ff6a3b 100644 --- a/functions.js +++ b/functions.js @@ -195,7 +195,7 @@ exports.error = function(err, customFileName, sendConsoleLog) { log_filename = log_filename.replace(/\:/g, '.') // Replaces : with . so its a valid format fs.writeFileSync(`./files/log/${log_filename}.txt`, error) // Write the file - if (sendConsoleLog) console.log(colors.red(`An error occured! The error can be found in ./files/log/${log_filename}.txt`)) // Console log that a error occured + if (sendConsoleLog) f.log(`An error occured! The error can be found in ./files/log/${log_filename}.txt`) // log that a error occured f.log(err, 3) } catch (error) { console.log('The error handler had a error.\n\n', error) diff --git a/modules/channel_watcher.js b/modules/channel_watcher.js index d1645b1..2e44579 100644 --- a/modules/channel_watcher.js +++ b/modules/channel_watcher.js @@ -29,6 +29,7 @@ module.exports = { client.on("voiceStateUpdate", async (oldState, newState) => { if (newState.channelId == config.watch_channel_id) { + if (oldState.channelId == newState.channelId) return; startCountdown(newState.member) } }) diff --git a/modules/report_watcher.js b/modules/report_watcher.js index de631c8..e941d35 100644 --- a/modules/report_watcher.js +++ b/modules/report_watcher.js @@ -30,7 +30,7 @@ module.exports = { warnConent = { "id": id, "warnid": parseInt(fs.readFileSync("./files/warns/id.txt", "utf-8")) + 1, - "name": msg.embeds[0].fields[5].value.trim(), + "name": msg.embeds[0].fields[8].value.trim(), "grund": "REPORT-NAMEUPDATE", "extra": "HIDDEN", "punkte": 0, diff --git a/package.json b/package.json index 80e05ec..23da601 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dlgmwarn", - "version": "2.6.8", + "version": "2.6.9", "description": "", "main": "bot.js", "scripts": { diff --git a/shell/eval.js b/shell/eval.js index 8e1f455..8ebb336 100644 --- a/shell/eval.js +++ b/shell/eval.js @@ -3,7 +3,6 @@ const fs = require("fs") const shell = require("../eventhandler/shell.js") const util = require("util") const discord = require("discord.js") -const fs = require("fs") module.exports = { help: "Exekutiere Code", @@ -18,7 +17,7 @@ module.exports = { else return text; } - // message.channel.send(shell.shellResponse("Eval gestartet.")) + const start = process.hrtime() let evaled try { diff --git a/shell/help.js b/shell/help.js new file mode 100644 index 0000000..3d1bacf --- /dev/null +++ b/shell/help.js @@ -0,0 +1,19 @@ +const f = require('../functions') +const fs = require('fs'); +const path = require('path'); + +module.exports = { + help: "Hilfe.", + permissionLevel: "user", + run: function (args) { + return new Promise((resolve, reject) => { + const dir = fs.readdirSync("./shell"); + let help = "Hifle:\n"; + dir.forEach(element => { + let curElement = require(`../shell/${element}`) + help += `${path.parse(element).name} - ${curElement.help} - Permission level: ${curElement.permissionLevel}\n\n` + }); + resolve(help); + }) + } +} \ No newline at end of file diff --git a/shell/ping.js b/shell/ping.js new file mode 100644 index 0000000..f712678 --- /dev/null +++ b/shell/ping.js @@ -0,0 +1,11 @@ +module.exports = { + help: "Sehe den Ping von dem Bot.", + permissionLevel: "user", + run: function (args, message) { + return new Promise(async (resolve, reject) => { + const msgPing = message.createdTimestamp - Date.now() + + resolve(`Bot: ${msgPing}\nAPI: ${client.ws.ping}`) + }) + } +} \ No newline at end of file