From 69c37a535b91226ad744068fb38cdfdea5be167e Mon Sep 17 00:00:00 2001 From: JeDaYoshi Date: Sun, 4 Jul 2021 00:31:43 +0000 Subject: [PATCH] Only add /search when there's a message provider --- src/plugins/inputs/index.js | 16 +++++++++++----- src/server.js | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/plugins/inputs/index.js b/src/plugins/inputs/index.js index 5f012254..112615b5 100644 --- a/src/plugins/inputs/index.js +++ b/src/plugins/inputs/index.js @@ -1,4 +1,4 @@ -const clientSideCommands = ["/collapse", "/expand", "/search"]; +const clientSideCommands = ["/collapse", "/expand"]; const passThroughCommands = [ "/as", @@ -43,13 +43,19 @@ const userInputs = [ const pluginCommands = new Map(); -const getCommands = () => - Array.from(userInputs.keys()) +const getCommands = (client) => { + const commands = Array.from(userInputs.keys()) .concat(Array.from(pluginCommands.keys())) .map((command) => `/${command}`) .concat(clientSideCommands) - .concat(passThroughCommands) - .sort(); + .concat(passThroughCommands); + + if (client.messageProvider !== undefined) { + commands.push("/search"); + } + + return commands.sort(); +}; const addPluginCommand = (packageInfo, command, func) => { func.packageInfo = packageInfo; diff --git a/src/server.js b/src/server.js index f50ee078..880d6e7c 100644 --- a/src/server.js +++ b/src/server.js @@ -692,7 +692,7 @@ function initializeClient(socket, client, token, lastMessage, openChannel) { ), token: tokenToSend, }); - socket.emit("commands", inputs.getCommands()); + socket.emit("commands", inputs.getCommands(client)); }; if (Helper.config.public) {