diff --git a/src/http/github/push.listener.ts b/src/http/github/push.listener.ts index a300ad3..3185e64 100644 --- a/src/http/github/push.listener.ts +++ b/src/http/github/push.listener.ts @@ -1,7 +1,6 @@ import { Push } from './github.events'; import { Client, MessageEmbed, TextChannel } from 'discord.js'; import config from '../../../config'; -import {autoUpdate} from '../../util/update'; let lastEmbedMessageId: string | undefined = undefined; @@ -39,15 +38,8 @@ export default async (client: Client, event: Push) => { ]})).id; } - function restartIfSelf() { - if (event.repository.full_name === 'unnamed/rose') { - autoUpdate(); - } - } - if (!lastEmbedMessageId) { await sendNewEmbed(); - restartIfSelf(); return; } @@ -57,21 +49,15 @@ export default async (client: Client, event: Push) => { if (lastEmbed.author.name !== title || (lastEmbed.description.match(/\n/g) ?? []).length > 7) { - sendNewEmbed() - .then(() => restartIfSelf()) - .catch(console.error); + sendNewEmbed().catch(console.error); } else { lastEmbedMessage.edit({ embeds: [ new MessageEmbed() .setColor(config.color) .setAuthor(title, iconURL, event.repository.url) .setDescription(lastEmbed.description + '\n' + history) - ]}) - .then(() => restartIfSelf()) - .catch(console.error); + ]}).catch(console.error); } }) - .catch(() => { - sendNewEmbed().then(() => restartIfSelf()); - }); + .catch(() => sendNewEmbed()); }; \ No newline at end of file diff --git a/src/util/update.ts b/src/util/update.ts deleted file mode 100644 index bf8bb07..0000000 --- a/src/util/update.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { spawn, execSync } from 'child_process'; -import signale from 'signale'; - -export function autoUpdate(): boolean { - const output = execSync('git pull').toString(); - - if (output === 'Already up to date.\n') { - signale.info('Tried to update but we are up to date'); - return false; - } - - signale.info('Restarting process due to update'); - - spawn(process.argv[0], process.argv.slice(1), { - cwd: process.cwd(), - detached: true, - stdio: 'inherit' - }).unref(); - process.exit(); - return true; -} \ No newline at end of file