mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Refactor if checks on /sendas
This commit is contained in:
@ -3107,30 +3107,20 @@ async function setNarratorName(_, text) {
|
|||||||
|
|
||||||
export async function sendMessageAs(args, text) {
|
export async function sendMessageAs(args, text) {
|
||||||
if (!text) {
|
if (!text) {
|
||||||
|
toastr.warning('You must specify text to send as');
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
let name;
|
let name = args.name?.trim();
|
||||||
let mesText;
|
let mesText;
|
||||||
|
|
||||||
if (args.name) {
|
if (!name) {
|
||||||
name = args.name.trim();
|
|
||||||
|
|
||||||
if (!name && !text) {
|
|
||||||
toastr.warning('You must specify a name and text to send as');
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const namelessWarningKey = 'sendAsNamelessWarningShown';
|
const namelessWarningKey = 'sendAsNamelessWarningShown';
|
||||||
if (localStorage.getItem(namelessWarningKey) !== 'true') {
|
if (localStorage.getItem(namelessWarningKey) !== 'true') {
|
||||||
toastr.warning('To avoid confusion, please use /sendas name="Character Name"', 'Name defaulted to {{char}}', { timeOut: 10000 });
|
toastr.warning('To avoid confusion, please use /sendas name="Character Name"', 'Name defaulted to {{char}}', { timeOut: 10000 });
|
||||||
localStorage.setItem(namelessWarningKey, 'true');
|
localStorage.setItem(namelessWarningKey, 'true');
|
||||||
}
|
}
|
||||||
name = name2;
|
name = name2;
|
||||||
if (!text) {
|
|
||||||
toastr.warning('You must specify text to send as');
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mesText = text.trim();
|
mesText = text.trim();
|
||||||
|
Reference in New Issue
Block a user