Lint
This commit is contained in:
parent
59d04b3879
commit
9af9d8d974
8 changed files with 72 additions and 72 deletions
|
@ -181,12 +181,12 @@ const aboutServer = function (c) {
|
|||
}
|
||||
|
||||
const displayServerList = function (c) {
|
||||
for(const i in index.bot){
|
||||
if(index.bot[i].host.options && index.bot[i].host.options.hidden) continue
|
||||
for (const i in index.bot) {
|
||||
if (index.bot[i].host.options && index.bot[i].host.options.hidden) continue
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.about.serverListItem'),
|
||||
color: c.colors.secondary,
|
||||
with:[
|
||||
with: [
|
||||
{
|
||||
text: i.toString(),
|
||||
color: c.colors.primary
|
||||
|
|
|
@ -2,9 +2,9 @@ const { bot } = require('../index.js')
|
|||
const { getMessage } = require('../util/lang.js')
|
||||
module.exports = {
|
||||
execute: (c) => {
|
||||
if(c.bot.host && c.bot.host.options.hidden){
|
||||
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
|
||||
|
@ -37,7 +37,7 @@ module.exports = {
|
|||
color: 'white'
|
||||
}
|
||||
for (const i in bot) {
|
||||
if(bot[i].host.options.hidden) continue
|
||||
if (bot[i].host.options.hidden) continue
|
||||
bot[i].tellraw('@a', json)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,38 +4,38 @@ 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)){
|
||||
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){
|
||||
for (const i in languages) {
|
||||
c.reply({
|
||||
translate: "%s (%s)",
|
||||
translate: '%s (%s)',
|
||||
color: c.colors.secondary,
|
||||
with:[
|
||||
with: [
|
||||
{
|
||||
text: getMessage(languages[i], 'language.name'),
|
||||
color: c.colors.primary
|
||||
color: c.colors.primary
|
||||
},
|
||||
{
|
||||
text: getMessage(languages[i], 'language.region'),
|
||||
color: c.colors.primary
|
||||
}
|
||||
],
|
||||
hoverEvent:{
|
||||
action: "show_text",
|
||||
hoverEvent: {
|
||||
action: 'show_text',
|
||||
value: {
|
||||
translate: getMessage(languages[i], 'command.settings.setLanguage'),
|
||||
with:[
|
||||
with: [
|
||||
{
|
||||
text: `${c.prefix}settings set lang ${languages[i]}`,
|
||||
color: c.colors.secondary
|
||||
|
@ -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
|
||||
|
||||
|
@ -67,19 +67,20 @@ module.exports = {
|
|||
fs.writeFileSync(`userPref/${c.uuid}.json`, JSON.stringify(c.prefs))
|
||||
|
||||
// Delete require cache
|
||||
for(const i in require.cache){
|
||||
if(i.endsWith(`${c.uuid}.json`)) delete require.cache[i]
|
||||
for (const i in require.cache) {
|
||||
if (i.endsWith(`${c.uuid}.json`)) delete require.cache[i]
|
||||
}
|
||||
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:[
|
||||
with: [
|
||||
{
|
||||
text: getMessage(c.lang, 'command.settings.get.colorPrimary'),
|
||||
color: c.colors.secondary
|
||||
|
@ -91,9 +92,9 @@ module.exports = {
|
|||
]
|
||||
})
|
||||
c.reply({
|
||||
translate: "%s: %s",
|
||||
translate: '%s: %s',
|
||||
color: c.colors.primary,
|
||||
with:[
|
||||
with: [
|
||||
{
|
||||
text: getMessage(c.lang, 'command.settings.get.colorSecondary'),
|
||||
color: c.colors.secondary
|
||||
|
@ -105,9 +106,9 @@ module.exports = {
|
|||
]
|
||||
})
|
||||
c.reply({
|
||||
translate: "%s: %s (%s)",
|
||||
translate: '%s: %s (%s)',
|
||||
color: c.colors.primary,
|
||||
with:[
|
||||
with: [
|
||||
{
|
||||
text: getMessage(c.lang, 'command.settings.get.language'),
|
||||
color: c.colors.secondary
|
||||
|
@ -123,7 +124,6 @@ module.exports = {
|
|||
]
|
||||
})
|
||||
break
|
||||
}
|
||||
default:
|
||||
c.reply({
|
||||
translate: getMessage(c.lang, 'command.cloop.error.subcommand'),
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
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
|
||||
} catch(e){
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,10 @@ checkLog() // and at bot startup.
|
|||
module.exports = {
|
||||
load: (b) => {
|
||||
b.on('plainchat', (msg, type) => {
|
||||
if(!settings.disableLogging && !settings.disableChatLogging) chatlog(`chat_${b.host.host}_${b.host.port}`, `[${type}] ${msg}`)
|
||||
if (!settings.disableLogging && !settings.disableChatLogging) chatlog(`chat_${b.host.host}_${b.host.port}`, `[${type}] ${msg}`)
|
||||
})
|
||||
b.on('command', (name, uuid, text) => {
|
||||
if(!settings.disableLogging && !settings.disableCommandLogging) chatlog(`cmd_${b.host.host}_${b.host.port}`, `${name} (${uuid}): ${text}`)
|
||||
if (!settings.disableLogging && !settings.disableCommandLogging) chatlog(`cmd_${b.host.host}_${b.host.port}`, `${name} (${uuid}): ${text}`)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,11 +3,11 @@ 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){
|
||||
const loadSettings = function (uuid) {
|
||||
try {
|
||||
return require(`../userPref/${uuid}.json`)
|
||||
} catch (e) {
|
||||
|
@ -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) {
|
||||
|
|
|
@ -13,7 +13,7 @@ module.exports = {
|
|||
b.sc_tasks = {}
|
||||
b.selfcareRun = 0
|
||||
b.interval.sc = setInterval(() => {
|
||||
if(Date.now() - b.selfcareRun <= 600){
|
||||
if (Date.now() - b.selfcareRun <= 600) {
|
||||
return
|
||||
}
|
||||
for (const i in b.sc_tasks) {
|
||||
|
|
|
@ -18,19 +18,19 @@ class Command {
|
|||
this.port = bot.host.port
|
||||
// this.lang = lang
|
||||
this.prefs = prefs
|
||||
if(prefs.lang){
|
||||
if (prefs.lang) {
|
||||
this.lang = prefs.lang
|
||||
} else {
|
||||
this.lang = settings.defaultLang
|
||||
}
|
||||
|
||||
let _colors = {}
|
||||
if(prefs.colorPrimary){
|
||||
|
||||
const _colors = {}
|
||||
if (prefs.colorPrimary) {
|
||||
_colors.primary = prefs.colorPrimary
|
||||
} else {
|
||||
_colors.primary = settings.colors.primary
|
||||
}
|
||||
if(prefs.colorSecondary){
|
||||
if (prefs.colorSecondary) {
|
||||
_colors.secondary = prefs.colorSecondary
|
||||
} else {
|
||||
_colors.secondary = settings.colors.secondary
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
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}`;
|
||||
fs.appendFileSync(`botvXLogs/${filenameToday}/${fileName}.txt`, `[${logDate}] ${item}\n`)
|
||||
}
|
||||
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}`
|
||||
fs.appendFileSync(`botvXLogs/${filenameToday}/${fileName}.txt`, `[${logDate}] ${item}\n`)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue