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
SwiftHooks
did shutdown.Declaration
Swift
public private(set) var didShutdown: Bool { get }
-
Config used for this
SwiftHooks
instance.Declaration
Swift
public let config: SwiftHooksConfig
-
Registered
GlobalListener
s.Declaration
Swift
public internal(set) var globalListeners: [GlobalEvent : [GlobalEventClosure]] { get }
-
Registered
ExecutableCommand
sDeclaration
Swift
public internal(set) var commands: [_ExecutableCommand] { get }
-
Global
JSONDecoder
Declaration
Swift
public static let decoder: JSONDecoder
-
Global
JSONEncoder
Declaration
Swift
public static let encoder: JSONEncoder
-
Create a new
SwiftHooks
instanceDeclaration
Swift
public init(eventLoopGroup: EventLoopGroup? = nil, config: SwiftHooksConfig = .default)
Parameters
eventLoopGroup
EventLoopGroup to run SwiftHooks on. If not passed in a new one will be created.
config
Configuration to use. Defaults to
SwiftHooksConfig.default
-
Run the SwiftHooks process. Will boot all connected
Hook
s and block forever.Declaration
Swift
public func run() throws
-
Dispatch an event from a
_Hook
into the centralSwiftHooks
system.Declaration
Parameters
e
Event to dispatch
raw
Raw bytes containing the event.
h
Hook 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 : Plugin
Parameters
plugin
Plugin to register
-
Global SwiftHooks logger
Declaration
Swift
public static var logger: Logger { get }
-
Global SwiftHooks logger
Declaration
Swift
public var logger: Logger { get }