-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.js
More file actions
35 lines (29 loc) · 717 Bytes
/
log.js
File metadata and controls
35 lines (29 loc) · 717 Bytes
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
let exitRequested = false
const info = (message) => {
console.log(message)
}
const fatal = (message) => {
// Show the message in bold red.
console.error(`\x1b[1;31m${message}\x1b[m`)
exitRequested = true
}
const checkFatal = () => {
if (exitRequested) {
process.exit(1)
}
}
const logDiscordMessage = (message) => {
const {username, discriminator} = message.author
info(
bold(`<${username}#${discriminator}>`) + ' ' + message.cleanContent
)
}
// Add ANSI sequences to the given string that cause a terminal to bold it.
const bold = (string) => `\x1b[1m${string}\x1b[m`
module.exports = {
info,
fatal,
checkFatal,
logDiscordMessage,
bold,
}