Allow sending empty messages with /sendas, /sys, etc.

9a03aac224f07821fecadd7aa051e7e12cb5b0be

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +7 -27Ignore whitespace
public/scripts/slash-commands.js+7 -27
@@ -2002,16 +2002,16 @@ export function initDefaultSlashCommands() {
20022002 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
20032003 name: 'replace',
20042004 aliases: ['re'],
20052005 callback: (async ({ mode = 'literal', pattern, replacer = '' }, text) => {
20062006 if (pattern === '')
20072007 throw new Error("'Argument of \'pattern=\' cannot be empty"');
20082008 switch (mode) {
20092009 case 'literal':
20102010 return text.replaceAll(pattern, replacer);
20112011 case 'regex':
20122012 return text.replace(regexFromString(pattern), replacer);
20132013 default:
20142014 throw new Error("'Invalid \'/replace mode=\' argument specified!"');
20152015 }
20162016 }),
20172017 returns: 'replaced text',
@@ -3250,12 +3250,7 @@ function findPersonaByName(name) {
32503250}
32513251
32523252async function sendUserMessageCallback(args, text) {
3253- if (!text) {
3253+ text = String(text ?? '').trim();
3254- toastr.warning('You must specify text to send');
3255- return;
3256- }
3257-
3258- text = text.trim();
32593254 const compact = isTrueBoolean(args?.compact);
32603255 const bias = extractMessageBias(text);
32613256
@@ -3564,13 +3559,7 @@ export function getNameAndAvatarForMessage(character, name = null) {
35643559}
35653560
35663561export async function sendMessageAs(args, text) {
3567- if (!text) {
3568- toastr.warning('You must specify text to send as');
3569- return '';
3570- }
3571-
35723562 let name = args.name?.trim();
3573- let mesText;
35743563
35753564 if (!name) {
35763565 const namelessWarningKey = 'sendAsNamelessWarningShown';
@@ -3581,7 +3570,7 @@ export async function sendMessageAs(args, text) {
35813570 name = name2;
35823571 }
35833572
35843573 let mesText = String(text ?? '').trim();
35853574
35863575 // Requires a regex check after the slash command is pushed to output
35873576 mesText = getRegexedString(mesText, regex_placement.SLASH_COMMAND, { characterOverride: name });
@@ -3659,11 +3648,7 @@ export async function sendMessageAs(args, text) {
36593648}
36603649
36613650export async function sendNarratorMessage(args, text) {
3662- if (!text) {
3651+ text = String(text ?? '');
3663- toastr.warning('You must specify text to send');
3664- return '';
3665- }
3666-
36673652 const name = chat_metadata[NARRATOR_NAME_KEY] || NARRATOR_NAME_DEFAULT;
36683653 // Messages that do nothing but set bias will be hidden from the context
36693654 const bias = extractMessageBias(text);
@@ -3754,18 +3739,13 @@ export async function promptQuietForLoudResponse(who, text) {
37543739}
37553740
37563741async function sendCommentMessage(args, text) {
3757- if (!text) {
3758- toastr.warning('You must specify text to send');
3759- return '';
3760- }
3761-
37623742 const compact = isTrueBoolean(args?.compact);
37633743 const message = {
37643744 name: COMMENT_NAME_DEFAULT,
37653745 is_user: false,
37663746 is_system: true,
37673747 send_date: getMessageTimeStamp(),
37683748 mes: substituteParams(String(text ?? '').trim()),
37693749 force_avatar: comment_avatar,
37703750 extra: {
37713751 type: system_message_types.COMMENT,