Skip to content

Commit 676572d

Browse files
HandyS11claude
andcommitted
fix(3c-ii): filter autocomplete by typed input + pin wipe handler in reg test
Address final whole-branch review minors: ServerAutocompleteHandler now filters the guild's servers by the user's in-progress text (case-insensitive) before the 25-cap, so a server past the 25th alphabetically is reachable; CommandRegistrationTests now asserts the 'wipe' handler is registered (the count tripwire alone wouldn't catch a rename of the newly-surfaced /wipe). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 6394e9d commit 676572d

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

src/RustPlusBot.Features.Commands/Servers/ServerAutocompleteHandler.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@ public override async Task<AutocompletionResult> GenerateSuggestionsAsync(
2323
return AutocompletionResult.FromSuccess();
2424
}
2525

26+
var typed = autocompleteInteraction.Data.Current.Value as string;
2627
var scope = services.CreateAsyncScope();
2728
await using (scope.ConfigureAwait(false))
2829
{
2930
var servers = scope.ServiceProvider.GetRequiredService<IServerService>();
3031
var known = await servers.ListAsync(context.Guild.Id).ConfigureAwait(false);
3132
var results = known
33+
.Where(s => string.IsNullOrEmpty(typed) ||
34+
s.Name.Contains(typed, StringComparison.OrdinalIgnoreCase))
3235
.Take(25)
3336
.Select(s => new AutocompleteResult(s.Name, s.Id.ToString()));
3437
return AutocompletionResult.FromSuccess(results);

tests/RustPlusBot.Features.Commands.Tests/CommandRegistrationTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public void Dispatcher_and_handlers_resolve()
4848
Assert.Contains(handlers, h => h.Name == "mute");
4949
Assert.Contains(handlers, h => h.Name == "pop");
5050
Assert.Contains(handlers, h => h.Name == "time");
51+
Assert.Contains(handlers, h => h.Name == "wipe");
5152
Assert.Contains(handlers, h => h.Name == "online");
5253
Assert.Contains(handlers, h => h.Name == "offline");
5354
Assert.Contains(handlers, h => h.Name == "team");

0 commit comments

Comments
 (0)