@@ -45,6 +45,7 @@ async function statusPoll (bot) {
45
45
function subscribe ( bot , liveGame , games ) {
46
46
LOGGER . trace ( 'Gameday: subscribing...' ) ;
47
47
const ws = mlbAPIUtil . websocketSubscribe ( liveGame . gamePk ) ;
48
+ const feed = liveFeed . init ( globalCache . values . game . currentLiveFeed ) ;
48
49
ws . addEventListener ( 'message' , async ( e ) => {
49
50
try {
50
51
const eventJSON = JSON . parse ( e . data ) ;
@@ -65,6 +66,11 @@ function subscribe (bot, liveGame, games) {
65
66
globalCache . values . game . finished = true ;
66
67
globalCache . values . game . startReported = false ;
67
68
LOGGER . info ( 'NOTIFIED OF GAME CONCLUSION: CLOSING...' ) ;
69
+ await processAndPushPlay ( bot , {
70
+ reply : `## Final: ${ feed . awayAbbreviation ( ) } ${ feed . awayTeamScore ( ) } - ${ feed . homeTeamScore ( ) } ${ feed . homeAbbreviation ( ) } ` ,
71
+ isScoringPlay : true ,
72
+ isOut : false
73
+ } , liveGame , globalCache . values . game . lastReportedCompleteAtBatIndex , false ) ;
68
74
ws . close ( ) ;
69
75
await statusPoll ( bot , games ) ;
70
76
} else if ( ! globalCache . values . game . finished ) {
@@ -138,7 +144,7 @@ async function reportAnyMissedEvents (atBat, bot, gamePk, atBatIndex) {
138
144
}
139
145
}
140
146
141
- async function processAndPushPlay ( bot , play , gamePk , atBatIndex ) {
147
+ async function processAndPushPlay ( bot , play , gamePk , atBatIndex , includeTitle = true ) {
142
148
if ( play . reply
143
149
&& play . reply . length > 0
144
150
&& ! globalCache . values . game . reportedDescriptions
@@ -152,17 +158,19 @@ async function processAndPushPlay (bot, play, gamePk, atBatIndex) {
152
158
globalCache . values . game . lastReportedCompleteAtBatIndex = atBatIndex ;
153
159
}
154
160
const embed = new EmbedBuilder ( )
155
- . setTitle ( gamedayUtil . deriveHalfInning ( feed . halfInning ( ) ) + ' ' +
156
- feed . inning ( ) + ', ' +
157
- feed . awayAbbreviation ( ) + ( play . isScoringPlay
158
- ? ' vs. '
159
- : ' ' + play . awayScore + ' - ' + play . homeScore + ' ' ) +
160
- feed . homeAbbreviation ( ) + ( play . isScoringPlay ? ' - Scoring Play \u2757' : '' ) )
161
161
. setDescription ( play . reply + ( play . isOut && play . outs === 3 && ! gamedayUtil . didGameEnd ( play . homeScore , play . awayScore ) ? gamedayUtil . getDueUp ( ) : '' ) )
162
162
. setColor ( ( feed . halfInning ( ) === 'top'
163
163
? globalCache . values . game . awayTeamColor
164
164
: globalCache . values . game . homeTeamColor
165
165
) ) ;
166
+ if ( includeTitle ) {
167
+ embed . setTitle ( gamedayUtil . deriveHalfInning ( feed . halfInning ( ) ) + ' ' +
168
+ feed . inning ( ) + ', ' +
169
+ feed . awayAbbreviation ( ) + ( play . isScoringPlay
170
+ ? ' vs. '
171
+ : ' ' + play . awayScore + ' - ' + play . homeScore + ' ' ) +
172
+ feed . homeAbbreviation ( ) + ( play . isScoringPlay ? ' - Scoring Play \u2757' : '' ) ) ;
173
+ }
166
174
const messages = [ ] ;
167
175
for ( const channelSubscription of globalCache . values . subscribedChannels ) {
168
176
const returnedChannel = await bot . channels . fetch ( channelSubscription . channel_id ) ;
0 commit comments