chomens-bot-js/plugins/self_care.js

91 lines
3.1 KiB
JavaScript
Raw Permalink Normal View History

2022-11-27 02:35:28 -05:00
function inject (bot, dcclient, config) {
let vanish = false
2023-03-02 02:29:13 -05:00
let nickname = true
let socialspy = false
2022-11-27 02:35:28 -05:00
let cspy = false
2023-03-02 03:08:00 -05:00
let prefix = false
2023-03-02 02:29:13 -05:00
let op = false
2022-11-27 02:35:28 -05:00
let gameMode = 1
let muted = false
2022-08-14 05:51:45 -04:00
2022-12-12 03:06:50 -05:00
bot.on('message', (data) => {
2022-11-27 02:35:28 -05:00
if (data.toString() === 'You are now completely invisible to normal users, and hidden from in-game commands.') vanish = true
2023-03-02 02:29:13 -05:00
if (!bot.visibility && data.toString() === `Vanish for ${bot.username}: disabled`) vanish = false
if (data.toString() === 'You no longer have a nickname.') nickname = true
if (data.toString().startsWith('Your nickname is now ')) nickname = false
if (data.toString() === `SocialSpy for ${bot.username}: enabled`) socialspy = true
if (data.toString() === `SocialSpy for ${bot.username}: disabled`) socialspy = false
if (data.toString().startsWith('You have been muted')) muted = true
if (data.toString() === 'You have been unmuted.') muted = false
2022-11-27 02:35:28 -05:00
if (data.toString() === 'Successfully enabled CommandSpy' || data.toString() === ' Enabled your command spy.' || data.toString() === ' Your command spy is already enabled.') cspy = true
if (data.toString() === 'Successfully disabled CommandSpy' || data.toString() === ' Disabled your command spy.') cspy = false
2023-03-02 02:29:13 -05:00
if (data.toString() === 'You now have the tag: [ChomeNS Bot]' || // for 1.19.2 (or 1.19?) and older clones
2023-01-21 06:10:18 -05:00
data.toString() === 'You now have the tag: &8[&eChomeNS Bot&8]'
2022-12-27 23:27:25 -05:00
) {
2022-11-27 02:35:28 -05:00
prefix = true
return
2022-08-14 05:51:45 -04:00
}
2022-11-27 02:35:28 -05:00
if (data.toString().startsWith('You no longer have a tag')) prefix = false
if (data.toString().startsWith('You now have the tag: ')) prefix = false
})
2022-08-14 05:51:45 -04:00
bot._client.on('entity_status', (data) => {
2022-11-27 02:35:28 -05:00
if (data.entityId !== bot.entityId) return
2022-08-14 05:51:45 -04:00
switch (data.entityStatus) {
case 24:
2022-11-27 02:35:28 -05:00
op = false
2022-08-14 05:51:45 -04:00
2022-11-27 02:35:28 -05:00
bot.emit('deop')
break
2022-08-14 05:51:45 -04:00
case 28:
2022-11-27 02:35:28 -05:00
op = true
2022-08-14 05:51:45 -04:00
2022-11-27 02:35:28 -05:00
bot.emit('op')
break
2022-08-14 05:51:45 -04:00
}
2022-11-27 02:35:28 -05:00
bot.emit('entity_status', data)
})
2022-08-14 05:51:45 -04:00
bot._client.on('game_state_change', (data) => {
2023-03-02 02:29:13 -05:00
if (data.reason === 4 && config.self_care.endCredits) bot.write('client_command', { payload: 0 })
2022-11-27 02:35:28 -05:00
if (data.reason !== 3) return
2022-08-14 05:51:45 -04:00
2022-11-27 02:35:28 -05:00
gameMode = data.gameMode
})
2022-08-14 05:51:45 -04:00
2022-11-30 04:45:20 -05:00
bot._client.on('login', (data) => {
2022-11-27 02:35:28 -05:00
gameMode = data.gameMode
})
2022-08-14 05:51:45 -04:00
const interval = setInterval(() => {
if (bot.options.kaboom) {
2022-11-27 02:35:28 -05:00
if (!prefix && config.self_care.prefix) bot.chat('/extras:prefix &8[&eChomeNS Bot&8]')
if (!op && config.self_care.op) bot.chat('/minecraft:op @s[type=player]')
if (!cspy && config.self_care.cspy) bot.chat('/commandspy:commandspy on')
2022-08-20 04:18:54 -04:00
}
2023-03-02 02:29:13 -05:00
2022-11-27 02:35:28 -05:00
if (!vanish && config.self_care.vanish) bot.chat('/essentials:vanish enable')
2023-03-02 02:29:13 -05:00
if (!socialspy && config.self_care.socialspy) bot.chat('/essentials:socialspy enable')
if (!nickname && config.self_care.nickname) bot.chat('/essentials:nickname off')
2022-11-27 02:35:28 -05:00
if (gameMode !== 1 && config.self_care.gamemode) bot.chat('/minecraft:gamemode creative @s[type=player]')
if (muted && config.self_care.mute) bot.chat('/essentials:mute ' + bot.uuid)
}, config.self_care_check_interval)
2022-11-30 04:45:20 -05:00
bot.on('end', () => {
2022-11-27 02:35:28 -05:00
clearInterval(interval)
})
};
2022-11-27 02:35:28 -05:00
module.exports = { inject }