DiscordClientDelegate

public protocol DiscordClientDelegate : class

Declares that a type will be a delegate for a DiscordClient. After the client handles any events, the corresponding delegate method will be called.

  • client(_:didConnect:) Default implementation

    Called when the client connects to Discord.

    Default Implementation

    Default.

    Declaration

    Swift

    func client(_ client: DiscordClient, didConnect connected: Bool)

    Parameters

    client

    The client that is calling.

    didConnect

    Should always be true.

  • client(_:didDisconnectWithReason:) Default implementation

    Called when the client disconnects with discord.

    Default Implementation

    Default.

    Declaration

    Swift

    func client(_ client: DiscordClient, didDisconnectWithReason reason: String)

    Parameters

    client

    The client that is calling.

    didDisconnectWithReason

    The reason the client disconnected.

  • client(_:didCreateChannel:) Default implementation

    Called when the client creates a new channel.

    Default Implementation

    Default.

    Declaration

    Swift

    func client(_ client: DiscordClient, didCreateChannel channel: DiscordChannel)

    Parameters

    client

    The client that is calling.

    didCreateChannel

    The channel that was created.

  • client(_:didDeleteChannel:) Default implementation

    Called when the client deletes a channel.

    Default Implementation

    Default.

    Declaration

    Swift

    func client(_ client: DiscordClient, didDeleteChannel channel: DiscordChannel)

    Parameters

    client

    The client that is calling.

    didDeleteChannel

    The channel that was deleted.

  • client(_:didUpdateChannel:) Default implementation

    Called when the client updates a channel.

    Default Implementation

    Default.

    Declaration

    Swift

    func client(_ client: DiscordClient, didUpdateChannel channel: DiscordChannel)

    Parameters

    client

    The client that is calling.

    didUpdateChannel

    The channel that was updated.

  • client(_:didCreateGuild:) Default implementation

    Called when the client creates a new guild.

    Default Implementation

    Default.

    Declaration

    Swift

    func client(_ client: DiscordClient, didCreateGuild guild: DiscordGuild)

    Parameters

    client

    The client that is calling.

    didCreateGuild

    The guild that was created.

  • client(_:didDeleteGuild:) Default implementation

    Called when the client deletes a guild.

    Default Implementation

    Default.

    Declaration

    Swift

    func client(_ client: DiscordClient, didDeleteGuild guild: DiscordGuild)

    Parameters

    client

    The client that is calling.

    didDeleteGuild

    The guild that was deleted.

  • client(_:didUpdateGuild:) Default implementation

    Called when the client updates a guild.

    Default Implementation

    Default.

    Declaration

    Swift

    func client(_ client: DiscordClient, didUpdateGuild guild: DiscordGuild)

    Parameters

    client

    The client that is calling.

    didUpdateGuild

    The guild that was updated.

  • client(_:didAddGuildMember:) Default implementation

    Called when the client adds a new guild member.

    Default Implementation

    Default.

    Declaration

    Swift

    func client(_ client: DiscordClient, didAddGuildMember member: DiscordGuildMember)

    Parameters

    client

    The client that is calling.

    didAddGuildMember

    The guild member that was added.

  • client(_:didRemoveGuildMember:) Default implementation

    Called when the client removes a guild member.

    Default Implementation

    Default.

    Declaration

    Swift

    func client(_ client: DiscordClient, didRemoveGuildMember member: DiscordGuildMember)

    Parameters

    client

    The client that is calling.

    didRemoveGuildMember

    The guild member that was removed.

  • client(_:didUpdateGuildMember:) Default implementation

    Called when the client updates a guild member.

    Default Implementation

    Default.

    Declaration

    Swift

    func client(_ client: DiscordClient, didUpdateGuildMember member: DiscordGuildMember)

    Parameters

    client

    The client that is calling.

    didUpdateGuildMember

    The guild member that was updated.

  • client(_:didUpdateMessage:) Default implementation

    Called when the client receives a message update from Discord.

    Default Implementation

    Default.

    Declaration

    Swift

    func client(_ client: DiscordClient, didUpdateMessage message: DiscordMessage)

    Parameters

    client

    The client that is calling.

    didUpdateMessage

    The message that was received.

  • client(_:didCreateMessage:) Default implementation

    Called when the client receives a message from Discord.

    Default Implementation

    Default.

    Declaration

    Swift

    func client(_ client: DiscordClient, didCreateMessage message: DiscordMessage)

    Parameters

    client

    The client that is calling.

    didCreateMessage

    The message that was received.

  • client(_:didCreateRole:onGuild:) Default implementation

    Called when the client adds a new role.

    Default Implementation

    Default.

    Declaration

    Swift

    func client(_ client: DiscordClient, didCreateRole role: DiscordRole, onGuild guild: DiscordGuild)

    Parameters

    client

    The client that is calling.

    didCreateRole

    The role that was created.

    onGuild

    The guild the role was created on.

  • client(_:didDeleteRole:fromGuild:) Default implementation

    Called when the client deletes a role.

    Default Implementation

    Default.

    Declaration

    Swift

    func client(_ client: DiscordClient, didDeleteRole role: DiscordRole, fromGuild guild: DiscordGuild)

    Parameters

    client

    The client that is calling.

    didDeleteRole

    The role that was deleted.

    fromGuild

    The guild the role was deleted from.

  • client(_:didUpdateRole:onGuild:) Default implementation

    Called when the client updates a role.

    Default Implementation

    Default.

    Declaration

    Swift

    func client(_ client: DiscordClient, didUpdateRole role: DiscordRole, onGuild guild: DiscordGuild)

    Parameters

    client

    The client that is calling.

    didUpdateRole

    The role that was updated.

    onGuild

    The guild the role was updated on.

  • client(_:didReceivePresenceUpdate:) Default implementation

    Called when the client receives a message from Discord.

    Default Implementation

    Default.

    Declaration

    Swift

    func client(_ client: DiscordClient, didReceivePresenceUpdate presence: DiscordPresence)

    Parameters

    client

    The client that is calling.

    didReceivePresenceUpdate

    The presence that was received.

  • client(_:didReceiveReady:) Default implementation

    Called when the client receives a ready event.

    Default Implementation

    Default.

    Declaration

    Swift

    func client(_ client: DiscordClient, didReceiveReady readyData: [String: Any])

    Parameters

    client

    The client that is calling.

    didReceiveReady

    The presence that was received.

  • client(_:didReceiveVoiceStateUpdate:) Default implementation

    Called when the client receives a voice state update.

    Default Implementation

    Default.

    Declaration

    Swift

    func client(_ client: DiscordClient, didReceiveVoiceStateUpdate voiceState: DiscordVoiceState)

    Parameters

    client

    The client that is calling.

    didReceiveVoiceStateUpdate

    The voice state that was received.

  • Called when the client is ready to start sending voice data.

    Default Implementation

    Default.

    Declaration

    Swift

    func client(_ client: DiscordClient, isReadyToSendVoiceWithEngine engine: DiscordVoiceEngine)

    Parameters

    client

    The client that is calling.

    isReadyToSendVoiceWithEngine

    The encoder that will be used.

  • Called when the client receives opus voice data.

    Note This is called from a queue that is dedicated to voice data, not the handleQueue.

    Default Implementation

    Default.

    Declaration

    Swift

    func client(_ client: DiscordClient, didReceiveOpusVoiceData voiceData: DiscordOpusVoiceData,

    Parameters

    client

    The client that is calling.

    didReceiveOpusVoiceData

    The voice data that was received.

    fromEngine

    The voice engine that received the data.

  • Called when the client receives raw voice data.

    Note This is called from a queue that is dedicated to voice data, not the handleQueue.

    Default Implementation

    Default.

    Declaration

    Swift

    func client(_ client: DiscordClient, didReceiveRawVoiceData voiceData: DiscordRawVoiceData,

    Parameters

    client

    The client that is calling.

    didReceiveRawVoiceData

    The voice data that was received.

    fromEngine

    The voice engine that received the data.

  • Called when the client handles a guild member chunk.

    Default Implementation

    Default.

    Declaration

    Swift

    func client(_ client: DiscordClient, didHandleGuildMemberChunk chunk: DiscordLazyDictionary<UserID, DiscordGuildMember>,

    Parameters

    client

    The client that is calling.

    didHandleGuildMemberChunk

    The chunk of guild members that was handled.

    forGuild

    The guild the members were added to.

  • Called when the client does not handle a dispatch event.

    Default Implementation

    Default.

    Declaration

    Swift

    func client(_ client: DiscordClient, didNotHandleDispatchEvent event: DiscordDispatchEvent,

    Parameters

    client

    The client that is calling.

    didNotHandleDispatchEvent

    The event that wasn’t handled.

    withData

    The data for the event.

  • client(_:didUpdateEmojis:onGuild:) Default implementation

    Called when the client updates a guild’s emojis.

    Default Implementation

    Default.

    Declaration

    Swift

    func client(_ client: DiscordClient, didUpdateEmojis emojis: [EmojiID: DiscordEmoji],

    Parameters

    client

    The client that is calling.

    didUpdateEmojis

    The chunk of guild members that was handled.

    onGuild

    The guild the emojis were updated on.

  • client(_:needsDataSourceForEngine:) Default implementation

    Called when a voice engine is requesting a new data source, can be used to override the default encoder with different bitrate/sample rate/etc.

    This should return the data source to use.

    Note: This method is not called on the main queue. Note: This method must be implemented on iOS; there is no FFmpeg middleware on iOS.

    Default Implementation

    Default

    Declaration

    Swift

    func client(_ client: DiscordClient, needsDataSourceForEngine engine: DiscordVoiceEngine) throws -> DiscordVoiceDataSource

    Parameters

    client

    The client that is calling.

    needsDataSourceForEngine

    The engine that needs an encoder.

    Return Value

    A DiscordVoiceEncoder to use to encode with.