Prefer const variables

3918192dee20e9d1a8e6ae25c4a461cc7a1f7648

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

1 files changed, +6 -7Ignore whitespace
public/scripts/group-chats.js+6 -7
@@ -855,7 +855,7 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
855 const bias = getBiasStrings(userInput, type);855 const bias = getBiasStrings(userInput, type);
856 await sendMessageAsUser(userInput, bias.messageBias);856 await sendMessageAsUser(userInput, bias.messageBias);
857 await saveChatConditional();857 await saveChatConditional();
858 $('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles:true }));858 $('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles: true }));
859 }859 }
860860
861 // now the real generation begins: cycle through every activated character861 // now the real generation begins: cycle through every activated character
@@ -1006,7 +1006,7 @@ function activateNaturalOrder(members, input, lastMessage, allowSelfResponses, i
1006 }1006 }
1007 }1007 }
10081008
1009 let chattyMembers = [];1009 const chattyMembers = [];
1010 // activation by talkativeness (in shuffled order, except banned)1010 // activation by talkativeness (in shuffled order, except banned)
1011 const shuffledMembers = shuffle([...members]);1011 const shuffledMembers = shuffle([...members]);
1012 for (let member of shuffledMembers) {1012 for (let member of shuffledMembers) {
@@ -1017,14 +1017,13 @@ function activateNaturalOrder(members, input, lastMessage, allowSelfResponses, i
1017 }1017 }
10181018
1019 const rollValue = Math.random();1019 const rollValue = Math.random();
1020 let talkativeness = Number(character.talkativeness);1020 const talkativeness = isNaN(character.talkativeness)
1021 talkativeness = Number.isNaN(talkativeness)
1022 ? talkativeness_default1021 ? talkativeness_default
1023 : talkativeness;1022 : Number(character.talkativeness);
1024 if (talkativeness >= rollValue) {1023 if (talkativeness >= rollValue) {
1025 activatedMembers.push(member);1024 activatedMembers.push(member);
1026 }1025 }
1027 if (talkativeness > 0){1026 if (talkativeness > 0) {
1028 chattyMembers.push(member);1027 chattyMembers.push(member);
1029 }1028 }
1030 }1029 }
@@ -1032,7 +1031,7 @@ function activateNaturalOrder(members, input, lastMessage, allowSelfResponses, i
1032 // pick 1 at random if no one was activated1031 // pick 1 at random if no one was activated
1033 let retries = 0;1032 let retries = 0;
1034 // try to limit the selected random character to those with talkativeness > 01033 // try to limit the selected random character to those with talkativeness > 0
1035 let randomPool = chattyMembers.length > 0? chattyMembers : members;1034 const randomPool = chattyMembers.length > 0 ? chattyMembers : members;
1036 while (activatedMembers.length === 0 && ++retries <= randomPool.length) {1035 while (activatedMembers.length === 0 && ++retries <= randomPool.length) {
1037 const randomIndex = Math.floor(Math.random() * randomPool.length);1036 const randomIndex = Math.floor(Math.random() * randomPool.length);
1038 const character = characters.find((x) => x.avatar === randomPool[randomIndex]);1037 const character = characters.find((x) => x.avatar === randomPool[randomIndex]);