hardcoded and mentions

* added options to queries

* removed hard coded vals, added message options

* updated importing

* added check for message mentions

* fix missing botID

* updated token to uid

* added contributer

---------

Co-authored-by: JT2M0L3Y <jtsmoley@icloud.com>
This commit is contained in:
Kevin Dang
2024-01-29 12:49:04 -08:00
committed by Kevin Dang
parent 97acae3d08
commit 9247463480
8 changed files with 166 additions and 75 deletions

View File

@@ -11,6 +11,11 @@ export interface EventProps {
client: Client
log: LogMethod
msgHist: { role: string, content: string }[]
tokens: {
channel: string,
model: string,
botUid: string
}
}
export type EventCallback<T extends EventKeys> = (
props: EventProps,
@@ -27,7 +32,16 @@ export function event<T extends EventKeys>(key: T, callback: EventCallback<T>):
return { key, callback }
}
export function registerEvents(client: Client, events: Event[], msgHist: { role: string, content: string }[]): void {
export function registerEvents(
client: Client,
events: Event[],
msgHist: { role: string, content: string }[],
tokens: {
channel: string,
model: string,
botUid: string
}
): void {
for (const { key, callback } of events) {
client.on(key, (...args) => {
// Create a new log method for this event
@@ -35,7 +49,7 @@ export function registerEvents(client: Client, events: Event[], msgHist: { role:
// Handle Errors, call callback, log errors as needed
try {
callback({ client, log, msgHist }, ...args)
callback({ client, log, msgHist, tokens }, ...args)
} catch (error) {
log('[Uncaught Error]', error)
}