~exprez135/go-hypixel

a75ff4947247ff6631c84414143c1a7c29b3adee — Nate Ijams 3 years ago 6d442e8 v0.0.16
Check for empty online player list.

Fixes crash in case of no online players.
2 files changed, 7 insertions(+), 2 deletions(-)

M engine/discord.go
M engine/tracking.go
M engine/discord.go => engine/discord.go +6 -1
@@ 2,12 2,12 @@ package engine

import (
	"log"
	"math/rand"
	"os"
	"os/signal"
	"strings"
	"syscall"
	"time"
	"math/rand"

	"git.sr.ht/~exprez135/go-hypixel/api"



@@ 408,6 408,11 @@ func listOnline(ctx *exrouter.Context) {
	// Fetch list of online UUIDs in the monitored guilds
	onlineList := ListOnlinePlayers(guilds)

	if len(onlineList) == 0 {
		ctx.Reply("There are no players online. Do the bed defence yourself, dummy!")
		return
	}

	// Get actual usernames for each UUID in onlineList

	var userOnlineList []string

M engine/tracking.go => engine/tracking.go +1 -1
@@ 215,7 215,7 @@ func SendStatusNotifications(uuid string, newStatus bool) error {

// TODO add error checking
func GetCachedPlayerStatus(uuid string) bool {
	var result bool
	var result = false 

	Iron.View(func(tx *bolt.Tx) error {
		b := tx.Bucket([]byte("tracked"))