@@ -18,7 +18,7 @@ interface RCONCommandSuccessOutput {
1818}
1919interface RCONCommandFailOutput {
2020 resp : false ;
21- server : FactorioServer ;
21+ identifier : string ;
2222}
2323type RCONCommandOutput = RCONCommandSuccessOutput | RCONCommandFailOutput ;
2424
@@ -30,7 +30,7 @@ interface Connection {
3030
3131class RconInterface {
3232 private servers : FactorioServer [ ] ;
33- private client : Comfy | null ;
33+ public client : Comfy | null ;
3434 public rconConnections : Connection [ ] ;
3535 /**
3636 * Intervals of checking if a server is online
@@ -67,24 +67,28 @@ class RconInterface {
6767 // reconnection mechanism
6868 rcon . on ( "end" , ( ) => {
6969 this . reconnectRcon ( rcon , server ) ; // start the reconnection mechanism
70- this . client . sendToErrorChannel (
71- `Server <#${
72- server . discordid
73- } > has dropped connection to RCON at <t:${ Math . floor (
74- Date . now ( ) / 1000
75- ) } >`
76- ) ;
70+ if ( ! server . dev ) {
71+ this . client . sendToErrorChannel (
72+ `Server <#${
73+ server . discordid
74+ } > has dropped connection to RCON at <t:${ Math . floor (
75+ Date . now ( ) / 1000
76+ ) } >`
77+ ) ;
78+ }
7779 } ) ;
7880 } catch ( error ) {
7981 // mechanism to reconnect to RCON after some time
8082 this . reconnectRcon ( rcon , server ) ; // start the reconnection mechanism
81- this . client . sendToErrorChannel (
82- `Server <#${
83- server . discordid
84- } > has failed to initially connect to RCON at <t:${ Math . floor (
85- Date . now ( ) / 1000
86- ) } >`
87- ) ;
83+ if ( ! server . dev ) {
84+ this . client . sendToErrorChannel (
85+ `Server <#${
86+ server . discordid
87+ } > has failed to initially connect to RCON at <t:${ Math . floor (
88+ Date . now ( ) / 1000
89+ ) } >`
90+ ) ;
91+ }
8892 }
8993 }
9094
@@ -124,13 +128,15 @@ class RconInterface {
124128 if ( connectionAttempts === 11520 ) connectionAttempts = 5760 ;
125129 // dayjs is used to get the relative time since the start of the reconnection attempts
126130 if ( attempts . includes ( connectionAttempts ) ) {
127- this . client . sendToErrorChannel (
128- `Server <#${
129- server . discordid
130- } > has been unable to connect to RCON since ${ dayjs (
131- startedAt
132- ) . fromNow ( ) } `
133- ) ;
131+ if ( ! server . dev ) {
132+ this . client . sendToErrorChannel (
133+ `Server <#${
134+ server . discordid
135+ } > has dropped connection to RCON at <t:${ Math . floor (
136+ Date . now ( ) / 1000
137+ ) } >`
138+ ) ;
139+ }
134140 }
135141 }
136142 } ;
@@ -153,17 +159,19 @@ class RconInterface {
153159 s . server . name === serverIdentifier ||
154160 s . server . discordid === serverIdentifier
155161 ) ;
162+ // if (serverIdentifier == "724696348871622818")
163+ // console.log(server)
156164 if ( ! server )
157165 return {
158166 resp : false ,
159- server : server . server ,
167+ identifier : serverIdentifier ,
160168 } ;
161169 // eslint-disable-next-line @typescript-eslint/no-empty-function
162170 const response = await server . rcon . send ( command ) . catch ( ( ) => { } ) ;
163171 if ( ! response )
164172 return {
165173 resp : false ,
166- server : server . server ,
174+ identifier : serverIdentifier ,
167175 } ;
168176 return {
169177 resp : response ,
0 commit comments