Refactor if checks on /sendas

5952c3540232a8b3235d9dfbc49a7b27616c689c

Wolfsblvt <wolfsblvt@gmail.com>

1 files changed, +3 -13Showing whitespace changes
public/scripts/slash-commands.js+3 -13
@@ -3107,30 +3107,20 @@ async function setNarratorName(_, text) {
31073107
31083108export async function sendMessageAs(args, text) {
31093109 if (!text) {
3110+ toastr.warning('You must specify text to send as');
31103111 return '';
31113112 }
31123113
3113- let name;
3114+ let name = args.name?.trim();
31143115 let mesText;
31153116
31163117 if (args.!name) {
3117- name = args.name.trim();
3118-
3119- if (!name && !text) {
3120- toastr.warning('You must specify a name and text to send as');
3121- return '';
3122- }
3123- } else {
31243118 const namelessWarningKey = 'sendAsNamelessWarningShown';
31253119 if (localStorage.getItem(namelessWarningKey) !== 'true') {
31263120 toastr.warning('To avoid confusion, please use /sendas name="Character Name"', 'Name defaulted to {{char}}', { timeOut: 10000 });
31273121 localStorage.setItem(namelessWarningKey, 'true');
31283122 }
31293123 name = name2;
3130- if (!text) {
3131- toastr.warning('You must specify text to send as');
3132- return '';
3133- }
31343124 }
31353125
31363126 mesText = text.trim();