internal Shard(DiscordSharder sharder, DiscordClientGateway gateway) { _sharder = sharder; _gateway = gateway; Id = gateway.ShardId.Value; Guilds = new ReadOnlyValuePredicateArgumentDictionary <Snowflake, CachedGuild, Shard>( _sharder.Guilds, (x, shard) => shard._sharder.GetShardId(x.Id) == shard.Id, this); }
public IdentifyLock(DiscordClientGateway gateway) { _gateway = gateway; // TODO: tie this to application id? // TODO: persistence? _semaphore = _semaphores.GetOrAdd(gateway.Client.Token, _ => new SemaphoreSlim(1, 1)); }
internal Task InternalSetPresenceAsync(DiscordClientGateway gateway, UserStatus?status = default, Optional <LocalActivity> activity = default) { ThrowIfDisposed(); if (!status.HasValue && !activity.HasValue) { return(Task.CompletedTask); } if (status.HasValue) { gateway.SetStatus(status.Value); } if (activity.HasValue) { gateway.SetActivity(activity.Value); } return(gateway.SendPresenceAsync()); }