2024-10-23 10:33:14 -04:00
|
|
|
const CommandSource = require('../util/command_source');
|
2025-01-15 11:32:27 -05:00
|
|
|
|
|
|
|
|
function inject (context) {
|
2024-10-23 10:33:14 -04:00
|
|
|
let ratelimit = 0;
|
2024-11-22 12:49:22 -05:00
|
|
|
const bot = context.bot;
|
|
|
|
|
const config = context.config;
|
|
|
|
|
const options = context.options;
|
v7.0.5, build: 2200. debloated the bot, implemented some v8 features, converted the config to js, made the disconnect, error, and kick_disconnect packets emit as clientDisconnect, fixed mem leaks, made vanish and command spy selfcare use core, removed filter, customchat, command suggestions and boot modules
2025-04-02 16:52:01 -04:00
|
|
|
|
2024-10-23 10:33:14 -04:00
|
|
|
bot.on("parsed_message", (data) => {
|
|
|
|
|
if (data.type !== "minecraft:chat") return;
|
|
|
|
|
const prefixes = config.prefixes;
|
|
|
|
|
prefixes.map((prefix) => {
|
|
|
|
|
const plainMessage = bot.getMessageAsPrismarine(data.contents)?.toString();
|
2025-03-14 08:01:58 -04:00
|
|
|
|
2024-10-23 10:33:14 -04:00
|
|
|
if (!plainMessage.startsWith(prefix)) return
|
|
|
|
|
const command = plainMessage.substring(prefix.length)
|
|
|
|
|
const source = new CommandSource(data.sender, { discord: false, console: false }, true)
|
|
|
|
|
ratelimit++
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
ratelimit--
|
|
|
|
|
}, 1000)
|
2025-01-15 11:32:27 -05:00
|
|
|
if (ratelimit > 2) {
|
2025-03-07 11:14:42 -05:00
|
|
|
bot.tellraw('@a', { text: 'You are using commands too fast!', color: 'dark_red'})
|
2024-10-23 10:33:14 -04:00
|
|
|
} else if (command.split(" ")[0].length === 0) {
|
|
|
|
|
} else {
|
|
|
|
|
bot.commandManager.executeString(source, command)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
2025-01-15 11:32:27 -05:00
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
data: {
|
|
|
|
|
enabled: true,
|
|
|
|
|
name: "command handler",
|
|
|
|
|
type: "commands"
|
|
|
|
|
},
|
|
|
|
|
inject
|
|
|
|
|
};
|