Skip to content

Commit 57dda18

Browse files
committed
add update command
1 parent 1e6f501 commit 57dda18

3 files changed

Lines changed: 39 additions & 1 deletion

File tree

run.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#! /bin/sh
2+
3+
while :
4+
do
5+
echo "Starting process..."
6+
cd /home/bot/bin/src
7+
node index.js
8+
if [ $? -eq 0 ]
9+
then
10+
echo "Stopping process..." # exit shell script if exit code is 0
11+
break
12+
fi
13+
sleep 10 # wait 10 seconds before restarting
14+
done

src/commands/misc/update.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Command, CommandStore, CommandOptions, KlasaClient, KlasaMessage } from 'klasa';
2+
import { DefaultCommandOptions } from '../../constants';
3+
import { execSync } from 'child_process';
4+
5+
const ThisCommandOptions: CommandOptions = {
6+
...DefaultCommandOptions,
7+
name: 'update',
8+
requiredPermissions: ['ADMINISTRATOR']
9+
};
10+
11+
export default class extends Command {
12+
constructor (store: CommandStore, file: string[], directory: string) {
13+
super(store, file, directory, ThisCommandOptions);
14+
}
15+
16+
public async run (message: KlasaMessage): Promise<KlasaMessage | KlasaMessage[] | null> {
17+
const msg = await message.sendMessage('Pulling from Git');
18+
execSync('git pull');
19+
await msg.edit('Transpiling');
20+
execSync('tsc');
21+
await msg.edit('Restarting');
22+
process.exit(-1);
23+
}
24+
}

src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ClientOptions as dBioClientOptions } from 'dbiowrap/lib/src/client';
55

66
export const COMMAND_MESSAGE_LIFETIME = 30000;
77

8-
export const DISABLED_STOCK_COMMANDS = ['stats'];
8+
export const DISABLED_STOCK_COMMANDS = ['stats', 'info'];
99

1010
export const SUGGESTION_CHANNEL_ID = "725762022490374164";
1111

0 commit comments

Comments
 (0)