import { MatrixClient } from "matrix-js-sdk"; import type { ICallbackStore } from "../types.js"; import { config } from "../../config.js"; import { getRank, getUserById, getUserName } from "../../helpers.js"; import { state } from "../../store/store.js"; import type { IUser } from "../../store/types.js"; let client: MatrixClient; const registerModuleUser = ( matrixClient: MatrixClient, callbackStore: ICallbackStore, ) => { client = matrixClient; callbackStore.messageCallbacks.push({ startCondition: `${config.app.triggerPrefix}rank`, callbackFunc: onRank, }); callbackStore.messageCallbacks.push({ startCondition: `${config.app.triggerPrefix}leaderboard`, callbackFunc: onLeaderboard, }); }; const onRank = (_text: string, roomId: string, sender: string) => { const rank = getRank(getUserById(sender).experience); client.sendHtmlMessage( roomId, "", `