Skip to content

Commit

Permalink
Merge pull request #9 from Simyon264/dev
Browse files Browse the repository at this point in the history
Update 2.6.9
  • Loading branch information
Simyon264 authored Mar 25, 2022
2 parents 9e8d025 + 843bf25 commit d579df9
Show file tree
Hide file tree
Showing 14 changed files with 92 additions and 31 deletions.
65 changes: 45 additions & 20 deletions bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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]}`)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion commands/searchbyname.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions eventhandler/WShandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
});
Expand Down
2 changes: 1 addition & 1 deletion eventhandler/warnMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
5 changes: 3 additions & 2 deletions files/important files/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Version 2.6.8
- Rechtschreibung gefixt.
Version 2.6.9
- Alles war Kaputt, jetzt nicht mehr.
- Ping Shell-Command hinzugefügt.
2 changes: 1 addition & 1 deletion files/important files/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.6.8
2.6.9
3 changes: 2 additions & 1 deletion files/strings/de_lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
2 changes: 1 addition & 1 deletion functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions modules/channel_watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
Expand Down
2 changes: 1 addition & 1 deletion modules/report_watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dlgmwarn",
"version": "2.6.8",
"version": "2.6.9",
"description": "",
"main": "bot.js",
"scripts": {
Expand Down
3 changes: 1 addition & 2 deletions shell/eval.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -18,7 +17,7 @@ module.exports = {
else
return text;
}
// message.channel.send(shell.shellResponse("Eval gestartet."))

const start = process.hrtime()
let evaled
try {
Expand Down
19 changes: 19 additions & 0 deletions shell/help.js
Original file line number Diff line number Diff line change
@@ -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);
})
}
}
11 changes: 11 additions & 0 deletions shell/ping.js
Original file line number Diff line number Diff line change
@@ -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}`)
})
}
}

0 comments on commit d579df9

Please sign in to comment.