From 157493b0f4dee5a308308e627e47e33454f375e7 Mon Sep 17 00:00:00 2001 From: BordedDev <> Date: Sun, 1 Jun 2025 20:56:24 +0200 Subject: [PATCH] Simplified some code --- src/snek/static/chat-input.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/snek/static/chat-input.js b/src/snek/static/chat-input.js index 8405e26..c0ca401 100644 --- a/src/snek/static/chat-input.js +++ b/src/snek/static/chat-input.js @@ -45,17 +45,18 @@ class ChatInputComponent extends HTMLElement { } resolveAutoComplete() { - let count = 0; let value = null; - Object.keys(this.allAutoCompletions).forEach((key) => { - if (key.startsWith(this.value.split(" ")[0])) { - count++; + for (const key of Object.keys(this.allAutoCompletions)) { + if (key.startsWith(this.value.split(" ", 1)[0])) { + if (value) { + return null; + } value = key; } - }); - if (count == 1) return value; - return null; + } + + return value; } isActive() {