From 6aa4c73d5dff5903e412b7889457836e9bdbc0d3 Mon Sep 17 00:00:00 2001 From: Ean Milligan Date: Tue, 8 Jul 2025 02:36:59 -0400 Subject: [PATCH] remove command prompt, its never been used and its just legacy code that never got cleaned up --- mod.ts | 9 +---- src/utils/utils.ts | 83 +--------------------------------------------- 2 files changed, 2 insertions(+), 90 deletions(-) diff --git a/mod.ts b/mod.ts index b113b80..c44d63e 100644 --- a/mod.ts +++ b/mod.ts @@ -7,13 +7,11 @@ import { Intents, startBot } from '@discordeno'; import { initLog } from '@Log4Deno'; import config from '~config'; -import { DEBUG, DEVMODE, LOCALMODE } from '~flags'; +import { DEBUG, LOCALMODE } from '~flags'; import api from 'src/api.ts'; import eventHandlers from 'src/events.ts'; -import utils from 'utils/utils.ts'; - // Extend the BigInt prototype to support JSON.stringify interface BigIntX extends BigInt { // Convert to BigInt to string form in JSON.stringify @@ -33,11 +31,6 @@ startBot({ eventHandlers, }); -// Start up the command prompt for debug usage -if (DEBUG && DEVMODE) { - utils.cmdPrompt(config.logChannel, config.name); -} - // Start up the API for rolling from third party apps (like excel macros) if (config.api.enable) { api.start(); diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 1d52c28..bc8c8ad 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -4,87 +4,7 @@ * December 21, 2020 */ import { log, LogTypes as LT } from '@Log4Deno'; -import { DiscordenoMessage, Interaction, sendMessage } from '@discordeno'; - -// ask(prompt) returns string -// ask prompts the user at command line for message -const ask = async (question: string, stdin = Deno.stdin, stdout = Deno.stdout): Promise => { - const buf = new Uint8Array(1024); - - // Write question to console - await stdout.write(new TextEncoder().encode(question)); - - // Read console's input into answer - const n = await stdin.read(buf); - const answer = new TextDecoder().decode(buf.subarray(0, n)); - - return answer.trim(); -}; - -// cmdPrompt(logChannel, botName) returns nothing -// cmdPrompt creates an interactive CLI for the bot, commands can vary -const cmdPrompt = async (logChannel: bigint, botName: string): Promise => { - let done = false; - - while (!done) { - // Get a command and its args - const fullCmd = await ask('cmd> '); - - // Split the args off of the command and prep the command - const args = fullCmd.split(' '); - const command = args.shift()?.toLowerCase(); - - // All commands below here - - // exit or e - // Fully closes the bot - if (command === 'exit' || command === 'e') { - console.log(`${botName} Shutting down.\n\nGoodbye.`); - done = true; - Deno.exit(0); - } // stop - // Closes the CLI only, leaving the bot running truly headless - else if (command === 'stop') { - console.log(`Closing ${botName} CLI. Bot will continue to run.\n\nGoodbye.`); - done = true; - } // m [channel] [message] - // Sends [message] to specified [channel] - else if (command === 'm') { - try { - const channelId = args.shift() || ''; - const message = args.join(' '); - - sendMessage(BigInt(channelId), message).catch((reason) => { - console.error(reason); - }); - } catch (e) { - console.error(e); - } - } // ml [message] - // Sends a message to the specified log channel - else if (command === 'ml') { - const message = args.join(' '); - - sendMessage(logChannel, message).catch((reason) => { - console.error(reason); - }); - } // help or h - // Shows a basic help menu - else if (command === 'help' || command === 'h') { - console.log(`${botName} CLI Help: - -Available Commands: - exit - closes bot - stop - closes the CLI - m [ChannelID] [message] - sends message to specific ChannelID as the bot - ml [message] sends a message to the specified bot log channel - help - this message`); - } // Unhandled commands die here - else { - console.log('undefined command'); - } - } -}; +import { DiscordenoMessage, Interaction } from '@discordeno'; const genericLogger = (level: LT, message: string) => log(level, message); const messageEditError = (location: string, message: DiscordenoMessage | Interaction | string, err: Error) => @@ -102,5 +22,4 @@ export default { messageSendError, messageDeleteError, }, - cmdPrompt, };