Browse Source

fix: Implement fix for Custom Id Segments NRE (#2274)

tags/3.6.1
Cenk Ergen GitHub 3 years ago
parent
commit
0d74c5cc62
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 4 deletions
  1. +9
    -4
      src/Discord.Net.Interactions/InteractionService.cs

+ 9
- 4
src/Discord.Net.Interactions/InteractionService.cs View File

@@ -834,11 +834,16 @@ namespace Discord.Interactions
if (!searchResult.Command.SupportsWildCards || context is not IRouteMatchContainer matchContainer)
return;

var matches = new RouteSegmentMatch[searchResult.RegexCaptureGroups.Length];
for (var i = 0; i < searchResult.RegexCaptureGroups.Length; i++)
matches[i] = new RouteSegmentMatch(searchResult.RegexCaptureGroups[i]);
if (searchResult.RegexCaptureGroups?.Length > 0)
{
var matches = new RouteSegmentMatch[searchResult.RegexCaptureGroups.Length];
for (var i = 0; i < searchResult.RegexCaptureGroups.Length; i++)
matches[i] = new RouteSegmentMatch(searchResult.RegexCaptureGroups[i]);

matchContainer.SetSegmentMatches(matches);
matchContainer.SetSegmentMatches(matches);
}
else
matchContainer.SetSegmentMatches(Array.Empty<RouteSegmentMatch>());
}

internal TypeConverter GetTypeConverter(Type type, IServiceProvider services = null)


Loading…
Cancel
Save