SwiftHooks
public final class SwiftHooks
Main SwiftHooks class. Acts as global controller.
let swiftHooks = SwiftHooks()
Hooks and Plugins are both connected to the main SwiftHooks class.
-
EventLoopGroup this application runs on.
Declaration
Swift
public let eventLoopGroup: EventLoopGroup -
Wether or not
SwiftHooksdid shutdown.Declaration
Swift
public private(set) var didShutdown: Bool { get } -
Config used for this
SwiftHooksinstance.Declaration
Swift
public let config: SwiftHooksConfig -
Registered
GlobalListeners.Declaration
Swift
public internal(set) var globalListeners: [GlobalEvent : [GlobalEventClosure]] { get } -
Registered
ExecutableCommandsDeclaration
Swift
public internal(set) var commands: [_ExecutableCommand] { get } -
Global
JSONDecoderDeclaration
Swift
public static let decoder: JSONDecoder -
Global
JSONEncoderDeclaration
Swift
public static let encoder: JSONEncoder -
Create a new
SwiftHooksinstanceDeclaration
Swift
public init(eventLoopGroup: EventLoopGroup? = nil, config: SwiftHooksConfig = .default)Parameters
eventLoopGroupEventLoopGroup to run SwiftHooks on. If not passed in a new one will be created.
configConfiguration to use. Defaults to
SwiftHooksConfig.default -
Run the SwiftHooks process. Will boot all connected
Hooks and block forever.Declaration
Swift
public func run() throws -
Dispatch an event from a
_Hookinto the centralSwiftHookssystem.Declaration
Parameters
eEvent to dispatch
rawRaw bytes containing the event.
hHook this event originated from.
-
Register a plugin to the SwiftHooks system.
swiftHooks.register(MyPlugin())This will add all commands & listeners in the plugin to all registered hooks.
Declaration
Swift
public func register<P>(_ plugin: P) throws where P : PluginParameters
pluginPlugin to register
-
Global SwiftHooks logger
Declaration
Swift
public static var logger: Logger { get } -
Global SwiftHooks logger
Declaration
Swift
public var logger: Logger { get }
View on GitHub
SwiftHooks Class Reference