2022-12-05 03:16:48 -05:00
2022-11-27 02:35:28 -05:00
function inject ( bot , dcclient , config ) {
let vanish = false
let cspy = false
let op = true
let gameMode = 1
let prefix = false
let muted = false
let endCredits = 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
2022-11-18 02:19:56 -05:00
if ( ! bot . visibility &&
data . toString ( ) . startsWith ( 'Vanish for ' ) &&
data . toString ( ) . endsWith ( 'disabled' )
2022-11-27 02:35:28 -05:00
) vanish = false
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
2022-12-27 23:27:25 -05:00
if ( data . toString ( ) === 'You now have the tag: [ChomeNS Bot]' ||
data . toString ( ) === 'You now have the tag: &8[&eChomeNS Bot&8]' // kaboom is having ploblem idk
) {
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
if ( data . toString ( ) . startsWith ( 'You have been muted' ) ) muted = true
if ( data . toString ( ) === 'You have been unmuted.' ) muted = 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 ) => {
2022-11-27 02:35:28 -05:00
if ( data . reason === 4 ) endCredits = true
2022-11-27 01:16:49 -05:00
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
2022-08-17 06:24:54 -04:00
const interval = setInterval ( ( ) => {
2022-11-17 02:46:04 -05:00
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
}
2022-11-27 02:35:28 -05:00
if ( ! vanish && config . self _care . vanish ) bot . chat ( '/essentials:vanish enable' )
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 )
if ( endCredits && config . self _care . endCredits ) bot . write ( 'client_command' , { payload : 0 } )
} , config . self _care _check _interval )
2022-08-17 06:24:54 -04:00
2022-11-30 04:45:20 -05:00
bot . on ( 'end' , ( ) => {
2022-11-27 02:35:28 -05:00
clearInterval ( interval )
} )
2022-11-16 08:21:19 -05:00
} ;
2022-11-27 02:35:28 -05:00
module . exports = { inject }