diff --git a/package.json b/package.json index 599ba48..858a672 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aslobot-matrix", - "version": "0.7.0", + "version": "0.7.1", "description": "", "license": "ISC", "author": "", diff --git a/src/helpers.ts b/src/helpers.ts index 8724a8f..9c1df6d 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -66,7 +66,9 @@ const getUserName = (user: IUser): string => { return ""; } - return match.replaceAll("@", ""); + let username = match.replaceAll("@", ""); + username = username.charAt(0).toUpperCase() + username.slice(1); + return username; }; const getUserFromMention = (mention: string | undefined): IUser | undefined => { diff --git a/src/modules/admin/admin.ts b/src/modules/admin/admin.ts index 2fefee4..66117f1 100644 --- a/src/modules/admin/admin.ts +++ b/src/modules/admin/admin.ts @@ -3,7 +3,7 @@ import type { ICallbackStore } from "../types.js"; import { config } from "../../config.js"; import { load, save, state } from "../../store/store.js"; import type { TRole } from "../../store/types.js"; -import { getUserFromMention } from "../../helpers.js"; +import { getUserFromMention, getUserName } from "../../helpers.js"; let client: MatrixClient; @@ -46,8 +46,12 @@ const onSetRole = async (text: string, roomId: string) => { } user.role = role; + const username = getUserName(user); - client.sendTextMessage(roomId, `Role for ${user} has been set to ${role}`); + client.sendTextMessage( + roomId, + `Role for ${username} has been set to ${role}`, + ); }; const onShutdown = async (text: string, roomId: string) => { diff --git a/src/modules/user/user.ts b/src/modules/user/user.ts index f5038bd..86dc36b 100644 --- a/src/modules/user/user.ts +++ b/src/modules/user/user.ts @@ -54,11 +54,9 @@ const onMe = (text: string, roomId: string, sender: string) => { const onLeaderboard = (_text: string, roomId: string) => { const mapUsersToLeaderboard = (user: IUser): string => { const level = getLevel(user.experience); - const userName = getUserName(user); - const userNameMod = - userName.charAt(0).toUpperCase() + userName.slice(1); + const username = getUserName(user); - return `