Fixes; Logging
This commit is contained in:
parent
76e496bd38
commit
1e94df499c
8 changed files with 79 additions and 33 deletions
|
|
@ -3,6 +3,7 @@ import { config } from "./config.js";
|
|||
import { state } from "./store/store.js";
|
||||
import { type IUser, type TRole } from "./store/types.js";
|
||||
import type { ILevel } from "./types.js";
|
||||
import { appendFileSync } from "fs";
|
||||
|
||||
const fixUserData = (user: IUser) => {
|
||||
if (!user.experience) {
|
||||
|
|
@ -25,6 +26,7 @@ const fixUserData = (user: IUser) => {
|
|||
const getUserById = (userId: string): IUser => {
|
||||
const user = state.users.find((user) => user.id === userId);
|
||||
if (!user) {
|
||||
log(`Tried to get a non existing user ${userId}}`);
|
||||
return {
|
||||
id: ":",
|
||||
role: "NONE",
|
||||
|
|
@ -110,17 +112,25 @@ const changePersonality = (
|
|||
return false;
|
||||
}
|
||||
|
||||
const name =
|
||||
personalityName.charAt(0).toUpperCase() + personalityName.slice(1);
|
||||
|
||||
state.personality = {
|
||||
index: personalityIndex,
|
||||
startTime: Date.now(),
|
||||
};
|
||||
client.setDisplayName(
|
||||
`AsloBot (${config.app.ai.personalities[state.personality.index]?.personalityName})`,
|
||||
);
|
||||
client.setDisplayName(name);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
const log = (logMessage: string) => {
|
||||
appendFileSync(
|
||||
config.logPath,
|
||||
`[${new Date().toLocaleString()}] ${logMessage}`,
|
||||
);
|
||||
};
|
||||
|
||||
export {
|
||||
fixUserData,
|
||||
getUserById,
|
||||
|
|
@ -129,4 +139,5 @@ export {
|
|||
getUserName,
|
||||
getUserFromMention,
|
||||
changePersonality,
|
||||
log,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue