vanilla chat fixes

This commit is contained in:
Parker2991 2024-08-30 12:23:48 -04:00
parent 088e0a4c02
commit 5e08befb6b
7 changed files with 16 additions and 52 deletions

View file

@ -33,10 +33,3 @@ for (const options of config.bots) {
loadModules(bot, options, config, discordClient);
bot.console.useReadlineInterface(rl);
}
/*config.bots.filter((options) => {
const bot = createBot(options, config);
bots.push(bot);
bot.bots = bots;
loadModules(bot, options, config, discordClient);
bot.console.useReadlineInterface(rl);
})*/

View file

@ -22,8 +22,8 @@ function CommandConsole (bot, options, config) {
rl.output.write("\x1b[2K\r");
console.log(args.toString());
rl._refreshLine();
}
}
}
}
}
bot.console.logs = function (message) {
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)
@ -38,7 +38,7 @@ function CommandConsole (bot, options, config) {
bot.console.source.sendFeedback = message => {
const ansi = bot.getMessageAsPrismarine(message)?.toAnsi(bot.registry.language).replaceAll('BlackStone Mafia On Top!', "Fuck off you god damn cunt")
if (!options.logging) return
bot.console.logs(ChatMessage.fromNotch('§8[§6Command§8]')?.toAnsi() + ansi);
bot.console.logs(ChatMessage.fromNotch('§8[§6Command§8] ')?.toAnsi() + 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)

View file

@ -8,7 +8,6 @@ const client = new Client({ intents: [Guilds, GuildMessages, MessageContent] })
const util = require('util')
function discord(bot, options, config, discordClient) {
// client.login(config.discord.token)
if (!options?.channelId) {
bot.discord = {
invite: config.discord?.invite
@ -40,8 +39,7 @@ function discord(bot, options, config, discordClient) {
try {
bot?.discord?.channel?.send(`\`\`\`ansi\n${discordQueue.join('\n').substring(0, 1984)}\n\`\`\``)
} catch (error) {
bot.console.error(error.toString())
bot.console.warn(error.toString())
}
discordQueue = []
}, 2000)

View file

@ -1,35 +1,27 @@
function chipmunkmod (message, data, context, bot) {
function ChipmunkMod (message, data, context, bot) {
try {
if (message === null || typeof message !== 'object') return
if (message === null || typeof message !== 'object') return
if (message.with?.length < 3 || (message.translate !== '[%s] %s %s' && message.translate !== '%s %s %s')) return
const senderComponent = message.with[1]
// wtf spam again -
//console.log(senderComponent)//wtf...
const contents = message.with[2]
// spam lol - console.log(contents)
let sender
const hoverEvent = senderComponent.hoverEvent
//console.log(JSON.stringify(hoverEvent))
if (hoverEvent?.action === 'show_entity') {
const id = hoverEvent.contents.id
//
sender = data.players.find(player => player.uuid === id)
} else {
const stringUsername = data.getMessageAsPrismarine(senderComponent).toString() // TypeError: data.getMessageAsPrismarine is not a function
sender = data.players.find(player => player.profile.name) //=== stringusername)
sender = data.players.find(player => player.profile.name === stringUsername)
}
if (!sender) return null
return { sender, contents, type: 'minecraft:chat', senderComponent }
} catch(e) {
console.error(e)
console.error(e)
}
}
module.exports = chipmunkmod
module.exports = ChipmunkMod

View file

@ -1,6 +1,6 @@
const util = require('util')
function parseMessage (message, data) {
function kaboom (message, data) {
if (message === null || typeof message !== 'object') return
if (message.text !== '' || !Array.isArray(message.extra) || message.extra.length < 3) return
@ -38,4 +38,4 @@ function isSeparatorAt (children, start) {
return (children[start]?.text === ':' || children[start]?.text === '\xa7f:') && children[start + 1]?.text === ' '
}
module.exports = parseMessage
module.exports = kaboom

View file

@ -3,31 +3,21 @@ function VanillaChat (message, data, context) {
if (message === null || typeof message !== 'object') return
if (message.with?.length < 2 || (message.translate !== 'chat.type.text' && message.translate !== '%s %s')) return
const senderComponent = message.with[0]
// wtf spam again - console.log(senderComponent)//wtf...
//console.log(senderComponent)
const senderComponent = message.with[0]
const contents = message.with[1]
// spam lol - console.log(contents)
//console.log(contents)
let sender
const hoverEvent = senderComponent.hoverEvent
if (hoverEvent?.action === 'show_entity') {
const id = hoverEvent.contents.id
//
sender = data.players.find(player => player.uuid === id)
} else {
const stringUsername = data.getMessageAsPrismarine(senderComponent).toString() // TypeError: data.getMessageAsPrismarine is not a function
sender = data.players.find(player => player.profile.name) //=== stringusername)
sender = data.players.find(player => player.profile.name === stringUsername)
}
if (!sender) return undefined
return { sender, contents, type: 'minecraft:chat', senderComponent }
} catch(e) {
} catch(e) {
console.log(e.stack)
}
}

View file

@ -5,31 +5,22 @@ function sayConsole (message, data, context, bot) {
if (message.with?.length < 2 || (message.translate !== 'chat.type.announcement' && message.translate !== '%s %s')) return
const senderComponent = message.with[0]
// wtf spam again -
//console.log(senderComponent)//wtf...
const contents = message.with[1]
// spam lol - console.log(contents)
let sender
const hoverEvent = senderComponent.hoverEvent
//console.log(JSON.stringify(hoverEvent))
if (hoverEvent?.action === 'show_entity') {
const id = hoverEvent?.contents?.id
//
sender = data.players.find(player => player.uuid === id)
} else {
const stringUsername = data.getMessageAsPrismarine(senderComponent).toString() // TypeError: data.getMessageAsPrismarine is not a function
sender = data.players.find(player => player.profile.name) //=== stringusername)
}
if (!sender) return null
return { sender, contents, type: 'minecraft:chat', senderComponent }
} catch(e) {
console.error(e)
console.error(e);
}
}
module.exports = sayConsole