function elapsedStr( from , to = Date.now()) { return moment.duration( to - from ).format('d[d]hh:mm:ss.SSS',{ stopTrim: "h" }) }
/** * Convert seconds into timecode format * @param {Number} seconds - Duration in seconds * @returns {String} - Timecode / HH:mm:ss */ let convertSecondsToTimecode = (seconds) => { // console.debug('convertSecondsToTimecode') return moment.duration(seconds, 'seconds').format(etaFormat, { trim: false }) }
function getPosition(){ return execute('tell application "Spotify" to player position').then((positionSecs) => { var position = moment.duration(positionSecs, 'seconds').format('h:mm:ss', { forceLength: true }); if(position.length < 3){ position = `00:${position}`; } return position; }); }
async run(message, args, level) { // eslint-disable-line no-unused-vars const duration = moment.duration(this.client.uptime).format(" D [days], H [hrs], m [mins], s [secs]"); message.channel.send(stripIndents` = STATISTICS = • Users :: ${this.client.users.size.toLocaleString()} • Servers :: ${this.client.guilds.size.toLocaleString()} • Channels :: ${this.client.channels.size.toLocaleString()} • Uptime :: ${duration} • RAM usage :: ${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MB • Build :: ${NODE_ENV.toProperCase()} • Platform :: ${process.platform === "win32" ? "Windows" : process.platform.toProperCase()} = VERSIONS = • delet :: v${pkg.version} • Discord.js :: v${version} • Node.js :: ${process.version}`, { code: "asciidoc" }); }
function status(){ return Promise.props({ status: execute('tell application "Spotify" to player state as string'), artist: execute('tell application "Spotify" to artist of current track as string'), album: execute('tell application "Spotify" to album of current track as string'), track: execute('tell application "Spotify" to name of current track as string'), durationSecs: execute('tell application "Spotify" to duration of current track').then((durationMs) => { return moment.duration(durationMs, 'milliseconds').asSeconds(); }), duration: execute('tell application "Spotify" to duration of current track').then((durationMs) => { return moment.duration(durationMs, 'milliseconds').format(); }), positionSecs: execute('tell application "Spotify" to player position'), position: getPosition() }); }
function trackParserFn(resultType, data){ // Added to reuse this function for recommendations as well var tracks = []; if (data.body[resultType].items) { tracks = data.body[resultType].items; } else { tracks = data.body[resultType]; } return tracks.map((resultEntry, index) => { var resultIndex = index + 1; var trackName = resultEntry.name; var albumName = resultEntry.album.name; var artistNames = resultEntry.artists.map((artist) => artist.name ).join(', '); var duration = moment.duration(resultEntry.duration_ms, 'milliseconds').format(); var spotifyURI = resultEntry.uri; return { resultIndex, trackName, albumName, artistNames, duration, spotifyURI }; }); }
if (doc) { let value = Math.round(Math.random() * 300) + 50; const time = moment.duration.format( [moment.duration(parseInt(doc.daily) + 86400000 - Date.now())], "D MMMM YYYY, h:mm:ss"
app.get("/stats", (req, res) => { const duration = moment.duration(client.uptime).format(" D [days], H [hrs], m [mins], s [secs]"); const members = client.guilds.reduce((p, c) => p + c.memberCount, 0); const textChannels = client.channels.filter(c => c.type === "text").size; const voiceChannels = client.channels.filter(c => c.type === "voice").size; const guilds = client.guilds.size; renderTemplate(res, req, "stats.ejs", { stats: { servers: guilds, members: members, text: textChannels, voice: voiceChannels, uptime: duration, memoryUsage: (process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2), dVersion: Discord.version, nVersion: process.version } }); });
hexColor: m.highestRole.hexColor }, memberFor: moment.duration(Date.now() - m.joinedAt).format(" D [days], H [hrs], m [mins], s [secs]"), roles: m.roles.map(r=>({ name: r.name,
}, footer: { text: `Live for ${moment.duration(Math.max(0, moment().unix() - moment(stream.created_at).unix()), "seconds").format("h [hour and] m [minute]")}`
async run(message, args, level, settings) { // eslint-disable-line no-unused-vars const uptime = moment.duration(this.client.uptime).format("D [days], H [hrs], m [mins], s [secs]"); message.channel.send(stripIndents` \`\`\`asciidoc • Uptime :: ${uptime} \`\`\` For a full list of bot stats, use the \`${settings.prefix}stats\` command. `); }
function elapsedStr( from , to = Date.now()) { return moment.duration( to - from ).format('d[d]hh:mm:ss.SSS',{ stopTrim: "h" }) }
function elapsedStr( from , to = Date.now()) { return moment.duration( to - from ).format('d[d]hh:mm:ss.SSS',{ stopTrim: "h" }) }
function elapsedStr( from , to = Date.now()) { return moment.duration( to - from ).format('d[d]hh:mm:ss.SSS',{ stopTrim: "h" }) }
// Bot statistics. Notice that most of the rendering of data is done through this code, // not in the template, to simplify the page code. Most of it **could** be done on the page. app.get("/stats", (req, res) => { const duration = moment.duration(client.uptime).format(" D [days], H [hrs], m [mins], s [secs]"); const members = client.guilds.reduce((p, c) => p + c.memberCount, 0); const textChannels = client.channels.filter(c => c.type === "text").size; const voiceChannels = client.channels.filter(c => c.type === "voice").size; const guilds = client.guilds.size; renderTemplate(res, req, "stats.ejs", { stats: { servers: guilds, members: members, text: textChannels, voice: voiceChannels, uptime: duration, memoryUsage: (process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2), dVersion: Discord.version, nVersion: process.version } }); });