Open kevinthedang opened 7 months ago
console.log(...)
events.ts
utils
export function registerEvents( client: Client, events: Event[], msgHist: Queue<UserMessage>, tokens: Tokens, ollama: Ollama ): void { for (const { key, callback } of events) { client.on(key, (...args) => { // Create a new log method for this event const log = console.log.bind(console, `[Event: ${key}]`) // Handle Errors, call callback, log errors as needed try { callback({ client, log, msgHist, tokens, ollama }, ...args) } catch (error) { log('[Uncaught Error]', error) } }) } }
I have mirrored the above method for log binding across commands and utilties in place. Though I have explored options for abstracting this into a universal log bind, I have not found a successful solution yet.
Issue
console.log(...)
is only bound when setting upevents.ts
found inutils
.Notes
Sample Binding in
events.ts