internal DiscloseUser(IServerUser user, DiscloseServer server) { DiscordUser = user; IEnumerable <DiscloseRole> roles = server.GetRoles(); Roles = user.RoleIds.Select(ur => roles.FirstOrDefault(r => ur == r.Id)).Where(r => r != null).ToList().AsReadOnly(); }
public async Task SetServerDataAsync <TData>(DiscloseServer server, string key, TData data) { SemaphoreSlim semaphore = _locks.GetOrAdd(server.Id, new SemaphoreSlim(1)); await semaphore.WaitAsync(); try { await DataStore.SetServerDataAsync(server, key, data); } finally { semaphore.Release(); } }
private void OnServerAvailable(object sender, ServerEventArgs e) { DiscloseServer server = new DiscloseServer(e.Server); if (_server?.Id == e.Server.Id) { return; } if (_server == null && (_options.ServerFilter == null || _options.ServerFilter(server))) { _server = server; } else if (_server != null && (_options.ServerFilter == null || _options.ServerFilter(server))) { throw new InvalidOperationException("More than 1 server matched your filter, or no filter was supplied, make your filter more specific."); } }
/// <inheritdoc /> public abstract Task Handle(DiscloseUser user, DiscloseServer server);