From 18a5b9fd3161da4a73d842f0df91bbdbe5ba30a7 Mon Sep 17 00:00:00 2001 From: Aidan Harvey-Nelson Date: Wed, 26 Jun 2024 16:20:34 +1000 Subject: [PATCH] Added additional logic to better handle slow containers --- main.go | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index 5b3647e..85488b5 100644 --- a/main.go +++ b/main.go @@ -107,17 +107,13 @@ var ( switch options[0].Name { case "start": - docker.StartContainer(subCommand[0].Value.(string)) - content = "Server: has been succesfully started" + content = "Request to start server has been recieved" case "stop": - docker.StopContainer(subCommand[0].Value.(string)) - content = "Server has been succesfully stopped" + content = "Request to stop server has been recieved" case "status": - status := docker.StatusContainer(subCommand[0].Value.(string)) - content = "Server is currently in status \"" + status + "\"" + content = "Request to get server status has been recieved" case "restart": - docker.RestartContainer(subCommand[0].Value.(string)) - content = "Server has been succesfully restarted" + content = "Request to restart server has been recieved" } s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{ Type: discordgo.InteractionResponseChannelMessageWithSource, @@ -125,6 +121,29 @@ var ( Content: content, }, }) + switch options[0].Name { + case "start": + docker.StartContainer(subCommand[0].Value.(string)) + content = "Server has been succesfully started" + case "stop": + go docker.StopContainer(subCommand[0].Value.(string)) + content = "Server has been succesfully stopped" + case "status": + status := docker.StatusContainer(subCommand[0].Value.(string)) + content = "Server is currently in status \"" + status + "\"" + case "restart": + go docker.RestartContainer(subCommand[0].Value.(string)) + content = "Server has been succesfully restarted" + } + _, err := s.InteractionResponseEdit(i.Interaction, &discordgo.WebhookEdit{ + Content: &content, + }) + if err != nil { + s.FollowupMessageCreate(i.Interaction, true, &discordgo.WebhookParams{ + Content: "Something went wrong", + }) + return + } case discordgo.InteractionApplicationCommandAutocomplete: data := i.ApplicationCommandData()