Classes

The following classes are available globally.

  • The backing class for DiscordLazyDictionary’s lazy values.

    See more

    Declaration

    Swift

    public class DiscordLazyValue<V>
  • The shard manager is responsible for a client’s shards. It decides when a client is considered connected. Connected being when all shards have recieved a ready event and are receiving events from the gateway. It also decides when a client has fully disconnected. Disconnected being when all shards have closed.

    See more

    Declaration

    Swift

    open class DiscordShardManager : DiscordShardDelegate, Lockable
  • The DiscordRateLimiter is in charge of making sure we don’t flood Discord with requests. It keeps a dictionary of DiscordRateLimitKeys and DiscordRateLimits. All requests to the REST api should be routed through the DiscordRateLimiter. If a DiscordRateLimit determines we have hit a limit, we add the request and its callback to the limit’s queue. After that it is up to the DiscordRateLimit to decide when to make the request. TODO handle the global rate limit

    See more

    Declaration

    Swift

    public final class DiscordRateLimiter : DiscordRateLimiterSpec
  • DiscordBufferedVoiceDataSource is generic data source around a pipe. The only condition is that it expects raw PCM 16-bit-le out of the pipe.

    It buffers ~5 minutes worth of voice data

    Usage:

    func client(_ client: DiscordClient, needsDataSourceForEngine engine: DiscordVoiceEngine) throws -> DiscordVoiceDataSource {
        return DiscordBufferedVoiceDataSource(opusEncoder: try DiscordOpusEncoder(bitrate: 128_000))
        // Somewhere down the line we setup some middleware which will use this source.
    }
    
    See more

    Declaration

    Swift

    open class DiscordBufferedVoiceDataSource : DiscordVoiceDataSource
  • A subclass of DiscordBufferedVoiceDataSource that buffers a raw audio file.

    Usage:

    func client(_ client: DiscordClient, needsDataSourceForEngine engine: DiscordVoiceEngine) throws -> DiscordVoiceDataSource {
        return try DiscordVoiceFileDataSource(opusEncoder: try DiscordOpusEncoder(bitrate: 128_000),
                                              file: URL(string: "file://output.raw")!)
    }
    
    See more

    Declaration

    Swift

    open class DiscordVoiceFileDataSource : DiscordBufferedVoiceDataSource
  • A voice source that returns Opus silence. Only sends 5 packets of silence and is then spent.

    See more

    Declaration

    Swift

    public final class DiscordSilenceVoiceDataSource : DiscordVoiceDataSource
  • A wrapper class for a process that spits out audio data that can be fed into an FFmpeg process that is then sent to the engine.

    See more

    Declaration

    Swift

    public class DiscordEncoderMiddleware
  • Class that decodes Opus voice data into raw PCM data for a VoiceEngine. It can decode multiple streams. Decoding is not thread safe, and it is up to the caller to decode safely.

    See more

    Declaration

    Swift

    open class DiscordVoiceSessionDecoder
  • A subclass of DiscordEngine that provides functionality for voice communication.

    Discord uses encrypted OPUS encoded voice packets. The engine is responsible for encyrptingdecrypting voice packets that are sent and received.

    See more

    Declaration

    Swift

    public final class DiscordVoiceEngine : DiscordVoiceEngineSpec