Switched ids to use int64 rather than strings
This commit is contained in:
@@ -4,7 +4,7 @@ namespace Discord.Commands.Permissions.Userlist
|
||||
{
|
||||
public class BlacklistService : UserlistService
|
||||
{
|
||||
public BlacklistService(IEnumerable<string> initialList = null)
|
||||
public BlacklistService(IEnumerable<long> initialList = null)
|
||||
: base(initialList)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -7,18 +7,18 @@ namespace Discord.Commands.Permissions.Userlist
|
||||
{
|
||||
public class UserlistService : IService
|
||||
{
|
||||
protected readonly ConcurrentDictionary<string, bool> _userList;
|
||||
protected readonly ConcurrentDictionary<long, bool> _userList;
|
||||
private DiscordClient _client;
|
||||
|
||||
public DiscordClient Client => _client;
|
||||
public IEnumerable<string> UserIds => _userList.Select(x => x.Key);
|
||||
public IEnumerable<long> UserIds => _userList.Select(x => x.Key);
|
||||
|
||||
public UserlistService(IEnumerable<string> initialList = null)
|
||||
public UserlistService(IEnumerable<long> initialList = null)
|
||||
{
|
||||
if (initialList != null)
|
||||
_userList = new ConcurrentDictionary<string, bool>(initialList.Select(x => new KeyValuePair<string, bool>(x, true)));
|
||||
_userList = new ConcurrentDictionary<long, bool>(initialList.Select(x => new KeyValuePair<long, bool>(x, true)));
|
||||
else
|
||||
_userList = new ConcurrentDictionary<string, bool>();
|
||||
_userList = new ConcurrentDictionary<long, bool>();
|
||||
}
|
||||
|
||||
public void Add(User user)
|
||||
@@ -26,9 +26,9 @@ namespace Discord.Commands.Permissions.Userlist
|
||||
if (user == null) throw new ArgumentNullException(nameof(user));
|
||||
_userList[user.Id] = true;
|
||||
}
|
||||
public void Add(string userId)
|
||||
public void Add(long userId)
|
||||
{
|
||||
if (userId == null) throw new ArgumentNullException(nameof(userId));
|
||||
if (userId <= 0) throw new ArgumentOutOfRangeException(nameof(userId));
|
||||
_userList[userId] = true;
|
||||
}
|
||||
public bool Remove(User user)
|
||||
@@ -37,9 +37,9 @@ namespace Discord.Commands.Permissions.Userlist
|
||||
bool ignored;
|
||||
return _userList.TryRemove(user.Id, out ignored);
|
||||
}
|
||||
public bool Remove(string userId)
|
||||
public bool Remove(long userId)
|
||||
{
|
||||
if (userId == null) throw new ArgumentNullException(nameof(userId));
|
||||
if (userId <= 0) throw new ArgumentOutOfRangeException(nameof(userId));
|
||||
bool ignored;
|
||||
return _userList.TryRemove(userId, out ignored);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Discord.Commands.Permissions.Userlist
|
||||
{
|
||||
public class WhitelistService : UserlistService
|
||||
{
|
||||
public WhitelistService(IEnumerable<string> initialList = null)
|
||||
public WhitelistService(IEnumerable<long> initialList = null)
|
||||
: base(initialList)
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user