11import { Context } from 'aws-lambda' ;
22import * as AWS from 'aws-sdk' ;
33import axios from 'axios' ;
4+ import { getFullDiscordCommand } from '../shared_util' ;
45
56const InstanceIds = [ process . env . INSTANCE_ID ! ] ;
67const ec2_instance_region = process . env . EC2_REGION ;
@@ -20,7 +21,7 @@ exports.handler = async (event: any, context: Context) => {
2021 const commandName = body . data . name ;
2122 console . log ( 'commandName: ' , commandName ) ;
2223
23- if ( commandName == 'mc_start' ) {
24+ if ( commandName == getFullDiscordCommand ( 'start' ) ) {
2425 try {
2526 const result = await ec2 . startInstances ( { InstanceIds } ) . promise ( ) ;
2627 console . log ( 'startInstances succeed, result: \n' , result ) ;
@@ -34,7 +35,7 @@ exports.handler = async (event: any, context: Context) => {
3435 }
3536 }
3637
37- if ( commandName == 'mc_stop' ) {
38+ if ( commandName == getFullDiscordCommand ( 'stop' ) ) {
3839 try {
3940 const result = await ec2 . stopInstances ( { InstanceIds } ) . promise ( ) ;
4041 console . log ( 'stopInstance suceeed, result: \n' , result ) ;
@@ -47,7 +48,7 @@ exports.handler = async (event: any, context: Context) => {
4748 }
4849 }
4950
50- if ( commandName == 'mc_restart' ) {
51+ if ( commandName == getFullDiscordCommand ( 'restart' ) ) {
5152 try {
5253 const result = await sendCommands ( [ 'sudo systemctl restart minecloud' ] ) ;
5354 console . log ( 'mc_restart result: ' , result ) ;
@@ -60,7 +61,7 @@ exports.handler = async (event: any, context: Context) => {
6061 }
6162 }
6263
63- if ( commandName == 'mc_backup' ) {
64+ if ( commandName == getFullDiscordCommand ( 'backup' ) ) {
6465 try {
6566 const result = await sendCommands ( [
6667 'cd /opt/minecloud/' ,
@@ -76,7 +77,7 @@ exports.handler = async (event: any, context: Context) => {
7677 }
7778 }
7879
79- if ( commandName == 'mc_backup_download' ) {
80+ if ( commandName == getFullDiscordCommand ( 'backup_download' ) ) {
8081 const s3 = new AWS . S3 ( { signatureVersion : 'v4' } ) ;
8182
8283 const bucketName : string = process . env . BACKUP_BUCKET_NAME as string ;
0 commit comments