Classes
The following classes are available globally.
-
Represents an audit log.
See moreDeclaration
Swift
public class DiscordAuditLog
-
The base class for SwiftDiscord. Most interaction with Discord will be done through this class.
See
DiscordEndpointConsumer
for methods dealing with sending to Discord.Creating a client:
self.client = DiscordClient(token: "Bot mysupersecretbottoken", configuration: [.log(.info)])
Once a client is created, you need to set its delegate so that you can start receiving events:
self.client.delegate = self
See
See moreDiscordClientDelegate
for a list of delegate methods that can be implemented.Declaration
Swift
open class DiscordClient : DiscordClientSpec, DiscordDispatchEventHandler, DiscordEndpointConsumer
-
The backing class for DiscordLazyDictionary’s lazy values.
See moreDeclaration
Swift
public class DiscordLazyValue<V>
-
The base class for Discord WebSocket communications.
See moreDeclaration
Swift
open class DiscordEngine : DiscordEngineSpec
-
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 moreDeclaration
Swift
open class DiscordShardManager : DiscordShardDelegate, Lockable
-
Represents a Guild.
See moreDeclaration
Swift
public final class DiscordGuild : DiscordClientHolder, CustomStringConvertible
-
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 moreDeclaration
Swift
public final class DiscordRateLimiter : DiscordRateLimiterSpec
-
An Opus encoder.
Takes raw PCM 16-bit-lesample data and returns Opus encoded voice packets.
See moreDeclaration
Swift
open class DiscordOpusEncoder : DiscordOpusCodeable
-
Declaration
Swift
open class DiscordOpusDecoder : DiscordOpusCodeable
-
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:
See morefunc 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. }
Declaration
Swift
open class DiscordBufferedVoiceDataSource : DiscordVoiceDataSource
-
A subclass of
DiscordBufferedVoiceDataSource
that buffers a raw audio file.Usage:
See morefunc client(_ client: DiscordClient, needsDataSourceForEngine engine: DiscordVoiceEngine) throws -> DiscordVoiceDataSource { return try DiscordVoiceFileDataSource(opusEncoder: try DiscordOpusEncoder(bitrate: 128_000), file: URL(string: "file://output.raw")!) }
Declaration
Swift
open class DiscordVoiceFileDataSource : DiscordBufferedVoiceDataSource
-
A voice source that returns Opus silence. Only sends 5 packets of silence and is then spent.
See moreDeclaration
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 moreDeclaration
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 moreDeclaration
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 moreDeclaration
Swift
public final class DiscordVoiceEngine : DiscordVoiceEngineSpec
-
A manager for voice engines.
See moreDeclaration
Swift
open class DiscordVoiceManager : DiscordVoiceEngineDelegate, Lockable