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

This commit is contained in:
Cenk Ergen
2022-04-30 04:37:22 +03:00
committed by GitHub
parent a8f607553b
commit 0d74c5cc62

View File

@@ -834,12 +834,17 @@ namespace Discord.Interactions
if (!searchResult.Command.SupportsWildCards || context is not IRouteMatchContainer matchContainer) if (!searchResult.Command.SupportsWildCards || context is not IRouteMatchContainer matchContainer)
return; return;
if (searchResult.RegexCaptureGroups?.Length > 0)
{
var matches = new RouteSegmentMatch[searchResult.RegexCaptureGroups.Length]; var matches = new RouteSegmentMatch[searchResult.RegexCaptureGroups.Length];
for (var i = 0; i < searchResult.RegexCaptureGroups.Length; i++) for (var i = 0; i < searchResult.RegexCaptureGroups.Length; i++)
matches[i] = new RouteSegmentMatch(searchResult.RegexCaptureGroups[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) internal TypeConverter GetTypeConverter(Type type, IServiceProvider services = null)
=> _typeConverterMap.Get(type, services); => _typeConverterMap.Get(type, services);