remove command prompt, its never been used and its just legacy code that never got cleaned up
This commit is contained in:
parent
4b6683525c
commit
6aa4c73d5d
9
mod.ts
9
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();
|
||||
|
|
|
@ -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<string> => {
|
||||
const buf = new Uint8Array(1024);
|
||||
|
||||
// Write question to console
|
||||
await stdout.write(new TextEncoder().encode(question));
|
||||
|
||||
// Read console's input into answer
|
||||
const n = <number> 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<void> => {
|
||||
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,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue