-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.js
62 lines (61 loc) · 1.77 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const { writeFile } = require("node:fs");
module.exports = {
async execute(
prefix,
commandName,
args,
error = undefined,
channelID,
guildID,
completionTime
) {
const time = new Date();
const timeLog = `${time.toString()}`;
let errorMessage = "";
if (error != undefined) errorMessage = error.message;
const LOG = `${"-".repeat(
60
)}\nTIME= ${timeLog}\nCOMMAND= ${prefix}${commandName}\nARGUMENTS= ${args}\nID= [channel: ${channelID} guild: ${guildID}]\ntime-to-complete:${completionTime}ms\nerror: ${errorMessage}\n`;
try {
await writeFile("./info/log.txt", LOG, { flag: "a" }, (error) => {
if (error) throw console.error(error);
});
} catch (error) {
console.error(error);
}
},
async LEAVE_JOINLOG(error = undefined, guildID, event) {
let LOG;
if (error) {
LOG = `${"+".repeat(30)}USER EVENT${"+".repeat(
30
)}\n${event}\nguild: ${guildID}\nerror: ${error}\n`;
} else {
LOG = `${"+".repeat(30)}USER EVENT${"+".repeat(
30
)}\n${event}\nguild: ${guildID}\n`;
}
try {
await writeFile("./info/log.txt", LOG, { flag: "a" }, (error) => {
if (error) throw console.error(error);
});
} catch (error) {
console.error(error);
}
},
async profanity(channelID, guildID, Content) {
const time = new Date();
const timeLog = `${time.toString()}`;
let LOG;
LOG = `${"#".repeat(31)}PROFANITY${"#".repeat(
30
)}\nguild: ${guildID}\nchannel: ${channelID}\ntime: ${timeLog}\ncontent: ${Content}`;
try {
await writeFile("./info/log.txt", LOG, { flag: "a" }, (error) => {
if (error) throw console.error(error);
});
} catch (error) {
console.error(error);
}
},
};