Compare commits
17 Commits
5909c36582
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 0fc68e9bd8 | |||
| 50b98be6d3 | |||
| 30d4eeea40 | |||
| f0c5e19870 | |||
| c0abf72041 | |||
| 780002b35f | |||
| 1dae50a918 | |||
| f4f563c530 | |||
| ff20bbef2c | |||
| c5c733d14c | |||
| 2517d0cb37 | |||
| f3698f0fc6 | |||
| 950662e0b9 | |||
| 67ad8488a5 | |||
| 9cc0e21dcb | |||
| a8ad64f5a4 | |||
| 667144d0ab |
@@ -7,4 +7,4 @@ Production instance is named Zenno Rob Roy, because she has read all about Umamu
|
|||||||
## Running
|
## Running
|
||||||
|
|
||||||
The bot always uses the Gateway API.
|
The bot always uses the Gateway API.
|
||||||
If the `-http` argument is provided, it will also use the HTTP API, and `-token` must also be provided.
|
If the `-http` argument is provided, it will also use the HTTP API, and `-key` must also be provided.
|
||||||
|
|||||||
56
autocomplete/autocomplete.go
Normal file
56
autocomplete/autocomplete.go
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
package autocomplete
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"cmp"
|
||||||
|
"slices"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/junegunn/fzf/src/algo"
|
||||||
|
"github.com/junegunn/fzf/src/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Set is an autocomplete set.
|
||||||
|
type Set[V any] struct {
|
||||||
|
keys []util.Chars
|
||||||
|
vals []V
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add associates a value with a key in the autocomplete set.
|
||||||
|
// The behavior is undefined if the key already has a value.
|
||||||
|
func (s *Set[V]) Add(key string, val V) {
|
||||||
|
k := util.ToChars([]byte(key))
|
||||||
|
i, _ := slices.BinarySearchFunc(s.keys, k, func(a, b util.Chars) int {
|
||||||
|
return bytes.Compare(a.Bytes(), b.Bytes())
|
||||||
|
})
|
||||||
|
s.keys = slices.Insert(s.keys, i, k)
|
||||||
|
s.vals = slices.Insert(s.vals, i, val)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find appends to r all values in the set with keys that key matches.
|
||||||
|
func (s *Set[V]) Find(r []V, key string) []V {
|
||||||
|
initFzf()
|
||||||
|
var (
|
||||||
|
p = []rune(key)
|
||||||
|
|
||||||
|
got []V
|
||||||
|
t []algo.Result
|
||||||
|
slab util.Slab
|
||||||
|
)
|
||||||
|
for i := range s.keys {
|
||||||
|
res, _ := algo.FuzzyMatchV2(false, true, true, &s.keys[i], p, false, &slab)
|
||||||
|
if res.Score <= 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
j, _ := slices.BinarySearchFunc(t, res, func(a, b algo.Result) int { return -cmp.Compare(a.Score, b.Score) })
|
||||||
|
// Insert after all other matches with the same score for stability.
|
||||||
|
for j < len(t) && t[j].Score == res.Score {
|
||||||
|
j++
|
||||||
|
}
|
||||||
|
t = slices.Insert(t, j, res)
|
||||||
|
got = slices.Insert(got, j, s.vals[i])
|
||||||
|
}
|
||||||
|
return append(r, got...)
|
||||||
|
}
|
||||||
|
|
||||||
|
var initFzf = sync.OnceFunc(func() { algo.Init("default") })
|
||||||
70
autocomplete/autocomplete_test.go
Normal file
70
autocomplete/autocomplete_test.go
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
package autocomplete_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"slices"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"git.sunturtle.xyz/zephyr/horsebot/autocomplete"
|
||||||
|
)
|
||||||
|
|
||||||
|
func these(s ...string) []string { return s }
|
||||||
|
|
||||||
|
func TestAutocomplete(t *testing.T) {
|
||||||
|
cases := []struct {
|
||||||
|
name string
|
||||||
|
add []string
|
||||||
|
search string
|
||||||
|
want []string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "empty",
|
||||||
|
add: nil,
|
||||||
|
search: "",
|
||||||
|
want: nil,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "exact",
|
||||||
|
add: these("bocchi"),
|
||||||
|
search: "bocchi",
|
||||||
|
want: these("bocchi"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "extra",
|
||||||
|
add: these("bocchi", "ryo", "nijika", "kita"),
|
||||||
|
search: "bocchi",
|
||||||
|
want: these("bocchi"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "short",
|
||||||
|
add: these("bocchi", "ryo", "nijika", "kita"),
|
||||||
|
search: "o",
|
||||||
|
want: these("bocchi", "ryo"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "unrelated",
|
||||||
|
add: these("bocchi", "ryo", "nijika", "kita"),
|
||||||
|
search: "x",
|
||||||
|
want: nil,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "map",
|
||||||
|
add: these("Corazón ☆ Ardiente"),
|
||||||
|
search: "corazo",
|
||||||
|
want: these("Corazón ☆ Ardiente"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, c := range cases {
|
||||||
|
t.Run(c.name, func(t *testing.T) {
|
||||||
|
var set autocomplete.Set[string]
|
||||||
|
for _, s := range c.add {
|
||||||
|
set.Add(s, s)
|
||||||
|
}
|
||||||
|
got := set.Find(nil, c.search)
|
||||||
|
slices.Sort(c.want)
|
||||||
|
slices.Sort(got)
|
||||||
|
if !slices.Equal(c.want, got) {
|
||||||
|
t.Errorf("wrong results: want %q, got %q", c.want, got)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
7
go.mod
7
go.mod
@@ -1,10 +1,11 @@
|
|||||||
module git.sunturtle.xyz/zephyr/horsebot
|
module git.sunturtle.xyz/zephyr/horsebot
|
||||||
|
|
||||||
go 1.25.6
|
go 1.25.5
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.sunturtle.xyz/zephyr/horse v0.0.0-20260117063336-b22b77c53578
|
git.sunturtle.xyz/zephyr/horse v0.0.0-20260210125822-b55e1bc200a1
|
||||||
github.com/disgoorg/disgo v0.19.0-rc.15
|
github.com/disgoorg/disgo v0.19.0-rc.15
|
||||||
|
github.com/junegunn/fzf v0.67.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
@@ -13,6 +14,8 @@ require (
|
|||||||
github.com/disgoorg/snowflake/v2 v2.0.3 // indirect
|
github.com/disgoorg/snowflake/v2 v2.0.3 // indirect
|
||||||
github.com/gorilla/websocket v1.5.3 // indirect
|
github.com/gorilla/websocket v1.5.3 // indirect
|
||||||
github.com/klauspost/compress v1.18.2 // indirect
|
github.com/klauspost/compress v1.18.2 // indirect
|
||||||
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
|
github.com/rivo/uniseg v0.4.7 // indirect
|
||||||
github.com/sasha-s/go-csync v0.0.0-20240107134140-fcbab37b09ad // indirect
|
github.com/sasha-s/go-csync v0.0.0-20240107134140-fcbab37b09ad // indirect
|
||||||
golang.org/x/crypto v0.46.0 // indirect
|
golang.org/x/crypto v0.46.0 // indirect
|
||||||
golang.org/x/sys v0.39.0 // indirect
|
golang.org/x/sys v0.39.0 // indirect
|
||||||
|
|||||||
11
go.sum
11
go.sum
@@ -1,5 +1,5 @@
|
|||||||
git.sunturtle.xyz/zephyr/horse v0.0.0-20260117063336-b22b77c53578 h1:FI54vRfCtesXfcwi4oHo86nB/x/2T+ZrZvyFVKiQSYA=
|
git.sunturtle.xyz/zephyr/horse v0.0.0-20260210125822-b55e1bc200a1 h1:nIk5Mis384wx/ndMa/3zSr1omkWK8rg4I/Z46BCAIe8=
|
||||||
git.sunturtle.xyz/zephyr/horse v0.0.0-20260117063336-b22b77c53578/go.mod h1:qGXO/93EfCOI1oGSLqrRkPDF/EAdsgLNZJjRKx+i4Lk=
|
git.sunturtle.xyz/zephyr/horse v0.0.0-20260210125822-b55e1bc200a1/go.mod h1:qGXO/93EfCOI1oGSLqrRkPDF/EAdsgLNZJjRKx+i4Lk=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/disgoorg/disgo v0.19.0-rc.15 h1:x0NsV2gcbdjwuztsg2wYXw76p1Cpc8f6ByDrkPcfQtU=
|
github.com/disgoorg/disgo v0.19.0-rc.15 h1:x0NsV2gcbdjwuztsg2wYXw76p1Cpc8f6ByDrkPcfQtU=
|
||||||
@@ -12,16 +12,23 @@ github.com/disgoorg/snowflake/v2 v2.0.3 h1:3B+PpFjr7j4ad7oeJu4RlQ+nYOTadsKapJIzg
|
|||||||
github.com/disgoorg/snowflake/v2 v2.0.3/go.mod h1:W6r7NUA7DwfZLwr00km6G4UnZ0zcoLBRufhkFWgAc4c=
|
github.com/disgoorg/snowflake/v2 v2.0.3/go.mod h1:W6r7NUA7DwfZLwr00km6G4UnZ0zcoLBRufhkFWgAc4c=
|
||||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
|
github.com/junegunn/fzf v0.67.0 h1:naiOdIkV5/ZCfHgKQIV/f5YDWowl95G6yyOQqW8FeSo=
|
||||||
|
github.com/junegunn/fzf v0.67.0/go.mod h1:xlXX2/rmsccKQUnr9QOXPDi5DyV9cM0UjKy/huScBeE=
|
||||||
github.com/klauspost/compress v1.18.2 h1:iiPHWW0YrcFgpBYhsA6D1+fqHssJscY/Tm/y2Uqnapk=
|
github.com/klauspost/compress v1.18.2 h1:iiPHWW0YrcFgpBYhsA6D1+fqHssJscY/Tm/y2Uqnapk=
|
||||||
github.com/klauspost/compress v1.18.2/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4=
|
github.com/klauspost/compress v1.18.2/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4=
|
||||||
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||||
|
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||||
github.com/sasha-s/go-csync v0.0.0-20240107134140-fcbab37b09ad h1:qIQkSlF5vAUHxEmTbaqt1hkJ/t6skqEGYiMag343ucI=
|
github.com/sasha-s/go-csync v0.0.0-20240107134140-fcbab37b09ad h1:qIQkSlF5vAUHxEmTbaqt1hkJ/t6skqEGYiMag343ucI=
|
||||||
github.com/sasha-s/go-csync v0.0.0-20240107134140-fcbab37b09ad/go.mod h1:/pA7k3zsXKdjjAiUhB5CjuKib9KJGCaLvZwtxGC8U0s=
|
github.com/sasha-s/go-csync v0.0.0-20240107134140-fcbab37b09ad/go.mod h1:/pA7k3zsXKdjjAiUhB5CjuKib9KJGCaLvZwtxGC8U0s=
|
||||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU=
|
golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU=
|
||||||
golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0=
|
golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0=
|
||||||
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
|
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
|
||||||
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
|||||||
36
main.go
36
main.go
@@ -9,7 +9,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.sunturtle.xyz/zephyr/horse/horse"
|
"git.sunturtle.xyz/zephyr/horse/horse"
|
||||||
@@ -85,12 +84,7 @@ func main() {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
slog.Info("connect",
|
slog.Info("connect", slog.String("disgo", disgo.Version))
|
||||||
slog.String("disgo", disgo.Version),
|
|
||||||
slog.Bool("http", addr != ""),
|
|
||||||
slog.String("address", addr),
|
|
||||||
slog.String("route", route),
|
|
||||||
)
|
|
||||||
client, err := disgo.New(string(token), opts...)
|
client, err := disgo.New(string(token), opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("building bot", slog.Any("err", err))
|
slog.Error("building bot", slog.Any("err", err))
|
||||||
@@ -102,11 +96,19 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := client.OpenGateway(ctx); err != nil {
|
if addr != "" {
|
||||||
slog.Error("opening gateway", slog.Any("err", err))
|
slog.Info("start HTTP server", slog.String("address", addr), slog.String("route", route))
|
||||||
|
if err := client.OpenHTTPServer(); err != nil {
|
||||||
|
slog.Error("starting HTTP server", slog.Any("err", err))
|
||||||
stop()
|
stop()
|
||||||
}
|
}
|
||||||
slog.Info("running")
|
}
|
||||||
|
slog.Info("start gateway")
|
||||||
|
if err := client.OpenGateway(ctx); err != nil {
|
||||||
|
slog.Error("starting gateway", slog.Any("err", err))
|
||||||
|
stop()
|
||||||
|
}
|
||||||
|
slog.Info("ready")
|
||||||
<-ctx.Done()
|
<-ctx.Done()
|
||||||
stop()
|
stop()
|
||||||
|
|
||||||
@@ -159,17 +161,9 @@ func skillHandler(data discord.SlashCommandInteractionData, e *handler.CommandEv
|
|||||||
}
|
}
|
||||||
|
|
||||||
func skillAutocomplete(e *handler.AutocompleteEvent) error {
|
func skillAutocomplete(e *handler.AutocompleteEvent) error {
|
||||||
q := strings.ToLower(e.Data.String("query"))
|
q := e.Data.String("query")
|
||||||
r := make([]discord.AutocompleteChoice, 0, 25)
|
opts := skillGlobalAuto().Find(nil, q)
|
||||||
for k, _ := range global.SkillNameToID {
|
return e.AutocompleteResult(opts[:min(len(opts), 25)])
|
||||||
if strings.HasPrefix(strings.ToLower(k), q) {
|
|
||||||
r = append(r, discord.AutocompleteChoiceString{Name: k, Value: k})
|
|
||||||
if len(r) == cap(r) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return e.AutocompleteResult(r)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func skillButton(data discord.ButtonInteractionData, e *handler.ComponentEvent) error {
|
func skillButton(data discord.ButtonInteractionData, e *handler.ComponentEvent) error {
|
||||||
|
|||||||
39
skill.go
39
skill.go
@@ -3,8 +3,11 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"git.sunturtle.xyz/zephyr/horse/horse"
|
"git.sunturtle.xyz/zephyr/horse/horse"
|
||||||
|
"git.sunturtle.xyz/zephyr/horse/horse/global"
|
||||||
|
"git.sunturtle.xyz/zephyr/horsebot/autocomplete"
|
||||||
"github.com/disgoorg/disgo/discord"
|
"github.com/disgoorg/disgo/discord"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -15,13 +18,25 @@ func RenderSkill(id horse.SkillID, all map[horse.SkillID]horse.Skill, groups map
|
|||||||
}
|
}
|
||||||
|
|
||||||
thumburl := fmt.Sprintf("https://gametora.com/images/umamusume/skill_icons/utx_ico_skill_%d.png", s.IconID)
|
thumburl := fmt.Sprintf("https://gametora.com/images/umamusume/skill_icons/utx_ico_skill_%d.png", s.IconID)
|
||||||
r := discord.NewContainer(discord.NewSection(discord.NewTextDisplayf("## %s\n%s", s.Name, s.Description)).WithAccessory(discord.NewThumbnail(thumburl)))
|
top := "## " + s.Name
|
||||||
|
if s.UniqueOwner != "" {
|
||||||
|
top += "\n-# " + s.UniqueOwner
|
||||||
|
}
|
||||||
|
r := discord.NewContainer(
|
||||||
|
discord.NewSection(
|
||||||
|
discord.NewTextDisplay(top),
|
||||||
|
discord.NewTextDisplay(s.Description),
|
||||||
|
).WithAccessory(discord.NewThumbnail(thumburl)),
|
||||||
|
)
|
||||||
var skilltype string
|
var skilltype string
|
||||||
switch {
|
switch {
|
||||||
case s.Rarity == 3, s.Rarity == 4, s.Rarity == 5:
|
case s.Rarity == 3, s.Rarity == 4, s.Rarity == 5:
|
||||||
// unique of various star levels
|
// unique of various star levels
|
||||||
r.AccentColor = 0xaca4d4
|
r.AccentColor = 0xaca4d4
|
||||||
skilltype = "Unique Skill"
|
skilltype = "Unique Skill"
|
||||||
|
case s.UniqueOwner != "":
|
||||||
|
r.AccentColor = 0xcccccc
|
||||||
|
skilltype = "Inherited Unique"
|
||||||
case s.Rarity == 2:
|
case s.Rarity == 2:
|
||||||
// rare (gold)
|
// rare (gold)
|
||||||
r.AccentColor = 0xd7c25b
|
r.AccentColor = 0xd7c25b
|
||||||
@@ -73,7 +88,9 @@ func RenderSkill(id horse.SkillID, all map[horse.SkillID]horse.Skill, groups map
|
|||||||
text = append(text, t)
|
text = append(text, t)
|
||||||
r.Components = append(r.Components, discord.NewTextDisplay(strings.Join(text, "\n")))
|
r.Components = append(r.Components, discord.NewTextDisplay(strings.Join(text, "\n")))
|
||||||
}
|
}
|
||||||
r.Components = append(r.Components, discord.NewSmallSeparator(), discord.NewTextDisplayf("%s ・ SP cost %d ・ Grade value %d", skilltype, s.SPCost, s.GradeValue))
|
|
||||||
|
l := discord.NewTextDisplayf("%s ・ SP cost %d ・ Grade value %d ・ [Conditions on GameTora](https://gametora.com/umamusume/skill-condition-viewer?skill=%d)", skilltype, s.SPCost, s.GradeValue, s.ID)
|
||||||
|
r.Components = append(r.Components, discord.NewSmallSeparator(), l)
|
||||||
rel := make([]horse.Skill, 0, 4)
|
rel := make([]horse.Skill, 0, 4)
|
||||||
for _, id := range groups[s.Group] {
|
for _, id := range groups[s.Group] {
|
||||||
if id != 0 {
|
if id != 0 {
|
||||||
@@ -113,6 +130,18 @@ func isDebuff(s horse.Skill) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(zeph): autocomplete
|
var skillGlobalAuto = sync.OnceValue(func() *autocomplete.Set[discord.AutocompleteChoice] {
|
||||||
// if we want to backgroundify construction of an autocomplete map,
|
var set autocomplete.Set[discord.AutocompleteChoice]
|
||||||
// use sync.OnceValue and launch a goroutine in main to get the value and discard it
|
for _, id := range global.OrderedSkills {
|
||||||
|
s := global.AllSkills[id]
|
||||||
|
set.Add(s.Name, discord.AutocompleteChoiceString{Name: s.Name, Value: s.Name})
|
||||||
|
if s.UniqueOwner != "" {
|
||||||
|
if s.Rarity >= 3 {
|
||||||
|
set.Add(s.UniqueOwner, discord.AutocompleteChoiceString{Name: "Unique: " + s.UniqueOwner, Value: s.Name})
|
||||||
|
} else {
|
||||||
|
set.Add(s.UniqueOwner, discord.AutocompleteChoiceString{Name: "Inherited unique: " + s.UniqueOwner, Value: s.Name})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &set
|
||||||
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user