Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        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();
            }
        }
Ejemplo n.º 3
0
        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.");
            }
        }
Ejemplo n.º 4
0
 /// <inheritdoc />
 public abstract Task Handle(DiscloseUser user, DiscloseServer server);