Skip to content

Commit

Permalink
chore(deps): update eslint/prettier config
Browse files Browse the repository at this point in the history
  • Loading branch information
jejebecarte committed Dec 1, 2024
1 parent a8c3b4e commit 24bb7b9
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"zod": "^3.23.8"
},
"devDependencies": {
"@jejebecarte/eslint-config": "^1.0.6",
"@jejebecarte/eslint-config": "^1.0.7",
"@types/node-fetch": "^2.6.11",
"eslint": "^8.57.1",
"pm2": "^5.4.2",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions scripts/setup-files.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
const fs = require('fs');

const oldPaths = ['.env.template', 'src/blacklist/_blacklist.json.template'];
Expand Down
2 changes: 1 addition & 1 deletion src/events/discord/interaction-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default {
ephemeral: true,
});

winston.error(`An error occured in ${interaction.commandName}: ${(e as Error).message}`);
winston.error(`An error occured in ${interaction.commandName}:`, e);
}
},
} as Event;
5 changes: 2 additions & 3 deletions src/events/mineflayer/handler/end.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import winston from 'winston';
export default {
name: 'end',
runOnce: false,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
run: (bot) => {
winston.error('The bot session has abruptly ended. Restarting the bot in 15 seconds...');
run: (_bot) => {
winston.error('The bot session has abruptly ended. Exiting in 15 seconds...');

setTimeout(() => {
process.exit(1);
Expand Down
5 changes: 2 additions & 3 deletions src/events/mineflayer/handler/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import winston from 'winston';
export default {
name: 'error',
runOnce: false,
run: (bot, error: Error) => {
winston.error('Encountered an unexpected error. Restarting the bot in 15 seconds...');
winston.error(error);
run: (_bot, error: Error) => {
winston.error('Encountered an unexpected error. Exiting in 15 seconds...', error);

setTimeout(() => {
process.exit(1);
Expand Down
4 changes: 2 additions & 2 deletions src/events/mineflayer/handler/kicked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ export default {

await bot.sendToDiscord(
'gc',
`${Emojis.error} The bot was kicked from the server due to ${message}. Restarting the bot in 15 seconds...`
`${Emojis.error} The bot was kicked from the server due to ${message}. Exiting in 15 seconds...`
);

winston.error(
`The bot was kicked from the server. Restarting the bot in 15 seconds...\nReason: ${reason}\nLogged in: ${loggedIn}`
`The bot was kicked from the server. Exiting in 15 seconds...\nReason: ${reason}\nLogged in: ${loggedIn}`
);

setTimeout(() => {
Expand Down
38 changes: 2 additions & 36 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,4 @@
import winston, { format } from 'winston';

//* Uppercasing must be done before colorizing - https://github.com/winstonjs/winston/issues/1345
const upperCaseLogLevel = format((info) => {
info.level = info.level?.toUpperCase();
return info;
});

winston.configure({
level: 'info',
format: format.combine(format.timestamp(), format.errors({ stack: true })),
transports: [
new winston.transports.File({
filename: 'logs/error.log',
level: 'error',
maxFiles: 10,
maxsize: 10_000_000, // 10MB
format: format.prettyPrint(),
}),
new winston.transports.Console({
format: format.combine(
upperCaseLogLevel(),
format.colorize(),
format.align(),
format.printf((info) => {
const message = `[${info.level}] ${info.message}`;

return info.stack
? message + `\n\t${(info.stack as string).replaceAll('\n', '\n\t')}`
: message;
})
),
}),
],
});

import '@util/logger';
import Bot from '@classes/bot';

export default new Bot();
35 changes: 35 additions & 0 deletions src/util/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import winston, { format } from 'winston';

//* Uppercasing must be done before colorizing - https://github.com/winstonjs/winston/issues/1345
const upperCaseLogLevel = format((info) => {
info.level = info.level?.toUpperCase();
return info;
});

winston.configure({
level: 'info',
format: format.combine(format.timestamp(), format.errors({ stack: true })),
transports: [
new winston.transports.File({
filename: 'logs/error.log',
level: 'error',
maxFiles: 10,
maxsize: 10_000_000, // 10MB
format: format.prettyPrint(),
}),
new winston.transports.Console({
format: format.combine(
upperCaseLogLevel(),
format.colorize(),
format.align(),
format.printf((info) => {
const message = `[${info.level}] ${info.message}`;

return info.stack
? `${message}\n\t${(info.stack as string).replaceAll('\n', '\n\t')}`
: message;
})
),
}),
],
});

0 comments on commit 24bb7b9

Please sign in to comment.