mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 12:21:00 -05:00
Fetch commit via Octokit
This commit is contained in:
parent
a8fac40e75
commit
c87fe041dc
@ -31,7 +31,8 @@
|
|||||||
"node-cron": "3.0.2",
|
"node-cron": "3.0.2",
|
||||||
"sequelize": "6.28.0",
|
"sequelize": "6.28.0",
|
||||||
"sqlite3": "5.1.4",
|
"sqlite3": "5.1.4",
|
||||||
"systeminformation": "5.17.3",
|
"systeminformation": "5.17.4",
|
||||||
|
"@octokit/rest": "19.0.7",
|
||||||
"typescript": "4.9.4",
|
"typescript": "4.9.4",
|
||||||
"xml-js": "1.6.11"
|
"xml-js": "1.6.11"
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import Discord,{SlashCommandBuilder} from 'discord.js';
|
import Discord,{SlashCommandBuilder} from 'discord.js';
|
||||||
import TClient from 'src/client';
|
import TClient from 'src/client';
|
||||||
import * as util from 'node:util';
|
import * as util from 'node:util';
|
||||||
|
import { Octokit } from '@octokit/rest';
|
||||||
import {exec} from 'node:child_process';
|
import {exec} from 'node:child_process';
|
||||||
import { readFileSync } from 'node:fs';
|
import { readFileSync } from 'node:fs';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
@ -68,6 +69,10 @@ export default {
|
|||||||
interaction.reply(`Uptime before restarting: **${client.formatTime(client.uptime as number, 3, {commas: true, longNames: true})}**`).then(()=>exec('pm2 restart Daggerbot'))
|
interaction.reply(`Uptime before restarting: **${client.formatTime(client.uptime as number, 3, {commas: true, longNames: true})}**`).then(()=>exec('pm2 restart Daggerbot'))
|
||||||
break
|
break
|
||||||
case 'update':
|
case 'update':
|
||||||
|
var githubRepo = {owner: 'AnxietyisReal', repo: 'Daggerbot-TS', ref: 'HEAD'}
|
||||||
|
const octokit = new Octokit({timeZone: 'Australia/NSW', userAgent: 'Daggerbot'})
|
||||||
|
const fetchCommitMsg = await octokit.repos.getCommit(githubRepo).then(x=>x.data.commit.message);
|
||||||
|
const fetchCommitAuthor = await octokit.repos.getCommit(githubRepo).then(x=>x.data.commit.author);
|
||||||
const clarkson = await interaction.reply({content: 'Pulling from repository...', fetchReply: true});
|
const clarkson = await interaction.reply({content: 'Pulling from repository...', fetchReply: true});
|
||||||
exec('git pull',(err:Error,stdout)=>{
|
exec('git pull',(err:Error,stdout)=>{
|
||||||
if (err){
|
if (err){
|
||||||
@ -75,7 +80,7 @@ export default {
|
|||||||
} else if (stdout.includes('Already up to date')){
|
} else if (stdout.includes('Already up to date')){
|
||||||
clarkson.edit('Bot is already up to date with the repository, did you forgor to push the changes? :skull:')
|
clarkson.edit('Bot is already up to date with the repository, did you forgor to push the changes? :skull:')
|
||||||
} else {
|
} else {
|
||||||
setTimeout(()=>{clarkson.edit(`Uptime before restarting: **${client.formatTime(client.uptime as number, 3, {commas: true, longNames: true})}**`).then(()=>exec('pm2 restart Daggerbot'))},650)
|
setTimeout(()=>{clarkson.edit(`Commit: **${fetchCommitMsg}**\nCommit author: **${fetchCommitAuthor}**\n\nUptime before restarting: **${client.formatTime(client.uptime as number, 3, {commas: true, longNames: true})}**`).then(()=>exec('pm2 restart Daggerbot'))},650)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user