1
1
import * as requestSchema from "./structures/StatusRequest.json" ;
2
- import { CountdownType } from "./structures/StatusRequest" ;
3
2
import { GameServer } from ".." ;
4
3
import { StatusRequest } from "./structures" ;
5
4
import Discord , { TextChannel } from "discord.js" ;
@@ -101,9 +100,6 @@ export default class StatusPayload extends Payload {
101
100
const gamemodeExtras = GamemodeExtras [ gamemodeName as keyof typeof GamemodeExtras ] ;
102
101
const gamemodeIcon = gamemodeExtras ?. seagull ?? gamemodeExtras ?. icon ;
103
102
104
- if ( current_countdown && current_countdown . typ === CountdownType . AOWL_COUNTDOWN_CUSTOM )
105
- return ;
106
-
107
103
const count = current_players . length ;
108
104
109
105
if ( ! discord ) return ;
@@ -155,7 +151,7 @@ export default class StatusPayload extends Payload {
155
151
}
156
152
// Permanent status message
157
153
// Map name w/ workshop link
158
- let desc = `>>> ### ${
154
+ let desc = `### ${
159
155
current_workshopMap
160
156
? `[${ current_workshopMap . name } ](https://steamcommunity.com/sharedfiles/filedetails/?id=${ current_workshopMap . id } )`
161
157
: current_map
@@ -170,8 +166,8 @@ export default class StatusPayload extends Payload {
170
166
const servertime = dayjs ( ) . subtract ( current_serverUptime , "s" ) . unix ( ) ;
171
167
const maptime = dayjs ( ) . subtract ( current_mapUptime , "s" ) . unix ( ) ;
172
168
173
- desc += `\n:repeat: Map uptime : <t:${ maptime } :R>` ;
174
- desc += `\n:file_cabinet: Server uptime : <t:${ servertime } :R>` ;
169
+ desc += `\n:repeat: Map up since : <t:${ maptime } :R>` ;
170
+ desc += `\n:file_cabinet: Server up since : <t:${ servertime } :R>` ;
175
171
if ( current_countdown )
176
172
desc += `\n<a:ALERTA:843518761160015933> \`${ current_countdown . text } in ${ current_countdown . time } seconds\` <a:ALERTA:843518761160015933>` ;
177
173
if ( current_defcon && current_defcon !== 5 )
@@ -186,58 +182,92 @@ export default class StatusPayload extends Payload {
186
182
} else if ( current_map && current_map . toLowerCase ( ) . trim ( ) == "rp_unioncity" ) {
187
183
mapThumbnail = `${ url } /map-thumbnails/rp_unioncity.png` ;
188
184
}
185
+
186
+ if ( ! mapThumbnail && current_workshopMap ) {
187
+ const res = await Steam . getPublishedFileDetails ( [ current_workshopMap . id ] ) . catch (
188
+ console . error
189
+ ) ;
190
+ const thumbnailURI = res ?. publishedfiledetails ?. [ 0 ] ?. preview_url ;
191
+
192
+ if ( thumbnailURI ) {
193
+ mapThumbnail = thumbnailURI ;
194
+ }
195
+ }
189
196
}
190
197
191
- const embed = new Discord . EmbedBuilder ( )
192
- . setColor (
198
+ const container = {
199
+ type : Discord . ComponentType . Container ,
200
+ accent_color :
193
201
current_defcon === 1 || current_countdown
194
202
? 0xff0000
195
203
: current_gamemode
196
204
? gamemodeExtras ?. color ?? null
197
- : null
198
- )
199
- . setFooter ( {
200
- text : gamemodeName ,
201
- iconURL : gamemodeExtras ?. icon ,
202
- } )
203
- . setAuthor ( {
204
- name : server . config . name ,
205
- iconURL : gamemodeIcon ,
206
- url : `https://metastruct.net/${
207
- server . config . label ? "join/" + server . config . label : ""
208
- } `,
209
- } )
210
- . setDescription ( desc )
211
- . setThumbnail ( mapThumbnail ) ;
205
+ : null ,
206
+ components : [
207
+ {
208
+ type : Discord . ComponentType . Section ,
209
+ components : [
210
+ {
211
+ type : Discord . ComponentType . TextDisplay ,
212
+ content : desc ,
213
+ } ,
214
+ ] ,
215
+ accessory : {
216
+ type : Discord . ComponentType . Thumbnail ,
217
+ media : {
218
+ url : mapThumbnail ?? `${ url } /map-thumbnails/gm_construct_m.png` ,
219
+ } ,
220
+ description : current_map ,
221
+ } ,
222
+ } ,
223
+ ] ,
224
+ } as Discord . APIContainerComponent ;
212
225
213
226
if ( count > 0 ) {
214
- embed
215
- . setImage (
216
- players
217
- ? `http://${ host } :${ port } /server-status/${
218
- server . config . id
219
- } /${ Date . now ( ) } `
220
- : server . status . image
221
- )
222
- . setFooter ( {
223
- text : `${
224
- embed . data . footer ? `${ embed . data . footer . text } | ` : ""
225
- } Middle-click the player list to open an interactive version`,
226
- iconURL : embed . data . footer ?. icon_url ,
227
- } ) ;
228
- }
229
-
230
- if ( mapThumbnail === null && current_workshopMap ) {
231
- const res = await Steam . getPublishedFileDetails ( [ current_workshopMap . id ] ) . catch (
232
- console . error
227
+ container . components . push (
228
+ { type : Discord . ComponentType . Separator } ,
229
+ {
230
+ type : Discord . ComponentType . MediaGallery ,
231
+ items : [
232
+ {
233
+ media : {
234
+ url : players
235
+ ? `http://${ host } :${ port } /server-status/${
236
+ server . config . id
237
+ } /${ Date . now ( ) } `
238
+ : server . status . image ?? "" ,
239
+ } ,
240
+ } ,
241
+ ] ,
242
+ }
233
243
) ;
234
- const thumbnailURI = res ?. publishedfiledetails ?. [ 0 ] ?. preview_url ;
235
-
236
- if ( thumbnailURI ) {
237
- embed . setThumbnail ( thumbnailURI ) ;
238
- mapThumbnail = thumbnailURI ;
239
- }
240
244
}
245
+ // footer
246
+ container . components . push (
247
+ { type : Discord . ComponentType . Separator } ,
248
+ {
249
+ type : Discord . ComponentType . TextDisplay ,
250
+ content : `-# ${ gamemodeName } ${
251
+ count > 0
252
+ ? " | Middle-click the player list to open an interactive version"
253
+ : ""
254
+ } `,
255
+ }
256
+ ) ;
257
+
258
+ container . components . push ( {
259
+ type : Discord . ComponentType . ActionRow ,
260
+ components : [
261
+ {
262
+ type : Discord . ComponentType . Button ,
263
+ style : Discord . ButtonStyle . Link ,
264
+ label : "Connect" ,
265
+ url : `https://metastruct.net/${
266
+ server . config . label ? "join/" + server . config . label : ""
267
+ } `,
268
+ } ,
269
+ ] ,
270
+ } ) ;
241
271
242
272
if ( mapThumbnail && server . discordBanner !== mapThumbnail ) {
243
273
server . changeBanner ( mapThumbnail ) ;
@@ -257,7 +287,12 @@ export default class StatusPayload extends Payload {
257
287
server . mapName = current_map ;
258
288
server . mapUptime = current_mapUptime ;
259
289
server . serverUptime = current_serverUptime ;
260
- server . status . image = embed . data . image ?. url ?? null ;
290
+ server . status . image =
291
+ (
292
+ container . components . find (
293
+ c => c . type === Discord . ComponentType . MediaGallery
294
+ ) as Discord . APIMediaGalleryComponent
295
+ ) ?. items [ 0 ] . media . url ?? null ;
261
296
server . status . mapThumbnail = mapThumbnail ;
262
297
server . status . players = current_players ;
263
298
server . workshopMap = current_workshopMap ;
@@ -294,9 +329,9 @@ export default class StatusPayload extends Payload {
294
329
. filter ( ( msg : Discord . Message ) => msg . author . id == discord . user ?. id )
295
330
. first ( ) ;
296
331
if ( message ) {
297
- await message . edit ( { embeds : [ embed ] } ) . catch ( ) ;
332
+ await message . edit ( { components : [ container ] , flags : 1 << 15 } ) . catch ( ) ;
298
333
} else {
299
- channel . send ( { embeds : [ embed ] } ) . catch ( ) ;
334
+ channel . send ( { components : [ container ] , flags : 1 << 15 } ) . catch ( ) ;
300
335
}
301
336
} ;
302
337
0 commit comments