Merge pull request #4149 from Culpeo/release Added new slash command member-count
Signed| @@ -54,7 +54,7 @@ import { getMessageTimeStamp, isMobile } from './RossAscends-mods.js'; | ||
| 54 | 54 | import { hideChatMessageRange } from './chats.js'; |
| 55 | 55 | import { getContext, saveMetadataDebounced } from './extensions.js'; |
| 56 | 56 | import { getRegexedString, regex_placement } from './extensions/regex/engine.js'; |
| 57 | 57 | import { findGroupMemberId, groups, is_group_generating, openGroupById, resetSelectedGroup, saveGroupChat, selected_group, getGroupMembers } from './group-chats.js'; |
| 58 | 58 | import { chat_completion_sources, oai_settings, promptManager } from './openai.js'; |
| 59 | 59 | import { user_avatar } from './personas.js'; |
| 60 | 60 | import { addEphemeralStoppingString, chat_styles, flushEphemeralStoppingStrings, power_user } from './power-user.js'; |
| @@ -944,6 +944,12 @@ export function initDefaultSlashCommands() { | ||
| 944 | 944 | `, |
| 945 | 945 | })); |
| 946 | 946 | 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({ | |
| 947 | 953 | name: 'delswipe', |
| 948 | 954 | callback: deleteSwipeCallback, |
| 949 | 955 | returns: 'the new, currently selected swipe id', |
| @@ -3546,6 +3552,15 @@ async function peekCallback(_, arg) { | ||
| 3546 | 3552 | return ''; |
| 3547 | 3553 | } |
| 3548 | 3554 | |
| 3555 | +async function countGroupMemberCallback() { | |
| 3556 | + if (!selected_group) { | |
| 3557 | + toastr.warning('Cannot run /member-count command outside of a group chat.'); | |
| 3558 | + return ''; | |
| 3559 | + } | |
| 3560 | + | |
| 3561 | + return getGroupMembers(selected_group).length; | |
| 3562 | +} | |
| 3563 | + | |
| 3549 | 3564 | async function removeGroupMemberCallback(_, arg) { |
| 3550 | 3565 | if (!selected_group) { |
| 3551 | 3566 | toastr.warning('Cannot run /member-remove command outside of a group chat.'); |