Refactor prompt converters with group names awareness

This commit is contained in:
Cohee
2024-12-20 23:30:57 +02:00
parent d7328af4c8
commit 73614f2f8d
4 changed files with 148 additions and 108 deletions

View File

@ -275,6 +275,17 @@ export function getGroupMembers(groupId = selected_group) {
return group?.members.map(member => characters.find(x => x.avatar === member)) ?? [];
}
/**
* Retrieves the member names of a group. If the group is not selected, an empty array is returned.
* @returns {string[]} An array of character names representing the members of the group.
*/
export function getGroupNames() {
const groupMembers = selected_group ? groups.find(x => x.id == selected_group)?.members : null;
return Array.isArray(groupMembers)
? groupMembers.map(x => characters.find(y => y.avatar === x)?.name).filter(x => x)
: [];
}
/**
* Finds the character ID for a group member.
* @param {string} arg 0-based member index or character name