Extension
Extension allows you to split your code into multiple files.
Make a new extension
Make a new module, and extend Discorb::Extension.
module MyExtension
extend Discorb::Extension
# ...
end
Register Event
Use Extension#event to register event, or Extension#once_event to register event only once.
module MyExtension
extend Discorb::Extension
event :message do ||
# ...
end
once_event :ready do ||
# ...
end
end
Load extension
Use Client#extend to load extension.
Access Client from extension
You can access Client from extension with @client
.
module MyExtension
extend Discorb::Extension
event :ready do ||
puts "Logged in as #{client.user}"
end
end