Added new slash command member-count

9cfb913b3dc1a62ab802e24099919a405ce40ade

Culpeo <Culpeo@users.noreply.github.com.>

1 files changed, +21 -1Ignore whitespace
public/scripts/slash-commands.js+21 -1
@@ -54,7 +54,7 @@ import { getMessageTimeStamp, isMobile } from './RossAscends-mods.js';
5454import { hideChatMessageRange } from './chats.js';
5555import { getContext, saveMetadataDebounced } from './extensions.js';
5656import { getRegexedString, regex_placement } from './extensions/regex/engine.js';
5757import { findGroupMemberId, groups, is_group_generating, openGroupById, resetSelectedGroup, saveGroupChat, selected_group, getGroupMembers } from './group-chats.js';
5858import { chat_completion_sources, oai_settings, promptManager } from './openai.js';
5959import { user_avatar } from './personas.js';
6060import { addEphemeralStoppingString, chat_styles, flushEphemeralStoppingStrings, power_user } from './power-user.js';
@@ -944,6 +944,12 @@ export function initDefaultSlashCommands() {
944944 `,
945945 }));
946946 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
947+ name: 'member-count',
948+ callback: countGroupMemberCallback,
949+ aliases: ['countmember', 'membercount'],
950+ helpString: 'Returns the total number of group members in the group chat list.',
951+ }));
952+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
947953 name: 'delswipe',
948954 callback: deleteSwipeCallback,
949955 returns: 'the new, currently selected swipe id',
@@ -3493,6 +3499,20 @@ async function peekCallback(_, arg) {
34933499 return '';
34943500}
34953501
3502+async function countGroupMemberCallback() {
3503+ if (!selected_group) {
3504+ toastr.warning('Cannot run /member-count command outside of a group chat.');
3505+ return '';
3506+ }
3507+
3508+ if (is_group_generating) {
3509+ toastr.warning('Cannot run /member-count command while the group reply is generating.');
3510+ return '';
3511+ }
3512+
3513+ return getGroupMembers(selected_group).length;
3514+}
3515+
34963516async function removeGroupMemberCallback(_, arg) {
34973517 if (!selected_group) {
34983518 toastr.warning('Cannot run /member-remove command outside of a group chat.');