2024-01-12 12:24:01 -05:00
|
|
|
const CommandSource = require("../CommandModules/command_source");
|
|
|
|
const CommandError = require("../CommandModules/command_error");
|
2023-12-17 14:55:27 -05:00
|
|
|
|
2024-01-12 12:24:01 -05:00
|
|
|
function chat_command_handler(bot) {
|
|
|
|
bot.on("parsed_message", (data) => {
|
|
|
|
if (data.type !== "minecraft:chat") return;
|
2023-12-17 14:55:27 -05:00
|
|
|
|
2024-01-12 12:24:01 -05:00
|
|
|
const plainMessage = bot.getMessageAsPrismarine(data.contents)?.toString();
|
|
|
|
if (
|
|
|
|
!plainMessage.startsWith(bot.commandManager.MainPrefix) &&
|
|
|
|
!plainMessage.startsWith(bot.commandManager.SecondaryPrefix) &&
|
|
|
|
!plainMessage.startsWith(bot.commandManager.TertiaryPrefix)
|
|
|
|
)
|
|
|
|
return;
|
|
|
|
// else if (!plainMessage.startsWith(bot.commandManager.prefix2)) return
|
|
|
|
// MainPrefix: "~",
|
|
|
|
// SecondaryPrefix:'%',
|
|
|
|
//TertiaryPrefix:'@'
|
|
|
|
|
|
|
|
const command = plainMessage.substring(
|
|
|
|
bot.commandManager.MainPrefix.length ||
|
|
|
|
plainMessage.substring(
|
|
|
|
bot.commandManager.SecondaryPrefix.length ||
|
|
|
|
plainMessage.substring(bot.commandManager.TertiaryPrefix.length),
|
|
|
|
),
|
|
|
|
); // if the prefixes are the same length just make it 1 or the length
|
2023-12-24 12:11:42 -05:00
|
|
|
/*
|
|
|
|
lifes sus
|
|
|
|
*/
|
2024-01-12 12:24:01 -05:00
|
|
|
const source = new CommandSource(
|
|
|
|
data.sender,
|
|
|
|
{ discord: false, console: false },
|
|
|
|
true,
|
|
|
|
);
|
|
|
|
source.sendFeedback = (message) => {
|
2023-12-17 14:55:27 -05:00
|
|
|
const prefix = {
|
2024-01-12 12:24:01 -05:00
|
|
|
translate: "[%s%s%s] \u203a ",
|
|
|
|
bold: false,
|
|
|
|
color: "dark_gray",
|
|
|
|
with: [
|
|
|
|
{
|
|
|
|
color: "dark_purple",
|
|
|
|
text: "FNF",
|
|
|
|
bold: true,
|
|
|
|
hoverEvent: {
|
|
|
|
action: "show_text",
|
|
|
|
value: `${process.env["buildstring"]}\n${process.env["FoundationBuildString"]}`,
|
|
|
|
},
|
|
|
|
clickEvent: bot.options.Core.customName
|
|
|
|
? { action: "open_url", value: bot.options.Core.customName }
|
|
|
|
: undefined,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
color: "#00FFFF",
|
|
|
|
text: "Boyfriend",
|
|
|
|
bold: true,
|
|
|
|
clickEvent: bot.options.discord.invite
|
|
|
|
? { action: "open_url", value: bot.options.discord.invite }
|
|
|
|
: undefined,
|
|
|
|
hoverEvent: {
|
|
|
|
action: "show_text",
|
|
|
|
value: `Bot Username: ${bot.username}\nBot UUID: ${bot.uuid}\nServer Host: ${bot.options.host}:${bot.options.port}\nBot Minecraft Java Version: ${bot.options.version}`,
|
|
|
|
},
|
2023-12-17 14:55:27 -05:00
|
|
|
},
|
2024-01-12 12:24:01 -05:00
|
|
|
{
|
|
|
|
color: "dark_red",
|
|
|
|
text: "Bot",
|
|
|
|
bold: true,
|
|
|
|
clickEvent: bot.options.discord.invite
|
|
|
|
? { action: "open_url", value: "https://code.chipmunk.land" }
|
|
|
|
: undefined,
|
|
|
|
hoverEvent: {
|
|
|
|
action: "show_text",
|
|
|
|
value: "§aMan i like frogs - _ChipMC_",
|
|
|
|
},
|
|
|
|
}, //§aMan i like frogs - _ChipMC_
|
2023-12-17 14:55:27 -05:00
|
|
|
|
2024-01-12 12:24:01 -05:00
|
|
|
{ color: "green", text: command.split(" ")[0] },
|
|
|
|
],
|
|
|
|
};
|
2023-12-17 14:55:27 -05:00
|
|
|
|
2024-01-12 12:24:01 -05:00
|
|
|
bot.tellraw(["", prefix, message]);
|
|
|
|
};
|
2023-12-17 14:55:27 -05:00
|
|
|
|
2024-01-12 12:24:01 -05:00
|
|
|
bot.commandManager.executeString(source, command);
|
|
|
|
});
|
2023-12-17 14:55:27 -05:00
|
|
|
}
|
|
|
|
|
2024-01-12 12:24:01 -05:00
|
|
|
module.exports = chat_command_handler;
|