Files
NitoriBot/src/modules/team.js
T

62 lines
2.3 KiB
JavaScript
Raw Normal View History

2024-12-06 11:04:23 -05:00
const sleep = require('../util/sleep');
2025-01-15 11:32:27 -05:00
function inject (context) {
2024-12-06 11:04:23 -05:00
const bot = context.bot;
const options = context.options;
const config = context.config;
2025-02-03 09:15:29 -06:00
if (options.mode !== "kaboom" || config.team.enabled === false) return;
2024-12-06 11:04:23 -05:00
bot.on("packet.login", async () => {
2025-02-03 09:15:29 -06:00
if (options.mode === "kaboom") {
2024-12-06 11:04:23 -05:00
await sleep(100);
bot.chat.command(`minecraft:team add ${config.team.name}`);
await sleep(100);
bot.core.run(`minecraft:team join ${config.team.name} @a[name="${bot.options.username}"]`);
}
})
bot.on("packet.teams", async (data) => {
2025-01-15 11:32:27 -05:00
// if (options.isSavage || options.isCreayun) return;
2024-12-06 11:04:23 -05:00
try {
if (data.team === config.team.name) {
data?.players?.map(async (player) => {
if (player !== bot.options.username) {
await sleep(100);
2024-12-16 13:52:23 -05:00
bot.core.run(`minecraft:team empty ${config.team.name}`);
2024-12-06 11:04:23 -05:00
await sleep(100);
2024-12-16 13:52:23 -05:00
bot.core.run(`minecraft:team join ${config.team.name} @a[name="${bot.options.username}"]`);
2024-12-06 11:04:23 -05:00
// this removes players who are not the bot
}
});
if (data.mode == 1) {
// this is checking if the team has been deleted
bot.core.run(`minecraft:team add ${config.team.name}`);
await sleep(100);
bot.core.run(`minecraft:team join ${config.team.name} @a[name="${bot.options.username}"]`);
} if (data.name !== JSON.stringify(config.team.displayName)) {
// this checks if the team displayName matches the one set in the config
bot.core.run(`minecraft:team modify ${config.team.name} displayName ${JSON.stringify(config.team.displayName)}`);
} if (data.prefix !== JSON.stringify(config.team.prefix)) {
// this checks if the team prefix matches the one set in the config
bot.core.run(`minecraft:team modify ${config.team.name} prefix ${JSON.stringify(config.team.prefix)}`);
} if (data.suffix !== JSON.stringify(config.team.suffix)) {
// this checks if the team suffix matches the one set in the config
bot.core.run(`minecraft:team modify ${config.team.name} suffix ${JSON.stringify(config.team.suffix)}`)
}
}
} catch (e) {
console.log(e.stack)
}
})
}
2025-01-15 11:32:27 -05:00
module.exports = {
data: {
2025-01-24 10:00:06 -05:00
enabled: true,
2025-01-15 11:32:27 -05:00
name: "teams",
type: "extras"
},
inject
}