Skip to content

Commit

Permalink
Merge pull request #7 from AidanHarveyNelson/fix/slow-stopping-contai…
Browse files Browse the repository at this point in the history
…ners

Added additional logic to better handle slow containers
  • Loading branch information
AidanHarveyNelson authored Jun 26, 2024
2 parents 459d443 + 18a5b9f commit ea56e79
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,24 +107,43 @@ 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,
Data: &discordgo.InteractionResponseData{
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()
Expand Down

0 comments on commit ea56e79

Please sign in to comment.