oberknecht-utils
Version:
Utils for oberknecht packages
8 lines (7 loc) • 301 B
text/typescript
export function messageUser<usertype extends string>(
rawMessage: usertype | undefined
): usertype extends string ? string : string | undefined {
let match = rawMessage?.match(/(?<=^:)\w+(?=!)/g);
if (!(rawMessage ?? undefined) || !(match ?? undefined)) return undefined;
return match?.[0];
}