Alias /note-pos command to match /inject

c5bd43405cda0eaa1b5e2e1e1d47b71984b2da34

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

1 files changed, +26 -18Ignore whitespace
public/scripts/authors-note.js+26 -18
@@ -52,7 +52,7 @@ function setNoteDepthCommand(_, text) {
5252 toastr.error(t`Not a valid number`);
5353 return;
5454 }
55-
55+
5656 $('#extension_floating_depth').val(Math.abs(value)).trigger('input');
5757 toastr.success(t`Author's Note depth updated`);
5858 }
@@ -76,15 +76,17 @@ function setNoteIntervalCommand(_, text) {
7676
7777function setNotePositionCommand(_, text) {
7878 const validPositions = {
79+ 'after': 0,
7980 'scenario': 0,
8081 'chat': 1,
8182 'before_scenario': 2,
83+ 'before': 2,
8284 };
8385
8486 if (text) {
8587 const position = validPositions[text?.trim()?.toLowerCase()];
8688
8789 if (typeof position === 'undefined') {
8890 toastr.error(t`Not a valid position`);
8991 return;
9092 }
@@ -94,22 +96,23 @@ function setNotePositionCommand(_, text) {
9496 }
9597 return Object.keys(validPositions).find(key => validPositions[key] == chat_metadata[metadata_keys.position]);
9698}
99+
97100function setNoteRoleCommand(_, text) {
98101 const validRoles = {
99102 'system': 0,
100103 'user': 1,
101104 'assistant': 2,
102105 };
103106
104107 if (text) {
105108 const role = validRoles[text?.trim()?.toLowerCase()];
106109
107110 if (typeof role === 'undefined') {
108111 toastr.error(t`Not a valid role`);
109112 return;
110113 }
111114
112115 $(`'#extension_floating_role`').val(Math.abs(role)).trigger('input');
113116 toastr.info(t`Author's Note role updated`);
114117 }
115118 return Object.keys(validRoles).find(key => validRoles[key] == chat_metadata[metadata_keys.role]);
@@ -491,7 +494,8 @@ export function initAuthorsNote() {
491494 });
492495 $('#option_toggle_AN').on('click', onANMenuItemClick);
493496
494497 SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'note',
498+ name: 'note',
495499 callback: setNoteTextCommand,
496500 returns: 'current author\'s note',
497501 unnamedArgumentList: [
@@ -505,8 +509,9 @@ export function initAuthorsNote() {
505509 </div>
506510 `,
507511 }));
508512 SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'depth',
509513 aliasesname: ['note-depth'],
514+ aliases: ['depth'],
510515 callback: setNoteDepthCommand,
511516 returns: 'current author\'s note depth',
512517 unnamedArgumentList: [
@@ -520,8 +525,9 @@ export function initAuthorsNote() {
520525 </div>
521526 `,
522527 }));
523528 SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'freq',
524529 aliasesname: ['note-freqfrequency'],
530+ aliases: ['freq', 'note-freq'],
525531 callback: setNoteIntervalCommand,
526532 returns: 'current author\'s note insertion frequency',
527533 namedArgumentList: [],
@@ -536,14 +542,15 @@ export function initAuthorsNote() {
536542 </div>
537543 `,
538544 }));
539545 SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'pos',
546+ name: 'note-position',
540547 callback: setNotePositionCommand,
541548 aliases: ['pos', 'note-pos'],
542549 returns: 'current author\'s note insertion position',
543550 namedArgumentList: [],
544551 unnamedArgumentList: [
545552 new SlashCommandArgument(
546553 'position', [ARGUMENT_TYPE.STRING], false, false, null, ['chatbefore', 'scenarioafter', 'before_scenariochat'],
547554 ),
548555 ],
549556 helpString: `
@@ -552,13 +559,14 @@ export function initAuthorsNote() {
552559 </div>
553560 `,
554561 }));
555562 SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'note-role',
563+ name: 'note-role',
556564 callback: setNoteRoleCommand,
557565 returns: 'current author\'s note chat insertion role',
558566 namedArgumentList: [],
559567 unnamedArgumentList: [
560568 new SlashCommandArgument(
561569 'position', [ARGUMENT_TYPE.STRING], false, false, null, ['system', 'user', 'assistant'],
562570 ),
563571 ],
564572 helpString: `