11import { APIEmbed , GuildChannel } from "discord.js" ;
2- import LCL from "last-commit-log" ;
32import { shuffle } from "lodash-es" ;
43import moment from "moment-timezone" ;
5- import { humanizeDuration } from "../../../humanizeDuration.js " ;
4+ import { accessSync , readFileSync } from "node:fs " ;
65import { rootDir } from "../../../paths.js" ;
7- import { getCurrentUptime } from "../../../uptime.js" ;
6+ import { getBotStartTime } from "../../../uptime.js" ;
87import { resolveMember , sorter } from "../../../utils.js" ;
98import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin.js" ;
109import { utilityCmd } from "../types.js" ;
1110
11+ let commitHash : string | null = null ;
12+ try {
13+ accessSync ( `${ rootDir } /.commit-hash` ) ;
14+ commitHash = readFileSync ( `${ rootDir } /.commit-hash` , "utf-8" ) . trim ( ) ;
15+ } catch { }
16+
17+ let buildTime : string | null = null ;
18+ try {
19+ accessSync ( `${ rootDir } /.build-time` ) ;
20+ buildTime = readFileSync ( `${ rootDir } /.build-time` , "utf-8" ) . trim ( ) ;
21+ } catch { }
22+
1223export const AboutCmd = utilityCmd ( {
1324 trigger : "about" ,
1425 description : "Show information about Zeppelin's status on the server" ,
@@ -17,39 +28,14 @@ export const AboutCmd = utilityCmd({
1728 async run ( { message : msg , pluginData } ) {
1829 const timeAndDate = pluginData . getPlugin ( TimeAndDatePlugin ) ;
1930
20- const uptime = getCurrentUptime ( ) ;
21- const prettyUptime = humanizeDuration ( uptime , { largest : 2 , round : true } ) ;
22-
23- let lastCommit ;
24-
25- try {
26- const lcl = new LCL ( rootDir ) ;
27- lastCommit = await lcl . getLastCommit ( ) ;
28- } catch { } // eslint-disable-line no-empty
29-
30- let lastUpdate ;
31- let version ;
32-
33- if ( lastCommit ) {
34- lastUpdate = timeAndDate
35- . inGuildTz ( moment . utc ( lastCommit . committer . date , "X" ) )
36- . format ( pluginData . getPlugin ( TimeAndDatePlugin ) . getDateFormat ( "pretty_datetime" ) ) ;
37- version = lastCommit . shortHash ;
38- } else {
39- lastUpdate = "?" ;
40- version = "?" ;
41- }
42-
43- const lastReload = humanizeDuration ( Date . now ( ) - pluginData . state . lastReload , {
44- largest : 2 ,
45- round : true ,
46- } ) ;
31+ const botStartTime = getBotStartTime ( ) ;
32+ const buildTimeMoment = buildTime ? moment . utc ( buildTime , "YYYY-MM-DDTHH:mm:ss[Z]" ) : null ;
4733
4834 const basicInfoRows = [
49- [ "Uptime " , prettyUptime ] ,
50- [ "Last config reload" , `${ lastReload } ago ` ] ,
51- [ "Last bot update" , lastUpdate ] ,
52- [ "Version" , version ] ,
35+ [ "Bot start time " , `<t: ${ Math . floor ( botStartTime / 1000 ) } :R>` ] ,
36+ [ "Last config reload" , `<t: ${ Math . floor ( pluginData . state . lastReload / 1000 ) } :R> ` ] ,
37+ [ "Last bot update" , buildTimeMoment ? `<t: ${ Math . floor ( buildTimeMoment . unix ( ) ) } :f>` : "Unknown" ] ,
38+ [ "Version" , commitHash ?. slice ( 0 , 7 ) || "Unknown" ] ,
5339 [ "API latency" , `${ pluginData . client . ws . ping } ms` ] ,
5440 [ "Server timezone" , timeAndDate . getGuildTz ( ) ] ,
5541 ] ;
0 commit comments