Skip to content

Commit

Permalink
fix MapNameCompleter
Browse files Browse the repository at this point in the history
  • Loading branch information
ebiiim committed Dec 23, 2023
1 parent 2dd6dee commit 59795fb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Albion Onlineのギルド [Dog The Boston](https://twitter.com/DogTheBoston) 用
- 2023-12-24 v1.7.0
- 改善: `ルートナビ` `/route-clear` 時にバックアップを取得&マークは削除せずルートだけを削除するようにした
- 機能: `ルートナビ` `/route-mark` にユーザ名を追加(情報提供目的)
- 改善: `ルートナビ` 見た目の改良
- 修正: `ルートナビ` 細かい改良や修正
- 2023-12-19 v1.6.0
- 機能: `ルートナビ` 色指定とコメントを追加
- 改善: `ルートナビ` ルートが多いときに画像生成に失敗する問題(タイムアウト値を増やした)
Expand Down
6 changes: 4 additions & 2 deletions cmd/autocomplete/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ func main() {
if _, err := fmt.Scanln(&input); err != nil {
continue
}
fmt.Printf("suggestions: %v\n", c.GetSuggestions(input))
fmt.Println("suggestions:")
for _, s := range c.GetSuggestions(input) {
fmt.Printf("\t%s\n", s)
}
}

}
10 changes: 9 additions & 1 deletion pkg/handlers/autocomplete.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ func NewMapNameCompleter(lim int) *MapNameCompleter {
}

func (c *MapNameCompleter) GetSuggestions(input string) []string {
return c.t.Search(input, c.lim)
// NOTE: some maps (e.g. "Brecilien") are somehow not found by this method, so use SearchAll instead.
// return c.t.Search(input, c.lim)

r := c.t.SearchAll(input)
if len(r) > c.lim {
r = r[:c.lim]
}

return r
}

func (c *MapNameCompleter) GetChoices(input string) []*discordgo.ApplicationCommandOptionChoice {
Expand Down

0 comments on commit 59795fb

Please sign in to comment.