FNFGirlfriendBot/src/modules/chat_command_handler.js
Parker2991 0aed4d7d7a improved how disconnects are logged.
removed reload since i basically dont ever use it.
removed xml for the same reason as reload.
added es6 support for commands only.
added back chat_command_handler.js
moved checks to src/util/checks.js
v6.0.7 build: 1080
2024-10-23 10:33:14 -04:00

24 lines
952 B
JavaScript

const CommandSource = require('../util/command_source');
module.exports = (bot, options, config) => {
let ratelimit = 0;
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();
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)
if (ratelimit > 2) {
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, { text: 'You are using commands too fast!', color: 'dark_red'})
} else if (command.split(" ")[0].length === 0) {
} else {
bot.commandManager.executeString(source, command)
}
})
})
}