docker added

This commit is contained in:
darius 2024-05-03 22:05:35 +02:00
parent a11654d6f8
commit 62e7283f47
6 changed files with 47 additions and 6 deletions

16
Dockerfile Normal file
View File

@ -0,0 +1,16 @@
# Use an official Golang runtime as a parent image
FROM golang:latest
# Set the working directory to /app
WORKDIR .
COPY . .
# Download and install any required dependencies
RUN go mod download
# Build the Go app
RUN go build .
# Define the command to run the app when the container starts
CMD ["./kleincordBot"]

9
docker-compose.yml Normal file
View File

@ -0,0 +1,9 @@
version: '3.8'
name: kleincord
services:
bot:
build:
context: .
dockerfile: Dockerfile
container_name: kleincord
restart: unless-stopped

View File

@ -16,7 +16,7 @@ func ReadBackCommand(data discordgo.ApplicationCommandInteractionData, s *discor
}, },
) )
if err != nil { if err != nil {
services.HandleError(err) services.HandleError(err, s)
} }
} }
@ -29,6 +29,6 @@ func Test1Command(s *discordgo.Session, i *discordgo.InteractionCreate) {
}, },
) )
if err != nil { if err != nil {
services.HandleError(err) services.HandleError(err, s)
} }
} }

View File

@ -47,6 +47,6 @@ func DeleteCommand(data discordgo.ApplicationCommandInteractionData, s *discordg
Content: strconv.Itoa(len(messages)) + " Message deleted", Content: strconv.Itoa(len(messages)) + " Message deleted",
}) })
if err != nil { if err != nil {
services.HandleError(err) services.HandleError(err, s)
} }
} }

View File

@ -21,7 +21,7 @@ func MessageTest(s *discordgo.Session, m *discordgo.MessageCreate) {
Type: discordgo.EmbedTypeArticle, Type: discordgo.EmbedTypeArticle,
}) })
if err != nil { if err != nil {
services.HandleError(err) services.HandleError(err, s)
} }
} }
@ -37,6 +37,6 @@ func MessageTest2(s *discordgo.Session, m *discordgo.MessageCreate) {
Type: discordgo.EmbedTypeArticle, Type: discordgo.EmbedTypeArticle,
}) })
if err != nil { if err != nil {
services.HandleError(err) services.HandleError(err, s)
} }
} }

View File

@ -1,5 +1,21 @@
package services package services
func HandleError(err error) { import (
"github.com/bwmarrin/discordgo"
"strconv"
)
func HandleError(err error, s *discordgo.Session) {
s.ChannelMessageSendComplex(strconv.Itoa(1236038688627101749), &discordgo.MessageSend{
Content: "@here",
Embed: &discordgo.MessageEmbed{
Title: "Error",
Color: 0xff0000,
Fields: []*discordgo.MessageEmbedField{
{
Value: "```" + err.Error() + "```",
},
},
},
})
} }