Lint
This commit is contained in:
parent
59d04b3879
commit
9af9d8d974
8 changed files with 72 additions and 72 deletions
|
@ -4,7 +4,7 @@ module.exports = {
|
|||
execute: (c) => {
|
||||
if (c.bot.host && c.bot.host.options.hidden) {
|
||||
c.reply({
|
||||
text: getMessage(c.lang, "command.netmsg.disabled"),
|
||||
text: getMessage(c.lang, 'command.netmsg.disabled'),
|
||||
color: c.colors.secondary
|
||||
})
|
||||
return
|
||||
|
|
|
@ -4,22 +4,22 @@ module.exports = {
|
|||
execute: (c) => {
|
||||
const subcmd = c.args.splice(0, 1)[0]
|
||||
switch (subcmd) {
|
||||
case 'set':
|
||||
const allowedKeys = ["colorPrimary", "colorSecondary", "lang"]
|
||||
case 'set':{
|
||||
const allowedKeys = ['colorPrimary', 'colorSecondary', 'lang']
|
||||
const key = c.args.splice(0, 1)[0]
|
||||
if (!allowedKeys.includes(key)) {
|
||||
c.reply({
|
||||
text: getMessage(c.lang, 'command.settings.error.invalidKey'),
|
||||
color: c.colors.secondary
|
||||
});
|
||||
return;
|
||||
})
|
||||
return
|
||||
}
|
||||
const value = c.args.join(" ")
|
||||
if(value === "" && key==="lang"){
|
||||
const value = c.args.join(' ')
|
||||
if (value === '' && key === 'lang') {
|
||||
// Show all valid languages to user
|
||||
for (const i in languages) {
|
||||
c.reply({
|
||||
translate: "%s (%s)",
|
||||
translate: '%s (%s)',
|
||||
color: c.colors.secondary,
|
||||
with: [
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ module.exports = {
|
|||
}
|
||||
],
|
||||
hoverEvent: {
|
||||
action: "show_text",
|
||||
action: 'show_text',
|
||||
value: {
|
||||
translate: getMessage(languages[i], 'command.settings.setLanguage'),
|
||||
with: [
|
||||
|
@ -47,19 +47,19 @@ module.exports = {
|
|||
}
|
||||
return
|
||||
}
|
||||
if(value === ""){
|
||||
if (value === '') {
|
||||
c.reply({
|
||||
text: getMessage(c.lang, 'command.settings.error.mustProvideValue'),
|
||||
color: c.colors.secondary
|
||||
});
|
||||
return;
|
||||
})
|
||||
return
|
||||
}
|
||||
if(key==="lang" && !languages.includes(value)){
|
||||
if (key === 'lang' && !languages.includes(value)) {
|
||||
c.reply({
|
||||
text: getMessage(c.lang, 'command.settings.error.invalidLanguage'),
|
||||
color: c.colors.secondary
|
||||
});
|
||||
return;
|
||||
})
|
||||
return
|
||||
}
|
||||
c.prefs[key] = value
|
||||
|
||||
|
@ -73,11 +73,12 @@ module.exports = {
|
|||
c.reply({
|
||||
text: getMessage(c.lang, 'command.settings.saved'),
|
||||
color: c.colors.secondary
|
||||
});
|
||||
break;
|
||||
case 'get':{
|
||||
})
|
||||
break
|
||||
}
|
||||
case 'get':
|
||||
c.reply({
|
||||
translate: "%s: %s",
|
||||
translate: '%s: %s',
|
||||
color: c.colors.primary,
|
||||
with: [
|
||||
{
|
||||
|
@ -91,7 +92,7 @@ module.exports = {
|
|||
]
|
||||
})
|
||||
c.reply({
|
||||
translate: "%s: %s",
|
||||
translate: '%s: %s',
|
||||
color: c.colors.primary,
|
||||
with: [
|
||||
{
|
||||
|
@ -105,7 +106,7 @@ module.exports = {
|
|||
]
|
||||
})
|
||||
c.reply({
|
||||
translate: "%s: %s (%s)",
|
||||
translate: '%s: %s (%s)',
|
||||
color: c.colors.primary,
|
||||
with: [
|
||||
{
|
||||
|
@ -123,7 +124,6 @@ module.exports = {
|
|||
]
|
||||
})
|
||||
break
|
||||
}
|
||||
default:
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.cloop.error.subcommand'),
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
const chatlog = require("../util/chatlog.js")
|
||||
const chatlog = require('../util/chatlog.js')
|
||||
const fs = require('fs')
|
||||
const settings = require('../settings.json')
|
||||
|
||||
const checkLog = () => {
|
||||
if(settings.disableLogging) return;
|
||||
if (settings.disableLogging) return
|
||||
try {
|
||||
if (!fs.readdirSync('.').includes('botvXLogs')) fs.mkdirSync('botvXLogs');
|
||||
const dateToday = new Date(Date.now());
|
||||
const dateTomorrow = new Date(Date.now()+86400000);
|
||||
const filenameToday = `${dateToday.getUTCMonth()+1}-${dateToday.getUTCDate()}-${dateToday.getUTCFullYear()}`;
|
||||
const filenameTomorrow = `${dateTomorrow.getUTCMonth()+1}-${dateTomorrow.getUTCDate()}-${dateTomorrow.getUTCFullYear()}`;
|
||||
if (!fs.readdirSync('./botvXLogs').includes(filenameToday)) fs.mkdirSync(`botvXLogs/${filenameToday}`);
|
||||
if (!fs.readdirSync('./botvXLogs').includes(filenameTomorrow)) fs.mkdirSync(`botvXLogs/${filenameTomorrow}`); // Create tomorrow's log directory early
|
||||
if (!fs.readdirSync('.').includes('botvXLogs')) fs.mkdirSync('botvXLogs')
|
||||
const dateToday = new Date(Date.now())
|
||||
const dateTomorrow = new Date(Date.now() + 86400000)
|
||||
const filenameToday = `${dateToday.getUTCMonth() + 1}-${dateToday.getUTCDate()}-${dateToday.getUTCFullYear()}`
|
||||
const filenameTomorrow = `${dateTomorrow.getUTCMonth() + 1}-${dateTomorrow.getUTCDate()}-${dateTomorrow.getUTCFullYear()}`
|
||||
if (!fs.readdirSync('./botvXLogs').includes(filenameToday)) fs.mkdirSync(`botvXLogs/${filenameToday}`)
|
||||
if (!fs.readdirSync('./botvXLogs').includes(filenameTomorrow)) fs.mkdirSync(`botvXLogs/${filenameTomorrow}`) // Create tomorrow's log directory early
|
||||
} catch (e) {
|
||||
console.log(e) // Prevents some crashes when disk space is full or when the permissions are incorrect
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@ const hashcheck = require('../util/hashcheck.js')
|
|||
const settings = require('../settings.json')
|
||||
const { getMessage } = require('../util/lang.js')
|
||||
const cmds = require('../util/commands.js')
|
||||
const fs = require("fs")
|
||||
const fs = require('fs')
|
||||
|
||||
if(!fs.readdirSync('.').includes('userPref')) fs.mkdirSync("userPref");
|
||||
if (!fs.readdirSync('.').includes('userPref')) fs.mkdirSync('userPref')
|
||||
|
||||
const loadSettings = function (uuid) {
|
||||
try {
|
||||
|
@ -21,7 +21,7 @@ module.exports = {
|
|||
b.runCommand = (name, uuid, text, prefix) => {
|
||||
if (uuid === '00000000-0000-0000-0000-000000000000') return
|
||||
if (Date.now() - b.lastCmd <= 1000) return
|
||||
const userSettings = loadSettings(uuid);
|
||||
const userSettings = loadSettings(uuid)
|
||||
b.lastCmd = Date.now()
|
||||
const cmd = text.split(' ')
|
||||
const lang = settings.defaultLang
|
||||
|
@ -29,7 +29,7 @@ module.exports = {
|
|||
if (verify > 0) {
|
||||
text = cmd.slice(0, cmd.length - 1).join(' ')
|
||||
}
|
||||
b.emit("command", name, uuid, text, prefix)
|
||||
b.emit('command', name, uuid, text, prefix)
|
||||
if (cmds[cmd[0].toLowerCase()]) {
|
||||
const command = cmds[cmd[0].toLowerCase()]
|
||||
if (command.level !== undefined && command.level > verify) {
|
||||
|
|
|
@ -24,7 +24,7 @@ class Command {
|
|||
this.lang = settings.defaultLang
|
||||
}
|
||||
|
||||
let _colors = {}
|
||||
const _colors = {}
|
||||
if (prefs.colorPrimary) {
|
||||
_colors.primary = prefs.colorPrimary
|
||||
} else {
|
||||
|
|
|
@ -2,13 +2,13 @@ const fs = require('fs')
|
|||
const settings = require('../settings.json')
|
||||
|
||||
module.exports = function (fileName, item) {
|
||||
if(settings.disableLogging) return;
|
||||
const dateToday = new Date(Date.now());
|
||||
const UTCHours = dateToday.getUTCHours();
|
||||
const UTCMinutes = dateToday.getUTCMinutes().toString().padStart(2,"0");
|
||||
const UTCSeconds = dateToday.getUTCSeconds().toString().padStart(2,"0");
|
||||
const UTCMilliSeconds = dateToday.getUTCMilliseconds().toString().padStart(3,"0");
|
||||
const filenameToday = `${dateToday.getUTCMonth()+1}-${dateToday.getUTCDate()}-${dateToday.getUTCFullYear()}`;
|
||||
const logDate = `${dateToday.getUTCMonth()+1}/${dateToday.getUTCDate()}/${dateToday.getUTCFullYear()} ${UTCHours}:${UTCMinutes}:${UTCSeconds}.${UTCMilliSeconds}`;
|
||||
if (settings.disableLogging) return
|
||||
const dateToday = new Date(Date.now())
|
||||
const UTCHours = dateToday.getUTCHours()
|
||||
const UTCMinutes = dateToday.getUTCMinutes().toString().padStart(2, '0')
|
||||
const UTCSeconds = dateToday.getUTCSeconds().toString().padStart(2, '0')
|
||||
const UTCMilliSeconds = dateToday.getUTCMilliseconds().toString().padStart(3, '0')
|
||||
const filenameToday = `${dateToday.getUTCMonth() + 1}-${dateToday.getUTCDate()}-${dateToday.getUTCFullYear()}`
|
||||
const logDate = `${dateToday.getUTCMonth() + 1}/${dateToday.getUTCDate()}/${dateToday.getUTCFullYear()} ${UTCHours}:${UTCMinutes}:${UTCSeconds}.${UTCMilliSeconds}`
|
||||
fs.appendFileSync(`botvXLogs/${filenameToday}/${fileName}.txt`, `[${logDate}] ${item}\n`)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue