better autocomplete
This commit is contained in:
14
skill.go
14
skill.go
@@ -3,8 +3,11 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"git.sunturtle.xyz/zephyr/horse/horse"
|
||||
"git.sunturtle.xyz/zephyr/horse/horse/global"
|
||||
"git.sunturtle.xyz/zephyr/horsebot/autocomplete"
|
||||
"github.com/disgoorg/disgo/discord"
|
||||
)
|
||||
|
||||
@@ -115,6 +118,11 @@ func isDebuff(s horse.Skill) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// TODO(zeph): autocomplete
|
||||
// if we want to backgroundify construction of an autocomplete map,
|
||||
// use sync.OnceValue and launch a goroutine in main to get the value and discard it
|
||||
var skillGlobalAuto = sync.OnceValue(func() *autocomplete.Set {
|
||||
var set autocomplete.Set
|
||||
for _, id := range global.OrderedSkills {
|
||||
s := global.AllSkills[id]
|
||||
set.Add(s.Name, s.Name)
|
||||
}
|
||||
return &set
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user