package discord import ( "fmt" "strings" "github.com/bwmarrin/discordgo" "go.jolheiser.com/gojang/query" ) func init() { cmd := command{ validate: func(cmd commandInit) bool { return true }, run: func(cmd commandInit) (string, error) { server := query.NewServer(cmd.config.Server.Address, cmd.config.Server.Port) q, err := server.Query(query.DefaultTimeout) if err != nil { return "", err } embed := &discordgo.MessageEmbed{ Color: 0x007D96, Title: fmt.Sprintf("Server Status for `%s`", cmd.config.Server.Address), Description: q.MOTD, Fields: []*discordgo.MessageEmbedField{ { Name: "Version", Value: fmt.Sprintf("%s %s", q.ServerMod.Name, q.Version), Inline: true, }, { Name: "Player's Online", Value: fmt.Sprintf("%d / %d", q.CurrentPlayers, q.MaxPlayers), Inline: true, }, { Name: "Players", Value: strings.Join(q.Players, ", "), }, }, } sendEmbed(cmd.session, cmd.message.ChannelID, embed) return "", nil }, help: "Get the server status", } commands["status"] = cmd commands["version"] = cmd commands["online"] = cmd }