| 3107 | 3107 | |
| 3108 | 3108 | export async function sendMessageAs(args, text) { |
| 3109 | 3109 | if (!text) { |
| 3110 | + toastr.warning('You must specify text to send as'); |
| 3110 | 3111 | return ''; |
| 3111 | 3112 | } |
| 3112 | 3113 | |
| 3113 | | - let name; |
| 3114 | + let name = args.name?.trim(); |
| 3114 | 3115 | let mesText; |
| 3115 | 3116 | |
| 3116 | 3117 | 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 { |
| 3124 | 3118 | const namelessWarningKey = 'sendAsNamelessWarningShown'; |
| 3125 | 3119 | if (localStorage.getItem(namelessWarningKey) !== 'true') { |
| 3126 | 3120 | toastr.warning('To avoid confusion, please use /sendas name="Character Name"', 'Name defaulted to {{char}}', { timeOut: 10000 }); |
| 3127 | 3121 | localStorage.setItem(namelessWarningKey, 'true'); |
| 3128 | 3122 | } |
| 3129 | 3123 | name = name2; |
| 3130 | | - if (!text) { |
| 3131 | | - toastr.warning('You must specify text to send as'); |
| 3132 | | - return ''; |
| 3133 | | - } |
| 3134 | 3124 | } |
| 3135 | 3125 | |
| 3136 | 3126 | mesText = text.trim(); |