mirror of
https://github.com/Fluffy-Bean/Lynxie.git
synced 2025-05-18 09:24:56 +00:00
Update pipeline
And commit half-baked code restructure
This commit is contained in:
parent
5d67b2e2b0
commit
2e5f4bce11
11 changed files with 32 additions and 59 deletions
77
pkg/commands/debug/debug.go
Normal file
77
pkg/commands/debug/debug.go
Normal file
|
@ -0,0 +1,77 @@
|
|||
package debug
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
|
||||
"github.com/Fluffy-Bean/lynxie/app"
|
||||
"github.com/Fluffy-Bean/lynxie/internal/color"
|
||||
"github.com/bwmarrin/discordgo"
|
||||
)
|
||||
|
||||
func RegisterDebugCommands(a *app.App) {
|
||||
a.RegisterCommand("debug", registerDebug(a))
|
||||
}
|
||||
|
||||
func registerDebug(a *app.App) app.Callback {
|
||||
return func(h *app.Handler, args []string) app.Error {
|
||||
buildTags := "-"
|
||||
goVersion := strings.TrimPrefix(runtime.Version(), "go")
|
||||
gcCount := runtime.MemStats{}.NumGC
|
||||
buildHash, _ := a.Config.CommandExtras["debug_build-hash"]
|
||||
buildPipeline, _ := a.Config.CommandExtras["debug_build-pipeline"]
|
||||
latency := h.Session.HeartbeatLatency().Milliseconds()
|
||||
|
||||
info, _ := debug.ReadBuildInfo()
|
||||
for _, setting := range info.Settings {
|
||||
switch setting.Key {
|
||||
case "-tags":
|
||||
buildTags = strings.ReplaceAll(setting.Value, ",", " ")
|
||||
}
|
||||
}
|
||||
|
||||
h.Session.ChannelMessageSendComplex(h.Message.ChannelID, &discordgo.MessageSend{
|
||||
Embed: &discordgo.MessageEmbed{
|
||||
Title: "Lynxie",
|
||||
Fields: []*discordgo.MessageEmbedField{
|
||||
{
|
||||
Name: "Build Tags",
|
||||
Value: buildTags,
|
||||
Inline: false,
|
||||
},
|
||||
{
|
||||
Name: "Go version",
|
||||
Value: goVersion,
|
||||
Inline: false,
|
||||
},
|
||||
{
|
||||
Name: "OS/Arch",
|
||||
Value: runtime.GOOS + "/" + runtime.GOARCH,
|
||||
Inline: false,
|
||||
},
|
||||
{
|
||||
Name: "GC Count",
|
||||
Value: fmt.Sprint(gcCount),
|
||||
Inline: false,
|
||||
},
|
||||
{
|
||||
Name: "Build Hash",
|
||||
Value: fmt.Sprintf("[%s](%s)", buildHash, buildPipeline),
|
||||
Inline: false,
|
||||
},
|
||||
{
|
||||
Name: "Latency",
|
||||
Value: fmt.Sprintf("%dms", latency),
|
||||
Inline: false,
|
||||
},
|
||||
},
|
||||
Color: color.RGBToDiscord(255, 255, 255),
|
||||
},
|
||||
Reference: h.Reference,
|
||||
})
|
||||
|
||||
return app.Error{}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue