mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
Using new .Chunk and .DistinctBy Linq Extensions
This commit is contained in:
@@ -39,7 +39,7 @@ public partial class Utility
|
||||
{
|
||||
var selection = typeof(Math).GetTypeInfo()
|
||||
.GetMethods()
|
||||
.Distinct(new MethodInfoEqualityComparer())
|
||||
.DistinctBy(x => x.Name)
|
||||
.Select(x => x.Name)
|
||||
.Except(new[]
|
||||
{
|
||||
@@ -51,11 +51,4 @@ public partial class Utility
|
||||
await SendConfirmAsync(GetText(strs.calcops(Prefix)), string.Join(", ", selection));
|
||||
}
|
||||
}
|
||||
|
||||
private class MethodInfoEqualityComparer : IEqualityComparer<MethodInfo>
|
||||
{
|
||||
public bool Equals(MethodInfo x, MethodInfo y) => x.Name == y.Name;
|
||||
|
||||
public int GetHashCode(MethodInfo obj) => obj.Name.GetHashCode(StringComparison.InvariantCulture);
|
||||
}
|
||||
}
|
@@ -30,7 +30,7 @@ public class CommandMapService : IInputTransformer, INService
|
||||
.ToDictionary(
|
||||
x => x.GuildId,
|
||||
x => new ConcurrentDictionary<string, string>(x.CommandAliases
|
||||
.Distinct(new CommandAliasEqualityComparer())
|
||||
.DistinctBy(ca => ca.Trigger)
|
||||
.ToDictionary(ca => ca.Trigger, ca => ca.Mapping))));
|
||||
|
||||
_db = db;
|
||||
@@ -96,11 +96,4 @@ public class CommandMapService : IInputTransformer, INService
|
||||
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
||||
public class CommandAliasEqualityComparer : IEqualityComparer<CommandAlias>
|
||||
{
|
||||
public bool Equals(CommandAlias x, CommandAlias y) => x.Trigger == y.Trigger;
|
||||
|
||||
public int GetHashCode(CommandAlias obj) => obj.Trigger.GetHashCode(StringComparison.InvariantCulture);
|
||||
}
|
Reference in New Issue
Block a user