-
Notifications
You must be signed in to change notification settings - Fork 16
/
logger.js
47 lines (40 loc) · 1.57 KB
/
logger.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const beautify = require('beautify.log').default;
const { name } = require('../../config/bot-config.json');
const { commands, guildJoin, guildLeave } = require('../../config/logging-config.json');
function formatText(text) {
return text.replace('BOTNAME', name);
}
// beautify is used to colorize console logs (https://github.com/lucasgdb/beautify.log)
module.exports = {
info(text) {
const prefix = '{fgGreen}[BOTNAME - INFO] {reset}';
beautify.log(formatText(prefix + text));
},
warn(text, warn) {
const prefix = '{fgYellow}[BOTNAME - WARN] {reset}';
beautify.log(formatText(`${prefix + text}\n${warn}`));
},
error(text, err) {
const prefix = '{fgRed}[BOTNAME - ERROR] {reset}';
beautify.log(formatText(`${prefix + text}\n${err}`));
},
command(ctx) {
if (commands) {
const prefix = '{fgMagenta}[BOTNAME - COMMAND] {reset}';
// eslint-disable-next-line max-len
beautify.log(formatText(`${prefix}${ctx.member.displayName} (${ctx.member.id}) used ${ctx.commandName} in ${ctx.guild.name} (${ctx.guild.id})`));
}
},
guildJoin(guild) {
if (guildJoin) {
const prefix = '{fgCyan}[BOTNAME - GUILD JOIN] {reset}';
beautify.log(formatText(`${prefix}Joined (${guild.name}) (${guild.id}), members: ${guild.memberCount}`));
}
},
guildLeave(guild) {
if (guildLeave) {
const prefix = '{fgYellow}[BOTNAME - GUILD LEAVE] {reset}';
beautify.log(formatText(`${prefix}Left (${guild.name}) (${guild.id}), members: ${guild.memberCount}`));
}
},
};