From ce4b3ea4e29d2f6786f74a3c4d0707a41a2b257b Mon Sep 17 00:00:00 2001 From: AnxietyisReal <96593068+AnxietyisReal@users.noreply.github.com> Date: Sat, 30 Sep 2023 10:56:35 +1000 Subject: [PATCH] Add commit URLs --- src/commands/statistics.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/commands/statistics.ts b/src/commands/statistics.ts index 31593fc..7649e88 100644 --- a/src/commands/statistics.ts +++ b/src/commands/statistics.ts @@ -6,6 +6,8 @@ import FormatTime from '../helpers/FormatTime.js'; import si from 'systeminformation'; import TClient from '../client.js'; import os from 'node:os'; +import {Octokit} from '@octokit/rest'; +import {createTokenAuth} from '@octokit/auth-token'; import {readFileSync} from 'node:fs'; import {execSync} from 'node:child_process'; const packageJson = JSON.parse(readFileSync('package.json', 'utf8')); @@ -50,11 +52,21 @@ export default { }); embed.addFields({name: '\u200b', value: `\`\`\`\n${fieldValue}\`\`\``}); } else embed.addFields({name: '\u200b', value: `\`\`\`\n${rows.join('')}\`\`\``}); + + const SummonAuthentication = createTokenAuth(client.tokens.octokit); + const {token} = await SummonAuthentication(); + let githubRepo = {owner: 'AnxietyisReal', repo: 'Daggerbot-TS', ref: 'HEAD'}; + const octokit = new Octokit({auth: token, timeZone: 'Australia/NSW', userAgent: 'Daggerbot-TS'}); + const github = { + remoteCommit: await octokit.repos.getCommit({...githubRepo, ref: commitHashes().remoteHash}), + localCommit: await octokit.repos.getCommit({...githubRepo, ref: commitHashes().localHash}), + } + embed.addFields( { name: '> __Repository__', value: MessageTool.concatMessage( - `**Local:** ${commitHashes().localHash}`, - `**Remote:** ${commitHashes().remoteHash}` + `**Local:** [${commitHashes().localHash}](${github.localCommit.data.html_url})`, + `**Remote:** [${commitHashes().remoteHash}](${github.remoteCommit.data.html_url})`, ) }, {name: '> __Dependencies__', value: MessageTool.concatMessage(