Allow sending empty messages with /sendas, /sys, etc.
| @@ -2004,14 +2004,14 @@ export function initDefaultSlashCommands() { | ||
| 2004 | 2004 | aliases: ['re'], |
| 2005 | 2005 | callback: (async ({ mode = 'literal', pattern, replacer = '' }, text) => { |
| 2006 | 2006 | if (pattern === '') |
| 2007 | 2007 | throw new Error("'Argument of \'pattern=\' cannot be empty"'); |
| 2008 | 2008 | switch (mode) { |
| 2009 | 2009 | case 'literal': |
| 2010 | 2010 | return text.replaceAll(pattern, replacer); |
| 2011 | 2011 | case 'regex': |
| 2012 | 2012 | return text.replace(regexFromString(pattern), replacer); |
| 2013 | 2013 | default: |
| 2014 | 2014 | throw new Error("'Invalid \'/replace mode=\' argument specified!"'); |
| 2015 | 2015 | } |
| 2016 | 2016 | }), |
| 2017 | 2017 | returns: 'replaced text', |
| @@ -3250,12 +3250,7 @@ function findPersonaByName(name) { | ||
| 3250 | 3250 | } |
| 3251 | 3251 | |
| 3252 | 3252 | async 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(); | |
| 3259 | 3254 | const compact = isTrueBoolean(args?.compact); |
| 3260 | 3255 | const bias = extractMessageBias(text); |
| 3261 | 3256 | |
| @@ -3564,13 +3559,7 @@ export function getNameAndAvatarForMessage(character, name = null) { | ||
| 3564 | 3559 | } |
| 3565 | 3560 | |
| 3566 | 3561 | export async function sendMessageAs(args, text) { |
| 3567 | - if (!text) { | |
| 3568 | - toastr.warning('You must specify text to send as'); | |
| 3569 | - return ''; | |
| 3570 | - } | |
| 3571 | - | |
| 3572 | 3562 | let name = args.name?.trim(); |
| 3573 | - let mesText; | |
| 3574 | 3563 | |
| 3575 | 3564 | if (!name) { |
| 3576 | 3565 | const namelessWarningKey = 'sendAsNamelessWarningShown'; |
| @@ -3581,7 +3570,7 @@ export async function sendMessageAs(args, text) { | ||
| 3581 | 3570 | name = name2; |
| 3582 | 3571 | } |
| 3583 | 3572 | |
| 3584 | 3573 | let mesText = String(text ?? '').trim(); |
| 3585 | 3574 | |
| 3586 | 3575 | // Requires a regex check after the slash command is pushed to output |
| 3587 | 3576 | mesText = getRegexedString(mesText, regex_placement.SLASH_COMMAND, { characterOverride: name }); |
| @@ -3659,11 +3648,7 @@ export async function sendMessageAs(args, text) { | ||
| 3659 | 3648 | } |
| 3660 | 3649 | |
| 3661 | 3650 | export 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 | - | |
| 3667 | 3652 | const name = chat_metadata[NARRATOR_NAME_KEY] || NARRATOR_NAME_DEFAULT; |
| 3668 | 3653 | // Messages that do nothing but set bias will be hidden from the context |
| 3669 | 3654 | const bias = extractMessageBias(text); |
| @@ -3754,18 +3739,13 @@ export async function promptQuietForLoudResponse(who, text) { | ||
| 3754 | 3739 | } |
| 3755 | 3740 | |
| 3756 | 3741 | async function sendCommentMessage(args, text) { |
| 3757 | - if (!text) { | |
| 3758 | - toastr.warning('You must specify text to send'); | |
| 3759 | - return ''; | |
| 3760 | - } | |
| 3761 | - | |
| 3762 | 3742 | const compact = isTrueBoolean(args?.compact); |
| 3763 | 3743 | const message = { |
| 3764 | 3744 | name: COMMENT_NAME_DEFAULT, |
| 3765 | 3745 | is_user: false, |
| 3766 | 3746 | is_system: true, |
| 3767 | 3747 | send_date: getMessageTimeStamp(), |
| 3768 | 3748 | mes: substituteParams(String(text ?? '').trim()), |
| 3769 | 3749 | force_avatar: comment_avatar, |
| 3770 | 3750 | extra: { |
| 3771 | 3751 | type: system_message_types.COMMENT, |