From fb837235a7424842038f97242b84ecc7c413146d Mon Sep 17 00:00:00 2001 From: Kwoth Date: Mon, 13 Feb 2017 10:28:49 +0100 Subject: [PATCH] a bit faster OwnerOnly checking --- src/NadekoBot/Services/IBotCredentials.cs | 4 +++- src/NadekoBot/Services/Impl/BotCredentials.cs | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/NadekoBot/Services/IBotCredentials.cs b/src/NadekoBot/Services/IBotCredentials.cs index 88bc5986..a03c6db3 100644 --- a/src/NadekoBot/Services/IBotCredentials.cs +++ b/src/NadekoBot/Services/IBotCredentials.cs @@ -1,4 +1,6 @@ using Discord; +using System.Collections.Generic; +using System.Collections.Immutable; namespace NadekoBot.Services { @@ -9,7 +11,7 @@ namespace NadekoBot.Services string Token { get; } string GoogleApiKey { get; } - ulong[] OwnerIds { get; } + ImmutableHashSet OwnerIds { get; } string MashapeKey { get; } string LoLApiKey { get; } diff --git a/src/NadekoBot/Services/Impl/BotCredentials.cs b/src/NadekoBot/Services/Impl/BotCredentials.cs index 47906e8c..56851762 100644 --- a/src/NadekoBot/Services/Impl/BotCredentials.cs +++ b/src/NadekoBot/Services/Impl/BotCredentials.cs @@ -5,6 +5,8 @@ using Discord; using System.Linq; using NLog; using Microsoft.Extensions.Configuration; +using System.Collections.Generic; +using System.Collections.Immutable; namespace NadekoBot.Services.Impl { @@ -21,7 +23,7 @@ namespace NadekoBot.Services.Impl public string Token { get; } - public ulong[] OwnerIds { get; } + public ImmutableHashSet OwnerIds { get; } public string LoLApiKey { get; } public string OsuApiKey { get; } @@ -61,7 +63,7 @@ namespace NadekoBot.Services.Impl Token = data[nameof(Token)]; if (string.IsNullOrWhiteSpace(Token)) throw new ArgumentNullException(nameof(Token), "Token is missing from credentials.json or Environment varibles."); - OwnerIds = data.GetSection("OwnerIds").GetChildren().Select(c => ulong.Parse(c.Value)).ToArray(); + OwnerIds = data.GetSection("OwnerIds").GetChildren().Select(c => ulong.Parse(c.Value)).ToImmutableHashSet(); LoLApiKey = data[nameof(LoLApiKey)]; GoogleApiKey = data[nameof(GoogleApiKey)]; MashapeKey = data[nameof(MashapeKey)];