2022-08-14 05:51:45 -04:00
/* eslint-disable max-len */
2022-10-29 03:14:49 -04:00
function inject ( bot , dcclient , config ) {
2022-08-14 05:51:45 -04:00
let vanish = false ;
let cspy = false ;
let op = true ;
let gameMode = 1 ;
let prefix = false ;
let muted = false ;
bot . on ( 'parsed_chat' , ( data ) => {
2022-11-07 07:26:38 -05:00
if ( data . toString ( ) === 'You are now completely invisible to normal users, and hidden from in-game commands.' ) vanish = true ;
2022-08-14 05:51:45 -04:00
if ( ! bot . visibility ) {
if ( data . toString ( ) . startsWith ( 'Vanish for ' ) && data . toString ( ) . endsWith ( 'disabled' ) ) vanish = false ;
}
2022-11-07 07:26:38 -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 ;
if ( data . toString ( ) === 'You now have the tag: [ChomeNS Bot]' ) {
2022-08-14 05:51:45 -04:00
prefix = true ;
return ;
}
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 ;
2022-11-07 07:26:38 -05:00
if ( data . toString ( ) === 'You have been unmuted.' ) muted = false ;
2022-08-14 05:51:45 -04:00
} ) ;
bot . _client . on ( 'entity_status' , ( data ) => {
if ( data . entityId !== bot . entityId ) return ;
switch ( data . entityStatus ) {
case 24 :
op = false ;
bot . emit ( 'deop' ) ;
break ;
case 28 :
op = true ;
bot . emit ( 'op' ) ;
break ;
}
bot . emit ( 'entity_status' , data ) ;
} ) ;
bot . _client . on ( 'game_state_change' , ( data ) => {
if ( data . reason !== 3 ) return ;
gameMode = data . gameMode ;
} ) ;
bot . _client . once ( 'login' , ( data ) => {
gameMode = data . gameMode ;
} ) ;
2022-08-17 06:24:54 -04:00
const interval = setInterval ( ( ) => {
2022-11-07 08:08:29 -05:00
if ( bot . options . host !== '0.tcp.ap.ngrok.io' ) {
2022-11-06 05:52:40 -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-06 05:52:40 -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 ) ;
2022-10-29 03:14:49 -04:00
} , config . self _care _check _interval ) ;
2022-08-17 06:24:54 -04:00
bot . once ( 'end' , ( ) => {
clearInterval ( interval ) ;
} ) ;
2022-08-14 05:51:45 -04:00
}
module . exports = { inject } ;