mirror of
https://github.com/samuelthomas2774/nxapi.git
synced 2026-07-15 07:41:28 -05:00
Update approximate play time, date format in Discord activities
This commit is contained in:
parent
2ddac1619f
commit
d00c988220
|
|
@ -1,5 +1,5 @@
|
|||
import Table from '../../util/table.js';
|
||||
import { PresenceState } from '../../api/coral-types.js';
|
||||
import { PresencePlatform, PresenceState } from '../../api/coral-types.js';
|
||||
import type { Arguments as ParentArguments } from './index.js';
|
||||
import createDebug from '../../util/debug.js';
|
||||
import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js';
|
||||
|
|
@ -83,9 +83,13 @@ export async function handler(argv: ArgumentsCamelCase<Arguments>) {
|
|||
friend.name,
|
||||
online ?
|
||||
'name' in friend.presence.game ?
|
||||
'Playing ' + friend.presence.game.name + ';\nplayed for ' +
|
||||
'Playing ' + friend.presence.game.name +
|
||||
('platform' in friend.presence ?
|
||||
friend.presence.platform === PresencePlatform.NX ? ' (Nintendo Switch)' :
|
||||
friend.presence.platform === PresencePlatform.OUNCE ? ' (Nintendo Switch 2)' : '' : '') +
|
||||
';\nplayed for ' +
|
||||
hrduration(friend.presence.game.totalPlayTime) + ' since ' +
|
||||
new Date(friend.presence.game.firstPlayedAt * 1000).toLocaleDateString('en-GB') :
|
||||
new Date(friend.presence.game.firstPlayedAt * 1000).toISOString() :
|
||||
'Online' :
|
||||
friend.presence.state === PresenceState.INACTIVE ?
|
||||
'Console online' + (friend.presence.logoutAt ?
|
||||
|
|
|
|||
|
|
@ -120,7 +120,8 @@ function getPlayTimeText(type: DiscordPresencePlayTime, game: PresenceGame) {
|
|||
|
||||
if (type === DiscordPresencePlayTime.HIDDEN || game.totalPlayTime < 0) return null;
|
||||
|
||||
const since = game.firstPlayedAt ? new Date(game.firstPlayedAt * 1000).toLocaleDateString('en-GB') : 'now';
|
||||
const since = game.firstPlayedAt ? new Date(game.firstPlayedAt * 1000)
|
||||
.toLocaleDateString('en-GB', {dateStyle: 'medium'}) : 'now';
|
||||
|
||||
switch (type) {
|
||||
case DiscordPresencePlayTime.APPROXIMATE_PLAY_TIME:
|
||||
|
|
@ -160,8 +161,8 @@ function getFirstPlayedText(first_played_at: number) {
|
|||
}
|
||||
|
||||
function getApproximatePlayTime(minutes: number) {
|
||||
if (minutes < 300) {
|
||||
// Less than 5 hours
|
||||
if (minutes < 600) {
|
||||
// Less than 10 hours
|
||||
return Math.floor(minutes / 60) * 60;
|
||||
} else {
|
||||
return Math.floor(minutes / 300) * 300;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user