From 13a25d0b5a7993bead72a69f3934630bac9bc327 Mon Sep 17 00:00:00 2001 From: AnxietyisReal <96593068+AnxietyisReal@users.noreply.github.com> Date: Sun, 16 Apr 2023 15:47:49 +1000 Subject: [PATCH] Improve the updater. --- src/commands/dev.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/commands/dev.ts b/src/commands/dev.ts index 4dc60fe..2a8571e 100644 --- a/src/commands/dev.ts +++ b/src/commands/dev.ts @@ -67,7 +67,10 @@ export default { exec('git pull',(err:Error,stdout)=>{ if (err) clarkson.edit(`\`\`\`${removeUsername(err.message)}\`\`\``) 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:') - else 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('tsc && pm2 restart Daggerbot')),650) + else clarkson.edit('Compiling TypeScript files...').then(()=>exec('tsc', (err:Error)=>{ + if (err) clarkson.edit(`\`\`\`${removeUsername(err.message)}\`\`\``) + else clarkson.edit(`Commit: **${fetchCommitMsg}**\nCommit author: **${fetchCommitAuthor}**\n\nSuccessfully compiled TypeScript files into JavaScript!\nUptime before restarting: **${client.formatTime(client.uptime as number, 3, {commas: true, longNames: true})}**`).then(()=>exec('pm2 restart Daggerbot')) + })) }); }, presence: ()=>{ @@ -106,7 +109,13 @@ export default { interaction.deferReply(); (client.channels.resolve(client.config.mainServer.channels.console) as Discord.TextChannel).send({content: `Uploaded the current console dump as of `, files: [`${process.env.pm2_home}/logs/Daggerbot-out-0.log`, `${process.env.pm2_home}/logs/Daggerbot-error-0.log`]}).then(()=>interaction.editReply('It has been uploaded to dev server.')).catch((e:Error)=>interaction.editReply(`\`${e.message}\``)) }, - restart: ()=>interaction.reply(`Uptime before restarting: **${client.formatTime(client.uptime as number, 3, {commas: true, longNames: true})}**`).then(()=>exec('pm2 restart Daggerbot')) + restart: async()=>{ + const i = await interaction.reply({content: 'Compiling TypeScript files...', fetchReply: true}); + exec('tsc',(err:Error)=>{ + if (err) i.edit(`\`\`\`${removeUsername(err.message)}\`\`\``) + else i.edit(`Successfully compiled TypeScript files into JavaScript!\nUptime before restarting: **${client.formatTime(client.uptime as number, 3, {commas: true, longNames: true})}**`).then(()=>exec('pm2 restart Daggerbot')) + }) + } } as any)[interaction.options.getSubcommand()](); }, data: new SlashCommandBuilder()