2024-07-20 20:27:17 -04:00
|
|
|
const CommandSource = require('../util/command_source');
|
2024-07-07 15:44:16 -04:00
|
|
|
function CommandConsole (bot, options, config) {
|
2024-07-20 20:27:17 -04:00
|
|
|
const ChatMessage = require('prismarine-chat')(options.version);
|
2024-07-07 15:44:16 -04:00
|
|
|
bot.console = {
|
|
|
|
|
readline: null,
|
|
|
|
|
consoleServer: 'all',
|
|
|
|
|
useReadlineInterface (rl) {
|
|
|
|
|
this.readline = rl
|
|
|
|
|
rl.on('line', line => {
|
2024-07-20 20:27:17 -04:00
|
|
|
if (bot.options.serverName !== this.consoleServer && this.consoleServer !== 'all') return
|
2024-07-25 22:57:29 -04:00
|
|
|
if (line.startsWith(config.console.prefix)) {
|
2024-07-07 15:44:16 -04:00
|
|
|
return bot.commandManager.executeString(bot.console.source, line.substring(2))
|
|
|
|
|
} if (line.startsWith("")) {
|
|
|
|
|
return bot.commandManager.executeString(bot.console.source, `echo ${line.substring(0)}`)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
rl.on('close', () => {
|
|
|
|
|
this.readline = null
|
|
|
|
|
})
|
2024-08-04 22:59:52 -04:00
|
|
|
log = function (...args) {
|
|
|
|
|
rl.output.write("\x1b[2K\r");
|
|
|
|
|
console.log(args.toString());
|
|
|
|
|
rl._refreshLine();
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-07 15:44:16 -04:00
|
|
|
}
|
2024-07-20 20:27:17 -04:00
|
|
|
bot.console.logs = function (message) {
|
2024-08-04 22:59:52 -04:00
|
|
|
log(ChatMessage.fromNotch(`§8[§1${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} §3${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} §6logs§8] §8[${options.serverName}§8] `)?.toAnsi() + message)
|
|
|
|
|
}
|
|
|
|
|
bot.console.info = function (message) {
|
|
|
|
|
log(ChatMessage.fromNotch(`§8[§1${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} §3${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} §2info§8] §8[${options.serverName}§8] `)?.toAnsi() + message)
|
|
|
|
|
}
|
|
|
|
|
bot.console.warn = function (message) {
|
|
|
|
|
console.log(ChatMessage.fromNotch(`§8[§1${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} §3${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} §ewarn§8] §8[${options.serverName}§8] `)?.toAnsi() + message)
|
2024-07-07 15:44:16 -04:00
|
|
|
}
|
2024-07-20 20:27:17 -04:00
|
|
|
bot.console.source = new CommandSource(bot.options.username, { console: true, discord: false });
|
2024-07-07 15:44:16 -04:00
|
|
|
bot.console.source.sendFeedback = message => {
|
2024-07-20 20:27:17 -04:00
|
|
|
const ansi = bot.getMessageAsPrismarine(message)?.toAnsi(bot.registry.language).replaceAll('BlackStone Mafia On Top!', "Fuck off you god damn cunt")
|
|
|
|
|
if (!options.logging) return
|
2024-08-04 22:59:52 -04:00
|
|
|
bot.console.info(ansi);
|
|
|
|
|
}
|
|
|
|
|
bot.console.error = function (message) {
|
|
|
|
|
console.log(ChatMessage.fromNotch(`§8[§1${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} §3${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} §4error§8] §8[${options.serverName}§8] `)?.toAnsi() + message)
|
2024-07-07 15:44:16 -04:00
|
|
|
}
|
|
|
|
|
bot.on('message', message => {
|
2024-07-20 20:27:17 -04:00
|
|
|
const ansi = bot.getMessageAsPrismarine(message)?.toAnsi(bot.registry.language).replaceAll('BlackStone Mafia On Top!', "Fuck off you god damn cunt")
|
|
|
|
|
const string = bot.getMessageAsPrismarine(message)?.toString(bot.registry.language).replaceAll('BlackStone Mafia On Top!', "Fuck off you god damn cunt")
|
|
|
|
|
if (!options.logging) return
|
2024-07-07 15:44:16 -04:00
|
|
|
bot.console.logs(`${ansi}`)
|
2024-07-20 20:27:17 -04:00
|
|
|
bot.console.filelogging(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ${string}`)
|
2024-07-07 15:44:16 -04:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
module.exports = CommandConsole;
|